Chromium Code Reviews| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 #endif | 111 #endif |
| 112 | 112 |
| 113 #if defined(OS_POSIX) | 113 #if defined(OS_POSIX) |
| 114 #include "ipc/ipc_channel_posix.h" | 114 #include "ipc/ipc_channel_posix.h" |
| 115 #endif | 115 #endif |
| 116 | 116 |
| 117 #if defined(ENABLE_WEBRTC) | 117 #if defined(ENABLE_WEBRTC) |
| 118 #include "third_party/webrtc/system_wrappers/interface/event_tracer.h" | 118 #include "third_party/webrtc/system_wrappers/interface/event_tracer.h" |
| 119 #endif | 119 #endif |
| 120 | 120 |
| 121 #if !defined(OS_ANDROID) && !defined(OS_MACOSX) | |
| 122 #include "base/memory/discardable_memory.h" | |
| 123 #include "content/renderer/render_process_discardable_memory_provider.h" | |
| 124 #include "content/renderer/render_process_visibility_manager.h" | |
| 125 #endif | |
| 126 | |
| 121 using base::ThreadRestrictions; | 127 using base::ThreadRestrictions; |
| 122 using WebKit::WebDocument; | 128 using WebKit::WebDocument; |
| 123 using WebKit::WebFrame; | 129 using WebKit::WebFrame; |
| 124 using WebKit::WebNetworkStateNotifier; | 130 using WebKit::WebNetworkStateNotifier; |
| 125 using WebKit::WebRuntimeFeatures; | 131 using WebKit::WebRuntimeFeatures; |
| 126 using WebKit::WebScriptController; | 132 using WebKit::WebScriptController; |
| 127 using WebKit::WebSecurityPolicy; | 133 using WebKit::WebSecurityPolicy; |
| 128 using WebKit::WebString; | 134 using WebKit::WebString; |
| 129 using WebKit::WebView; | 135 using WebKit::WebView; |
| 130 | 136 |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 | 403 |
| 398 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 404 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 399 if (command_line.HasSwitch(switches::kEnableGpuBenchmarking)) | 405 if (command_line.HasSwitch(switches::kEnableGpuBenchmarking)) |
| 400 RegisterExtension(GpuBenchmarkingExtension::Get()); | 406 RegisterExtension(GpuBenchmarkingExtension::Get()); |
| 401 | 407 |
| 402 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) | 408 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) |
| 403 if (command_line.HasSwitch(switches::kEnableMemoryBenchmarking)) | 409 if (command_line.HasSwitch(switches::kEnableMemoryBenchmarking)) |
| 404 RegisterExtension(MemoryBenchmarkingExtension::Get()); | 410 RegisterExtension(MemoryBenchmarkingExtension::Get()); |
| 405 #endif // USE_TCMALLOC | 411 #endif // USE_TCMALLOC |
| 406 | 412 |
| 413 #if !defined(OS_ANDROID) && !defined(OS_MACOSX) | |
| 414 discardable_provider_.reset(new RenderProcessDiscardableMemoryProvider); | |
| 415 RenderProcessVisibilityManager::GetInstance()->AddObserver( | |
| 416 discardable_provider_.get()); | |
|
jonathan.backer
2013/05/29 14:02:54
I don't see the advantage of a singleton here. Re
| |
| 417 base::DiscardableMemory::SetProvider(discardable_provider_.get()); | |
|
jonathan.backer
2013/05/29 14:02:54
I suspect that you may have many RenderThreadImpls
| |
| 418 #endif | |
| 419 | |
| 407 if (command_line.HasSwitch(switches::kEnableSkiaBenchmarking)) { | 420 if (command_line.HasSwitch(switches::kEnableSkiaBenchmarking)) { |
| 408 LOG(WARNING) << "Enabling unsafe Skia benchmarking extension."; | 421 LOG(WARNING) << "Enabling unsafe Skia benchmarking extension."; |
| 409 RegisterExtension(SkiaBenchmarkingExtension::Get()); | 422 RegisterExtension(SkiaBenchmarkingExtension::Get()); |
| 410 } | 423 } |
| 411 | 424 |
| 412 context_lost_cb_.reset(new GpuVDAContextLostCallback()); | 425 context_lost_cb_.reset(new GpuVDAContextLostCallback()); |
| 413 | 426 |
| 414 // Note that under Linux, the media library will normally already have | 427 // Note that under Linux, the media library will normally already have |
| 415 // been initialized by the Zygote before this instance became a Renderer. | 428 // been initialized by the Zygote before this instance became a Renderer. |
| 416 base::FilePath media_path; | 429 base::FilePath media_path; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 614 | 627 |
| 615 void RenderThreadImpl::SetResourceDispatcherDelegate( | 628 void RenderThreadImpl::SetResourceDispatcherDelegate( |
| 616 ResourceDispatcherDelegate* delegate) { | 629 ResourceDispatcherDelegate* delegate) { |
| 617 resource_dispatcher()->set_delegate(delegate); | 630 resource_dispatcher()->set_delegate(delegate); |
| 618 } | 631 } |
| 619 | 632 |
| 620 void RenderThreadImpl::WidgetHidden() { | 633 void RenderThreadImpl::WidgetHidden() { |
| 621 DCHECK(hidden_widget_count_ < widget_count_); | 634 DCHECK(hidden_widget_count_ < widget_count_); |
| 622 hidden_widget_count_++; | 635 hidden_widget_count_++; |
| 623 | 636 |
| 637 #if !defined(OS_ANDROID) && !defined(OS_MACOSX) | |
| 638 RenderProcessVisibilityManager::GetInstance()->WidgetVisibilityChanged(false); | |
| 639 #endif | |
| 640 | |
| 624 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 641 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
| 625 return; | 642 return; |
| 626 } | 643 } |
| 627 | 644 |
| 628 if (widget_count_ && hidden_widget_count_ == widget_count_) | 645 if (widget_count_ && hidden_widget_count_ == widget_count_) |
| 629 ScheduleIdleHandler(kInitialIdleHandlerDelayMs); | 646 ScheduleIdleHandler(kInitialIdleHandlerDelayMs); |
| 630 } | 647 } |
| 631 | 648 |
| 632 void RenderThreadImpl::WidgetRestored() { | 649 void RenderThreadImpl::WidgetRestored() { |
| 633 DCHECK_GT(hidden_widget_count_, 0); | 650 DCHECK_GT(hidden_widget_count_, 0); |
| 634 hidden_widget_count_--; | 651 hidden_widget_count_--; |
| 652 | |
| 653 #if !defined(OS_ANDROID) && !defined(OS_MACOSX) | |
| 654 RenderProcessVisibilityManager::GetInstance()->WidgetVisibilityChanged(true); | |
| 655 #endif | |
| 656 | |
| 635 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 657 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
| 636 return; | 658 return; |
| 637 } | 659 } |
| 638 | 660 |
| 639 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 661 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
| 640 } | 662 } |
| 641 | 663 |
| 642 static void AdjustRuntimeFeatureDefaultsForPlatform() { | 664 static void AdjustRuntimeFeatureDefaultsForPlatform() { |
| 643 #if defined(OS_ANDROID) && !defined(GOOGLE_TV) | 665 #if defined(OS_ANDROID) && !defined(GOOGLE_TV) |
| 644 WebRuntimeFeatures::enableWebKitMediaSource(false); | 666 WebRuntimeFeatures::enableWebKitMediaSource(false); |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1330 | 1352 |
| 1331 void RenderThreadImpl::SetFlingCurveParameters( | 1353 void RenderThreadImpl::SetFlingCurveParameters( |
| 1332 const std::vector<float>& new_touchpad, | 1354 const std::vector<float>& new_touchpad, |
| 1333 const std::vector<float>& new_touchscreen) { | 1355 const std::vector<float>& new_touchscreen) { |
| 1334 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, | 1356 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, |
| 1335 new_touchscreen); | 1357 new_touchscreen); |
| 1336 | 1358 |
| 1337 } | 1359 } |
| 1338 | 1360 |
| 1339 } // namespace content | 1361 } // namespace content |
| OLD | NEW |