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" | |
8 #include "base/logging.h" | 7 #include "base/logging.h" |
9 #include "base/time/default_tick_clock.h" | 8 #include "base/time/default_tick_clock.h" |
10 #include "content/public/common/content_client.h" | 9 #include "content/public/common/content_client.h" |
11 #include "content/public/renderer/content_renderer_client.h" | 10 #include "content/public/renderer/content_renderer_client.h" |
12 | 11 |
13 namespace content { | 12 namespace content { |
14 | 13 |
15 static base::LazyInstance<RenderMediaClient>::Leaky g_render_media_client = | |
16 LAZY_INSTANCE_INITIALIZER; | |
17 | |
18 void RenderMediaClient::Initialize() { | 14 void RenderMediaClient::Initialize() { |
19 g_render_media_client.Get(); | 15 GetInstance(); |
20 } | 16 } |
21 | 17 |
22 RenderMediaClient::RenderMediaClient() | 18 RenderMediaClient::RenderMediaClient() |
23 : has_updated_(false), | 19 : has_updated_(false), |
24 is_update_needed_(true), | 20 is_update_needed_(true), |
25 tick_clock_(new base::DefaultTickClock()) { | 21 tick_clock_(new base::DefaultTickClock()) { |
26 media::SetMediaClient(this); | 22 media::SetMediaClient(this); |
27 } | 23 } |
28 | 24 |
29 RenderMediaClient::~RenderMediaClient() { | 25 RenderMediaClient::~RenderMediaClient() { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 109 |
114 NOTREACHED(); | 110 NOTREACHED(); |
115 return false; | 111 return false; |
116 } | 112 } |
117 | 113 |
118 void RenderMediaClient::SetTickClockForTesting( | 114 void RenderMediaClient::SetTickClockForTesting( |
119 std::unique_ptr<base::TickClock> tick_clock) { | 115 std::unique_ptr<base::TickClock> tick_clock) { |
120 tick_clock_.swap(tick_clock); | 116 tick_clock_.swap(tick_clock); |
121 } | 117 } |
122 | 118 |
123 // This functions is for testing purpose only. The declaration in the | 119 // static |
124 // header file is guarded by "#if defined(UNIT_TEST)" so that it can be used | 120 RenderMediaClient* RenderMediaClient::GetInstance() { |
125 // by tests but not non-test code. However, this .cc file is compiled as part of | 121 static RenderMediaClient* client = new RenderMediaClient(); |
126 // "content" where "UNIT_TEST" is not defined. So we need to specify | 122 return client; |
127 // "CONTENT_EXPORT" here again so that it is visible to tests. | |
128 CONTENT_EXPORT RenderMediaClient* GetRenderMediaClientInstanceForTesting() { | |
129 return g_render_media_client.Pointer(); | |
130 } | 123 } |
131 | 124 |
132 } // namespace content | 125 } // namespace content |
OLD | NEW |