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

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

Powered by Google App Engine
This is Rietveld 408576698