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

Side by Side Diff: content/renderer/renderer_blink_platform_impl.cc

Issue 2643063002: Refactor Blink's ServiceConnector and add ability to mock in layout tests (Closed)
Patch Set: Rebase Created 3 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 <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 23 matching lines...) Expand all
34 #include "content/child/storage_util.h" 34 #include "content/child/storage_util.h"
35 #include "content/child/thread_safe_sender.h" 35 #include "content/child/thread_safe_sender.h"
36 #include "content/child/web_database_observer_impl.h" 36 #include "content/child/web_database_observer_impl.h"
37 #include "content/child/web_url_loader_impl.h" 37 #include "content/child/web_url_loader_impl.h"
38 #include "content/child/webfileutilities_impl.h" 38 #include "content/child/webfileutilities_impl.h"
39 #include "content/child/webmessageportchannel_impl.h" 39 #include "content/child/webmessageportchannel_impl.h"
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/webplugininfo.h" 45 #include "content/public/common/webplugininfo.h"
45 #include "content/public/renderer/content_renderer_client.h" 46 #include "content/public/renderer/content_renderer_client.h"
46 #include "content/public/renderer/media_stream_utils.h" 47 #include "content/public/renderer/media_stream_utils.h"
47 #include "content/public/renderer/render_frame.h" 48 #include "content/public/renderer/render_frame.h"
48 #include "content/renderer/cache_storage/webserviceworkercachestorage_impl.h" 49 #include "content/renderer/cache_storage/webserviceworkercachestorage_impl.h"
49 #include "content/renderer/device_sensors/device_light_event_pump.h" 50 #include "content/renderer/device_sensors/device_light_event_pump.h"
50 #include "content/renderer/device_sensors/device_motion_event_pump.h" 51 #include "content/renderer/device_sensors/device_motion_event_pump.h"
51 #include "content/renderer/device_sensors/device_orientation_event_pump.h" 52 #include "content/renderer/device_sensors/device_orientation_event_pump.h"
52 #include "content/renderer/dom_storage/local_storage_cached_areas.h" 53 #include "content/renderer/dom_storage/local_storage_cached_areas.h"
53 #include "content/renderer/dom_storage/local_storage_namespace.h" 54 #include "content/renderer/dom_storage/local_storage_namespace.h"
54 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" 55 #include "content/renderer/dom_storage/webstoragenamespace_impl.h"
55 #include "content/renderer/gamepad_shared_memory_reader.h" 56 #include "content/renderer/gamepad_shared_memory_reader.h"
56 #include "content/renderer/media/audio_decoder.h" 57 #include "content/renderer/media/audio_decoder.h"
57 #include "content/renderer/media/audio_device_factory.h" 58 #include "content/renderer/media/audio_device_factory.h"
58 #include "content/renderer/media/canvas_capture_handler.h" 59 #include "content/renderer/media/canvas_capture_handler.h"
59 #include "content/renderer/media/html_audio_element_capturer_source.h" 60 #include "content/renderer/media/html_audio_element_capturer_source.h"
60 #include "content/renderer/media/html_video_element_capturer_source.h" 61 #include "content/renderer/media/html_video_element_capturer_source.h"
61 #include "content/renderer/media/image_capture_frame_grabber.h" 62 #include "content/renderer/media/image_capture_frame_grabber.h"
62 #include "content/renderer/media/media_recorder_handler.h" 63 #include "content/renderer/media/media_recorder_handler.h"
63 #include "content/renderer/media/renderer_webaudiodevice_impl.h" 64 #include "content/renderer/media/renderer_webaudiodevice_impl.h"
64 #include "content/renderer/media/renderer_webmidiaccessor_impl.h" 65 #include "content/renderer/media/renderer_webmidiaccessor_impl.h"
66 #include "content/renderer/mojo/blink_connector_impl.h"
65 #include "content/renderer/mojo/blink_interface_provider_impl.h" 67 #include "content/renderer/mojo/blink_interface_provider_impl.h"
66 #include "content/renderer/render_thread_impl.h" 68 #include "content/renderer/render_thread_impl.h"
67 #include "content/renderer/renderer_clipboard_delegate.h" 69 #include "content/renderer/renderer_clipboard_delegate.h"
68 #include "content/renderer/screen_orientation/screen_orientation_observer.h" 70 #include "content/renderer/screen_orientation/screen_orientation_observer.h"
69 #include "content/renderer/webclipboard_impl.h" 71 #include "content/renderer/webclipboard_impl.h"
70 #include "content/renderer/webgraphicscontext3d_provider_impl.h" 72 #include "content/renderer/webgraphicscontext3d_provider_impl.h"
71 #include "content/renderer/webpublicsuffixlist_impl.h" 73 #include "content/renderer/webpublicsuffixlist_impl.h"
72 #include "gpu/command_buffer/client/gles2_interface.h" 74 #include "gpu/command_buffer/client/gles2_interface.h"
73 #include "gpu/config/gpu_info.h" 75 #include "gpu/config/gpu_info.h"
74 #include "gpu/ipc/client/gpu_channel_host.h" 76 #include "gpu/ipc/client/gpu_channel_host.h"
75 #include "gpu/ipc/common/gpu_stream_constants.h" 77 #include "gpu/ipc/common/gpu_stream_constants.h"
76 #include "ipc/ipc_sync_message_filter.h" 78 #include "ipc/ipc_sync_message_filter.h"
77 #include "media/audio/audio_output_device.h" 79 #include "media/audio/audio_output_device.h"
78 #include "media/blink/webcontentdecryptionmodule_impl.h" 80 #include "media/blink/webcontentdecryptionmodule_impl.h"
79 #include "media/filters/stream_parser_factory.h" 81 #include "media/filters/stream_parser_factory.h"
80 #include "mojo/public/cpp/bindings/associated_group.h" 82 #include "mojo/public/cpp/bindings/associated_group.h"
81 #include "ppapi/features/features.h" 83 #include "ppapi/features/features.h"
84 #include "services/service_manager/public/cpp/connector.h"
82 #include "services/service_manager/public/cpp/interface_provider.h" 85 #include "services/service_manager/public/cpp/interface_provider.h"
83 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" 86 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h"
84 #include "storage/common/database/database_identifier.h" 87 #include "storage/common/database/database_identifier.h"
85 #include "storage/common/quota/quota_types.h" 88 #include "storage/common/quota/quota_types.h"
86 #include "third_party/WebKit/public/platform/BlameContext.h" 89 #include "third_party/WebKit/public/platform/BlameContext.h"
87 #include "third_party/WebKit/public/platform/FilePathConversion.h" 90 #include "third_party/WebKit/public/platform/FilePathConversion.h"
88 #include "third_party/WebKit/public/platform/URLConversion.h" 91 #include "third_party/WebKit/public/platform/URLConversion.h"
89 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" 92 #include "third_party/WebKit/public/platform/WebBlobRegistry.h"
90 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" 93 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h"
91 #include "third_party/WebKit/public/platform/WebFileInfo.h" 94 #include "third_party/WebKit/public/platform/WebFileInfo.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 : BlinkPlatformImpl(renderer_scheduler->DefaultTaskRunner()), 244 : BlinkPlatformImpl(renderer_scheduler->DefaultTaskRunner()),
242 main_thread_(renderer_scheduler->CreateMainThread()), 245 main_thread_(renderer_scheduler->CreateMainThread()),
243 clipboard_delegate_(new RendererClipboardDelegate), 246 clipboard_delegate_(new RendererClipboardDelegate),
244 clipboard_(new WebClipboardImpl(clipboard_delegate_.get())), 247 clipboard_(new WebClipboardImpl(clipboard_delegate_.get())),
245 sudden_termination_disables_(0), 248 sudden_termination_disables_(0),
246 plugin_refresh_allowed_(true), 249 plugin_refresh_allowed_(true),
247 default_task_runner_(renderer_scheduler->DefaultTaskRunner()), 250 default_task_runner_(renderer_scheduler->DefaultTaskRunner()),
248 loading_task_runner_(renderer_scheduler->LoadingTaskRunner()), 251 loading_task_runner_(renderer_scheduler->LoadingTaskRunner()),
249 web_scrollbar_behavior_(new WebScrollbarBehaviorImpl), 252 web_scrollbar_behavior_(new WebScrollbarBehaviorImpl),
250 renderer_scheduler_(renderer_scheduler), 253 renderer_scheduler_(renderer_scheduler),
254 blink_connector_(new BlinkConnectorImpl(nullptr)),
251 blink_interface_provider_( 255 blink_interface_provider_(
252 new BlinkInterfaceProviderImpl(remote_interfaces)) { 256 new BlinkInterfaceProviderImpl(remote_interfaces)) {
253 #if !defined(OS_ANDROID) && !defined(OS_WIN) 257 #if !defined(OS_ANDROID) && !defined(OS_WIN)
254 if (g_sandbox_enabled && sandboxEnabled()) { 258 if (g_sandbox_enabled && sandboxEnabled()) {
255 sandbox_support_.reset(new RendererBlinkPlatformImpl::SandboxSupport); 259 sandbox_support_.reset(new RendererBlinkPlatformImpl::SandboxSupport);
256 } else { 260 } else {
257 DVLOG(1) << "Disabling sandbox support for testing."; 261 DVLOG(1) << "Disabling sandbox support for testing.";
258 } 262 }
259 #endif 263 #endif
260 264
261 // RenderThread may not exist in some tests. 265 // RenderThread may not exist in some tests.
262 if (RenderThreadImpl::current()) { 266 if (RenderThreadImpl::current()) {
267 blink_connector_->SetConnector(RenderThreadImpl::current()
esprehn 2017/02/01 06:02:23 Lets just do this inside blink itself. Pass the Se
268 ->GetServiceManagerConnection()
269 ->GetConnector()
270 ->Clone());
263 sync_message_filter_ = RenderThreadImpl::current()->sync_message_filter(); 271 sync_message_filter_ = RenderThreadImpl::current()->sync_message_filter();
264 thread_safe_sender_ = RenderThreadImpl::current()->thread_safe_sender(); 272 thread_safe_sender_ = RenderThreadImpl::current()->thread_safe_sender();
265 quota_message_filter_ = RenderThreadImpl::current()->quota_message_filter(); 273 quota_message_filter_ = RenderThreadImpl::current()->quota_message_filter();
266 shared_bitmap_manager_ = 274 shared_bitmap_manager_ =
267 RenderThreadImpl::current()->shared_bitmap_manager(); 275 RenderThreadImpl::current()->shared_bitmap_manager();
268 blob_registry_.reset(new WebBlobRegistryImpl( 276 blob_registry_.reset(new WebBlobRegistryImpl(
269 RenderThreadImpl::current()->GetIOTaskRunner().get(), 277 RenderThreadImpl::current()->GetIOTaskRunner().get(),
270 base::ThreadTaskRunnerHandle::Get(), thread_safe_sender_.get())); 278 base::ThreadTaskRunnerHandle::Get(), thread_safe_sender_.get()));
271 web_idb_factory_.reset(new WebIDBFactoryImpl( 279 web_idb_factory_.reset(new WebIDBFactoryImpl(
272 sync_message_filter_, 280 sync_message_filter_,
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 } 1190 }
1183 1191
1184 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting( 1192 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting(
1185 blink::WebPlatformEventType type, 1193 blink::WebPlatformEventType type,
1186 std::unique_ptr<PlatformEventObserverBase> observer) { 1194 std::unique_ptr<PlatformEventObserverBase> observer) {
1187 if (platform_event_observers_.Lookup(type)) 1195 if (platform_event_observers_.Lookup(type))
1188 platform_event_observers_.Remove(type); 1196 platform_event_observers_.Remove(type);
1189 platform_event_observers_.AddWithID(std::move(observer), type); 1197 platform_event_observers_.AddWithID(std::move(observer), type);
1190 } 1198 }
1191 1199
1200 blink::Connector* RendererBlinkPlatformImpl::connector() {
1201 return blink_connector_.get();
1202 }
1203
1192 blink::InterfaceProvider* RendererBlinkPlatformImpl::interfaceProvider() { 1204 blink::InterfaceProvider* RendererBlinkPlatformImpl::interfaceProvider() {
1193 return blink_interface_provider_.get(); 1205 return blink_interface_provider_.get();
1194 } 1206 }
1195 1207
1196 void RendererBlinkPlatformImpl::startListening( 1208 void RendererBlinkPlatformImpl::startListening(
1197 blink::WebPlatformEventType type, 1209 blink::WebPlatformEventType type,
1198 blink::WebPlatformEventListener* listener) { 1210 blink::WebPlatformEventListener* listener) {
1199 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); 1211 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type);
1200 if (!observer) { 1212 if (!observer) {
1201 std::unique_ptr<PlatformEventObserverBase> new_observer = 1213 std::unique_ptr<PlatformEventObserverBase> new_observer =
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 return &trial_token_validator_; 1299 return &trial_token_validator_;
1288 } 1300 }
1289 1301
1290 void RendererBlinkPlatformImpl::workerContextCreated( 1302 void RendererBlinkPlatformImpl::workerContextCreated(
1291 const v8::Local<v8::Context>& worker) { 1303 const v8::Local<v8::Context>& worker) {
1292 GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread( 1304 GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread(
1293 worker); 1305 worker);
1294 } 1306 }
1295 1307
1296 } // namespace content 1308 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698