| 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 <vector> | 10 #include <vector> |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 custom_histograms_.find(name) != custom_histograms_.end()) | 324 custom_histograms_.find(name) != custom_histograms_.end()) |
| 325 name += common_host_histogram_suffix_; | 325 name += common_host_histogram_suffix_; |
| 326 return name; | 326 return name; |
| 327 } | 327 } |
| 328 | 328 |
| 329 void RenderThreadImpl::HistogramCustomizer::SetCommonHost( | 329 void RenderThreadImpl::HistogramCustomizer::SetCommonHost( |
| 330 const std::string& host) { | 330 const std::string& host) { |
| 331 if (host != common_host_) { | 331 if (host != common_host_) { |
| 332 common_host_ = host; | 332 common_host_ = host; |
| 333 common_host_histogram_suffix_ = HostToCustomHistogramSuffix(host); | 333 common_host_histogram_suffix_ = HostToCustomHistogramSuffix(host); |
| 334 v8::V8::SetCreateHistogramFunction(CreateHistogram); | 334 blink::mainThreadIsolate()->SetCreateHistogramFunction(CreateHistogram); |
| 335 } | 335 } |
| 336 } | 336 } |
| 337 | 337 |
| 338 RenderThreadImpl* RenderThreadImpl::current() { | 338 RenderThreadImpl* RenderThreadImpl::current() { |
| 339 return lazy_tls.Pointer()->Get(); | 339 return lazy_tls.Pointer()->Get(); |
| 340 } | 340 } |
| 341 | 341 |
| 342 // When we run plugins in process, we actually run them on the render thread, | 342 // When we run plugins in process, we actually run them on the render thread, |
| 343 // which means that we need to make the render thread pump UI events. | 343 // which means that we need to make the render thread pump UI events. |
| 344 RenderThreadImpl::RenderThreadImpl() { | 344 RenderThreadImpl::RenderThreadImpl() { |
| 345 Init(); | 345 Init(); |
| 346 } | 346 } |
| 347 | 347 |
| 348 RenderThreadImpl::RenderThreadImpl(const std::string& channel_name) | 348 RenderThreadImpl::RenderThreadImpl(const std::string& channel_name) |
| 349 : ChildThread(channel_name) { | 349 : ChildThread(channel_name) { |
| 350 Init(); | 350 Init(); |
| 351 } | 351 } |
| 352 | 352 |
| 353 void RenderThreadImpl::Init() { | 353 void RenderThreadImpl::Init() { |
| 354 TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, ""); | 354 TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, ""); |
| 355 | 355 |
| 356 base::debug::TraceLog::GetInstance()->SetThreadSortIndex( | 356 base::debug::TraceLog::GetInstance()->SetThreadSortIndex( |
| 357 base::PlatformThread::CurrentId(), | 357 base::PlatformThread::CurrentId(), |
| 358 kTraceEventRendererMainThreadSortIndex); | 358 kTraceEventRendererMainThreadSortIndex); |
| 359 | 359 |
| 360 v8::V8::SetCounterFunction(base::StatsTable::FindLocation); | |
| 361 v8::V8::SetCreateHistogramFunction(CreateHistogram); | |
| 362 v8::V8::SetAddHistogramSampleFunction(AddHistogramSample); | |
| 363 | |
| 364 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 360 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
| 365 // On Mac and Android, the select popups are rendered by the browser. | 361 // On Mac and Android, the select popups are rendered by the browser. |
| 366 blink::WebView::setUseExternalPopupMenus(true); | 362 blink::WebView::setUseExternalPopupMenus(true); |
| 367 #endif | 363 #endif |
| 368 | 364 |
| 369 lazy_tls.Pointer()->Set(this); | 365 lazy_tls.Pointer()->Set(this); |
| 370 | 366 |
| 371 // Register this object as the main thread. | 367 // Register this object as the main thread. |
| 372 ChildProcess::current()->set_main_thread(this); | 368 ChildProcess::current()->set_main_thread(this); |
| 373 | 369 |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 resource_dispatcher()->set_delegate(delegate); | 780 resource_dispatcher()->set_delegate(delegate); |
| 785 } | 781 } |
| 786 | 782 |
| 787 void RenderThreadImpl::EnsureWebKitInitialized() { | 783 void RenderThreadImpl::EnsureWebKitInitialized() { |
| 788 if (webkit_platform_support_) | 784 if (webkit_platform_support_) |
| 789 return; | 785 return; |
| 790 | 786 |
| 791 webkit_platform_support_.reset(new RendererWebKitPlatformSupportImpl); | 787 webkit_platform_support_.reset(new RendererWebKitPlatformSupportImpl); |
| 792 blink::initialize(webkit_platform_support_.get()); | 788 blink::initialize(webkit_platform_support_.get()); |
| 793 | 789 |
| 790 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 791 |
| 792 isolate->SetCounterFunction(base::StatsTable::FindLocation); |
| 793 isolate->SetCreateHistogramFunction(CreateHistogram); |
| 794 isolate->SetAddHistogramSampleFunction(AddHistogramSample); |
| 795 |
| 794 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 796 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 795 | 797 |
| 796 bool enable = command_line.HasSwitch(switches::kEnableThreadedCompositing); | 798 bool enable = command_line.HasSwitch(switches::kEnableThreadedCompositing); |
| 797 if (enable) { | 799 if (enable) { |
| 798 #if defined(OS_ANDROID) | 800 #if defined(OS_ANDROID) |
| 799 if (SynchronousCompositorFactory* factory = | 801 if (SynchronousCompositorFactory* factory = |
| 800 SynchronousCompositorFactory::GetInstance()) | 802 SynchronousCompositorFactory::GetInstance()) |
| 801 compositor_message_loop_proxy_ = | 803 compositor_message_loop_proxy_ = |
| 802 factory->GetCompositorMessageLoop(); | 804 factory->GetCompositorMessageLoop(); |
| 803 #endif | 805 #endif |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 hidden_widget_count_--; | 1567 hidden_widget_count_--; |
| 1566 | 1568 |
| 1567 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 1569 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
| 1568 return; | 1570 return; |
| 1569 } | 1571 } |
| 1570 | 1572 |
| 1571 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 1573 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
| 1572 } | 1574 } |
| 1573 | 1575 |
| 1574 } // namespace content | 1576 } // namespace content |
| OLD | NEW |