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 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 base::StringToInt(string_value, &num_raster_threads); | 866 base::StringToInt(string_value, &num_raster_threads); |
867 DCHECK(parsed_num_raster_threads) << string_value; | 867 DCHECK(parsed_num_raster_threads) << string_value; |
868 DCHECK_GT(num_raster_threads, 0); | 868 DCHECK_GT(num_raster_threads, 0); |
869 | 869 |
870 // TODO(vmpstr): If the flag sticks, we should clean it up and always have | 870 // TODO(vmpstr): If the flag sticks, we should clean it up and always have |
871 // image decode tasks. | 871 // image decode tasks. |
872 are_image_decode_tasks_enabled_ = true; | 872 are_image_decode_tasks_enabled_ = true; |
873 | 873 |
874 categorized_worker_pool_->Start(num_raster_threads); | 874 categorized_worker_pool_->Start(num_raster_threads); |
875 | 875 |
| 876 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr; |
| 877 ChildThread::Get()->GetRemoteInterfaces()->GetInterface( |
| 878 mojo::GetProxy(&manager_ptr)); |
| 879 discardable_shared_memory_manager_ = base::MakeUnique< |
| 880 discardable_memory::ClientDiscardableSharedMemoryManager>( |
| 881 manager_ptr.PassInterface(), GetIOTaskRunner().get()); |
| 882 |
876 // TODO(boliu): In single process, browser main loop should set up the | 883 // TODO(boliu): In single process, browser main loop should set up the |
877 // discardable memory manager, and should skip this if kSingleProcess. | 884 // discardable memory manager, and should skip this if kSingleProcess. |
878 // See crbug.com/503724. | 885 // See crbug.com/503724. |
879 base::DiscardableMemoryAllocator::SetInstance( | 886 base::DiscardableMemoryAllocator::SetInstance( |
880 ChildThreadImpl::discardable_shared_memory_manager()); | 887 discardable_shared_memory_manager_.get()); |
881 | 888 |
882 GetContentClient()->renderer()->ExposeInterfacesToBrowser( | 889 GetContentClient()->renderer()->ExposeInterfacesToBrowser( |
883 GetInterfaceRegistry()); | 890 GetInterfaceRegistry()); |
884 | 891 |
885 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateFrameFactory)); | 892 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateFrameFactory)); |
886 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateEmbeddedWorkerSetup)); | 893 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateEmbeddedWorkerSetup)); |
887 GetInterfaceRegistry()->AddInterface( | 894 GetInterfaceRegistry()->AddInterface( |
888 base::Bind(&EmbeddedWorkerInstanceClientImpl::Create, | 895 base::Bind(&EmbeddedWorkerInstanceClientImpl::Create, |
889 base::Unretained(embedded_worker_dispatcher_.get()))); | 896 base::Unretained(embedded_worker_dispatcher_.get()))); |
890 | 897 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 blink_platform_impl_->Shutdown(); | 1025 blink_platform_impl_->Shutdown(); |
1019 // This must be at the very end of the shutdown sequence. | 1026 // This must be at the very end of the shutdown sequence. |
1020 // blink::shutdown() must be called after all strong references from | 1027 // blink::shutdown() must be called after all strong references from |
1021 // Chromium to Blink are cleared. | 1028 // Chromium to Blink are cleared. |
1022 blink::shutdown(); | 1029 blink::shutdown(); |
1023 } | 1030 } |
1024 | 1031 |
1025 // Delay shutting down DiscardableSharedMemoryManager until blink::shutdown | 1032 // Delay shutting down DiscardableSharedMemoryManager until blink::shutdown |
1026 // is complete, because blink::shutdown destructs Blink Resources and they | 1033 // is complete, because blink::shutdown destructs Blink Resources and they |
1027 // may try to unlock their underlying discardable memory. | 1034 // may try to unlock their underlying discardable memory. |
1028 ChildThreadImpl::ShutdownDiscardableSharedMemoryManager(); | 1035 discardable_shared_memory_manager_.reset(); |
1029 | 1036 |
1030 // The message loop must be cleared after shutting down | 1037 // The message loop must be cleared after shutting down |
1031 // the DiscardableSharedMemoryManager, which needs to send messages | 1038 // the DiscardableSharedMemoryManager, which needs to send messages |
1032 // to the browser process. | 1039 // to the browser process. |
1033 main_message_loop_.reset(); | 1040 main_message_loop_.reset(); |
1034 | 1041 |
1035 lazy_tls.Pointer()->Set(nullptr); | 1042 lazy_tls.Pointer()->Set(nullptr); |
1036 | 1043 |
1037 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this); | 1044 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this); |
1038 } | 1045 } |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1847 #else | 1854 #else |
1848 size_t malloc_usage = minfo.hblkhd + minfo.arena; | 1855 size_t malloc_usage = minfo.hblkhd + minfo.arena; |
1849 #endif | 1856 #endif |
1850 #else | 1857 #else |
1851 size_t malloc_usage = GetMallocUsage(); | 1858 size_t malloc_usage = GetMallocUsage(); |
1852 #endif | 1859 #endif |
1853 UMA_HISTOGRAM_MEMORY_MB("PurgeAndSuspend.Memory.MallocMB", | 1860 UMA_HISTOGRAM_MEMORY_MB("PurgeAndSuspend.Memory.MallocMB", |
1854 malloc_usage / 1024 / 1024); | 1861 malloc_usage / 1024 / 1024); |
1855 | 1862 |
1856 discardable_memory::ClientDiscardableSharedMemoryManager::Statistics | 1863 discardable_memory::ClientDiscardableSharedMemoryManager::Statistics |
1857 discardable_stats = | 1864 discardable_stats = discardable_shared_memory_manager_->GetStatistics(); |
1858 ChildThreadImpl::discardable_shared_memory_manager()->GetStatistics(); | |
1859 size_t discardable_usage = | 1865 size_t discardable_usage = |
1860 discardable_stats.total_size - discardable_stats.freelist_size; | 1866 discardable_stats.total_size - discardable_stats.freelist_size; |
1861 UMA_HISTOGRAM_MEMORY_KB("PurgeAndSuspend.Memory.DiscardableKB", | 1867 UMA_HISTOGRAM_MEMORY_KB("PurgeAndSuspend.Memory.DiscardableKB", |
1862 discardable_usage / 1024); | 1868 discardable_usage / 1024); |
1863 | 1869 |
1864 size_t v8_usage = 0; | 1870 size_t v8_usage = 0; |
1865 if (v8::Isolate* isolate = blink::mainThreadIsolate()) { | 1871 if (v8::Isolate* isolate = blink::mainThreadIsolate()) { |
1866 v8::HeapStatistics v8_heap_statistics; | 1872 v8::HeapStatistics v8_heap_statistics; |
1867 isolate->GetHeapStatistics(&v8_heap_statistics); | 1873 isolate->GetHeapStatistics(&v8_heap_statistics); |
1868 v8_usage = v8_heap_statistics.total_heap_size(); | 1874 v8_usage = v8_heap_statistics.total_heap_size(); |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2410 | 2416 |
2411 void RenderThreadImpl::OnRendererVisible() { | 2417 void RenderThreadImpl::OnRendererVisible() { |
2412 blink::mainThreadIsolate()->IsolateInForegroundNotification(); | 2418 blink::mainThreadIsolate()->IsolateInForegroundNotification(); |
2413 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) | 2419 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) |
2414 return; | 2420 return; |
2415 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 2421 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
2416 } | 2422 } |
2417 | 2423 |
2418 void RenderThreadImpl::ReleaseFreeMemory() { | 2424 void RenderThreadImpl::ReleaseFreeMemory() { |
2419 base::allocator::ReleaseFreeMemory(); | 2425 base::allocator::ReleaseFreeMemory(); |
2420 discardable_shared_memory_manager()->ReleaseFreeMemory(); | 2426 discardable_shared_memory_manager_->ReleaseFreeMemory(); |
2421 | 2427 |
2422 if (blink_platform_impl_) | 2428 if (blink_platform_impl_) |
2423 blink::decommitFreeableMemory(); | 2429 blink::decommitFreeableMemory(); |
2424 } | 2430 } |
2425 | 2431 |
2426 RenderThreadImpl::PendingFrameCreate::PendingFrameCreate( | 2432 RenderThreadImpl::PendingFrameCreate::PendingFrameCreate( |
2427 int routing_id, | 2433 int routing_id, |
2428 mojom::FrameRequest frame_request, | 2434 mojom::FrameRequest frame_request, |
2429 mojom::FrameHostPtr frame_host) | 2435 mojom::FrameHostPtr frame_host) |
2430 : routing_id_(routing_id), | 2436 : routing_id_(routing_id), |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2478 } | 2484 } |
2479 } | 2485 } |
2480 | 2486 |
2481 void RenderThreadImpl::OnRendererInterfaceRequest( | 2487 void RenderThreadImpl::OnRendererInterfaceRequest( |
2482 mojom::RendererAssociatedRequest request) { | 2488 mojom::RendererAssociatedRequest request) { |
2483 DCHECK(!renderer_binding_.is_bound()); | 2489 DCHECK(!renderer_binding_.is_bound()); |
2484 renderer_binding_.Bind(std::move(request)); | 2490 renderer_binding_.Bind(std::move(request)); |
2485 } | 2491 } |
2486 | 2492 |
2487 } // namespace content | 2493 } // namespace content |
OLD | NEW |