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

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

Issue 2402983002: [TimeZoneMonitor] Decouple renderer side impl from content to blink. (Closed)
Patch Set: Rebase only Created 4 years, 1 month 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') | media/blink/BUILD.gn » ('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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 histogram_name, min, max, buckets, 318 histogram_name, min, max, buckets,
320 base::Histogram::kUmaTargetedHistogramFlag); 319 base::Histogram::kUmaTargetedHistogramFlag);
321 return histogram; 320 return histogram;
322 } 321 }
323 322
324 void AddHistogramSample(void* hist, int sample) { 323 void AddHistogramSample(void* hist, int sample) {
325 base::Histogram* histogram = static_cast<base::Histogram*>(hist); 324 base::Histogram* histogram = static_cast<base::Histogram*>(hist);
326 histogram->Add(sample); 325 histogram->Add(sample);
327 } 326 }
328 327
329 void NotifyTimezoneChangeOnThisThread() {
330 v8::Isolate* isolate = v8::Isolate::GetCurrent();
331 if (!isolate)
332 return;
333 v8::Date::DateTimeConfigurationChangeNotification(isolate);
334 }
335
336 class FrameFactoryImpl : public mojom::FrameFactory { 328 class FrameFactoryImpl : public mojom::FrameFactory {
337 public: 329 public:
338 FrameFactoryImpl() : routing_id_highmark_(-1) {} 330 FrameFactoryImpl() : routing_id_highmark_(-1) {}
339 331
340 private: 332 private:
341 // mojom::FrameFactory: 333 // mojom::FrameFactory:
342 void CreateFrame(int32_t frame_routing_id, 334 void CreateFrame(int32_t frame_routing_id,
343 mojom::FrameRequest frame_request, 335 mojom::FrameRequest frame_request,
344 mojom::FrameHostPtr frame_host) override { 336 mojom::FrameHostPtr frame_host) override {
345 // TODO(morrita): This is for investigating http://crbug.com/415059 and 337 // TODO(morrita): This is for investigating http://crbug.com/415059 and
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 RenderThreadImpl::RenderThreadImpl( 594 RenderThreadImpl::RenderThreadImpl(
603 const InProcessChildThreadParams& params, 595 const InProcessChildThreadParams& params,
604 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler, 596 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler,
605 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) 597 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue)
606 : ChildThreadImpl(Options::Builder() 598 : ChildThreadImpl(Options::Builder()
607 .InBrowserProcess(params) 599 .InBrowserProcess(params)
608 .AutoStartServiceManagerConnection(false) 600 .AutoStartServiceManagerConnection(false)
609 .ConnectToBrowser(true) 601 .ConnectToBrowser(true)
610 .Build()), 602 .Build()),
611 renderer_scheduler_(std::move(scheduler)), 603 renderer_scheduler_(std::move(scheduler)),
612 time_zone_monitor_binding_(this),
613 categorized_worker_pool_(new CategorizedWorkerPool()), 604 categorized_worker_pool_(new CategorizedWorkerPool()),
614 renderer_binding_(this), 605 renderer_binding_(this),
615 client_id_(1) { 606 client_id_(1) {
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 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 624 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
635 switches::kRendererClientId)); 625 switches::kRendererClientId));
636 base::StringToInt(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 626 base::StringToInt(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
637 switches::kRendererClientId), 627 switches::kRendererClientId),
638 &client_id_); 628 &client_id_);
639 Init(test_task_counter); 629 Init(test_task_counter);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 883
894 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateFrameFactory)); 884 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateFrameFactory));
895 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateEmbeddedWorkerSetup)); 885 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateEmbeddedWorkerSetup));
896 GetInterfaceRegistry()->AddInterface( 886 GetInterfaceRegistry()->AddInterface(
897 base::Bind(&EmbeddedWorkerInstanceClientImpl::Create, 887 base::Bind(&EmbeddedWorkerInstanceClientImpl::Create,
898 base::Unretained(embedded_worker_dispatcher_.get()))); 888 base::Unretained(embedded_worker_dispatcher_.get())));
899 889
900 GetRemoteInterfaces()->GetInterface( 890 GetRemoteInterfaces()->GetInterface(
901 mojo::GetProxy(&storage_partition_service_)); 891 mojo::GetProxy(&storage_partition_service_));
902 892
903 device::mojom::TimeZoneMonitorPtr time_zone_monitor;
904 GetRemoteInterfaces()->GetInterface(mojo::GetProxy(&time_zone_monitor));
905 time_zone_monitor->AddClient(
906 time_zone_monitor_binding_.CreateInterfacePtrAndBind());
907
908 #if defined(OS_LINUX) 893 #if defined(OS_LINUX)
909 ChildProcess::current()->SetIOThreadPriority(base::ThreadPriority::DISPLAY); 894 ChildProcess::current()->SetIOThreadPriority(base::ThreadPriority::DISPLAY);
910 ChildThreadImpl::current()->SetThreadPriority( 895 ChildThreadImpl::current()->SetThreadPriority(
911 categorized_worker_pool_->background_worker_thread_id(), 896 categorized_worker_pool_->background_worker_thread_id(),
912 base::ThreadPriority::BACKGROUND); 897 base::ThreadPriority::BACKGROUND);
913 #endif 898 #endif
914 899
915 record_purge_suspend_metric_closure_.Reset(base::Bind( 900 record_purge_suspend_metric_closure_.Reset(base::Bind(
916 &RenderThreadImpl::RecordPurgeAndSuspendMetrics, base::Unretained(this))); 901 &RenderThreadImpl::RecordPurgeAndSuspendMetrics, base::Unretained(this)));
917 is_renderer_suspended_ = false; 902 is_renderer_suspended_ = false;
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 1334
1350 // chrome-devtools: 1335 // chrome-devtools:
1351 WebString devtools_scheme(WebString::fromASCII(kChromeDevToolsScheme)); 1336 WebString devtools_scheme(WebString::fromASCII(kChromeDevToolsScheme));
1352 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(devtools_scheme); 1337 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(devtools_scheme);
1353 1338
1354 // view-source: 1339 // view-source:
1355 WebString view_source_scheme(WebString::fromASCII(kViewSourceScheme)); 1340 WebString view_source_scheme(WebString::fromASCII(kViewSourceScheme));
1356 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(view_source_scheme); 1341 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(view_source_scheme);
1357 } 1342 }
1358 1343
1359 void RenderThreadImpl::NotifyTimezoneChange() {
1360 NotifyTimezoneChangeOnThisThread();
1361 RenderThread::Get()->PostTaskToAllWebWorkers(
1362 base::Bind(&NotifyTimezoneChangeOnThisThread));
1363 }
1364
1365 void RenderThreadImpl::RecordAction(const base::UserMetricsAction& action) { 1344 void RenderThreadImpl::RecordAction(const base::UserMetricsAction& action) {
1366 Send(new ViewHostMsg_UserMetricsRecordAction(action.str_)); 1345 Send(new ViewHostMsg_UserMetricsRecordAction(action.str_));
1367 } 1346 }
1368 1347
1369 void RenderThreadImpl::RecordComputedAction(const std::string& action) { 1348 void RenderThreadImpl::RecordComputedAction(const std::string& action) {
1370 Send(new ViewHostMsg_UserMetricsRecordAction(action)); 1349 Send(new ViewHostMsg_UserMetricsRecordAction(action));
1371 } 1350 }
1372 1351
1373 std::unique_ptr<base::SharedMemory> 1352 std::unique_ptr<base::SharedMemory>
1374 RenderThreadImpl::HostAllocateSharedMemoryBuffer(size_t size) { 1353 RenderThreadImpl::HostAllocateSharedMemoryBuffer(size_t size) {
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 blink::resetPluginCache(reload_pages); 2233 blink::resetPluginCache(reload_pages);
2255 blink_platform_impl_->set_plugin_refresh_allowed(true); 2234 blink_platform_impl_->set_plugin_refresh_allowed(true);
2256 2235
2257 for (auto& observer : observers_) 2236 for (auto& observer : observers_)
2258 observer.PluginListChanged(); 2237 observer.PluginListChanged();
2259 #else 2238 #else
2260 NOTREACHED(); 2239 NOTREACHED();
2261 #endif 2240 #endif
2262 } 2241 }
2263 2242
2264 void RenderThreadImpl::OnTimeZoneChange(const std::string& zone_id) {
2265 if (!blink_platform_impl_)
2266 return;
2267 if (!zone_id.empty()) {
2268 icu::TimeZone *new_zone = icu::TimeZone::createTimeZone(
2269 icu::UnicodeString::fromUTF8(zone_id));
2270 icu::TimeZone::adoptDefault(new_zone);
2271 VLOG(1) << "ICU default timezone is set to " << zone_id;
2272 }
2273 NotifyTimezoneChange();
2274 }
2275
2276 void RenderThreadImpl::OnCreateNewSharedWorker( 2243 void RenderThreadImpl::OnCreateNewSharedWorker(
2277 const WorkerProcessMsg_CreateWorker_Params& params) { 2244 const WorkerProcessMsg_CreateWorker_Params& params) {
2278 // EmbeddedSharedWorkerStub will self-destruct. 2245 // EmbeddedSharedWorkerStub will self-destruct.
2279 new EmbeddedSharedWorkerStub( 2246 new EmbeddedSharedWorkerStub(
2280 params.url, params.name, params.content_security_policy, 2247 params.url, params.name, params.content_security_policy,
2281 params.security_policy_type, params.creation_address_space, 2248 params.security_policy_type, params.creation_address_space,
2282 params.pause_on_start, params.route_id); 2249 params.pause_on_start, params.route_id);
2283 } 2250 }
2284 2251
2285 void RenderThreadImpl::OnMemoryPressure( 2252 void RenderThreadImpl::OnMemoryPressure(
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
2510 } 2477 }
2511 } 2478 }
2512 2479
2513 void RenderThreadImpl::OnRendererInterfaceRequest( 2480 void RenderThreadImpl::OnRendererInterfaceRequest(
2514 mojom::RendererAssociatedRequest request) { 2481 mojom::RendererAssociatedRequest request) {
2515 DCHECK(!renderer_binding_.is_bound()); 2482 DCHECK(!renderer_binding_.is_bound());
2516 renderer_binding_.Bind(std::move(request)); 2483 renderer_binding_.Bind(std::move(request));
2517 } 2484 }
2518 2485
2519 } // namespace content 2486 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | media/blink/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698