Fix crash on app list start page contents not existing.
[chromium-blink-merge.git] / content / renderer / media / render_media_client.h
blobb873eb5bdf7b84531c59f89421686720e0762b5f
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(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);
35 private:
36 friend struct base::DefaultLazyInstanceTraits<RenderMediaClient>;
38 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.
45 bool has_updated_;
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
60 // tests.
61 CONTENT_EXPORT RenderMediaClient* GetRenderMediaClientInstanceForTesting();
62 #endif
64 } // namespace content
66 #endif // CONTENT_RENDERER_MEDIA_RENDER_MEDIA_CLIENT_H_