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 <utility> | 10 #include <utility> |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 632 gpu_ = ui::Gpu::Create( | 632 gpu_ = ui::Gpu::Create( |
| 633 GetConnector(), | 633 GetConnector(), |
| 634 IsRunningInMash() ? ui::mojom::kServiceName : mojom::kBrowserServiceName, | 634 IsRunningInMash() ? ui::mojom::kServiceName : mojom::kBrowserServiceName, |
| 635 GetIOTaskRunner()); | 635 GetIOTaskRunner()); |
| 636 | 636 |
| 637 channel()->GetThreadSafeRemoteAssociatedInterface( | 637 channel()->GetThreadSafeRemoteAssociatedInterface( |
| 638 &thread_safe_render_message_filter_); | 638 &thread_safe_render_message_filter_); |
| 639 shared_bitmap_manager_.reset( | 639 shared_bitmap_manager_.reset( |
| 640 new ChildSharedBitmapManager(thread_safe_render_message_filter_)); | 640 new ChildSharedBitmapManager(thread_safe_render_message_filter_)); |
| 641 | 641 |
| 642 memory_pressure_listener_.reset(new base::MemoryPressureListener( | |
| 643 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)), | |
| 644 base::Bind(&RenderThreadImpl::OnSyncMemoryPressure, | |
| 645 base::Unretained(this)))); | |
| 646 | |
| 647 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) { | |
| 648 // Disable MemoryPressureListener when memory coordinator is enabled. | |
| 649 base::MemoryPressureListener::SetNotificationsSuppressed(true); | |
| 650 | |
| 651 mojom::MemoryCoordinatorHandlePtr parent_coordinator; | |
| 652 GetConnector()->BindInterface(mojom::kBrowserServiceName, | |
| 653 mojo::MakeRequest(&parent_coordinator)); | |
| 654 memory_coordinator_ = | |
| 655 CreateChildMemoryCoordinator(std::move(parent_coordinator), this); | |
| 656 } | |
| 657 | |
| 642 InitializeWebKit(resource_task_queue); | 658 InitializeWebKit(resource_task_queue); |
| 643 | 659 |
| 644 // In single process the single process is all there is. | 660 // In single process the single process is all there is. |
| 645 webkit_shared_timer_suspended_ = false; | 661 webkit_shared_timer_suspended_ = false; |
| 646 widget_count_ = 0; | 662 widget_count_ = 0; |
| 647 hidden_widget_count_ = 0; | 663 hidden_widget_count_ = 0; |
| 648 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; | 664 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; |
| 649 idle_notifications_to_skip_ = 0; | 665 idle_notifications_to_skip_ = 0; |
| 650 | 666 |
| 651 appcache_dispatcher_.reset( | 667 appcache_dispatcher_.reset( |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 817 media::EnablePlatformDecoderSupport(); | 833 media::EnablePlatformDecoderSupport(); |
| 818 } | 834 } |
| 819 #endif | 835 #endif |
| 820 | 836 |
| 821 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableHDR) || | 837 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableHDR) || |
| 822 base::CommandLine::ForCurrentProcess()->HasSwitch( | 838 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 823 switches::kEnableNewVp9CodecString)) { | 839 switches::kEnableNewVp9CodecString)) { |
| 824 media::EnableNewVp9CodecStringSupport(); | 840 media::EnableNewVp9CodecStringSupport(); |
| 825 } | 841 } |
| 826 | 842 |
| 827 memory_pressure_listener_.reset(new base::MemoryPressureListener( | |
| 828 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)), | |
| 829 base::Bind(&RenderThreadImpl::OnSyncMemoryPressure, | |
| 830 base::Unretained(this)))); | |
| 831 | |
| 832 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) { | |
| 833 // Disable MemoryPressureListener when memory coordinator is enabled. | |
| 834 base::MemoryPressureListener::SetNotificationsSuppressed(true); | |
| 835 | |
| 836 // TODO(bashi): Revisit how to manage the lifetime of | |
|
bashi
2017/03/23 07:47:52
Removed this TODO as this looks a common pattern t
| |
| 837 // ChildMemoryCoordinatorImpl. | |
| 838 // https://codereview.chromium.org/2094583002/#msg52 | |
| 839 mojom::MemoryCoordinatorHandlePtr parent_coordinator; | |
| 840 GetConnector()->BindInterface(mojom::kBrowserServiceName, | |
| 841 mojo::MakeRequest(&parent_coordinator)); | |
| 842 memory_coordinator_ = CreateChildMemoryCoordinator( | |
| 843 std::move(parent_coordinator), this); | |
| 844 } | |
| 845 | |
| 846 int num_raster_threads = 0; | 843 int num_raster_threads = 0; |
| 847 std::string string_value = | 844 std::string string_value = |
| 848 command_line.GetSwitchValueASCII(switches::kNumRasterThreads); | 845 command_line.GetSwitchValueASCII(switches::kNumRasterThreads); |
| 849 bool parsed_num_raster_threads = | 846 bool parsed_num_raster_threads = |
| 850 base::StringToInt(string_value, &num_raster_threads); | 847 base::StringToInt(string_value, &num_raster_threads); |
| 851 DCHECK(parsed_num_raster_threads) << string_value; | 848 DCHECK(parsed_num_raster_threads) << string_value; |
| 852 DCHECK_GT(num_raster_threads, 0); | 849 DCHECK_GT(num_raster_threads, 0); |
| 853 | 850 |
| 854 // TODO(vmpstr): If the flag sticks, we should clean it up and always have | 851 // TODO(vmpstr): If the flag sticks, we should clean it up and always have |
| 855 // image decode tasks. | 852 // image decode tasks. |
| (...skipping 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2428 } | 2425 } |
| 2429 } | 2426 } |
| 2430 | 2427 |
| 2431 void RenderThreadImpl::OnRendererInterfaceRequest( | 2428 void RenderThreadImpl::OnRendererInterfaceRequest( |
| 2432 mojom::RendererAssociatedRequest request) { | 2429 mojom::RendererAssociatedRequest request) { |
| 2433 DCHECK(!renderer_binding_.is_bound()); | 2430 DCHECK(!renderer_binding_.is_bound()); |
| 2434 renderer_binding_.Bind(std::move(request)); | 2431 renderer_binding_.Bind(std::move(request)); |
| 2435 } | 2432 } |
| 2436 | 2433 |
| 2437 } // namespace content | 2434 } // namespace content |
| OLD | NEW |