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

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: fix compile Created 3 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 <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 24 matching lines...) Expand all
35 #include "content/child/storage_util.h" 35 #include "content/child/storage_util.h"
36 #include "content/child/thread_safe_sender.h" 36 #include "content/child/thread_safe_sender.h"
37 #include "content/child/web_database_observer_impl.h" 37 #include "content/child/web_database_observer_impl.h"
38 #include "content/child/web_url_loader_impl.h" 38 #include "content/child/web_url_loader_impl.h"
39 #include "content/child/webfileutilities_impl.h" 39 #include "content/child/webfileutilities_impl.h"
40 #include "content/child/webmessageportchannel_impl.h" 40 #include "content/child/webmessageportchannel_impl.h"
41 #include "content/common/file_utilities_messages.h" 41 #include "content/common/file_utilities_messages.h"
42 #include "content/common/frame_messages.h" 42 #include "content/common/frame_messages.h"
43 #include "content/common/render_process_messages.h" 43 #include "content/common/render_process_messages.h"
44 #include "content/public/common/content_switches.h" 44 #include "content/public/common/content_switches.h"
45 #include "content/public/common/service_manager_connection.h"
45 #include "content/public/common/webplugininfo.h" 46 #include "content/public/common/webplugininfo.h"
46 #include "content/public/renderer/content_renderer_client.h" 47 #include "content/public/renderer/content_renderer_client.h"
47 #include "content/public/renderer/media_stream_utils.h" 48 #include "content/public/renderer/media_stream_utils.h"
48 #include "content/public/renderer/render_frame.h" 49 #include "content/public/renderer/render_frame.h"
49 #include "content/renderer/cache_storage/webserviceworkercachestorage_impl.h" 50 #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_light_event_pump.h"
51 #include "content/renderer/device_sensors/device_motion_event_pump.h" 52 #include "content/renderer/device_sensors/device_motion_event_pump.h"
52 #include "content/renderer/device_sensors/device_orientation_event_pump.h" 53 #include "content/renderer/device_sensors/device_orientation_event_pump.h"
53 #include "content/renderer/dom_storage/local_storage_cached_areas.h" 54 #include "content/renderer/dom_storage/local_storage_cached_areas.h"
54 #include "content/renderer/dom_storage/local_storage_namespace.h" 55 #include "content/renderer/dom_storage/local_storage_namespace.h"
55 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" 56 #include "content/renderer/dom_storage/webstoragenamespace_impl.h"
56 #include "content/renderer/gamepad_shared_memory_reader.h" 57 #include "content/renderer/gamepad_shared_memory_reader.h"
57 #include "content/renderer/image_capture/image_capture_frame_grabber.h" 58 #include "content/renderer/image_capture/image_capture_frame_grabber.h"
58 #include "content/renderer/media/audio_decoder.h" 59 #include "content/renderer/media/audio_decoder.h"
59 #include "content/renderer/media/audio_device_factory.h" 60 #include "content/renderer/media/audio_device_factory.h"
60 #include "content/renderer/media/renderer_webaudiodevice_impl.h" 61 #include "content/renderer/media/renderer_webaudiodevice_impl.h"
61 #include "content/renderer/media/renderer_webmidiaccessor_impl.h" 62 #include "content/renderer/media/renderer_webmidiaccessor_impl.h"
62 #include "content/renderer/media_capture_from_element/canvas_capture_handler.h" 63 #include "content/renderer/media_capture_from_element/canvas_capture_handler.h"
63 #include "content/renderer/media_capture_from_element/html_audio_element_capture r_source.h" 64 #include "content/renderer/media_capture_from_element/html_audio_element_capture r_source.h"
64 #include "content/renderer/media_capture_from_element/html_video_element_capture r_source.h" 65 #include "content/renderer/media_capture_from_element/html_video_element_capture r_source.h"
65 #include "content/renderer/media_recorder/media_recorder_handler.h" 66 #include "content/renderer/media_recorder/media_recorder_handler.h"
67 #include "content/renderer/mojo/blink_connector_impl.h"
66 #include "content/renderer/mojo/blink_interface_provider_impl.h" 68 #include "content/renderer/mojo/blink_interface_provider_impl.h"
67 #include "content/renderer/render_thread_impl.h" 69 #include "content/renderer/render_thread_impl.h"
68 #include "content/renderer/renderer_clipboard_delegate.h" 70 #include "content/renderer/renderer_clipboard_delegate.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 "ppapi/features/features.h" 82 #include "ppapi/features/features.h"
83 #include "services/service_manager/public/cpp/connector.h"
81 #include "services/service_manager/public/cpp/interface_provider.h" 84 #include "services/service_manager/public/cpp/interface_provider.h"
82 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" 85 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h"
83 #include "storage/common/database/database_identifier.h" 86 #include "storage/common/database/database_identifier.h"
84 #include "storage/common/quota/quota_types.h" 87 #include "storage/common/quota/quota_types.h"
85 #include "third_party/WebKit/public/platform/BlameContext.h" 88 #include "third_party/WebKit/public/platform/BlameContext.h"
86 #include "third_party/WebKit/public/platform/FilePathConversion.h" 89 #include "third_party/WebKit/public/platform/FilePathConversion.h"
87 #include "third_party/WebKit/public/platform/URLConversion.h" 90 #include "third_party/WebKit/public/platform/URLConversion.h"
88 #include "third_party/WebKit/public/platform/WebAudioLatencyHint.h" 91 #include "third_party/WebKit/public/platform/WebAudioLatencyHint.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"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 : BlinkPlatformImpl(renderer_scheduler->DefaultTaskRunner()), 245 : BlinkPlatformImpl(renderer_scheduler->DefaultTaskRunner()),
243 main_thread_(renderer_scheduler->CreateMainThread()), 246 main_thread_(renderer_scheduler->CreateMainThread()),
244 clipboard_delegate_(new RendererClipboardDelegate), 247 clipboard_delegate_(new RendererClipboardDelegate),
245 clipboard_(new WebClipboardImpl(clipboard_delegate_.get())), 248 clipboard_(new WebClipboardImpl(clipboard_delegate_.get())),
246 sudden_termination_disables_(0), 249 sudden_termination_disables_(0),
247 plugin_refresh_allowed_(true), 250 plugin_refresh_allowed_(true),
248 default_task_runner_(renderer_scheduler->DefaultTaskRunner()), 251 default_task_runner_(renderer_scheduler->DefaultTaskRunner()),
249 loading_task_runner_(renderer_scheduler->LoadingTaskRunner()), 252 loading_task_runner_(renderer_scheduler->LoadingTaskRunner()),
250 web_scrollbar_behavior_(new WebScrollbarBehaviorImpl), 253 web_scrollbar_behavior_(new WebScrollbarBehaviorImpl),
251 renderer_scheduler_(renderer_scheduler), 254 renderer_scheduler_(renderer_scheduler),
255 blink_connector_(new BlinkConnectorImpl(nullptr)),
252 blink_interface_provider_( 256 blink_interface_provider_(
253 new BlinkInterfaceProviderImpl(remote_interfaces)) { 257 new BlinkInterfaceProviderImpl(remote_interfaces)) {
254 #if !defined(OS_ANDROID) && !defined(OS_WIN) 258 #if !defined(OS_ANDROID) && !defined(OS_WIN)
255 if (g_sandbox_enabled && sandboxEnabled()) { 259 if (g_sandbox_enabled && sandboxEnabled()) {
256 sandbox_support_.reset(new RendererBlinkPlatformImpl::SandboxSupport); 260 sandbox_support_.reset(new RendererBlinkPlatformImpl::SandboxSupport);
257 } else { 261 } else {
258 DVLOG(1) << "Disabling sandbox support for testing."; 262 DVLOG(1) << "Disabling sandbox support for testing.";
259 } 263 }
260 #endif 264 #endif
261 265
262 // RenderThread may not exist in some tests. 266 // RenderThread may not exist in some tests.
263 if (RenderThreadImpl::current()) { 267 if (RenderThreadImpl::current()) {
dcheng 2017/03/21 18:56:18 Ah... bah. This issue again... I guess you can ig
268 blink_connector_->SetConnector(RenderThreadImpl::current()
269 ->GetServiceManagerConnection()
270 ->GetConnector()
271 ->Clone());
264 sync_message_filter_ = RenderThreadImpl::current()->sync_message_filter(); 272 sync_message_filter_ = RenderThreadImpl::current()->sync_message_filter();
265 thread_safe_sender_ = RenderThreadImpl::current()->thread_safe_sender(); 273 thread_safe_sender_ = RenderThreadImpl::current()->thread_safe_sender();
266 quota_message_filter_ = RenderThreadImpl::current()->quota_message_filter(); 274 quota_message_filter_ = RenderThreadImpl::current()->quota_message_filter();
267 shared_bitmap_manager_ = 275 shared_bitmap_manager_ =
268 RenderThreadImpl::current()->shared_bitmap_manager(); 276 RenderThreadImpl::current()->shared_bitmap_manager();
269 blob_registry_.reset(new WebBlobRegistryImpl( 277 blob_registry_.reset(new WebBlobRegistryImpl(
270 RenderThreadImpl::current()->GetIOTaskRunner().get(), 278 RenderThreadImpl::current()->GetIOTaskRunner().get(),
271 base::ThreadTaskRunnerHandle::Get(), thread_safe_sender_.get())); 279 base::ThreadTaskRunnerHandle::Get(), thread_safe_sender_.get()));
272 web_idb_factory_.reset(new WebIDBFactoryImpl( 280 web_idb_factory_.reset(new WebIDBFactoryImpl(
273 sync_message_filter_, 281 sync_message_filter_,
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 } 1150 }
1143 1151
1144 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting( 1152 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting(
1145 blink::WebPlatformEventType type, 1153 blink::WebPlatformEventType type,
1146 std::unique_ptr<PlatformEventObserverBase> observer) { 1154 std::unique_ptr<PlatformEventObserverBase> observer) {
1147 if (platform_event_observers_.Lookup(type)) 1155 if (platform_event_observers_.Lookup(type))
1148 platform_event_observers_.Remove(type); 1156 platform_event_observers_.Remove(type);
1149 platform_event_observers_.AddWithID(std::move(observer), type); 1157 platform_event_observers_.AddWithID(std::move(observer), type);
1150 } 1158 }
1151 1159
1160 blink::Connector* RendererBlinkPlatformImpl::connector() {
1161 return blink_connector_.get();
1162 }
1163
1152 blink::InterfaceProvider* RendererBlinkPlatformImpl::interfaceProvider() { 1164 blink::InterfaceProvider* RendererBlinkPlatformImpl::interfaceProvider() {
1153 return blink_interface_provider_.get(); 1165 return blink_interface_provider_.get();
1154 } 1166 }
1155 1167
1156 void RendererBlinkPlatformImpl::startListening( 1168 void RendererBlinkPlatformImpl::startListening(
1157 blink::WebPlatformEventType type, 1169 blink::WebPlatformEventType type,
1158 blink::WebPlatformEventListener* listener) { 1170 blink::WebPlatformEventListener* listener) {
1159 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); 1171 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type);
1160 if (!observer) { 1172 if (!observer) {
1161 std::unique_ptr<PlatformEventObserverBase> new_observer = 1173 std::unique_ptr<PlatformEventObserverBase> new_observer =
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 //------------------------------------------------------------------------------ 1268 //------------------------------------------------------------------------------
1257 void RendererBlinkPlatformImpl::requestPurgeMemory() { 1269 void RendererBlinkPlatformImpl::requestPurgeMemory() {
1258 // TODO(tasak|bashi): We should use ChildMemoryCoordinator here, but 1270 // TODO(tasak|bashi): We should use ChildMemoryCoordinator here, but
1259 // ChildMemoryCoordinator isn't always available as it's only initialized 1271 // ChildMemoryCoordinator isn't always available as it's only initialized
1260 // when kMemoryCoordinatorV0 is enabled. 1272 // when kMemoryCoordinatorV0 is enabled.
1261 // Use ChildMemoryCoordinator when memory coordinator is always enabled. 1273 // Use ChildMemoryCoordinator when memory coordinator is always enabled.
1262 base::MemoryCoordinatorClientRegistry::GetInstance()->PurgeMemory(); 1274 base::MemoryCoordinatorClientRegistry::GetInstance()->PurgeMemory();
1263 } 1275 }
1264 1276
1265 } // namespace content 1277 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698