Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / content / renderer / media / render_media_client.h
blobdbc1db4a7acdcd0a021b17bb74b8f4e539580cf8
1 // Copyright 2014 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.
5 #ifndef CONTENT_RENDERER_MEDIA_RENDER_MEDIA_CLIENT_H_
6 #define CONTENT_RENDERER_MEDIA_RENDER_MEDIA_CLIENT_H_
8 #include "base/lazy_instance.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/threading/thread_checker.h"
11 #include "base/time/tick_clock.h"
12 #include "base/time/time.h"
13 #include "content/common/content_export.h"
14 #include "media/base/media_client.h"
16 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
18 namespace content {
20 class CONTENT_EXPORT RenderMediaClient : public media::MediaClient {
21 public:
22 // Initialize RenderMediaClient and SetMediaClient(). Note that the instance
23 // is not exposed because no content code needs to directly access it.
24 static void Initialize();
26 // MediaClient implementation.
27 void AddKeySystemsInfoForUMA(
28 std::vector<media::KeySystemInfoForUMA>* key_systems_info_for_uma) final;
29 bool IsKeySystemsUpdateNeeded() final;
30 void AddSupportedKeySystems(
31 std::vector<media::KeySystemInfo>* key_systems_info) final;
32 void RecordRapporURL(const std::string& metric, const GURL& url) final;
34 void SetTickClockForTesting(scoped_ptr<base::TickClock> tick_clock);
36 private:
37 friend struct base::DefaultLazyInstanceTraits<RenderMediaClient>;
39 RenderMediaClient();
40 ~RenderMediaClient() override;
42 // Makes sure all methods are called from the same thread.
43 base::ThreadChecker thread_checker_;
45 // Whether AddSupportedKeySystems() has ever been called.
46 bool has_updated_;
48 // Whether a future update is needed. For example, when some potentially
49 // supported key systems are NOT supported yet. This could happen when the
50 // required component for a key system is not yet available.
51 bool is_update_needed_;
53 base::TimeTicks last_update_time_ticks_;
54 scoped_ptr<base::TickClock> tick_clock_;
56 DISALLOW_COPY_AND_ASSIGN(RenderMediaClient);
59 #if defined(UNIT_TEST)
60 // Helper function to access the RenderMediaClient instance. Used only by unit
61 // tests.
62 CONTENT_EXPORT RenderMediaClient* GetRenderMediaClientInstanceForTesting();
63 #endif
65 } // namespace content
67 #endif // CONTENT_RENDERER_MEDIA_RENDER_MEDIA_CLIENT_H_