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

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: Created 4 years, 11 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/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...) Expand all
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...) Expand 10 before | Expand all | Expand 10 after
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 987 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 DVLOG(1) << "RendererBlinkPlatformImpl::startListening() with " 1174 DVLOG(1) << "RendererBlinkPlatformImpl::startListening() with "
1180 "unknown type."; 1175 "unknown type.";
1181 } 1176 }
1182 1177
1183 return NULL; 1178 return NULL;
1184 } 1179 }
1185 1180
1186 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting( 1181 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting(
1187 blink::WebPlatformEventType type, 1182 blink::WebPlatformEventType type,
1188 scoped_ptr<PlatformEventObserverBase> observer) { 1183 scoped_ptr<PlatformEventObserverBase> observer) {
1189 DCHECK(type != blink::WebPlatformEventTypeBattery);
1190
1191 if (platform_event_observers_.Lookup(type)) 1184 if (platform_event_observers_.Lookup(type))
1192 platform_event_observers_.Remove(type); 1185 platform_event_observers_.Remove(type);
1193 platform_event_observers_.AddWithID(observer.release(), type); 1186 platform_event_observers_.AddWithID(observer.release(), type);
1194 } 1187 }
1195 1188
1189 void RendererBlinkPlatformImpl::connectToRemoteService(
1190 const char* name, mojo::ScopedMessagePipeHandle handle) {
1191 if (ServiceRegistry* registry = RenderThread::Get()->GetServiceRegistry()) {
1192 // registry can be null during testing.
1193 registry->ConnectToRemoteService(name, std::move(handle));
1194 }
1195 }
1196
1196 void RendererBlinkPlatformImpl::startListening( 1197 void RendererBlinkPlatformImpl::startListening(
1197 blink::WebPlatformEventType type, 1198 blink::WebPlatformEventType type,
1198 blink::WebPlatformEventListener* listener) { 1199 blink::WebPlatformEventListener* listener) {
1199 if (type == blink::WebPlatformEventTypeBattery) {
1200 if (RenderThreadImpl::current() &&
1201 RenderThreadImpl::current()->layout_test_mode()) {
1202 g_test_battery_status_listener =
1203 static_cast<blink::WebBatteryStatusListener*>(listener);
1204 } else {
1205 battery_status_dispatcher_.reset(new BatteryStatusDispatcher(
1206 static_cast<blink::WebBatteryStatusListener*>(listener)));
1207 }
1208 return;
1209 }
1210
1211 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); 1200 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type);
1212 if (!observer) { 1201 if (!observer) {
1213 observer = CreatePlatformEventObserverFromType(type); 1202 observer = CreatePlatformEventObserverFromType(type);
1214 if (!observer) 1203 if (!observer)
1215 return; 1204 return;
1216 platform_event_observers_.AddWithID(observer, static_cast<int32_t>(type)); 1205 platform_event_observers_.AddWithID(observer, static_cast<int32_t>(type));
1217 } 1206 }
1218 observer->Start(listener); 1207 observer->Start(listener);
1219 1208
1220 // Device events (motion, orientation and light) expect to get an event fired 1209 // Device events (motion, orientation and light) expect to get an event fired
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 if (!data) 1249 if (!data)
1261 return; 1250 return;
1262 1251
1263 base::ThreadTaskRunnerHandle::Get()->PostTask( 1252 base::ThreadTaskRunnerHandle::Get()->PostTask(
1264 FROM_HERE, base::Bind(&PlatformEventObserverBase::SendFakeDataForTesting, 1253 FROM_HERE, base::Bind(&PlatformEventObserverBase::SendFakeDataForTesting,
1265 base::Unretained(observer), data)); 1254 base::Unretained(observer), data));
1266 } 1255 }
1267 1256
1268 void RendererBlinkPlatformImpl::stopListening( 1257 void RendererBlinkPlatformImpl::stopListening(
1269 blink::WebPlatformEventType type) { 1258 blink::WebPlatformEventType type) {
1270 if (type == blink::WebPlatformEventTypeBattery) {
1271 g_test_battery_status_listener = nullptr;
1272 battery_status_dispatcher_.reset();
1273 return;
1274 }
1275
1276 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); 1259 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type);
1277 if (!observer) 1260 if (!observer)
1278 return; 1261 return;
1279 observer->Stop(); 1262 observer->Stop();
1280 } 1263 }
1281 1264
1282 //------------------------------------------------------------------------------ 1265 //------------------------------------------------------------------------------
1283 1266
1284 void RendererBlinkPlatformImpl::queryStorageUsageAndQuota( 1267 void RendererBlinkPlatformImpl::queryStorageUsageAndQuota(
1285 const blink::WebURL& storage_partition, 1268 const blink::WebURL& storage_partition,
1286 blink::WebStorageQuotaType type, 1269 blink::WebStorageQuotaType type,
1287 blink::WebStorageQuotaCallbacks callbacks) { 1270 blink::WebStorageQuotaCallbacks callbacks) {
1288 if (!thread_safe_sender_.get() || !quota_message_filter_.get()) 1271 if (!thread_safe_sender_.get() || !quota_message_filter_.get())
1289 return; 1272 return;
1290 QuotaDispatcher::ThreadSpecificInstance(thread_safe_sender_.get(), 1273 QuotaDispatcher::ThreadSpecificInstance(thread_safe_sender_.get(),
1291 quota_message_filter_.get()) 1274 quota_message_filter_.get())
1292 ->QueryStorageUsageAndQuota( 1275 ->QueryStorageUsageAndQuota(
1293 storage_partition, 1276 storage_partition,
1294 static_cast<storage::StorageType>(type), 1277 static_cast<storage::StorageType>(type),
1295 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); 1278 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks));
1296 } 1279 }
1297 1280
1298 //------------------------------------------------------------------------------
1299
1300 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting(
1301 const blink::WebBatteryStatus& status) {
1302 if (!g_test_battery_status_listener)
1303 return;
1304 g_test_battery_status_listener->updateBatteryStatus(status);
1305 }
1306
1307 } // namespace content 1281 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698