| 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 <utility> | 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 11 #include "base/guid.h" | 12 #include "base/guid.h" |
| 12 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 13 #include "base/location.h" | 14 #include "base/location.h" |
| 14 #include "base/logging.h" | 15 #include "base/logging.h" |
| 15 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 16 #include "base/memory/shared_memory.h" | 17 #include "base/memory/shared_memory.h" |
| (...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 } | 1186 } |
| 1186 | 1187 |
| 1187 return NULL; | 1188 return NULL; |
| 1188 } | 1189 } |
| 1189 | 1190 |
| 1190 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting( | 1191 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting( |
| 1191 blink::WebPlatformEventType type, | 1192 blink::WebPlatformEventType type, |
| 1192 std::unique_ptr<PlatformEventObserverBase> observer) { | 1193 std::unique_ptr<PlatformEventObserverBase> observer) { |
| 1193 if (platform_event_observers_.Lookup(type)) | 1194 if (platform_event_observers_.Lookup(type)) |
| 1194 platform_event_observers_.Remove(type); | 1195 platform_event_observers_.Remove(type); |
| 1195 platform_event_observers_.AddWithID(observer.release(), type); | 1196 platform_event_observers_.AddWithID(std::move(observer), type); |
| 1196 } | 1197 } |
| 1197 | 1198 |
| 1198 blink::InterfaceProvider* RendererBlinkPlatformImpl::interfaceProvider() { | 1199 blink::InterfaceProvider* RendererBlinkPlatformImpl::interfaceProvider() { |
| 1199 return blink_interface_provider_.get(); | 1200 return blink_interface_provider_.get(); |
| 1200 } | 1201 } |
| 1201 | 1202 |
| 1202 void RendererBlinkPlatformImpl::startListening( | 1203 void RendererBlinkPlatformImpl::startListening( |
| 1203 blink::WebPlatformEventType type, | 1204 blink::WebPlatformEventType type, |
| 1204 blink::WebPlatformEventListener* listener) { | 1205 blink::WebPlatformEventListener* listener) { |
| 1205 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); | 1206 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); |
| 1206 if (!observer) { | 1207 if (!observer) { |
| 1207 observer = CreatePlatformEventObserverFromType(type); | 1208 observer = CreatePlatformEventObserverFromType(type); |
| 1208 if (!observer) | 1209 if (!observer) |
| 1209 return; | 1210 return; |
| 1210 platform_event_observers_.AddWithID(observer, static_cast<int32_t>(type)); | 1211 platform_event_observers_.AddWithID( |
| 1212 std::unique_ptr<PlatformEventObserverBase>(observer), |
| 1213 static_cast<int32_t>(type)); |
| 1211 } | 1214 } |
| 1212 observer->Start(listener); | 1215 observer->Start(listener); |
| 1213 | 1216 |
| 1214 // Device events (motion, orientation and light) expect to get an event fired | 1217 // Device events (motion, orientation and light) expect to get an event fired |
| 1215 // as soon as a listener is registered if a fake data was passed before. | 1218 // as soon as a listener is registered if a fake data was passed before. |
| 1216 // TODO(mlamouri,timvolodine): make those send mock values directly instead of | 1219 // TODO(mlamouri,timvolodine): make those send mock values directly instead of |
| 1217 // using this broken pattern. | 1220 // using this broken pattern. |
| 1218 if (RenderThreadImpl::current() && | 1221 if (RenderThreadImpl::current() && |
| 1219 RenderThreadImpl::current()->layout_test_mode() && | 1222 RenderThreadImpl::current()->layout_test_mode() && |
| 1220 (type == blink::WebPlatformEventTypeDeviceMotion || | 1223 (type == blink::WebPlatformEventTypeDeviceMotion || |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 return &trial_token_validator_; | 1293 return &trial_token_validator_; |
| 1291 } | 1294 } |
| 1292 | 1295 |
| 1293 void RendererBlinkPlatformImpl::workerContextCreated( | 1296 void RendererBlinkPlatformImpl::workerContextCreated( |
| 1294 const v8::Local<v8::Context>& worker) { | 1297 const v8::Local<v8::Context>& worker) { |
| 1295 GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread( | 1298 GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread( |
| 1296 worker); | 1299 worker); |
| 1297 } | 1300 } |
| 1298 | 1301 |
| 1299 } // namespace content | 1302 } // namespace content |
| OLD | NEW |