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 13 matching lines...) Expand all Loading... |
24 is_update_needed_(true), | 24 is_update_needed_(true), |
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) << __func__; |
35 #if defined(WIDEVINE_CDM_AVAILABLE) | 35 #if defined(WIDEVINE_CDM_AVAILABLE) |
36 key_systems_info_for_uma->push_back(media::KeySystemInfoForUMA( | 36 key_systems_info_for_uma->push_back(media::KeySystemInfoForUMA( |
37 kWidevineKeySystem, kWidevineKeySystemNameForUMA)); | 37 kWidevineKeySystem, kWidevineKeySystemNameForUMA)); |
38 #endif // WIDEVINE_CDM_AVAILABLE | 38 #endif // WIDEVINE_CDM_AVAILABLE |
39 } | 39 } |
40 | 40 |
41 bool RenderMediaClient::IsKeySystemsUpdateNeeded() { | 41 bool RenderMediaClient::IsKeySystemsUpdateNeeded() { |
42 DVLOG(2) << __FUNCTION__; | 42 DVLOG(2) << __func__; |
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_); |
49 return true; | 49 return true; |
50 } | 50 } |
51 | 51 |
52 if (!is_update_needed_) | 52 if (!is_update_needed_) |
53 return false; | 53 return false; |
54 | 54 |
55 // The update could be expensive. For example, it could involve a sync IPC to | 55 // The update could be expensive. For example, it could involve a sync IPC to |
56 // the browser process. Use a minimum update interval to avoid unnecessarily | 56 // the browser process. Use a minimum update interval to avoid unnecessarily |
57 // frequent update. | 57 // frequent update. |
58 static const int kMinUpdateIntervalInMilliseconds = 1000; | 58 static const int kMinUpdateIntervalInMilliseconds = 1000; |
59 if ((tick_clock_->NowTicks() - last_update_time_ticks_).InMilliseconds() < | 59 if ((tick_clock_->NowTicks() - last_update_time_ticks_).InMilliseconds() < |
60 kMinUpdateIntervalInMilliseconds) { | 60 kMinUpdateIntervalInMilliseconds) { |
61 return false; | 61 return false; |
62 } | 62 } |
63 | 63 |
64 return true; | 64 return true; |
65 } | 65 } |
66 | 66 |
67 void RenderMediaClient::AddSupportedKeySystems( | 67 void RenderMediaClient::AddSupportedKeySystems( |
68 std::vector<std::unique_ptr<media::KeySystemProperties>>* | 68 std::vector<std::unique_ptr<media::KeySystemProperties>>* |
69 key_systems_properties) { | 69 key_systems_properties) { |
70 DVLOG(2) << __FUNCTION__; | 70 DVLOG(2) << __func__; |
71 DCHECK(thread_checker_.CalledOnValidThread()); | 71 DCHECK(thread_checker_.CalledOnValidThread()); |
72 | 72 |
73 GetContentClient()->renderer()->AddSupportedKeySystems( | 73 GetContentClient()->renderer()->AddSupportedKeySystems( |
74 key_systems_properties); | 74 key_systems_properties); |
75 | 75 |
76 has_updated_ = true; | 76 has_updated_ = true; |
77 last_update_time_ticks_ = tick_clock_->NowTicks(); | 77 last_update_time_ticks_ = tick_clock_->NowTicks(); |
78 | 78 |
79 // Check whether all potentially supported key systems are supported. If so, | 79 // Check whether all potentially supported key systems are supported. If so, |
80 // no need to update again. | 80 // no need to update again. |
(...skipping 20 matching lines...) Expand all Loading... |
101 // This functions is for testing purpose only. The declaration in the | 101 // This functions is for testing purpose only. The declaration in the |
102 // header file is guarded by "#if defined(UNIT_TEST)" so that it can be used | 102 // header file is guarded by "#if defined(UNIT_TEST)" so that it can be used |
103 // by tests but not non-test code. However, this .cc file is compiled as part of | 103 // by tests but not non-test code. However, this .cc file is compiled as part of |
104 // "content" where "UNIT_TEST" is not defined. So we need to specify | 104 // "content" where "UNIT_TEST" is not defined. So we need to specify |
105 // "CONTENT_EXPORT" here again so that it is visible to tests. | 105 // "CONTENT_EXPORT" here again so that it is visible to tests. |
106 CONTENT_EXPORT RenderMediaClient* GetRenderMediaClientInstanceForTesting() { | 106 CONTENT_EXPORT RenderMediaClient* GetRenderMediaClientInstanceForTesting() { |
107 return g_render_media_client.Pointer(); | 107 return g_render_media_client.Pointer(); |
108 } | 108 } |
109 | 109 |
110 } // namespace content | 110 } // namespace content |
OLD | NEW |