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 | |
658 InitializeWebKit(resource_task_queue); | 642 InitializeWebKit(resource_task_queue); |
659 | 643 |
660 // In single process the single process is all there is. | 644 // In single process the single process is all there is. |
661 webkit_shared_timer_suspended_ = false; | 645 webkit_shared_timer_suspended_ = false; |
662 widget_count_ = 0; | 646 widget_count_ = 0; |
663 hidden_widget_count_ = 0; | 647 hidden_widget_count_ = 0; |
664 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; | 648 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; |
665 idle_notifications_to_skip_ = 0; | 649 idle_notifications_to_skip_ = 0; |
666 | 650 |
667 appcache_dispatcher_.reset( | 651 appcache_dispatcher_.reset( |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 media::EnablePlatformDecoderSupport(); | 817 media::EnablePlatformDecoderSupport(); |
834 } | 818 } |
835 #endif | 819 #endif |
836 | 820 |
837 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableHDR) || | 821 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableHDR) || |
838 base::CommandLine::ForCurrentProcess()->HasSwitch( | 822 base::CommandLine::ForCurrentProcess()->HasSwitch( |
839 switches::kEnableNewVp9CodecString)) { | 823 switches::kEnableNewVp9CodecString)) { |
840 media::EnableNewVp9CodecStringSupport(); | 824 media::EnableNewVp9CodecStringSupport(); |
841 } | 825 } |
842 | 826 |
| 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 |
| 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 |
843 int num_raster_threads = 0; | 846 int num_raster_threads = 0; |
844 std::string string_value = | 847 std::string string_value = |
845 command_line.GetSwitchValueASCII(switches::kNumRasterThreads); | 848 command_line.GetSwitchValueASCII(switches::kNumRasterThreads); |
846 bool parsed_num_raster_threads = | 849 bool parsed_num_raster_threads = |
847 base::StringToInt(string_value, &num_raster_threads); | 850 base::StringToInt(string_value, &num_raster_threads); |
848 DCHECK(parsed_num_raster_threads) << string_value; | 851 DCHECK(parsed_num_raster_threads) << string_value; |
849 DCHECK_GT(num_raster_threads, 0); | 852 DCHECK_GT(num_raster_threads, 0); |
850 | 853 |
851 // TODO(vmpstr): If the flag sticks, we should clean it up and always have | 854 // TODO(vmpstr): If the flag sticks, we should clean it up and always have |
852 // image decode tasks. | 855 // image decode tasks. |
(...skipping 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2425 } | 2428 } |
2426 } | 2429 } |
2427 | 2430 |
2428 void RenderThreadImpl::OnRendererInterfaceRequest( | 2431 void RenderThreadImpl::OnRendererInterfaceRequest( |
2429 mojom::RendererAssociatedRequest request) { | 2432 mojom::RendererAssociatedRequest request) { |
2430 DCHECK(!renderer_binding_.is_bound()); | 2433 DCHECK(!renderer_binding_.is_bound()); |
2431 renderer_binding_.Bind(std::move(request)); | 2434 renderer_binding_.Bind(std::move(request)); |
2432 } | 2435 } |
2433 | 2436 |
2434 } // namespace content | 2437 } // namespace content |
OLD | NEW |