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

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

Issue 2455983004: NOT FOR SUBMISSION: local copy of leon.han's CL (Closed)
Patch Set: Rebase 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 RenderThreadImpl::RenderThreadImpl( 598 RenderThreadImpl::RenderThreadImpl(
607 const InProcessChildThreadParams& params, 599 const InProcessChildThreadParams& params,
608 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler, 600 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler,
609 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) 601 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue)
610 : ChildThreadImpl(Options::Builder() 602 : ChildThreadImpl(Options::Builder()
611 .InBrowserProcess(params) 603 .InBrowserProcess(params)
612 .AutoStartServiceManagerConnection(false) 604 .AutoStartServiceManagerConnection(false)
613 .ConnectToBrowser(true) 605 .ConnectToBrowser(true)
614 .Build()), 606 .Build()),
615 renderer_scheduler_(std::move(scheduler)), 607 renderer_scheduler_(std::move(scheduler)),
616 time_zone_monitor_binding_(this),
617 categorized_worker_pool_(new CategorizedWorkerPool()), 608 categorized_worker_pool_(new CategorizedWorkerPool()),
618 renderer_binding_(this), 609 renderer_binding_(this),
619 client_id_(1) { 610 client_id_(1) {
620 Init(resource_task_queue); 611 Init(resource_task_queue);
621 } 612 }
622 613
623 // When we run plugins in process, we actually run them on the render thread, 614 // When we run plugins in process, we actually run them on the render thread,
624 // which means that we need to make the render thread pump UI events. 615 // which means that we need to make the render thread pump UI events.
625 RenderThreadImpl::RenderThreadImpl( 616 RenderThreadImpl::RenderThreadImpl(
626 std::unique_ptr<base::MessageLoop> main_message_loop, 617 std::unique_ptr<base::MessageLoop> main_message_loop,
627 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler) 618 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler)
628 : ChildThreadImpl(Options::Builder() 619 : ChildThreadImpl(Options::Builder()
629 .AutoStartServiceManagerConnection(false) 620 .AutoStartServiceManagerConnection(false)
630 .ConnectToBrowser(true) 621 .ConnectToBrowser(true)
631 .Build()), 622 .Build()),
632 renderer_scheduler_(std::move(scheduler)), 623 renderer_scheduler_(std::move(scheduler)),
633 time_zone_monitor_binding_(this),
634 main_message_loop_(std::move(main_message_loop)), 624 main_message_loop_(std::move(main_message_loop)),
635 categorized_worker_pool_(new CategorizedWorkerPool()), 625 categorized_worker_pool_(new CategorizedWorkerPool()),
636 renderer_binding_(this) { 626 renderer_binding_(this) {
637 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter; 627 scoped_refptr<base::SingleThreadTaskRunner> test_task_counter;
638 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 628 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
639 switches::kRendererClientId)); 629 switches::kRendererClientId));
640 base::StringToInt(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 630 base::StringToInt(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
641 switches::kRendererClientId), 631 switches::kRendererClientId),
642 &client_id_); 632 &client_id_);
643 Init(test_task_counter); 633 Init(test_task_counter);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 887
898 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateFrameFactory)); 888 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateFrameFactory));
899 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateEmbeddedWorkerSetup)); 889 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateEmbeddedWorkerSetup));
900 GetInterfaceRegistry()->AddInterface( 890 GetInterfaceRegistry()->AddInterface(
901 base::Bind(&EmbeddedWorkerInstanceClientImpl::Create, 891 base::Bind(&EmbeddedWorkerInstanceClientImpl::Create,
902 base::Unretained(embedded_worker_dispatcher_.get()))); 892 base::Unretained(embedded_worker_dispatcher_.get())));
903 893
904 GetRemoteInterfaces()->GetInterface( 894 GetRemoteInterfaces()->GetInterface(
905 mojo::GetProxy(&storage_partition_service_)); 895 mojo::GetProxy(&storage_partition_service_));
906 896
907 device::mojom::TimeZoneMonitorPtr time_zone_monitor;
908 GetRemoteInterfaces()->GetInterface(mojo::GetProxy(&time_zone_monitor));
909 time_zone_monitor->AddClient(
910 time_zone_monitor_binding_.CreateInterfacePtrAndBind());
911
912 #if defined(OS_LINUX) 897 #if defined(OS_LINUX)
913 ChildProcess::current()->SetIOThreadPriority(base::ThreadPriority::DISPLAY); 898 ChildProcess::current()->SetIOThreadPriority(base::ThreadPriority::DISPLAY);
914 ChildThreadImpl::current()->SetThreadPriority( 899 ChildThreadImpl::current()->SetThreadPriority(
915 categorized_worker_pool_->background_worker_thread_id(), 900 categorized_worker_pool_->background_worker_thread_id(),
916 base::ThreadPriority::BACKGROUND); 901 base::ThreadPriority::BACKGROUND);
917 #endif 902 #endif
918 903
919 record_purge_suspend_metric_closure_.Reset(base::Bind( 904 record_purge_suspend_metric_closure_.Reset(base::Bind(
920 &RenderThreadImpl::RecordPurgeAndSuspendMetrics, base::Unretained(this))); 905 &RenderThreadImpl::RecordPurgeAndSuspendMetrics, base::Unretained(this)));
921 is_renderer_suspended_ = false; 906 is_renderer_suspended_ = false;
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 1338
1354 // chrome-devtools: 1339 // chrome-devtools:
1355 WebString devtools_scheme(WebString::fromASCII(kChromeDevToolsScheme)); 1340 WebString devtools_scheme(WebString::fromASCII(kChromeDevToolsScheme));
1356 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(devtools_scheme); 1341 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(devtools_scheme);
1357 1342
1358 // view-source: 1343 // view-source:
1359 WebString view_source_scheme(WebString::fromASCII(kViewSourceScheme)); 1344 WebString view_source_scheme(WebString::fromASCII(kViewSourceScheme));
1360 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(view_source_scheme); 1345 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(view_source_scheme);
1361 } 1346 }
1362 1347
1363 void RenderThreadImpl::NotifyTimezoneChange() {
1364 NotifyTimezoneChangeOnThisThread();
1365 RenderThread::Get()->PostTaskToAllWebWorkers(
1366 base::Bind(&NotifyTimezoneChangeOnThisThread));
1367 }
1368
1369 void RenderThreadImpl::RecordAction(const base::UserMetricsAction& action) { 1348 void RenderThreadImpl::RecordAction(const base::UserMetricsAction& action) {
1370 Send(new ViewHostMsg_UserMetricsRecordAction(action.str_)); 1349 Send(new ViewHostMsg_UserMetricsRecordAction(action.str_));
1371 } 1350 }
1372 1351
1373 void RenderThreadImpl::RecordComputedAction(const std::string& action) { 1352 void RenderThreadImpl::RecordComputedAction(const std::string& action) {
1374 Send(new ViewHostMsg_UserMetricsRecordAction(action)); 1353 Send(new ViewHostMsg_UserMetricsRecordAction(action));
1375 } 1354 }
1376 1355
1377 std::unique_ptr<base::SharedMemory> 1356 std::unique_ptr<base::SharedMemory>
1378 RenderThreadImpl::HostAllocateSharedMemoryBuffer(size_t size) { 1357 RenderThreadImpl::HostAllocateSharedMemoryBuffer(size_t size) {
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
2258 blink::resetPluginCache(reload_pages); 2237 blink::resetPluginCache(reload_pages);
2259 blink_platform_impl_->set_plugin_refresh_allowed(true); 2238 blink_platform_impl_->set_plugin_refresh_allowed(true);
2260 2239
2261 for (auto& observer : observers_) 2240 for (auto& observer : observers_)
2262 observer.PluginListChanged(); 2241 observer.PluginListChanged();
2263 #else 2242 #else
2264 NOTREACHED(); 2243 NOTREACHED();
2265 #endif 2244 #endif
2266 } 2245 }
2267 2246
2268 void RenderThreadImpl::OnTimeZoneChange(const std::string& zone_id) {
2269 if (!blink_platform_impl_)
2270 return;
2271 if (!zone_id.empty()) {
2272 icu::TimeZone *new_zone = icu::TimeZone::createTimeZone(
2273 icu::UnicodeString::fromUTF8(zone_id));
2274 icu::TimeZone::adoptDefault(new_zone);
2275 VLOG(1) << "ICU default timezone is set to " << zone_id;
2276 }
2277 NotifyTimezoneChange();
2278 }
2279
2280 void RenderThreadImpl::OnCreateNewSharedWorker( 2247 void RenderThreadImpl::OnCreateNewSharedWorker(
2281 const WorkerProcessMsg_CreateWorker_Params& params) { 2248 const WorkerProcessMsg_CreateWorker_Params& params) {
2282 // EmbeddedSharedWorkerStub will self-destruct. 2249 // EmbeddedSharedWorkerStub will self-destruct.
2283 new EmbeddedSharedWorkerStub( 2250 new EmbeddedSharedWorkerStub(
2284 params.url, params.name, params.content_security_policy, 2251 params.url, params.name, params.content_security_policy,
2285 params.security_policy_type, params.creation_address_space, 2252 params.security_policy_type, params.creation_address_space,
2286 params.pause_on_start, params.route_id); 2253 params.pause_on_start, params.route_id);
2287 } 2254 }
2288 2255
2289 void RenderThreadImpl::OnMemoryPressure( 2256 void RenderThreadImpl::OnMemoryPressure(
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
2514 } 2481 }
2515 } 2482 }
2516 2483
2517 void RenderThreadImpl::OnRendererInterfaceRequest( 2484 void RenderThreadImpl::OnRendererInterfaceRequest(
2518 mojom::RendererAssociatedRequest request) { 2485 mojom::RendererAssociatedRequest request) {
2519 DCHECK(!renderer_binding_.is_bound()); 2486 DCHECK(!renderer_binding_.is_bound());
2520 renderer_binding_.Bind(std::move(request)); 2487 renderer_binding_.Bind(std::move(request));
2521 } 2488 }
2522 2489
2523 } // namespace content 2490 } // 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