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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/numerics/safe_conversions.h" | 14 #include "base/numerics/safe_conversions.h" |
15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "base/thread_task_runner_handle.h" | 18 #include "base/thread_task_runner_handle.h" |
19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
20 #include "cc/blink/context_provider_web_context.h" | 20 #include "cc/blink/context_provider_web_context.h" |
21 #include "components/scheduler/child/web_scheduler_impl.h" | 21 #include "components/scheduler/child/web_scheduler_impl.h" |
22 #include "components/scheduler/child/web_task_runner_impl.h" | |
23 #include "components/scheduler/renderer/renderer_scheduler.h" | 22 #include "components/scheduler/renderer/renderer_scheduler.h" |
24 #include "components/scheduler/renderer/webthread_impl_for_renderer_scheduler.h" | 23 #include "components/scheduler/renderer/webthread_impl_for_renderer_scheduler.h" |
25 #include "components/url_formatter/url_formatter.h" | 24 #include "components/url_formatter/url_formatter.h" |
26 #include "content/child/database_util.h" | 25 #include "content/child/database_util.h" |
27 #include "content/child/file_info_util.h" | 26 #include "content/child/file_info_util.h" |
28 #include "content/child/fileapi/webfilesystem_impl.h" | 27 #include "content/child/fileapi/webfilesystem_impl.h" |
29 #include "content/child/indexed_db/webidbfactory_impl.h" | 28 #include "content/child/indexed_db/webidbfactory_impl.h" |
30 #include "content/child/npapi/npobject_util.h" | 29 #include "content/child/npapi/npobject_util.h" |
31 #include "content/child/quota_dispatcher.h" | 30 #include "content/child/quota_dispatcher.h" |
32 #include "content/child/quota_message_filter.h" | 31 #include "content/child/quota_message_filter.h" |
33 #include "content/child/simple_webmimeregistry_impl.h" | 32 #include "content/child/simple_webmimeregistry_impl.h" |
34 #include "content/child/thread_safe_sender.h" | 33 #include "content/child/thread_safe_sender.h" |
35 #include "content/child/web_database_observer_impl.h" | 34 #include "content/child/web_database_observer_impl.h" |
36 #include "content/child/web_url_loader_impl.h" | |
37 #include "content/child/webblobregistry_impl.h" | 35 #include "content/child/webblobregistry_impl.h" |
38 #include "content/child/webfileutilities_impl.h" | 36 #include "content/child/webfileutilities_impl.h" |
39 #include "content/child/webmessageportchannel_impl.h" | 37 #include "content/child/webmessageportchannel_impl.h" |
40 #include "content/common/file_utilities_messages.h" | 38 #include "content/common/file_utilities_messages.h" |
41 #include "content/common/frame_messages.h" | 39 #include "content/common/frame_messages.h" |
42 #include "content/common/gpu/client/context_provider_command_buffer.h" | 40 #include "content/common/gpu/client/context_provider_command_buffer.h" |
43 #include "content/common/gpu/client/gpu_channel_host.h" | 41 #include "content/common/gpu/client/gpu_channel_host.h" |
44 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 42 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
45 #include "content/common/gpu/gpu_process_launch_causes.h" | 43 #include "content/common/gpu/gpu_process_launch_causes.h" |
46 #include "content/common/mime_registry_messages.h" | 44 #include "content/common/mime_registry_messages.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 scheduler::RendererScheduler* renderer_scheduler) | 230 scheduler::RendererScheduler* renderer_scheduler) |
233 : BlinkPlatformImpl(renderer_scheduler->DefaultTaskRunner()), | 231 : BlinkPlatformImpl(renderer_scheduler->DefaultTaskRunner()), |
234 main_thread_( | 232 main_thread_( |
235 new scheduler::WebThreadImplForRendererScheduler(renderer_scheduler)), | 233 new scheduler::WebThreadImplForRendererScheduler(renderer_scheduler)), |
236 clipboard_delegate_(new RendererClipboardDelegate), | 234 clipboard_delegate_(new RendererClipboardDelegate), |
237 clipboard_(new WebClipboardImpl(clipboard_delegate_.get())), | 235 clipboard_(new WebClipboardImpl(clipboard_delegate_.get())), |
238 mime_registry_(new RendererBlinkPlatformImpl::MimeRegistry), | 236 mime_registry_(new RendererBlinkPlatformImpl::MimeRegistry), |
239 sudden_termination_disables_(0), | 237 sudden_termination_disables_(0), |
240 plugin_refresh_allowed_(true), | 238 plugin_refresh_allowed_(true), |
241 default_task_runner_(renderer_scheduler->DefaultTaskRunner()), | 239 default_task_runner_(renderer_scheduler->DefaultTaskRunner()), |
242 loading_task_runner_(renderer_scheduler->LoadingTaskRunner()), | |
243 web_scrollbar_behavior_(new WebScrollbarBehaviorImpl) { | 240 web_scrollbar_behavior_(new WebScrollbarBehaviorImpl) { |
244 #if !defined(OS_ANDROID) && !defined(OS_WIN) | 241 #if !defined(OS_ANDROID) && !defined(OS_WIN) |
245 if (g_sandbox_enabled && sandboxEnabled()) { | 242 if (g_sandbox_enabled && sandboxEnabled()) { |
246 sandbox_support_.reset(new RendererBlinkPlatformImpl::SandboxSupport); | 243 sandbox_support_.reset(new RendererBlinkPlatformImpl::SandboxSupport); |
247 } else { | 244 } else { |
248 DVLOG(1) << "Disabling sandbox support for testing."; | 245 DVLOG(1) << "Disabling sandbox support for testing."; |
249 } | 246 } |
250 #endif | 247 #endif |
251 | 248 |
252 // ChildThread may not exist in some tests. | 249 // ChildThread may not exist in some tests. |
(...skipping 16 matching lines...) Expand all Loading... |
269 #if !defined(OS_ANDROID) && !defined(OS_WIN) | 266 #if !defined(OS_ANDROID) && !defined(OS_WIN) |
270 // SandboxSupport contains a map of WebFontFamily objects, which hold | 267 // SandboxSupport contains a map of WebFontFamily objects, which hold |
271 // WebCStrings, which become invalidated when blink is shut down. Hence, we | 268 // WebCStrings, which become invalidated when blink is shut down. Hence, we |
272 // need to clear that map now, just before blink::shutdown() is called. | 269 // need to clear that map now, just before blink::shutdown() is called. |
273 sandbox_support_.reset(); | 270 sandbox_support_.reset(); |
274 #endif | 271 #endif |
275 } | 272 } |
276 | 273 |
277 //------------------------------------------------------------------------------ | 274 //------------------------------------------------------------------------------ |
278 | 275 |
279 blink::WebURLLoader* RendererBlinkPlatformImpl::createURLLoader() { | |
280 ChildThreadImpl* child_thread = ChildThreadImpl::current(); | |
281 // There may be no child thread in RenderViewTests. These tests can still use | |
282 // data URLs to bypass the ResourceDispatcher. | |
283 scoped_ptr<scheduler::WebTaskRunnerImpl> task_runner( | |
284 new scheduler::WebTaskRunnerImpl( | |
285 loading_task_runner_->BelongsToCurrentThread() | |
286 ? loading_task_runner_ : base::ThreadTaskRunnerHandle::Get())); | |
287 return new content::WebURLLoaderImpl( | |
288 child_thread ? child_thread->resource_dispatcher() : NULL, | |
289 task_runner.Pass()); | |
290 } | |
291 | |
292 blink::WebThread* RendererBlinkPlatformImpl::currentThread() { | 276 blink::WebThread* RendererBlinkPlatformImpl::currentThread() { |
293 if (main_thread_->isCurrentThread()) | 277 if (main_thread_->isCurrentThread()) |
294 return main_thread_.get(); | 278 return main_thread_.get(); |
295 return BlinkPlatformImpl::currentThread(); | 279 return BlinkPlatformImpl::currentThread(); |
296 } | 280 } |
297 | 281 |
298 blink::WebClipboard* RendererBlinkPlatformImpl::clipboard() { | 282 blink::WebClipboard* RendererBlinkPlatformImpl::clipboard() { |
299 blink::WebClipboard* clipboard = | 283 blink::WebClipboard* clipboard = |
300 GetContentClient()->renderer()->OverrideWebClipboard(); | 284 GetContentClient()->renderer()->OverrideWebClipboard(); |
301 if (clipboard) | 285 if (clipboard) |
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 //------------------------------------------------------------------------------ | 1245 //------------------------------------------------------------------------------ |
1262 | 1246 |
1263 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting( | 1247 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting( |
1264 const blink::WebBatteryStatus& status) { | 1248 const blink::WebBatteryStatus& status) { |
1265 if (!g_test_battery_status_listener) | 1249 if (!g_test_battery_status_listener) |
1266 return; | 1250 return; |
1267 g_test_battery_status_listener->updateBatteryStatus(status); | 1251 g_test_battery_status_listener->updateBatteryStatus(status); |
1268 } | 1252 } |
1269 | 1253 |
1270 } // namespace content | 1254 } // namespace content |
OLD | NEW |