Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: content/renderer/renderer_blink_platform_impl.cc

Issue 1538803002: Migrates battery_status from content/renderer/ to WebKit/platform/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: BatteryStatusDispatcher => BatteryDispatcherProxy Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer_blink_platform_impl.h" 5 #include "content/renderer/renderer_blink_platform_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "content/common/gpu/client/gpu_channel_host.h" 45 #include "content/common/gpu/client/gpu_channel_host.h"
46 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 46 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
47 #include "content/common/gpu/gpu_process_launch_causes.h" 47 #include "content/common/gpu/gpu_process_launch_causes.h"
48 #include "content/common/mime_registry_messages.h" 48 #include "content/common/mime_registry_messages.h"
49 #include "content/common/render_process_messages.h" 49 #include "content/common/render_process_messages.h"
50 #include "content/public/common/content_switches.h" 50 #include "content/public/common/content_switches.h"
51 #include "content/public/common/service_registry.h" 51 #include "content/public/common/service_registry.h"
52 #include "content/public/common/webplugininfo.h" 52 #include "content/public/common/webplugininfo.h"
53 #include "content/public/renderer/content_renderer_client.h" 53 #include "content/public/renderer/content_renderer_client.h"
54 #include "content/public/renderer/media_stream_api.h" 54 #include "content/public/renderer/media_stream_api.h"
55 #include "content/renderer/battery_status/battery_status_dispatcher.h"
56 #include "content/renderer/cache_storage/webserviceworkercachestorage_impl.h" 55 #include "content/renderer/cache_storage/webserviceworkercachestorage_impl.h"
57 #include "content/renderer/device_sensors/device_light_event_pump.h" 56 #include "content/renderer/device_sensors/device_light_event_pump.h"
58 #include "content/renderer/device_sensors/device_motion_event_pump.h" 57 #include "content/renderer/device_sensors/device_motion_event_pump.h"
59 #include "content/renderer/device_sensors/device_orientation_absolute_event_pump .h" 58 #include "content/renderer/device_sensors/device_orientation_absolute_event_pump .h"
60 #include "content/renderer/device_sensors/device_orientation_event_pump.h" 59 #include "content/renderer/device_sensors/device_orientation_event_pump.h"
61 #include "content/renderer/dom_storage/local_storage_namespace.h" 60 #include "content/renderer/dom_storage/local_storage_namespace.h"
62 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" 61 #include "content/renderer/dom_storage/webstoragenamespace_impl.h"
63 #include "content/renderer/gamepad_shared_memory_reader.h" 62 #include "content/renderer/gamepad_shared_memory_reader.h"
64 #include "content/renderer/media/audio_decoder.h" 63 #include "content/renderer/media/audio_decoder.h"
65 #include "content/renderer/media/canvas_capture_handler.h" 64 #include "content/renderer/media/canvas_capture_handler.h"
(...skipping 12 matching lines...) Expand all
78 #include "ipc/ipc_sync_message_filter.h" 77 #include "ipc/ipc_sync_message_filter.h"
79 #include "media/audio/audio_output_device.h" 78 #include "media/audio/audio_output_device.h"
80 #include "media/base/audio_hardware_config.h" 79 #include "media/base/audio_hardware_config.h"
81 #include "media/base/key_systems.h" 80 #include "media/base/key_systems.h"
82 #include "media/base/mime_util.h" 81 #include "media/base/mime_util.h"
83 #include "media/blink/webcontentdecryptionmodule_impl.h" 82 #include "media/blink/webcontentdecryptionmodule_impl.h"
84 #include "media/filters/stream_parser_factory.h" 83 #include "media/filters/stream_parser_factory.h"
85 #include "storage/common/database/database_identifier.h" 84 #include "storage/common/database/database_identifier.h"
86 #include "storage/common/quota/quota_types.h" 85 #include "storage/common/quota/quota_types.h"
87 #include "third_party/WebKit/public/platform/URLConversion.h" 86 #include "third_party/WebKit/public/platform/URLConversion.h"
88 #include "third_party/WebKit/public/platform/WebBatteryStatusListener.h"
89 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" 87 #include "third_party/WebKit/public/platform/WebBlobRegistry.h"
90 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" 88 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h"
91 #include "third_party/WebKit/public/platform/WebFileInfo.h" 89 #include "third_party/WebKit/public/platform/WebFileInfo.h"
92 #include "third_party/WebKit/public/platform/WebGamepads.h" 90 #include "third_party/WebKit/public/platform/WebGamepads.h"
93 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" 91 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h"
94 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" 92 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h"
95 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" 93 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h"
96 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 94 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
97 #include "third_party/WebKit/public/platform/WebURL.h" 95 #include "third_party/WebKit/public/platform/WebURL.h"
98 #include "third_party/WebKit/public/platform/WebVector.h" 96 #include "third_party/WebKit/public/platform/WebVector.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 namespace content { 169 namespace content {
172 170
173 namespace { 171 namespace {
174 172
175 bool g_sandbox_enabled = true; 173 bool g_sandbox_enabled = true;
176 double g_test_device_light_data = -1; 174 double g_test_device_light_data = -1;
177 base::LazyInstance<blink::WebDeviceMotionData>::Leaky 175 base::LazyInstance<blink::WebDeviceMotionData>::Leaky
178 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; 176 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER;
179 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky 177 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky
180 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; 178 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER;
181 // Set in startListening() when running layout tests, unset in stopListening(),
182 // not owned by us.
183 blink::WebBatteryStatusListener* g_test_battery_status_listener = nullptr;
184 179
185 } // namespace 180 } // namespace
186 181
187 //------------------------------------------------------------------------------ 182 //------------------------------------------------------------------------------
188 183
189 class RendererBlinkPlatformImpl::MimeRegistry 184 class RendererBlinkPlatformImpl::MimeRegistry
190 : public SimpleWebMimeRegistryImpl { 185 : public SimpleWebMimeRegistryImpl {
191 public: 186 public:
192 blink::WebMimeRegistry::SupportsType supportsMediaMIMEType( 187 blink::WebMimeRegistry::SupportsType supportsMediaMIMEType(
193 const blink::WebString& mime_type, 188 const blink::WebString& mime_type,
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 DVLOG(1) << "RendererBlinkPlatformImpl::startListening() with " 1168 DVLOG(1) << "RendererBlinkPlatformImpl::startListening() with "
1174 "unknown type."; 1169 "unknown type.";
1175 } 1170 }
1176 1171
1177 return NULL; 1172 return NULL;
1178 } 1173 }
1179 1174
1180 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting( 1175 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting(
1181 blink::WebPlatformEventType type, 1176 blink::WebPlatformEventType type,
1182 scoped_ptr<PlatformEventObserverBase> observer) { 1177 scoped_ptr<PlatformEventObserverBase> observer) {
1183 DCHECK(type != blink::WebPlatformEventTypeBattery);
1184
1185 if (platform_event_observers_.Lookup(type)) 1178 if (platform_event_observers_.Lookup(type))
1186 platform_event_observers_.Remove(type); 1179 platform_event_observers_.Remove(type);
1187 platform_event_observers_.AddWithID(observer.release(), type); 1180 platform_event_observers_.AddWithID(observer.release(), type);
1188 } 1181 }
1189 1182
1183 void RendererBlinkPlatformImpl::connectToRemoteService(
1184 const char* name, mojo::ScopedMessagePipeHandle handle) {
1185 // In the layout test mode, mock services should be used instead.
1186 // TODO(yukishiino): We'd like to inject mock services implemented in
1187 // JavaScript. Remove the following hack once we support JS-bindings
1188 // of Mojo and service mocking in JS.
1189 if (RenderThreadImpl::current() &&
1190 RenderThreadImpl::current()->layout_test_mode())
1191 return;
1192
1193 if (ServiceRegistry* registry = RenderThread::Get()->GetServiceRegistry()) {
1194 // registry can be null during testing.
1195 registry->ConnectToRemoteService(name, std::move(handle));
1196 }
1197 }
1198
1190 void RendererBlinkPlatformImpl::startListening( 1199 void RendererBlinkPlatformImpl::startListening(
1191 blink::WebPlatformEventType type, 1200 blink::WebPlatformEventType type,
1192 blink::WebPlatformEventListener* listener) { 1201 blink::WebPlatformEventListener* listener) {
1193 if (type == blink::WebPlatformEventTypeBattery) {
1194 if (RenderThreadImpl::current() &&
1195 RenderThreadImpl::current()->layout_test_mode()) {
1196 g_test_battery_status_listener =
1197 static_cast<blink::WebBatteryStatusListener*>(listener);
1198 } else {
1199 battery_status_dispatcher_.reset(new BatteryStatusDispatcher(
1200 static_cast<blink::WebBatteryStatusListener*>(listener)));
1201 }
1202 return;
1203 }
1204
1205 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); 1202 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type);
1206 if (!observer) { 1203 if (!observer) {
1207 observer = CreatePlatformEventObserverFromType(type); 1204 observer = CreatePlatformEventObserverFromType(type);
1208 if (!observer) 1205 if (!observer)
1209 return; 1206 return;
1210 platform_event_observers_.AddWithID(observer, static_cast<int32_t>(type)); 1207 platform_event_observers_.AddWithID(observer, static_cast<int32_t>(type));
1211 } 1208 }
1212 observer->Start(listener); 1209 observer->Start(listener);
1213 1210
1214 // Device events (motion, orientation and light) expect to get an event fired 1211 // Device events (motion, orientation and light) expect to get an event fired
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 if (!data) 1251 if (!data)
1255 return; 1252 return;
1256 1253
1257 base::ThreadTaskRunnerHandle::Get()->PostTask( 1254 base::ThreadTaskRunnerHandle::Get()->PostTask(
1258 FROM_HERE, base::Bind(&PlatformEventObserverBase::SendFakeDataForTesting, 1255 FROM_HERE, base::Bind(&PlatformEventObserverBase::SendFakeDataForTesting,
1259 base::Unretained(observer), data)); 1256 base::Unretained(observer), data));
1260 } 1257 }
1261 1258
1262 void RendererBlinkPlatformImpl::stopListening( 1259 void RendererBlinkPlatformImpl::stopListening(
1263 blink::WebPlatformEventType type) { 1260 blink::WebPlatformEventType type) {
1264 if (type == blink::WebPlatformEventTypeBattery) {
1265 g_test_battery_status_listener = nullptr;
1266 battery_status_dispatcher_.reset();
1267 return;
1268 }
1269
1270 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); 1261 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type);
1271 if (!observer) 1262 if (!observer)
1272 return; 1263 return;
1273 observer->Stop(); 1264 observer->Stop();
1274 } 1265 }
1275 1266
1276 //------------------------------------------------------------------------------ 1267 //------------------------------------------------------------------------------
1277 1268
1278 void RendererBlinkPlatformImpl::queryStorageUsageAndQuota( 1269 void RendererBlinkPlatformImpl::queryStorageUsageAndQuota(
1279 const blink::WebURL& storage_partition, 1270 const blink::WebURL& storage_partition,
1280 blink::WebStorageQuotaType type, 1271 blink::WebStorageQuotaType type,
1281 blink::WebStorageQuotaCallbacks callbacks) { 1272 blink::WebStorageQuotaCallbacks callbacks) {
1282 if (!thread_safe_sender_.get() || !quota_message_filter_.get()) 1273 if (!thread_safe_sender_.get() || !quota_message_filter_.get())
1283 return; 1274 return;
1284 QuotaDispatcher::ThreadSpecificInstance(thread_safe_sender_.get(), 1275 QuotaDispatcher::ThreadSpecificInstance(thread_safe_sender_.get(),
1285 quota_message_filter_.get()) 1276 quota_message_filter_.get())
1286 ->QueryStorageUsageAndQuota( 1277 ->QueryStorageUsageAndQuota(
1287 storage_partition, 1278 storage_partition,
1288 static_cast<storage::StorageType>(type), 1279 static_cast<storage::StorageType>(type),
1289 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); 1280 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks));
1290 } 1281 }
1291 1282
1292 //------------------------------------------------------------------------------ 1283 //------------------------------------------------------------------------------
1293 1284
1294 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting(
1295 const blink::WebBatteryStatus& status) {
1296 if (!g_test_battery_status_listener)
1297 return;
1298 g_test_battery_status_listener->updateBatteryStatus(status);
1299 }
1300
1301 //------------------------------------------------------------------------------
1302
1303 blink::WebTrialTokenValidator* 1285 blink::WebTrialTokenValidator*
1304 RendererBlinkPlatformImpl::trialTokenValidator() { 1286 RendererBlinkPlatformImpl::trialTokenValidator() {
1305 return &trial_token_validator_; 1287 return &trial_token_validator_;
1306 } 1288 }
1307 1289
1308 } // namespace content 1290 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698