Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 2485623002: discardable_memory: Using mojo IPC to replace Chrome IPC (Closed)
Patch Set: Address review issues Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 base::StringToInt(string_value, &num_raster_threads); 867 base::StringToInt(string_value, &num_raster_threads);
868 DCHECK(parsed_num_raster_threads) << string_value; 868 DCHECK(parsed_num_raster_threads) << string_value;
869 DCHECK_GT(num_raster_threads, 0); 869 DCHECK_GT(num_raster_threads, 0);
870 870
871 // TODO(vmpstr): If the flag sticks, we should clean it up and always have 871 // TODO(vmpstr): If the flag sticks, we should clean it up and always have
872 // image decode tasks. 872 // image decode tasks.
873 are_image_decode_tasks_enabled_ = true; 873 are_image_decode_tasks_enabled_ = true;
874 874
875 categorized_worker_pool_->Start(num_raster_threads); 875 categorized_worker_pool_->Start(num_raster_threads);
876 876
877 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr;
878 ChildThread::Get()->GetRemoteInterfaces()->GetInterface(
879 mojo::GetProxy(&manager_ptr));
880 discardable_shared_memory_manager_ = base::MakeUnique<
881 discardable_memory::ClientDiscardableSharedMemoryManager>(
882 std::move(manager_ptr), GetIOTaskRunner());
883
877 // TODO(boliu): In single process, browser main loop should set up the 884 // TODO(boliu): In single process, browser main loop should set up the
878 // discardable memory manager, and should skip this if kSingleProcess. 885 // discardable memory manager, and should skip this if kSingleProcess.
879 // See crbug.com/503724. 886 // See crbug.com/503724.
880 base::DiscardableMemoryAllocator::SetInstance( 887 base::DiscardableMemoryAllocator::SetInstance(
881 ChildThreadImpl::discardable_shared_memory_manager()); 888 discardable_shared_memory_manager_.get());
882 889
883 GetContentClient()->renderer()->ExposeInterfacesToBrowser( 890 GetContentClient()->renderer()->ExposeInterfacesToBrowser(
884 GetInterfaceRegistry()); 891 GetInterfaceRegistry());
885 892
886 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateFrameFactory)); 893 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateFrameFactory));
887 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateEmbeddedWorkerSetup)); 894 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateEmbeddedWorkerSetup));
888 GetInterfaceRegistry()->AddInterface( 895 GetInterfaceRegistry()->AddInterface(
889 base::Bind(&EmbeddedWorkerInstanceClientImpl::Create, 896 base::Bind(&EmbeddedWorkerInstanceClientImpl::Create,
890 base::Unretained(embedded_worker_dispatcher_.get()))); 897 base::Unretained(embedded_worker_dispatcher_.get())));
891 898
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 blink_platform_impl_->Shutdown(); 1033 blink_platform_impl_->Shutdown();
1027 // This must be at the very end of the shutdown sequence. 1034 // This must be at the very end of the shutdown sequence.
1028 // blink::shutdown() must be called after all strong references from 1035 // blink::shutdown() must be called after all strong references from
1029 // Chromium to Blink are cleared. 1036 // Chromium to Blink are cleared.
1030 blink::shutdown(); 1037 blink::shutdown();
1031 } 1038 }
1032 1039
1033 // Delay shutting down DiscardableSharedMemoryManager until blink::shutdown 1040 // Delay shutting down DiscardableSharedMemoryManager until blink::shutdown
1034 // is complete, because blink::shutdown destructs Blink Resources and they 1041 // is complete, because blink::shutdown destructs Blink Resources and they
1035 // may try to unlock their underlying discardable memory. 1042 // may try to unlock their underlying discardable memory.
1036 ChildThreadImpl::ShutdownDiscardableSharedMemoryManager(); 1043 discardable_shared_memory_manager_.reset();
1037 1044
1038 // The message loop must be cleared after shutting down 1045 // The message loop must be cleared after shutting down
1039 // the DiscardableSharedMemoryManager, which needs to send messages 1046 // the DiscardableSharedMemoryManager, which needs to send messages
1040 // to the browser process. 1047 // to the browser process.
1041 main_message_loop_.reset(); 1048 main_message_loop_.reset();
1042 1049
1043 lazy_tls.Pointer()->Set(nullptr); 1050 lazy_tls.Pointer()->Set(nullptr);
1044 1051
1045 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this); 1052 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this);
1046 } 1053 }
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 #else 1862 #else
1856 size_t malloc_usage = minfo.hblkhd + minfo.arena; 1863 size_t malloc_usage = minfo.hblkhd + minfo.arena;
1857 #endif 1864 #endif
1858 #else 1865 #else
1859 size_t malloc_usage = GetMallocUsage(); 1866 size_t malloc_usage = GetMallocUsage();
1860 #endif 1867 #endif
1861 UMA_HISTOGRAM_MEMORY_MB("PurgeAndSuspend.Memory.MallocMB", 1868 UMA_HISTOGRAM_MEMORY_MB("PurgeAndSuspend.Memory.MallocMB",
1862 malloc_usage / 1024 / 1024); 1869 malloc_usage / 1024 / 1024);
1863 1870
1864 discardable_memory::ClientDiscardableSharedMemoryManager::Statistics 1871 discardable_memory::ClientDiscardableSharedMemoryManager::Statistics
1865 discardable_stats = 1872 discardable_stats = discardable_shared_memory_manager_->GetStatistics();
1866 ChildThreadImpl::discardable_shared_memory_manager()->GetStatistics();
1867 size_t discardable_usage = 1873 size_t discardable_usage =
1868 discardable_stats.total_size - discardable_stats.freelist_size; 1874 discardable_stats.total_size - discardable_stats.freelist_size;
1869 UMA_HISTOGRAM_MEMORY_KB("PurgeAndSuspend.Memory.DiscardableKB", 1875 UMA_HISTOGRAM_MEMORY_KB("PurgeAndSuspend.Memory.DiscardableKB",
1870 discardable_usage / 1024); 1876 discardable_usage / 1024);
1871 1877
1872 size_t v8_usage = 0; 1878 size_t v8_usage = 0;
1873 if (v8::Isolate* isolate = blink::mainThreadIsolate()) { 1879 if (v8::Isolate* isolate = blink::mainThreadIsolate()) {
1874 v8::HeapStatistics v8_heap_statistics; 1880 v8::HeapStatistics v8_heap_statistics;
1875 isolate->GetHeapStatistics(&v8_heap_statistics); 1881 isolate->GetHeapStatistics(&v8_heap_statistics);
1876 v8_usage = v8_heap_statistics.total_heap_size(); 1882 v8_usage = v8_heap_statistics.total_heap_size();
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
2421 2427
2422 void RenderThreadImpl::OnRendererVisible() { 2428 void RenderThreadImpl::OnRendererVisible() {
2423 blink::mainThreadIsolate()->IsolateInForegroundNotification(); 2429 blink::mainThreadIsolate()->IsolateInForegroundNotification();
2424 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) 2430 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden())
2425 return; 2431 return;
2426 ScheduleIdleHandler(kLongIdleHandlerDelayMs); 2432 ScheduleIdleHandler(kLongIdleHandlerDelayMs);
2427 } 2433 }
2428 2434
2429 void RenderThreadImpl::ReleaseFreeMemory() { 2435 void RenderThreadImpl::ReleaseFreeMemory() {
2430 base::allocator::ReleaseFreeMemory(); 2436 base::allocator::ReleaseFreeMemory();
2431 discardable_shared_memory_manager()->ReleaseFreeMemory(); 2437 discardable_shared_memory_manager_->ReleaseFreeMemory();
2432 2438
2433 if (blink_platform_impl_) 2439 if (blink_platform_impl_)
2434 blink::decommitFreeableMemory(); 2440 blink::decommitFreeableMemory();
2435 } 2441 }
2436 2442
2437 RenderThreadImpl::PendingFrameCreate::PendingFrameCreate( 2443 RenderThreadImpl::PendingFrameCreate::PendingFrameCreate(
2438 int routing_id, 2444 int routing_id,
2439 mojom::FrameRequest frame_request, 2445 mojom::FrameRequest frame_request,
2440 mojom::FrameHostPtr frame_host) 2446 mojom::FrameHostPtr frame_host)
2441 : routing_id_(routing_id), 2447 : routing_id_(routing_id),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2489 } 2495 }
2490 } 2496 }
2491 2497
2492 void RenderThreadImpl::OnRendererInterfaceRequest( 2498 void RenderThreadImpl::OnRendererInterfaceRequest(
2493 mojom::RendererAssociatedRequest request) { 2499 mojom::RendererAssociatedRequest request) {
2494 DCHECK(!renderer_binding_.is_bound()); 2500 DCHECK(!renderer_binding_.is_bound());
2495 renderer_binding_.Bind(std::move(request)); 2501 renderer_binding_.Bind(std::move(request));
2496 } 2502 }
2497 2503
2498 } // namespace content 2504 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698