| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 histogram_name, min, max, buckets, | 322 histogram_name, min, max, buckets, |
| 324 base::Histogram::kUmaTargetedHistogramFlag); | 323 base::Histogram::kUmaTargetedHistogramFlag); |
| 325 return histogram; | 324 return histogram; |
| 326 } | 325 } |
| 327 | 326 |
| 328 void AddHistogramSample(void* hist, int sample) { | 327 void AddHistogramSample(void* hist, int sample) { |
| 329 base::Histogram* histogram = static_cast<base::Histogram*>(hist); | 328 base::Histogram* histogram = static_cast<base::Histogram*>(hist); |
| 330 histogram->Add(sample); | 329 histogram->Add(sample); |
| 331 } | 330 } |
| 332 | 331 |
| 333 void NotifyTimezoneChangeOnThisThread() { | |
| 334 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
| 335 if (!isolate) | |
| 336 return; | |
| 337 v8::Date::DateTimeConfigurationChangeNotification(isolate); | |
| 338 } | |
| 339 | |
| 340 class FrameFactoryImpl : public mojom::FrameFactory { | 332 class FrameFactoryImpl : public mojom::FrameFactory { |
| 341 public: | 333 public: |
| 342 FrameFactoryImpl() : routing_id_highmark_(-1) {} | 334 FrameFactoryImpl() : routing_id_highmark_(-1) {} |
| 343 | 335 |
| 344 private: | 336 private: |
| 345 // mojom::FrameFactory: | 337 // mojom::FrameFactory: |
| 346 void CreateFrame(int32_t frame_routing_id, | 338 void CreateFrame(int32_t frame_routing_id, |
| 347 mojom::FrameRequest frame_request, | 339 mojom::FrameRequest frame_request, |
| 348 mojom::FrameHostPtr frame_host) override { | 340 mojom::FrameHostPtr frame_host) override { |
| 349 // TODO(morrita): This is for investigating http://crbug.com/415059 and | 341 // TODO(morrita): This is for investigating http://crbug.com/415059 and |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 RenderThreadImpl::RenderThreadImpl( | 595 RenderThreadImpl::RenderThreadImpl( |
| 604 const InProcessChildThreadParams& params, | 596 const InProcessChildThreadParams& params, |
| 605 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler, | 597 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler, |
| 606 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) | 598 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) |
| 607 : ChildThreadImpl(Options::Builder() | 599 : ChildThreadImpl(Options::Builder() |
| 608 .InBrowserProcess(params) | 600 .InBrowserProcess(params) |
| 609 .AutoStartServiceManagerConnection(false) | 601 .AutoStartServiceManagerConnection(false) |
| 610 .ConnectToBrowser(true) | 602 .ConnectToBrowser(true) |
| 611 .Build()), | 603 .Build()), |
| 612 renderer_scheduler_(std::move(scheduler)), | 604 renderer_scheduler_(std::move(scheduler)), |
| 613 time_zone_monitor_binding_(this), | |
| 614 categorized_worker_pool_(new CategorizedWorkerPool()), | 605 categorized_worker_pool_(new CategorizedWorkerPool()), |
| 615 renderer_binding_(this) { | 606 renderer_binding_(this) { |
| 616 Init(resource_task_queue); | 607 Init(resource_task_queue); |
| 617 } | 608 } |
| 618 | 609 |
| 619 // When we run plugins in process, we actually run them on the render thread, | 610 // When we run plugins in process, we actually run them on the render thread, |
| 620 // which means that we need to make the render thread pump UI events. | 611 // which means that we need to make the render thread pump UI events. |
| 621 RenderThreadImpl::RenderThreadImpl( | 612 RenderThreadImpl::RenderThreadImpl( |
| 622 std::unique_ptr<base::MessageLoop> main_message_loop, | 613 std::unique_ptr<base::MessageLoop> main_message_loop, |
| 623 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler) | 614 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler) |
| 624 : ChildThreadImpl(Options::Builder() | 615 : ChildThreadImpl(Options::Builder() |
| 625 .AutoStartServiceManagerConnection(false) | 616 .AutoStartServiceManagerConnection(false) |
| 626 .ConnectToBrowser(true) | 617 .ConnectToBrowser(true) |
| 627 .Build()), | 618 .Build()), |
| 628 renderer_scheduler_(std::move(scheduler)), | 619 renderer_scheduler_(std::move(scheduler)), |
| 629 time_zone_monitor_binding_(this), | |
| 630 main_message_loop_(std::move(main_message_loop)), | 620 main_message_loop_(std::move(main_message_loop)), |
| 631 categorized_worker_pool_(new CategorizedWorkerPool()), | 621 categorized_worker_pool_(new CategorizedWorkerPool()), |
| 632 renderer_binding_(this) { | 622 renderer_binding_(this) { |
| 633 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter; | 623 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter; |
| 634 Init(test_task_counter); | 624 Init(test_task_counter); |
| 635 } | 625 } |
| 636 | 626 |
| 637 void RenderThreadImpl::Init( | 627 void RenderThreadImpl::Init( |
| 638 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) { | 628 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) { |
| 639 TRACE_EVENT0("startup", "RenderThreadImpl::Init"); | 629 TRACE_EVENT0("startup", "RenderThreadImpl::Init"); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 | 874 |
| 885 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateFrameFactory)); | 875 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateFrameFactory)); |
| 886 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateEmbeddedWorkerSetup)); | 876 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateEmbeddedWorkerSetup)); |
| 887 GetInterfaceRegistry()->AddInterface( | 877 GetInterfaceRegistry()->AddInterface( |
| 888 base::Bind(&EmbeddedWorkerInstanceClientImpl::Create, | 878 base::Bind(&EmbeddedWorkerInstanceClientImpl::Create, |
| 889 base::Unretained(embedded_worker_dispatcher_.get()))); | 879 base::Unretained(embedded_worker_dispatcher_.get()))); |
| 890 | 880 |
| 891 GetRemoteInterfaces()->GetInterface( | 881 GetRemoteInterfaces()->GetInterface( |
| 892 mojo::GetProxy(&storage_partition_service_)); | 882 mojo::GetProxy(&storage_partition_service_)); |
| 893 | 883 |
| 894 device::mojom::TimeZoneMonitorPtr time_zone_monitor; | |
| 895 GetRemoteInterfaces()->GetInterface(mojo::GetProxy(&time_zone_monitor)); | |
| 896 time_zone_monitor->AddClient( | |
| 897 time_zone_monitor_binding_.CreateInterfacePtrAndBind()); | |
| 898 | |
| 899 #if defined(OS_LINUX) | 884 #if defined(OS_LINUX) |
| 900 ChildProcess::current()->SetIOThreadPriority(base::ThreadPriority::DISPLAY); | 885 ChildProcess::current()->SetIOThreadPriority(base::ThreadPriority::DISPLAY); |
| 901 ChildThreadImpl::current()->SetThreadPriority( | 886 ChildThreadImpl::current()->SetThreadPriority( |
| 902 categorized_worker_pool_->background_worker_thread_id(), | 887 categorized_worker_pool_->background_worker_thread_id(), |
| 903 base::ThreadPriority::BACKGROUND); | 888 base::ThreadPriority::BACKGROUND); |
| 904 #endif | 889 #endif |
| 905 | 890 |
| 906 record_purge_suspend_metric_closure_.Reset(base::Bind( | 891 record_purge_suspend_metric_closure_.Reset(base::Bind( |
| 907 &RenderThreadImpl::RecordPurgeAndSuspendMetrics, base::Unretained(this))); | 892 &RenderThreadImpl::RecordPurgeAndSuspendMetrics, base::Unretained(this))); |
| 908 is_renderer_suspended_ = false; | 893 is_renderer_suspended_ = false; |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 | 1325 |
| 1341 // chrome-devtools: | 1326 // chrome-devtools: |
| 1342 WebString devtools_scheme(base::ASCIIToUTF16(kChromeDevToolsScheme)); | 1327 WebString devtools_scheme(base::ASCIIToUTF16(kChromeDevToolsScheme)); |
| 1343 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(devtools_scheme); | 1328 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(devtools_scheme); |
| 1344 | 1329 |
| 1345 // view-source: | 1330 // view-source: |
| 1346 WebString view_source_scheme(base::ASCIIToUTF16(kViewSourceScheme)); | 1331 WebString view_source_scheme(base::ASCIIToUTF16(kViewSourceScheme)); |
| 1347 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(view_source_scheme); | 1332 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(view_source_scheme); |
| 1348 } | 1333 } |
| 1349 | 1334 |
| 1350 void RenderThreadImpl::NotifyTimezoneChange() { | |
| 1351 NotifyTimezoneChangeOnThisThread(); | |
| 1352 RenderThread::Get()->PostTaskToAllWebWorkers( | |
| 1353 base::Bind(&NotifyTimezoneChangeOnThisThread)); | |
| 1354 } | |
| 1355 | |
| 1356 void RenderThreadImpl::RecordAction(const base::UserMetricsAction& action) { | 1335 void RenderThreadImpl::RecordAction(const base::UserMetricsAction& action) { |
| 1357 Send(new ViewHostMsg_UserMetricsRecordAction(action.str_)); | 1336 Send(new ViewHostMsg_UserMetricsRecordAction(action.str_)); |
| 1358 } | 1337 } |
| 1359 | 1338 |
| 1360 void RenderThreadImpl::RecordComputedAction(const std::string& action) { | 1339 void RenderThreadImpl::RecordComputedAction(const std::string& action) { |
| 1361 Send(new ViewHostMsg_UserMetricsRecordAction(action)); | 1340 Send(new ViewHostMsg_UserMetricsRecordAction(action)); |
| 1362 } | 1341 } |
| 1363 | 1342 |
| 1364 std::unique_ptr<base::SharedMemory> | 1343 std::unique_ptr<base::SharedMemory> |
| 1365 RenderThreadImpl::HostAllocateSharedMemoryBuffer(size_t size) { | 1344 RenderThreadImpl::HostAllocateSharedMemoryBuffer(size_t size) { |
| (...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2215 blink::resetPluginCache(reload_pages); | 2194 blink::resetPluginCache(reload_pages); |
| 2216 blink_platform_impl_->set_plugin_refresh_allowed(true); | 2195 blink_platform_impl_->set_plugin_refresh_allowed(true); |
| 2217 | 2196 |
| 2218 for (auto& observer : observers_) | 2197 for (auto& observer : observers_) |
| 2219 observer.PluginListChanged(); | 2198 observer.PluginListChanged(); |
| 2220 #else | 2199 #else |
| 2221 NOTREACHED(); | 2200 NOTREACHED(); |
| 2222 #endif | 2201 #endif |
| 2223 } | 2202 } |
| 2224 | 2203 |
| 2225 void RenderThreadImpl::OnTimeZoneChange(const std::string& zone_id) { | |
| 2226 if (!blink_platform_impl_) | |
| 2227 return; | |
| 2228 if (!zone_id.empty()) { | |
| 2229 icu::TimeZone *new_zone = icu::TimeZone::createTimeZone( | |
| 2230 icu::UnicodeString::fromUTF8(zone_id)); | |
| 2231 icu::TimeZone::adoptDefault(new_zone); | |
| 2232 VLOG(1) << "ICU default timezone is set to " << zone_id; | |
| 2233 } | |
| 2234 NotifyTimezoneChange(); | |
| 2235 } | |
| 2236 | |
| 2237 void RenderThreadImpl::OnCreateNewSharedWorker( | 2204 void RenderThreadImpl::OnCreateNewSharedWorker( |
| 2238 const WorkerProcessMsg_CreateWorker_Params& params) { | 2205 const WorkerProcessMsg_CreateWorker_Params& params) { |
| 2239 // EmbeddedSharedWorkerStub will self-destruct. | 2206 // EmbeddedSharedWorkerStub will self-destruct. |
| 2240 new EmbeddedSharedWorkerStub( | 2207 new EmbeddedSharedWorkerStub( |
| 2241 params.url, params.name, params.content_security_policy, | 2208 params.url, params.name, params.content_security_policy, |
| 2242 params.security_policy_type, params.creation_address_space, | 2209 params.security_policy_type, params.creation_address_space, |
| 2243 params.pause_on_start, params.route_id); | 2210 params.pause_on_start, params.route_id); |
| 2244 } | 2211 } |
| 2245 | 2212 |
| 2246 void RenderThreadImpl::OnMemoryPressure( | 2213 void RenderThreadImpl::OnMemoryPressure( |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2471 } | 2438 } |
| 2472 } | 2439 } |
| 2473 | 2440 |
| 2474 void RenderThreadImpl::OnRendererInterfaceRequest( | 2441 void RenderThreadImpl::OnRendererInterfaceRequest( |
| 2475 mojom::RendererAssociatedRequest request) { | 2442 mojom::RendererAssociatedRequest request) { |
| 2476 DCHECK(!renderer_binding_.is_bound()); | 2443 DCHECK(!renderer_binding_.is_bound()); |
| 2477 renderer_binding_.Bind(std::move(request)); | 2444 renderer_binding_.Bind(std::move(request)); |
| 2478 } | 2445 } |
| 2479 | 2446 |
| 2480 } // namespace content | 2447 } // namespace content |
| OLD | NEW |