Chromium Code Reviews

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: Synced. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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...)
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/webstoragenamespace_impl.h" 60 #include "content/renderer/dom_storage/webstoragenamespace_impl.h"
62 #include "content/renderer/gamepad_shared_memory_reader.h" 61 #include "content/renderer/gamepad_shared_memory_reader.h"
63 #include "content/renderer/media/audio_decoder.h" 62 #include "content/renderer/media/audio_decoder.h"
64 #include "content/renderer/media/canvas_capture_handler.h" 63 #include "content/renderer/media/canvas_capture_handler.h"
65 #include "content/renderer/media/html_video_element_capturer_source.h" 64 #include "content/renderer/media/html_video_element_capturer_source.h"
(...skipping 11 matching lines...)
77 #include "ipc/ipc_sync_message_filter.h" 76 #include "ipc/ipc_sync_message_filter.h"
78 #include "media/audio/audio_output_device.h" 77 #include "media/audio/audio_output_device.h"
79 #include "media/base/audio_hardware_config.h" 78 #include "media/base/audio_hardware_config.h"
80 #include "media/base/key_systems.h" 79 #include "media/base/key_systems.h"
81 #include "media/base/mime_util.h" 80 #include "media/base/mime_util.h"
82 #include "media/blink/webcontentdecryptionmodule_impl.h" 81 #include "media/blink/webcontentdecryptionmodule_impl.h"
83 #include "media/filters/stream_parser_factory.h" 82 #include "media/filters/stream_parser_factory.h"
84 #include "storage/common/database/database_identifier.h" 83 #include "storage/common/database/database_identifier.h"
85 #include "storage/common/quota/quota_types.h" 84 #include "storage/common/quota/quota_types.h"
86 #include "third_party/WebKit/public/platform/URLConversion.h" 85 #include "third_party/WebKit/public/platform/URLConversion.h"
87 #include "third_party/WebKit/public/platform/WebBatteryStatusListener.h"
88 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" 86 #include "third_party/WebKit/public/platform/WebBlobRegistry.h"
89 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" 87 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h"
90 #include "third_party/WebKit/public/platform/WebFileInfo.h" 88 #include "third_party/WebKit/public/platform/WebFileInfo.h"
91 #include "third_party/WebKit/public/platform/WebGamepads.h" 89 #include "third_party/WebKit/public/platform/WebGamepads.h"
92 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" 90 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h"
93 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" 91 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h"
94 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" 92 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h"
95 #include "third_party/WebKit/public/platform/WebURL.h" 93 #include "third_party/WebKit/public/platform/WebURL.h"
96 #include "third_party/WebKit/public/platform/WebVector.h" 94 #include "third_party/WebKit/public/platform/WebVector.h"
97 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic eMotionListener.h" 95 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic eMotionListener.h"
(...skipping 71 matching lines...)
169 namespace content { 167 namespace content {
170 168
171 namespace { 169 namespace {
172 170
173 bool g_sandbox_enabled = true; 171 bool g_sandbox_enabled = true;
174 double g_test_device_light_data = -1; 172 double g_test_device_light_data = -1;
175 base::LazyInstance<blink::WebDeviceMotionData>::Leaky 173 base::LazyInstance<blink::WebDeviceMotionData>::Leaky
176 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; 174 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER;
177 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky 175 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky
178 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; 176 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER;
179 // Set in startListening() when running layout tests, unset in stopListening(),
180 // not owned by us.
181 blink::WebBatteryStatusListener* g_test_battery_status_listener = nullptr;
182 177
183 } // namespace 178 } // namespace
184 179
185 //------------------------------------------------------------------------------ 180 //------------------------------------------------------------------------------
186 181
187 class RendererBlinkPlatformImpl::MimeRegistry 182 class RendererBlinkPlatformImpl::MimeRegistry
188 : public SimpleWebMimeRegistryImpl { 183 : public SimpleWebMimeRegistryImpl {
189 public: 184 public:
190 blink::WebMimeRegistry::SupportsType supportsMediaMIMEType( 185 blink::WebMimeRegistry::SupportsType supportsMediaMIMEType(
191 const blink::WebString& mime_type, 186 const blink::WebString& mime_type,
(...skipping 989 matching lines...)
1181 DVLOG(1) << "RendererBlinkPlatformImpl::startListening() with " 1176 DVLOG(1) << "RendererBlinkPlatformImpl::startListening() with "
1182 "unknown type."; 1177 "unknown type.";
1183 } 1178 }
1184 1179
1185 return NULL; 1180 return NULL;
1186 } 1181 }
1187 1182
1188 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting( 1183 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting(
1189 blink::WebPlatformEventType type, 1184 blink::WebPlatformEventType type,
1190 scoped_ptr<PlatformEventObserverBase> observer) { 1185 scoped_ptr<PlatformEventObserverBase> observer) {
1191 DCHECK(type != blink::WebPlatformEventTypeBattery);
1192
1193 if (platform_event_observers_.Lookup(type)) 1186 if (platform_event_observers_.Lookup(type))
1194 platform_event_observers_.Remove(type); 1187 platform_event_observers_.Remove(type);
1195 platform_event_observers_.AddWithID(observer.release(), type); 1188 platform_event_observers_.AddWithID(observer.release(), type);
1196 } 1189 }
1197 1190
1191 void RendererBlinkPlatformImpl::connectToRemoteService(
1192 const char* name, mojo::ScopedMessagePipeHandle handle) {
1193 // In the layout test mode, mock services should be used instead.
shalamov 2016/02/05 13:32:01 If I understand correctly, with this "if(layout_te
Yuki 2016/02/05 14:44:12 This is a dirty hack to make the layout test run a
1194 if (RenderThreadImpl::current() &&
1195 RenderThreadImpl::current()->layout_test_mode())
1196 return;
1197
1198 if (ServiceRegistry* registry = RenderThread::Get()->GetServiceRegistry()) {
1199 // registry can be null during testing.
1200 registry->ConnectToRemoteService(name, std::move(handle));
1201 }
1202 }
1203
1198 void RendererBlinkPlatformImpl::startListening( 1204 void RendererBlinkPlatformImpl::startListening(
1199 blink::WebPlatformEventType type, 1205 blink::WebPlatformEventType type,
1200 blink::WebPlatformEventListener* listener) { 1206 blink::WebPlatformEventListener* listener) {
1201 if (type == blink::WebPlatformEventTypeBattery) {
1202 if (RenderThreadImpl::current() &&
1203 RenderThreadImpl::current()->layout_test_mode()) {
1204 g_test_battery_status_listener =
1205 static_cast<blink::WebBatteryStatusListener*>(listener);
1206 } else {
1207 battery_status_dispatcher_.reset(new BatteryStatusDispatcher(
1208 static_cast<blink::WebBatteryStatusListener*>(listener)));
1209 }
1210 return;
1211 }
1212
1213 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); 1207 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type);
1214 if (!observer) { 1208 if (!observer) {
1215 observer = CreatePlatformEventObserverFromType(type); 1209 observer = CreatePlatformEventObserverFromType(type);
1216 if (!observer) 1210 if (!observer)
1217 return; 1211 return;
1218 platform_event_observers_.AddWithID(observer, static_cast<int32_t>(type)); 1212 platform_event_observers_.AddWithID(observer, static_cast<int32_t>(type));
1219 } 1213 }
1220 observer->Start(listener); 1214 observer->Start(listener);
1221 1215
1222 // Device events (motion, orientation and light) expect to get an event fired 1216 // Device events (motion, orientation and light) expect to get an event fired
(...skipping 39 matching lines...)
1262 if (!data) 1256 if (!data)
1263 return; 1257 return;
1264 1258
1265 base::ThreadTaskRunnerHandle::Get()->PostTask( 1259 base::ThreadTaskRunnerHandle::Get()->PostTask(
1266 FROM_HERE, base::Bind(&PlatformEventObserverBase::SendFakeDataForTesting, 1260 FROM_HERE, base::Bind(&PlatformEventObserverBase::SendFakeDataForTesting,
1267 base::Unretained(observer), data)); 1261 base::Unretained(observer), data));
1268 } 1262 }
1269 1263
1270 void RendererBlinkPlatformImpl::stopListening( 1264 void RendererBlinkPlatformImpl::stopListening(
1271 blink::WebPlatformEventType type) { 1265 blink::WebPlatformEventType type) {
1272 if (type == blink::WebPlatformEventTypeBattery) {
1273 g_test_battery_status_listener = nullptr;
1274 battery_status_dispatcher_.reset();
1275 return;
1276 }
1277
1278 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); 1266 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type);
1279 if (!observer) 1267 if (!observer)
1280 return; 1268 return;
1281 observer->Stop(); 1269 observer->Stop();
1282 } 1270 }
1283 1271
1284 //------------------------------------------------------------------------------ 1272 //------------------------------------------------------------------------------
1285 1273
1286 void RendererBlinkPlatformImpl::queryStorageUsageAndQuota( 1274 void RendererBlinkPlatformImpl::queryStorageUsageAndQuota(
1287 const blink::WebURL& storage_partition, 1275 const blink::WebURL& storage_partition,
1288 blink::WebStorageQuotaType type, 1276 blink::WebStorageQuotaType type,
1289 blink::WebStorageQuotaCallbacks callbacks) { 1277 blink::WebStorageQuotaCallbacks callbacks) {
1290 if (!thread_safe_sender_.get() || !quota_message_filter_.get()) 1278 if (!thread_safe_sender_.get() || !quota_message_filter_.get())
1291 return; 1279 return;
1292 QuotaDispatcher::ThreadSpecificInstance(thread_safe_sender_.get(), 1280 QuotaDispatcher::ThreadSpecificInstance(thread_safe_sender_.get(),
1293 quota_message_filter_.get()) 1281 quota_message_filter_.get())
1294 ->QueryStorageUsageAndQuota( 1282 ->QueryStorageUsageAndQuota(
1295 storage_partition, 1283 storage_partition,
1296 static_cast<storage::StorageType>(type), 1284 static_cast<storage::StorageType>(type),
1297 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); 1285 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks));
1298 } 1286 }
1299 1287
1300 //------------------------------------------------------------------------------
1301
1302 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting(
1303 const blink::WebBatteryStatus& status) {
1304 if (!g_test_battery_status_listener)
1305 return;
1306 g_test_battery_status_listener->updateBatteryStatus(status);
1307 }
1308
1309 } // namespace content 1288 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/renderer_blink_platform_impl.h ('k') | content/shell/renderer/layout_test/blink_test_runner.h » ('j') | no next file with comments »

Powered by Google App Engine