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

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, 9 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/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/FilePathConversion.h" 85 #include "third_party/WebKit/public/platform/FilePathConversion.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 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 DVLOG(1) << "RendererBlinkPlatformImpl::startListening() with " 1146 DVLOG(1) << "RendererBlinkPlatformImpl::startListening() with "
1152 "unknown type."; 1147 "unknown type.";
1153 } 1148 }
1154 1149
1155 return NULL; 1150 return NULL;
1156 } 1151 }
1157 1152
1158 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting( 1153 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting(
1159 blink::WebPlatformEventType type, 1154 blink::WebPlatformEventType type,
1160 scoped_ptr<PlatformEventObserverBase> observer) { 1155 scoped_ptr<PlatformEventObserverBase> observer) {
1161 DCHECK(type != blink::WebPlatformEventTypeBattery);
1162
1163 if (platform_event_observers_.Lookup(type)) 1156 if (platform_event_observers_.Lookup(type))
1164 platform_event_observers_.Remove(type); 1157 platform_event_observers_.Remove(type);
1165 platform_event_observers_.AddWithID(observer.release(), type); 1158 platform_event_observers_.AddWithID(observer.release(), type);
1166 } 1159 }
1167 1160
1161 void RendererBlinkPlatformImpl::connectToRemoteService(
1162 const char* name,
1163 mojo::ScopedMessagePipeHandle handle) {
1164 // In the layout test mode, mock services should be used instead.
1165 // TODO(yukishiino): We'd like to inject mock services implemented in
1166 // JavaScript. Remove the following hack once we support JS-bindings
1167 // of Mojo and service mocking in JS.
1168 if (RenderThreadImpl::current() &&
1169 RenderThreadImpl::current()->layout_test_mode())
1170 return;
1171
1172 if (ServiceRegistry* registry = RenderThread::Get()->GetServiceRegistry()) {
1173 // registry can be null during testing.
1174 registry->ConnectToRemoteService(name, std::move(handle));
1175 }
1176 }
1177
1168 void RendererBlinkPlatformImpl::startListening( 1178 void RendererBlinkPlatformImpl::startListening(
1169 blink::WebPlatformEventType type, 1179 blink::WebPlatformEventType type,
1170 blink::WebPlatformEventListener* listener) { 1180 blink::WebPlatformEventListener* listener) {
1171 if (type == blink::WebPlatformEventTypeBattery) {
1172 if (RenderThreadImpl::current() &&
1173 RenderThreadImpl::current()->layout_test_mode()) {
1174 g_test_battery_status_listener =
1175 static_cast<blink::WebBatteryStatusListener*>(listener);
1176 } else {
1177 battery_status_dispatcher_.reset(new BatteryStatusDispatcher(
1178 static_cast<blink::WebBatteryStatusListener*>(listener)));
1179 }
1180 return;
1181 }
1182
1183 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); 1181 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type);
1184 if (!observer) { 1182 if (!observer) {
1185 observer = CreatePlatformEventObserverFromType(type); 1183 observer = CreatePlatformEventObserverFromType(type);
1186 if (!observer) 1184 if (!observer)
1187 return; 1185 return;
1188 platform_event_observers_.AddWithID(observer, static_cast<int32_t>(type)); 1186 platform_event_observers_.AddWithID(observer, static_cast<int32_t>(type));
1189 } 1187 }
1190 observer->Start(listener); 1188 observer->Start(listener);
1191 1189
1192 // Device events (motion, orientation and light) expect to get an event fired 1190 // Device events (motion, orientation and light) expect to get an event fired
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 if (!data) 1230 if (!data)
1233 return; 1231 return;
1234 1232
1235 base::ThreadTaskRunnerHandle::Get()->PostTask( 1233 base::ThreadTaskRunnerHandle::Get()->PostTask(
1236 FROM_HERE, base::Bind(&PlatformEventObserverBase::SendFakeDataForTesting, 1234 FROM_HERE, base::Bind(&PlatformEventObserverBase::SendFakeDataForTesting,
1237 base::Unretained(observer), data)); 1235 base::Unretained(observer), data));
1238 } 1236 }
1239 1237
1240 void RendererBlinkPlatformImpl::stopListening( 1238 void RendererBlinkPlatformImpl::stopListening(
1241 blink::WebPlatformEventType type) { 1239 blink::WebPlatformEventType type) {
1242 if (type == blink::WebPlatformEventTypeBattery) {
1243 g_test_battery_status_listener = nullptr;
1244 battery_status_dispatcher_.reset();
1245 return;
1246 }
1247
1248 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); 1240 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type);
1249 if (!observer) 1241 if (!observer)
1250 return; 1242 return;
1251 observer->Stop(); 1243 observer->Stop();
1252 } 1244 }
1253 1245
1254 //------------------------------------------------------------------------------ 1246 //------------------------------------------------------------------------------
1255 1247
1256 void RendererBlinkPlatformImpl::queryStorageUsageAndQuota( 1248 void RendererBlinkPlatformImpl::queryStorageUsageAndQuota(
1257 const blink::WebURL& storage_partition, 1249 const blink::WebURL& storage_partition,
1258 blink::WebStorageQuotaType type, 1250 blink::WebStorageQuotaType type,
1259 blink::WebStorageQuotaCallbacks callbacks) { 1251 blink::WebStorageQuotaCallbacks callbacks) {
1260 if (!thread_safe_sender_.get() || !quota_message_filter_.get()) 1252 if (!thread_safe_sender_.get() || !quota_message_filter_.get())
1261 return; 1253 return;
1262 QuotaDispatcher::ThreadSpecificInstance(thread_safe_sender_.get(), 1254 QuotaDispatcher::ThreadSpecificInstance(thread_safe_sender_.get(),
1263 quota_message_filter_.get()) 1255 quota_message_filter_.get())
1264 ->QueryStorageUsageAndQuota( 1256 ->QueryStorageUsageAndQuota(
1265 storage_partition, 1257 storage_partition,
1266 static_cast<storage::StorageType>(type), 1258 static_cast<storage::StorageType>(type),
1267 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); 1259 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks));
1268 } 1260 }
1269 1261
1270 //------------------------------------------------------------------------------ 1262 //------------------------------------------------------------------------------
1271 1263
1272 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting(
1273 const blink::WebBatteryStatus& status) {
1274 if (!g_test_battery_status_listener)
1275 return;
1276 g_test_battery_status_listener->updateBatteryStatus(status);
1277 }
1278
1279 //------------------------------------------------------------------------------
1280
1281 blink::WebTrialTokenValidator* 1264 blink::WebTrialTokenValidator*
1282 RendererBlinkPlatformImpl::trialTokenValidator() { 1265 RendererBlinkPlatformImpl::trialTokenValidator() {
1283 return &trial_token_validator_; 1266 return &trial_token_validator_;
1284 } 1267 }
1285 1268
1286 } // namespace content 1269 } // 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
This is Rietveld 408576698