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.
20 class CONTENT_EXPORT RenderMediaClient
: public media::MediaClient
{
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(std::vector
<media::KeySystemInfoForUMA
>*
28 key_systems_info_for_uma
) override
;
29 bool IsKeySystemsUpdateNeeded() override
;
30 void AddSupportedKeySystems(
31 std::vector
<media::KeySystemInfo
>* key_systems_info
) override
;
33 void SetTickClockForTesting(scoped_ptr
<base::TickClock
> tick_clock
);
36 friend struct base::DefaultLazyInstanceTraits
<RenderMediaClient
>;
39 ~RenderMediaClient() override
;
41 // Makes sure all methods are called from the same thread.
42 base::ThreadChecker thread_checker_
;
44 // Whether AddSupportedKeySystems() has ever been called.
47 // Whether a future update is needed. For example, when some potentially
48 // supported key systems are NOT supported yet. This could happen when the
49 // required component for a key system is not yet available.
50 bool is_update_needed_
;
52 base::TimeTicks last_update_time_ticks_
;
53 scoped_ptr
<base::TickClock
> tick_clock_
;
55 DISALLOW_COPY_AND_ASSIGN(RenderMediaClient
);
58 #if defined(UNIT_TEST)
59 // Helper function to access the RenderMediaClient instance. Used only by unit
61 CONTENT_EXPORT RenderMediaClient
* GetRenderMediaClientInstanceForTesting();
64 } // namespace content
66 #endif // CONTENT_RENDERER_MEDIA_RENDER_MEDIA_CLIENT_H_