OLD | NEW |
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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 #include "content/common/file_utilities_messages.h" | 40 #include "content/common/file_utilities_messages.h" |
41 #include "content/common/frame_messages.h" | 41 #include "content/common/frame_messages.h" |
42 #include "content/common/render_process_messages.h" | 42 #include "content/common/render_process_messages.h" |
43 #include "content/public/common/content_switches.h" | 43 #include "content/public/common/content_switches.h" |
44 #include "content/public/common/service_manager_connection.h" | 44 #include "content/public/common/service_manager_connection.h" |
45 #include "content/public/common/webplugininfo.h" | 45 #include "content/public/common/webplugininfo.h" |
46 #include "content/public/renderer/content_renderer_client.h" | 46 #include "content/public/renderer/content_renderer_client.h" |
47 #include "content/public/renderer/media_stream_utils.h" | 47 #include "content/public/renderer/media_stream_utils.h" |
48 #include "content/public/renderer/render_frame.h" | 48 #include "content/public/renderer/render_frame.h" |
49 #include "content/renderer/cache_storage/webserviceworkercachestorage_impl.h" | 49 #include "content/renderer/cache_storage/webserviceworkercachestorage_impl.h" |
50 #include "content/renderer/device_sensors/device_light_event_pump.h" | |
51 #include "content/renderer/device_sensors/device_motion_event_pump.h" | 50 #include "content/renderer/device_sensors/device_motion_event_pump.h" |
52 #include "content/renderer/device_sensors/device_orientation_event_pump.h" | 51 #include "content/renderer/device_sensors/device_orientation_event_pump.h" |
53 #include "content/renderer/dom_storage/local_storage_cached_areas.h" | 52 #include "content/renderer/dom_storage/local_storage_cached_areas.h" |
54 #include "content/renderer/dom_storage/local_storage_namespace.h" | 53 #include "content/renderer/dom_storage/local_storage_namespace.h" |
55 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" | 54 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
56 #include "content/renderer/gamepad_shared_memory_reader.h" | 55 #include "content/renderer/gamepad_shared_memory_reader.h" |
57 #include "content/renderer/image_capture/image_capture_frame_grabber.h" | 56 #include "content/renderer/image_capture/image_capture_frame_grabber.h" |
58 #include "content/renderer/media/audio_decoder.h" | 57 #include "content/renderer/media/audio_decoder.h" |
59 #include "content/renderer/media/audio_device_factory.h" | 58 #include "content/renderer/media/audio_device_factory.h" |
60 #include "content/renderer/media/renderer_webaudiodevice_impl.h" | 59 #include "content/renderer/media/renderer_webaudiodevice_impl.h" |
(...skipping 21 matching lines...) Expand all Loading... |
82 #include "services/service_manager/public/cpp/connector.h" | 81 #include "services/service_manager/public/cpp/connector.h" |
83 #include "services/service_manager/public/cpp/interface_provider.h" | 82 #include "services/service_manager/public/cpp/interface_provider.h" |
84 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" | 83 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.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/BlameContext.h" | 86 #include "third_party/WebKit/public/platform/BlameContext.h" |
88 #include "third_party/WebKit/public/platform/FilePathConversion.h" | 87 #include "third_party/WebKit/public/platform/FilePathConversion.h" |
89 #include "third_party/WebKit/public/platform/URLConversion.h" | 88 #include "third_party/WebKit/public/platform/URLConversion.h" |
90 #include "third_party/WebKit/public/platform/WebAudioLatencyHint.h" | 89 #include "third_party/WebKit/public/platform/WebAudioLatencyHint.h" |
91 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" | 90 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" |
92 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" | |
93 #include "third_party/WebKit/public/platform/WebFileInfo.h" | 91 #include "third_party/WebKit/public/platform/WebFileInfo.h" |
94 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" | 92 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" |
95 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" | 93 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" |
96 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" | 94 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" |
97 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 95 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
98 #include "third_party/WebKit/public/platform/WebThread.h" | 96 #include "third_party/WebKit/public/platform/WebThread.h" |
99 #include "third_party/WebKit/public/platform/WebURL.h" | 97 #include "third_party/WebKit/public/platform/WebURL.h" |
100 #include "third_party/WebKit/public/platform/WebVector.h" | 98 #include "third_party/WebKit/public/platform/WebVector.h" |
101 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eMotionListener.h" | 99 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eMotionListener.h" |
102 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eOrientationListener.h" | 100 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic
eOrientationListener.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 using blink::WebSize; | 162 using blink::WebSize; |
165 using blink::WebString; | 163 using blink::WebString; |
166 using blink::WebURL; | 164 using blink::WebURL; |
167 using blink::WebVector; | 165 using blink::WebVector; |
168 | 166 |
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; | |
175 base::LazyInstance<device::MotionData>::Leaky g_test_device_motion_data = | 172 base::LazyInstance<device::MotionData>::Leaky g_test_device_motion_data = |
176 LAZY_INSTANCE_INITIALIZER; | 173 LAZY_INSTANCE_INITIALIZER; |
177 base::LazyInstance<device::OrientationData>::Leaky | 174 base::LazyInstance<device::OrientationData>::Leaky |
178 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; | 175 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; |
179 | 176 |
180 media::AudioParameters GetAudioHardwareParams() { | 177 media::AudioParameters GetAudioHardwareParams() { |
181 blink::WebLocalFrame* const web_frame = | 178 blink::WebLocalFrame* const web_frame = |
182 blink::WebLocalFrame::FrameForCurrentContext(); | 179 blink::WebLocalFrame::FrameForCurrentContext(); |
183 RenderFrame* const render_frame = RenderFrame::FromWebFrame(web_frame); | 180 RenderFrame* const render_frame = RenderFrame::FromWebFrame(web_frame); |
184 if (!render_frame) | 181 if (!render_frame) |
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 } | 1107 } |
1111 | 1108 |
1112 void RendererBlinkPlatformImpl::RecordRapporURL(const char* metric, | 1109 void RendererBlinkPlatformImpl::RecordRapporURL(const char* metric, |
1113 const blink::WebURL& url) { | 1110 const blink::WebURL& url) { |
1114 GetContentClient()->renderer()->RecordRapporURL(metric, url); | 1111 GetContentClient()->renderer()->RecordRapporURL(metric, url); |
1115 } | 1112 } |
1116 | 1113 |
1117 //------------------------------------------------------------------------------ | 1114 //------------------------------------------------------------------------------ |
1118 | 1115 |
1119 // static | 1116 // static |
1120 void RendererBlinkPlatformImpl::SetMockDeviceLightDataForTesting(double data) { | |
1121 g_test_device_light_data = data; | |
1122 } | |
1123 | |
1124 //------------------------------------------------------------------------------ | |
1125 | |
1126 // static | |
1127 void RendererBlinkPlatformImpl::SetMockDeviceMotionDataForTesting( | 1117 void RendererBlinkPlatformImpl::SetMockDeviceMotionDataForTesting( |
1128 const device::MotionData& data) { | 1118 const device::MotionData& data) { |
1129 g_test_device_motion_data.Get() = data; | 1119 g_test_device_motion_data.Get() = data; |
1130 } | 1120 } |
1131 | 1121 |
1132 //------------------------------------------------------------------------------ | 1122 //------------------------------------------------------------------------------ |
1133 | 1123 |
1134 // static | 1124 // static |
1135 void RendererBlinkPlatformImpl::SetMockDeviceOrientationDataForTesting( | 1125 void RendererBlinkPlatformImpl::SetMockDeviceOrientationDataForTesting( |
1136 const device::OrientationData& data) { | 1126 const device::OrientationData& data) { |
(...skipping 14 matching lines...) Expand all Loading... |
1151 if (thread && RenderThreadImpl::current()->layout_test_mode()) | 1141 if (thread && RenderThreadImpl::current()->layout_test_mode()) |
1152 thread = NULL; | 1142 thread = NULL; |
1153 | 1143 |
1154 switch (type) { | 1144 switch (type) { |
1155 case blink::kWebPlatformEventTypeDeviceMotion: | 1145 case blink::kWebPlatformEventTypeDeviceMotion: |
1156 return base::MakeUnique<DeviceMotionEventPump>(thread); | 1146 return base::MakeUnique<DeviceMotionEventPump>(thread); |
1157 case blink::kWebPlatformEventTypeDeviceOrientation: | 1147 case blink::kWebPlatformEventTypeDeviceOrientation: |
1158 return base::MakeUnique<DeviceOrientationEventPump>(thread); | 1148 return base::MakeUnique<DeviceOrientationEventPump>(thread); |
1159 case blink::kWebPlatformEventTypeDeviceOrientationAbsolute: | 1149 case blink::kWebPlatformEventTypeDeviceOrientationAbsolute: |
1160 return base::MakeUnique<DeviceOrientationAbsoluteEventPump>(thread); | 1150 return base::MakeUnique<DeviceOrientationAbsoluteEventPump>(thread); |
1161 case blink::kWebPlatformEventTypeDeviceLight: | |
1162 return base::MakeUnique<DeviceLightEventPump>(thread); | |
1163 case blink::kWebPlatformEventTypeGamepad: | 1151 case blink::kWebPlatformEventTypeGamepad: |
1164 return base::MakeUnique<GamepadSharedMemoryReader>(thread); | 1152 return base::MakeUnique<GamepadSharedMemoryReader>(thread); |
1165 default: | 1153 default: |
1166 // A default statement is required to prevent compilation errors when | 1154 // A default statement is required to prevent compilation errors when |
1167 // Blink adds a new type. | 1155 // Blink adds a new type. |
1168 DVLOG(1) << "RendererBlinkPlatformImpl::startListening() with " | 1156 DVLOG(1) << "RendererBlinkPlatformImpl::startListening() with " |
1169 "unknown type."; | 1157 "unknown type."; |
1170 } | 1158 } |
1171 | 1159 |
1172 return NULL; | 1160 return NULL; |
(...skipping 23 matching lines...) Expand all Loading... |
1196 std::unique_ptr<PlatformEventObserverBase> new_observer = | 1184 std::unique_ptr<PlatformEventObserverBase> new_observer = |
1197 CreatePlatformEventObserverFromType(type); | 1185 CreatePlatformEventObserverFromType(type); |
1198 if (!new_observer) | 1186 if (!new_observer) |
1199 return; | 1187 return; |
1200 observer = new_observer.get(); | 1188 observer = new_observer.get(); |
1201 platform_event_observers_.AddWithID(std::move(new_observer), | 1189 platform_event_observers_.AddWithID(std::move(new_observer), |
1202 static_cast<int32_t>(type)); | 1190 static_cast<int32_t>(type)); |
1203 } | 1191 } |
1204 observer->Start(listener); | 1192 observer->Start(listener); |
1205 | 1193 |
1206 // Device events (motion, orientation and light) expect to get an event fired | 1194 // Device events (motion and orientation) expect to get an event fired |
1207 // as soon as a listener is registered if a fake data was passed before. | 1195 // as soon as a listener is registered if a fake data was passed before. |
1208 // TODO(mlamouri,timvolodine): make those send mock values directly instead of | 1196 // TODO(mlamouri,timvolodine): make those send mock values directly instead of |
1209 // using this broken pattern. | 1197 // using this broken pattern. |
1210 if (RenderThreadImpl::current() && | 1198 if (RenderThreadImpl::current() && |
1211 RenderThreadImpl::current()->layout_test_mode() && | 1199 RenderThreadImpl::current()->layout_test_mode() && |
1212 (type == blink::kWebPlatformEventTypeDeviceMotion || | 1200 (type == blink::kWebPlatformEventTypeDeviceMotion || |
1213 type == blink::kWebPlatformEventTypeDeviceOrientation || | 1201 type == blink::kWebPlatformEventTypeDeviceOrientation || |
1214 type == blink::kWebPlatformEventTypeDeviceOrientationAbsolute || | 1202 type == blink::kWebPlatformEventTypeDeviceOrientationAbsolute)) { |
1215 type == blink::kWebPlatformEventTypeDeviceLight)) { | |
1216 SendFakeDeviceEventDataForTesting(type); | 1203 SendFakeDeviceEventDataForTesting(type); |
1217 } | 1204 } |
1218 } | 1205 } |
1219 | 1206 |
1220 void RendererBlinkPlatformImpl::SendFakeDeviceEventDataForTesting( | 1207 void RendererBlinkPlatformImpl::SendFakeDeviceEventDataForTesting( |
1221 blink::WebPlatformEventType type) { | 1208 blink::WebPlatformEventType type) { |
1222 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); | 1209 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); |
1223 CHECK(observer); | 1210 CHECK(observer); |
1224 | 1211 |
1225 void* data = 0; | 1212 void* data = 0; |
1226 | 1213 |
1227 switch (type) { | 1214 switch (type) { |
1228 case blink::kWebPlatformEventTypeDeviceMotion: | 1215 case blink::kWebPlatformEventTypeDeviceMotion: |
1229 if (!(g_test_device_motion_data == 0)) | 1216 if (!(g_test_device_motion_data == 0)) |
1230 data = &g_test_device_motion_data.Get(); | 1217 data = &g_test_device_motion_data.Get(); |
1231 break; | 1218 break; |
1232 case blink::kWebPlatformEventTypeDeviceOrientation: | 1219 case blink::kWebPlatformEventTypeDeviceOrientation: |
1233 case blink::kWebPlatformEventTypeDeviceOrientationAbsolute: | 1220 case blink::kWebPlatformEventTypeDeviceOrientationAbsolute: |
1234 if (!(g_test_device_orientation_data == 0)) | 1221 if (!(g_test_device_orientation_data == 0)) |
1235 data = &g_test_device_orientation_data.Get(); | 1222 data = &g_test_device_orientation_data.Get(); |
1236 break; | 1223 break; |
1237 case blink::kWebPlatformEventTypeDeviceLight: | |
1238 if (g_test_device_light_data >= 0) | |
1239 data = &g_test_device_light_data; | |
1240 break; | |
1241 default: | 1224 default: |
1242 NOTREACHED(); | 1225 NOTREACHED(); |
1243 break; | 1226 break; |
1244 } | 1227 } |
1245 | 1228 |
1246 if (!data) | 1229 if (!data) |
1247 return; | 1230 return; |
1248 | 1231 |
1249 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1232 base::ThreadTaskRunnerHandle::Get()->PostTask( |
1250 FROM_HERE, base::Bind(&PlatformEventObserverBase::SendFakeDataForTesting, | 1233 FROM_HERE, base::Bind(&PlatformEventObserverBase::SendFakeDataForTesting, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 //------------------------------------------------------------------------------ | 1274 //------------------------------------------------------------------------------ |
1292 void RendererBlinkPlatformImpl::RequestPurgeMemory() { | 1275 void RendererBlinkPlatformImpl::RequestPurgeMemory() { |
1293 // TODO(tasak|bashi): We should use ChildMemoryCoordinator here, but | 1276 // TODO(tasak|bashi): We should use ChildMemoryCoordinator here, but |
1294 // ChildMemoryCoordinator isn't always available as it's only initialized | 1277 // ChildMemoryCoordinator isn't always available as it's only initialized |
1295 // when kMemoryCoordinatorV0 is enabled. | 1278 // when kMemoryCoordinatorV0 is enabled. |
1296 // Use ChildMemoryCoordinator when memory coordinator is always enabled. | 1279 // Use ChildMemoryCoordinator when memory coordinator is always enabled. |
1297 base::MemoryCoordinatorClientRegistry::GetInstance()->PurgeMemory(); | 1280 base::MemoryCoordinatorClientRegistry::GetInstance()->PurgeMemory(); |
1298 } | 1281 } |
1299 | 1282 |
1300 } // namespace content | 1283 } // namespace content |
OLD | NEW |