OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/media/render_media_client.h" | 5 #include "content/renderer/media/render_media_client.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/time/default_tick_clock.h" | 9 #include "base/time/default_tick_clock.h" |
10 #include "content/public/common/content_client.h" | 10 #include "content/public/common/content_client.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 tick_clock_(new base::DefaultTickClock()) { | 25 tick_clock_(new base::DefaultTickClock()) { |
26 media::SetMediaClient(this); | 26 media::SetMediaClient(this); |
27 } | 27 } |
28 | 28 |
29 RenderMediaClient::~RenderMediaClient() { | 29 RenderMediaClient::~RenderMediaClient() { |
30 } | 30 } |
31 | 31 |
32 void RenderMediaClient::AddKeySystemsInfoForUMA( | 32 void RenderMediaClient::AddKeySystemsInfoForUMA( |
33 std::vector<media::KeySystemInfoForUMA>* key_systems_info_for_uma) { | 33 std::vector<media::KeySystemInfoForUMA>* key_systems_info_for_uma) { |
34 DVLOG(2) << __FUNCTION__; | 34 DVLOG(2) << __FUNCTION__; |
35 #if defined(WIDEVINE_CDM_AVAILABLE) | 35 #if defined(ENABLE_WIDEVINE_CDM) |
36 key_systems_info_for_uma->push_back(media::KeySystemInfoForUMA( | 36 key_systems_info_for_uma->push_back(media::KeySystemInfoForUMA( |
37 kWidevineKeySystem, kWidevineKeySystemNameForUMA, true)); | 37 kWidevineKeySystem, kWidevineKeySystemNameForUMA, true)); |
38 #endif // WIDEVINE_CDM_AVAILABLE | 38 #endif // ENABLE_WIDEVINE_CDM |
39 } | 39 } |
40 | 40 |
41 bool RenderMediaClient::IsKeySystemsUpdateNeeded() { | 41 bool RenderMediaClient::IsKeySystemsUpdateNeeded() { |
42 DVLOG(2) << __FUNCTION__; | 42 DVLOG(2) << __FUNCTION__; |
43 DCHECK(thread_checker_.CalledOnValidThread()); | 43 DCHECK(thread_checker_.CalledOnValidThread()); |
44 | 44 |
45 // Always needs update if we have never updated, regardless the | 45 // Always needs update if we have never updated, regardless the |
46 // |last_update_time_ticks_|'s initial value. | 46 // |last_update_time_ticks_|'s initial value. |
47 if (!has_updated_) { | 47 if (!has_updated_) { |
48 DCHECK(is_update_needed_); | 48 DCHECK(is_update_needed_); |
(...skipping 20 matching lines...) Expand all Loading... |
69 DVLOG(2) << __FUNCTION__; | 69 DVLOG(2) << __FUNCTION__; |
70 DCHECK(thread_checker_.CalledOnValidThread()); | 70 DCHECK(thread_checker_.CalledOnValidThread()); |
71 | 71 |
72 GetContentClient()->renderer()->AddKeySystems(key_systems_info); | 72 GetContentClient()->renderer()->AddKeySystems(key_systems_info); |
73 | 73 |
74 has_updated_ = true; | 74 has_updated_ = true; |
75 last_update_time_ticks_ = tick_clock_->NowTicks(); | 75 last_update_time_ticks_ = tick_clock_->NowTicks(); |
76 | 76 |
77 // Check whether all potentially supported key systems are supported. If so, | 77 // Check whether all potentially supported key systems are supported. If so, |
78 // no need to update again. | 78 // no need to update again. |
79 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) | 79 #if defined(ENABLE_WIDEVINE_CDM) && defined(WIDEVINE_CDM_IS_COMPONENT) |
80 for (const media::KeySystemInfo& key_system_info : *key_systems_info) { | 80 for (const media::KeySystemInfo& key_system_info : *key_systems_info) { |
81 if (key_system_info.key_system == kWidevineKeySystem) | 81 if (key_system_info.key_system == kWidevineKeySystem) |
82 is_update_needed_ = false; | 82 is_update_needed_ = false; |
83 } | 83 } |
84 #else | 84 #else |
85 is_update_needed_ = false; | 85 is_update_needed_ = false; |
86 #endif | 86 #endif |
87 } | 87 } |
88 | 88 |
89 void RenderMediaClient::SetTickClockForTesting( | 89 void RenderMediaClient::SetTickClockForTesting( |
90 scoped_ptr<base::TickClock> tick_clock) { | 90 scoped_ptr<base::TickClock> tick_clock) { |
91 tick_clock_.swap(tick_clock); | 91 tick_clock_.swap(tick_clock); |
92 } | 92 } |
93 | 93 |
94 // This functions is for testing purpose only. The declaration in the | 94 // This functions is for testing purpose only. The declaration in the |
95 // header file is guarded by "#if defined(UNIT_TEST)" so that it can be used | 95 // header file is guarded by "#if defined(UNIT_TEST)" so that it can be used |
96 // by tests but not non-test code. However, this .cc file is compiled as part of | 96 // by tests but not non-test code. However, this .cc file is compiled as part of |
97 // "content" where "UNIT_TEST" is not defined. So we need to specify | 97 // "content" where "UNIT_TEST" is not defined. So we need to specify |
98 // "CONTENT_EXPORT" here again so that it is visible to tests. | 98 // "CONTENT_EXPORT" here again so that it is visible to tests. |
99 CONTENT_EXPORT RenderMediaClient* GetRenderMediaClientInstanceForTesting() { | 99 CONTENT_EXPORT RenderMediaClient* GetRenderMediaClientInstanceForTesting() { |
100 return g_render_media_client.Pointer(); | 100 return g_render_media_client.Pointer(); |
101 } | 101 } |
102 | 102 |
103 } // namespace content | 103 } // namespace content |
OLD | NEW |