webrtc_video_stats_db_provider.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2022 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef MEDIA_CAPABILITIES_WEBRTC_VIDEO_STATS_DB_PROVIDER_H_
  5. #define MEDIA_CAPABILITIES_WEBRTC_VIDEO_STATS_DB_PROVIDER_H_
  6. #include "base/callback_forward.h"
  7. #include "media/base/media_export.h"
  8. namespace media {
  9. class WebrtcVideoStatsDB;
  10. // Interface for extracting a pointer to the DB from its owner. DB lifetime is
  11. // assumed to match that of the provider. Callers must not use DB after provider
  12. // has been destroyed. This allows sharing a "seed" DB instance between an
  13. // Incognito profile and the original profile, which re-uses the in-memory
  14. // cache for that DB and avoids race conditions of instantiating a second DB
  15. // that reads the same files.
  16. class MEDIA_EXPORT WebrtcVideoStatsDBProvider {
  17. public:
  18. // Request a pointer to the *initialized* DB owned by this provider. Call
  19. // lazily to avoid triggering unnecessary DB initialization. `db` is null in
  20. // the event of an error. Callback may be run immediately if `db` is already
  21. // initialized by provider.
  22. using GetCB = base::OnceCallback<void(WebrtcVideoStatsDB* db)>;
  23. virtual void GetWebrtcVideoStatsDB(GetCB get_db_b) = 0;
  24. protected:
  25. virtual ~WebrtcVideoStatsDBProvider();
  26. };
  27. } // namespace media
  28. #endif // MEDIA_CAPABILITIES_WEBRTC_VIDEO_STATS_DB_PROVIDER_H_