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

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

Issue 2402983002: [TimeZoneMonitor] Decouple renderer side impl from content to blink. (Closed)
Patch Set: Remove all duplicated calls to mojo::edk::init() Created 4 years, 2 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
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/test/run_all_unittests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 #include "third_party/WebKit/public/web/WebCache.h" 154 #include "third_party/WebKit/public/web/WebCache.h"
155 #include "third_party/WebKit/public/web/WebDatabase.h" 155 #include "third_party/WebKit/public/web/WebDatabase.h"
156 #include "third_party/WebKit/public/web/WebDocument.h" 156 #include "third_party/WebKit/public/web/WebDocument.h"
157 #include "third_party/WebKit/public/web/WebFrame.h" 157 #include "third_party/WebKit/public/web/WebFrame.h"
158 #include "third_party/WebKit/public/web/WebKit.h" 158 #include "third_party/WebKit/public/web/WebKit.h"
159 #include "third_party/WebKit/public/web/WebNetworkStateNotifier.h" 159 #include "third_party/WebKit/public/web/WebNetworkStateNotifier.h"
160 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 160 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
161 #include "third_party/WebKit/public/web/WebScriptController.h" 161 #include "third_party/WebKit/public/web/WebScriptController.h"
162 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" 162 #include "third_party/WebKit/public/web/WebSecurityPolicy.h"
163 #include "third_party/WebKit/public/web/WebView.h" 163 #include "third_party/WebKit/public/web/WebView.h"
164 #include "third_party/icu/source/i18n/unicode/timezone.h"
165 #include "third_party/skia/include/core/SkGraphics.h" 164 #include "third_party/skia/include/core/SkGraphics.h"
166 #include "ui/base/layout.h" 165 #include "ui/base/layout.h"
167 #include "ui/base/ui_base_switches.h" 166 #include "ui/base/ui_base_switches.h"
168 #include "ui/gl/gl_switches.h" 167 #include "ui/gl/gl_switches.h"
169 168
170 #if defined(OS_ANDROID) 169 #if defined(OS_ANDROID)
171 #include <cpu-features.h> 170 #include <cpu-features.h>
172 #include "content/renderer/android/synchronous_compositor_filter.h" 171 #include "content/renderer/android/synchronous_compositor_filter.h"
173 #include "content/renderer/android/synchronous_compositor_frame_sink.h" 172 #include "content/renderer/android/synchronous_compositor_frame_sink.h"
174 #include "content/renderer/media/android/stream_texture_factory.h" 173 #include "content/renderer/media/android/stream_texture_factory.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 histogram_name, min, max, buckets, 323 histogram_name, min, max, buckets,
325 base::Histogram::kUmaTargetedHistogramFlag); 324 base::Histogram::kUmaTargetedHistogramFlag);
326 return histogram; 325 return histogram;
327 } 326 }
328 327
329 void AddHistogramSample(void* hist, int sample) { 328 void AddHistogramSample(void* hist, int sample) {
330 base::Histogram* histogram = static_cast<base::Histogram*>(hist); 329 base::Histogram* histogram = static_cast<base::Histogram*>(hist);
331 histogram->Add(sample); 330 histogram->Add(sample);
332 } 331 }
333 332
334 void NotifyTimezoneChangeOnThisThread() {
335 v8::Isolate* isolate = v8::Isolate::GetCurrent();
336 if (!isolate)
337 return;
338 v8::Date::DateTimeConfigurationChangeNotification(isolate);
339 }
340
341 class FrameFactoryImpl : public mojom::FrameFactory { 333 class FrameFactoryImpl : public mojom::FrameFactory {
342 public: 334 public:
343 FrameFactoryImpl() : routing_id_highmark_(-1) {} 335 FrameFactoryImpl() : routing_id_highmark_(-1) {}
344 336
345 private: 337 private:
346 // mojom::FrameFactory: 338 // mojom::FrameFactory:
347 void CreateFrame(int32_t frame_routing_id, 339 void CreateFrame(int32_t frame_routing_id,
348 mojom::FrameRequest frame_request, 340 mojom::FrameRequest frame_request,
349 mojom::FrameHostPtr frame_host) override { 341 mojom::FrameHostPtr frame_host) override {
350 // TODO(morrita): This is for investigating http://crbug.com/415059 and 342 // TODO(morrita): This is for investigating http://crbug.com/415059 and
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 RenderThreadImpl::RenderThreadImpl( 596 RenderThreadImpl::RenderThreadImpl(
605 const InProcessChildThreadParams& params, 597 const InProcessChildThreadParams& params,
606 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler, 598 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler,
607 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) 599 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue)
608 : ChildThreadImpl(Options::Builder() 600 : ChildThreadImpl(Options::Builder()
609 .InBrowserProcess(params) 601 .InBrowserProcess(params)
610 .AutoStartServiceManagerConnection(false) 602 .AutoStartServiceManagerConnection(false)
611 .ConnectToBrowser(true) 603 .ConnectToBrowser(true)
612 .Build()), 604 .Build()),
613 renderer_scheduler_(std::move(scheduler)), 605 renderer_scheduler_(std::move(scheduler)),
614 time_zone_monitor_binding_(this),
615 categorized_worker_pool_(new CategorizedWorkerPool()), 606 categorized_worker_pool_(new CategorizedWorkerPool()),
616 renderer_binding_(this) { 607 renderer_binding_(this) {
617 Init(resource_task_queue); 608 Init(resource_task_queue);
618 } 609 }
619 610
620 // When we run plugins in process, we actually run them on the render thread, 611 // When we run plugins in process, we actually run them on the render thread,
621 // which means that we need to make the render thread pump UI events. 612 // which means that we need to make the render thread pump UI events.
622 RenderThreadImpl::RenderThreadImpl( 613 RenderThreadImpl::RenderThreadImpl(
623 std::unique_ptr<base::MessageLoop> main_message_loop, 614 std::unique_ptr<base::MessageLoop> main_message_loop,
624 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler) 615 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler)
625 : ChildThreadImpl(Options::Builder() 616 : ChildThreadImpl(Options::Builder()
626 .AutoStartServiceManagerConnection(false) 617 .AutoStartServiceManagerConnection(false)
627 .ConnectToBrowser(true) 618 .ConnectToBrowser(true)
628 .Build()), 619 .Build()),
629 renderer_scheduler_(std::move(scheduler)), 620 renderer_scheduler_(std::move(scheduler)),
630 time_zone_monitor_binding_(this),
631 main_message_loop_(std::move(main_message_loop)), 621 main_message_loop_(std::move(main_message_loop)),
632 categorized_worker_pool_(new CategorizedWorkerPool()), 622 categorized_worker_pool_(new CategorizedWorkerPool()),
633 renderer_binding_(this) { 623 renderer_binding_(this) {
634 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter; 624 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter;
635 Init(test_task_counter); 625 Init(test_task_counter);
636 } 626 }
637 627
638 void RenderThreadImpl::Init( 628 void RenderThreadImpl::Init(
639 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) { 629 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) {
640 TRACE_EVENT0("startup", "RenderThreadImpl::Init"); 630 TRACE_EVENT0("startup", "RenderThreadImpl::Init");
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 876
887 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateFrameFactory)); 877 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateFrameFactory));
888 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateEmbeddedWorkerSetup)); 878 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateEmbeddedWorkerSetup));
889 GetInterfaceRegistry()->AddInterface( 879 GetInterfaceRegistry()->AddInterface(
890 base::Bind(&EmbeddedWorkerInstanceClientImpl::Create, 880 base::Bind(&EmbeddedWorkerInstanceClientImpl::Create,
891 base::Unretained(embedded_worker_dispatcher_.get()))); 881 base::Unretained(embedded_worker_dispatcher_.get())));
892 882
893 GetRemoteInterfaces()->GetInterface( 883 GetRemoteInterfaces()->GetInterface(
894 mojo::GetProxy(&storage_partition_service_)); 884 mojo::GetProxy(&storage_partition_service_));
895 885
896 device::mojom::TimeZoneMonitorPtr time_zone_monitor;
897 GetRemoteInterfaces()->GetInterface(mojo::GetProxy(&time_zone_monitor));
898 time_zone_monitor->AddClient(
899 time_zone_monitor_binding_.CreateInterfacePtrAndBind());
900
901 #if defined(OS_LINUX) 886 #if defined(OS_LINUX)
902 ChildProcess::current()->SetIOThreadPriority(base::ThreadPriority::DISPLAY); 887 ChildProcess::current()->SetIOThreadPriority(base::ThreadPriority::DISPLAY);
903 ChildThreadImpl::current()->SetThreadPriority( 888 ChildThreadImpl::current()->SetThreadPriority(
904 categorized_worker_pool_->background_worker_thread_id(), 889 categorized_worker_pool_->background_worker_thread_id(),
905 base::ThreadPriority::BACKGROUND); 890 base::ThreadPriority::BACKGROUND);
906 #endif 891 #endif
907 892
908 record_purge_suspend_metric_closure_.Reset(base::Bind( 893 record_purge_suspend_metric_closure_.Reset(base::Bind(
909 &RenderThreadImpl::RecordPurgeAndSuspendMetrics, base::Unretained(this))); 894 &RenderThreadImpl::RecordPurgeAndSuspendMetrics, base::Unretained(this)));
910 is_renderer_suspended_ = false; 895 is_renderer_suspended_ = false;
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 1328
1344 // chrome-devtools: 1329 // chrome-devtools:
1345 WebString devtools_scheme(base::ASCIIToUTF16(kChromeDevToolsScheme)); 1330 WebString devtools_scheme(base::ASCIIToUTF16(kChromeDevToolsScheme));
1346 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(devtools_scheme); 1331 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(devtools_scheme);
1347 1332
1348 // view-source: 1333 // view-source:
1349 WebString view_source_scheme(base::ASCIIToUTF16(kViewSourceScheme)); 1334 WebString view_source_scheme(base::ASCIIToUTF16(kViewSourceScheme));
1350 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(view_source_scheme); 1335 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(view_source_scheme);
1351 } 1336 }
1352 1337
1353 void RenderThreadImpl::NotifyTimezoneChange() {
1354 NotifyTimezoneChangeOnThisThread();
1355 RenderThread::Get()->PostTaskToAllWebWorkers(
1356 base::Bind(&NotifyTimezoneChangeOnThisThread));
1357 }
1358
1359 void RenderThreadImpl::RecordAction(const base::UserMetricsAction& action) { 1338 void RenderThreadImpl::RecordAction(const base::UserMetricsAction& action) {
1360 Send(new ViewHostMsg_UserMetricsRecordAction(action.str_)); 1339 Send(new ViewHostMsg_UserMetricsRecordAction(action.str_));
1361 } 1340 }
1362 1341
1363 void RenderThreadImpl::RecordComputedAction(const std::string& action) { 1342 void RenderThreadImpl::RecordComputedAction(const std::string& action) {
1364 Send(new ViewHostMsg_UserMetricsRecordAction(action)); 1343 Send(new ViewHostMsg_UserMetricsRecordAction(action));
1365 } 1344 }
1366 1345
1367 std::unique_ptr<base::SharedMemory> 1346 std::unique_ptr<base::SharedMemory>
1368 RenderThreadImpl::HostAllocateSharedMemoryBuffer(size_t size) { 1347 RenderThreadImpl::HostAllocateSharedMemoryBuffer(size_t size) {
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/test/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698