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/render_thread_impl.h" | 5 #include "content/renderer/render_thread_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <map> | 9 #include <map> |
10 #include <utility> | 10 #include <utility> |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 #include "third_party/WebKit/public/web/WebCache.h" | 153 #include "third_party/WebKit/public/web/WebCache.h" |
154 #include "third_party/WebKit/public/web/WebDatabase.h" | 154 #include "third_party/WebKit/public/web/WebDatabase.h" |
155 #include "third_party/WebKit/public/web/WebDocument.h" | 155 #include "third_party/WebKit/public/web/WebDocument.h" |
156 #include "third_party/WebKit/public/web/WebFrame.h" | 156 #include "third_party/WebKit/public/web/WebFrame.h" |
157 #include "third_party/WebKit/public/web/WebKit.h" | 157 #include "third_party/WebKit/public/web/WebKit.h" |
158 #include "third_party/WebKit/public/web/WebNetworkStateNotifier.h" | 158 #include "third_party/WebKit/public/web/WebNetworkStateNotifier.h" |
159 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 159 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
160 #include "third_party/WebKit/public/web/WebScriptController.h" | 160 #include "third_party/WebKit/public/web/WebScriptController.h" |
161 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 161 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
162 #include "third_party/WebKit/public/web/WebView.h" | 162 #include "third_party/WebKit/public/web/WebView.h" |
163 #include "third_party/icu/source/i18n/unicode/timezone.h" | |
164 #include "third_party/skia/include/core/SkGraphics.h" | 163 #include "third_party/skia/include/core/SkGraphics.h" |
165 #include "ui/base/layout.h" | 164 #include "ui/base/layout.h" |
166 #include "ui/base/ui_base_switches.h" | 165 #include "ui/base/ui_base_switches.h" |
167 #include "ui/gl/gl_switches.h" | 166 #include "ui/gl/gl_switches.h" |
168 | 167 |
169 #if defined(OS_ANDROID) | 168 #if defined(OS_ANDROID) |
170 #include <cpu-features.h> | 169 #include <cpu-features.h> |
171 #include "content/renderer/android/synchronous_compositor_filter.h" | 170 #include "content/renderer/android/synchronous_compositor_filter.h" |
172 #include "content/renderer/android/synchronous_compositor_frame_sink.h" | 171 #include "content/renderer/android/synchronous_compositor_frame_sink.h" |
173 #include "content/renderer/media/android/stream_texture_factory.h" | 172 #include "content/renderer/media/android/stream_texture_factory.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 histogram_name, min, max, buckets, | 316 histogram_name, min, max, buckets, |
318 base::Histogram::kUmaTargetedHistogramFlag); | 317 base::Histogram::kUmaTargetedHistogramFlag); |
319 return histogram; | 318 return histogram; |
320 } | 319 } |
321 | 320 |
322 void AddHistogramSample(void* hist, int sample) { | 321 void AddHistogramSample(void* hist, int sample) { |
323 base::Histogram* histogram = static_cast<base::Histogram*>(hist); | 322 base::Histogram* histogram = static_cast<base::Histogram*>(hist); |
324 histogram->Add(sample); | 323 histogram->Add(sample); |
325 } | 324 } |
326 | 325 |
327 void NotifyTimezoneChangeOnThisThread() { | |
328 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
329 if (!isolate) | |
330 return; | |
331 v8::Date::DateTimeConfigurationChangeNotification(isolate); | |
332 } | |
333 | |
334 class FrameFactoryImpl : public mojom::FrameFactory { | 326 class FrameFactoryImpl : public mojom::FrameFactory { |
335 public: | 327 public: |
336 FrameFactoryImpl() : routing_id_highmark_(-1) {} | 328 FrameFactoryImpl() : routing_id_highmark_(-1) {} |
337 | 329 |
338 private: | 330 private: |
339 // mojom::FrameFactory: | 331 // mojom::FrameFactory: |
340 void CreateFrame(int32_t frame_routing_id, | 332 void CreateFrame(int32_t frame_routing_id, |
341 mojom::FrameRequest frame_request, | 333 mojom::FrameRequest frame_request, |
342 mojom::FrameHostPtr frame_host) override { | 334 mojom::FrameHostPtr frame_host) override { |
343 // TODO(morrita): This is for investigating http://crbug.com/415059 and | 335 // TODO(morrita): This is for investigating http://crbug.com/415059 and |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 RenderThreadImpl::RenderThreadImpl( | 589 RenderThreadImpl::RenderThreadImpl( |
598 const InProcessChildThreadParams& params, | 590 const InProcessChildThreadParams& params, |
599 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler, | 591 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler, |
600 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) | 592 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) |
601 : ChildThreadImpl(Options::Builder() | 593 : ChildThreadImpl(Options::Builder() |
602 .InBrowserProcess(params) | 594 .InBrowserProcess(params) |
603 .AutoStartServiceManagerConnection(false) | 595 .AutoStartServiceManagerConnection(false) |
604 .ConnectToBrowser(true) | 596 .ConnectToBrowser(true) |
605 .Build()), | 597 .Build()), |
606 renderer_scheduler_(std::move(scheduler)), | 598 renderer_scheduler_(std::move(scheduler)), |
607 time_zone_monitor_binding_(this), | |
608 categorized_worker_pool_(new CategorizedWorkerPool()), | 599 categorized_worker_pool_(new CategorizedWorkerPool()), |
609 renderer_binding_(this) { | 600 renderer_binding_(this) { |
610 Init(resource_task_queue); | 601 Init(resource_task_queue); |
611 } | 602 } |
612 | 603 |
613 // When we run plugins in process, we actually run them on the render thread, | 604 // When we run plugins in process, we actually run them on the render thread, |
614 // which means that we need to make the render thread pump UI events. | 605 // which means that we need to make the render thread pump UI events. |
615 RenderThreadImpl::RenderThreadImpl( | 606 RenderThreadImpl::RenderThreadImpl( |
616 std::unique_ptr<base::MessageLoop> main_message_loop, | 607 std::unique_ptr<base::MessageLoop> main_message_loop, |
617 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler) | 608 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler) |
618 : ChildThreadImpl(Options::Builder() | 609 : ChildThreadImpl(Options::Builder() |
619 .AutoStartServiceManagerConnection(false) | 610 .AutoStartServiceManagerConnection(false) |
620 .ConnectToBrowser(true) | 611 .ConnectToBrowser(true) |
621 .Build()), | 612 .Build()), |
622 renderer_scheduler_(std::move(scheduler)), | 613 renderer_scheduler_(std::move(scheduler)), |
623 time_zone_monitor_binding_(this), | |
624 main_message_loop_(std::move(main_message_loop)), | 614 main_message_loop_(std::move(main_message_loop)), |
625 categorized_worker_pool_(new CategorizedWorkerPool()), | 615 categorized_worker_pool_(new CategorizedWorkerPool()), |
626 renderer_binding_(this) { | 616 renderer_binding_(this) { |
627 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter; | 617 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter; |
628 Init(test_task_counter); | 618 Init(test_task_counter); |
629 } | 619 } |
630 | 620 |
631 void RenderThreadImpl::Init( | 621 void RenderThreadImpl::Init( |
632 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) { | 622 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) { |
633 TRACE_EVENT0("startup", "RenderThreadImpl::Init"); | 623 TRACE_EVENT0("startup", "RenderThreadImpl::Init"); |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 | 866 |
877 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateFrameFactory)); | 867 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateFrameFactory)); |
878 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateEmbeddedWorkerSetup)); | 868 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateEmbeddedWorkerSetup)); |
879 GetInterfaceRegistry()->AddInterface( | 869 GetInterfaceRegistry()->AddInterface( |
880 base::Bind(&EmbeddedWorkerInstanceClientImpl::Create, | 870 base::Bind(&EmbeddedWorkerInstanceClientImpl::Create, |
881 base::Unretained(embedded_worker_dispatcher_.get()))); | 871 base::Unretained(embedded_worker_dispatcher_.get()))); |
882 | 872 |
883 GetRemoteInterfaces()->GetInterface( | 873 GetRemoteInterfaces()->GetInterface( |
884 mojo::GetProxy(&storage_partition_service_)); | 874 mojo::GetProxy(&storage_partition_service_)); |
885 | 875 |
886 device::mojom::TimeZoneMonitorPtr time_zone_monitor; | |
887 GetRemoteInterfaces()->GetInterface(mojo::GetProxy(&time_zone_monitor)); | |
888 time_zone_monitor->AddClient( | |
889 time_zone_monitor_binding_.CreateInterfacePtrAndBind()); | |
890 | |
891 #if defined(OS_LINUX) | 876 #if defined(OS_LINUX) |
892 ChildProcess::current()->SetIOThreadPriority(base::ThreadPriority::DISPLAY); | 877 ChildProcess::current()->SetIOThreadPriority(base::ThreadPriority::DISPLAY); |
893 ChildThreadImpl::current()->SetThreadPriority( | 878 ChildThreadImpl::current()->SetThreadPriority( |
894 categorized_worker_pool_->background_worker_thread_id(), | 879 categorized_worker_pool_->background_worker_thread_id(), |
895 base::ThreadPriority::BACKGROUND); | 880 base::ThreadPriority::BACKGROUND); |
896 #endif | 881 #endif |
897 | 882 |
898 is_renderer_suspended_ = false; | 883 is_renderer_suspended_ = false; |
899 } | 884 } |
900 | 885 |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 | 1314 |
1330 // chrome-devtools: | 1315 // chrome-devtools: |
1331 WebString devtools_scheme(base::ASCIIToUTF16(kChromeDevToolsScheme)); | 1316 WebString devtools_scheme(base::ASCIIToUTF16(kChromeDevToolsScheme)); |
1332 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(devtools_scheme); | 1317 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(devtools_scheme); |
1333 | 1318 |
1334 // view-source: | 1319 // view-source: |
1335 WebString view_source_scheme(base::ASCIIToUTF16(kViewSourceScheme)); | 1320 WebString view_source_scheme(base::ASCIIToUTF16(kViewSourceScheme)); |
1336 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(view_source_scheme); | 1321 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(view_source_scheme); |
1337 } | 1322 } |
1338 | 1323 |
1339 void RenderThreadImpl::NotifyTimezoneChange() { | |
1340 NotifyTimezoneChangeOnThisThread(); | |
1341 RenderThread::Get()->PostTaskToAllWebWorkers( | |
1342 base::Bind(&NotifyTimezoneChangeOnThisThread)); | |
1343 } | |
1344 | |
1345 void RenderThreadImpl::RecordAction(const base::UserMetricsAction& action) { | 1324 void RenderThreadImpl::RecordAction(const base::UserMetricsAction& action) { |
1346 Send(new ViewHostMsg_UserMetricsRecordAction(action.str_)); | 1325 Send(new ViewHostMsg_UserMetricsRecordAction(action.str_)); |
1347 } | 1326 } |
1348 | 1327 |
1349 void RenderThreadImpl::RecordComputedAction(const std::string& action) { | 1328 void RenderThreadImpl::RecordComputedAction(const std::string& action) { |
1350 Send(new ViewHostMsg_UserMetricsRecordAction(action)); | 1329 Send(new ViewHostMsg_UserMetricsRecordAction(action)); |
1351 } | 1330 } |
1352 | 1331 |
1353 std::unique_ptr<base::SharedMemory> | 1332 std::unique_ptr<base::SharedMemory> |
1354 RenderThreadImpl::HostAllocateSharedMemoryBuffer(size_t size) { | 1333 RenderThreadImpl::HostAllocateSharedMemoryBuffer(size_t size) { |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2068 base::IntToString(render_view_routing_id)); | 2047 base::IntToString(render_view_routing_id)); |
2069 base::debug::SetCrashKeyValue("newproxy_opener_id", | 2048 base::debug::SetCrashKeyValue("newproxy_opener_id", |
2070 base::IntToString(opener_routing_id)); | 2049 base::IntToString(opener_routing_id)); |
2071 base::debug::SetCrashKeyValue("newproxy_parent_id", | 2050 base::debug::SetCrashKeyValue("newproxy_parent_id", |
2072 base::IntToString(parent_routing_id)); | 2051 base::IntToString(parent_routing_id)); |
2073 RenderFrameProxy::CreateFrameProxy(routing_id, render_view_routing_id, | 2052 RenderFrameProxy::CreateFrameProxy(routing_id, render_view_routing_id, |
2074 opener_routing_id, parent_routing_id, | 2053 opener_routing_id, parent_routing_id, |
2075 replicated_state); | 2054 replicated_state); |
2076 } | 2055 } |
2077 | 2056 |
2078 void RenderThreadImpl::OnTimeZoneChange(const std::string& zone_id) { | |
2079 if (!blink_platform_impl_) | |
2080 return; | |
2081 if (!zone_id.empty()) { | |
2082 icu::TimeZone *new_zone = icu::TimeZone::createTimeZone( | |
2083 icu::UnicodeString::fromUTF8(zone_id)); | |
2084 icu::TimeZone::adoptDefault(new_zone); | |
2085 VLOG(1) << "ICU default timezone is set to " << zone_id; | |
2086 } | |
2087 NotifyTimezoneChange(); | |
2088 } | |
2089 | |
2090 #if defined(OS_ANDROID) | 2057 #if defined(OS_ANDROID) |
2091 void RenderThreadImpl::OnSetWebKitSharedTimersSuspended(bool suspend) { | 2058 void RenderThreadImpl::OnSetWebKitSharedTimersSuspended(bool suspend) { |
2092 if (suspend) { | 2059 if (suspend) { |
2093 renderer_scheduler_->SuspendTimerQueue(); | 2060 renderer_scheduler_->SuspendTimerQueue(); |
2094 } else { | 2061 } else { |
2095 renderer_scheduler_->ResumeTimerQueue(); | 2062 renderer_scheduler_->ResumeTimerQueue(); |
2096 } | 2063 } |
2097 webkit_shared_timer_suspended_ = suspend; | 2064 webkit_shared_timer_suspended_ = suspend; |
2098 } | 2065 } |
2099 #endif | 2066 #endif |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2329 } | 2296 } |
2330 } | 2297 } |
2331 | 2298 |
2332 void RenderThreadImpl::OnRendererInterfaceRequest( | 2299 void RenderThreadImpl::OnRendererInterfaceRequest( |
2333 mojom::RendererAssociatedRequest request) { | 2300 mojom::RendererAssociatedRequest request) { |
2334 DCHECK(!renderer_binding_.is_bound()); | 2301 DCHECK(!renderer_binding_.is_bound()); |
2335 renderer_binding_.Bind(std::move(request)); | 2302 renderer_binding_.Bind(std::move(request)); |
2336 } | 2303 } |
2337 | 2304 |
2338 } // namespace content | 2305 } // namespace content |
OLD | NEW |