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

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

Issue 2485623002: discardable_memory: Using mojo IPC to replace Chrome IPC (Closed)
Patch Set: Fix bot 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 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 base::StringToInt(string_value, &num_raster_threads); 874 base::StringToInt(string_value, &num_raster_threads);
875 DCHECK(parsed_num_raster_threads) << string_value; 875 DCHECK(parsed_num_raster_threads) << string_value;
876 DCHECK_GT(num_raster_threads, 0); 876 DCHECK_GT(num_raster_threads, 0);
877 877
878 // TODO(vmpstr): If the flag sticks, we should clean it up and always have 878 // TODO(vmpstr): If the flag sticks, we should clean it up and always have
879 // image decode tasks. 879 // image decode tasks.
880 are_image_decode_tasks_enabled_ = true; 880 are_image_decode_tasks_enabled_ = true;
881 881
882 categorized_worker_pool_->Start(num_raster_threads); 882 categorized_worker_pool_->Start(num_raster_threads);
883 883
884 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr;
885 ChildThread::Get()->GetRemoteInterfaces()->GetInterface(
886 mojo::GetProxy(&manager_ptr));
887 discardable_shared_memory_manager_ = base::MakeUnique<
888 discardable_memory::ClientDiscardableSharedMemoryManager>(
889 std::move(manager_ptr), GetIOTaskRunner());
890
884 // TODO(boliu): In single process, browser main loop should set up the 891 // TODO(boliu): In single process, browser main loop should set up the
885 // discardable memory manager, and should skip this if kSingleProcess. 892 // discardable memory manager, and should skip this if kSingleProcess.
886 // See crbug.com/503724. 893 // See crbug.com/503724.
887 base::DiscardableMemoryAllocator::SetInstance( 894 base::DiscardableMemoryAllocator::SetInstance(
888 ChildThreadImpl::discardable_shared_memory_manager()); 895 discardable_shared_memory_manager_.get());
889 896
890 GetContentClient()->renderer()->ExposeInterfacesToBrowser( 897 GetContentClient()->renderer()->ExposeInterfacesToBrowser(
891 GetInterfaceRegistry()); 898 GetInterfaceRegistry());
892 899
893 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateFrameFactory)); 900 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateFrameFactory));
894 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateEmbeddedWorkerSetup)); 901 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateEmbeddedWorkerSetup));
895 GetInterfaceRegistry()->AddInterface( 902 GetInterfaceRegistry()->AddInterface(
896 base::Bind(&EmbeddedWorkerInstanceClientImpl::Create, 903 base::Bind(&EmbeddedWorkerInstanceClientImpl::Create,
897 base::Unretained(embedded_worker_dispatcher_.get()))); 904 base::Unretained(embedded_worker_dispatcher_.get())));
898 905
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 blink_platform_impl_->Shutdown(); 1040 blink_platform_impl_->Shutdown();
1034 // This must be at the very end of the shutdown sequence. 1041 // This must be at the very end of the shutdown sequence.
1035 // blink::shutdown() must be called after all strong references from 1042 // blink::shutdown() must be called after all strong references from
1036 // Chromium to Blink are cleared. 1043 // Chromium to Blink are cleared.
1037 blink::shutdown(); 1044 blink::shutdown();
1038 } 1045 }
1039 1046
1040 // Delay shutting down DiscardableSharedMemoryManager until blink::shutdown 1047 // Delay shutting down DiscardableSharedMemoryManager until blink::shutdown
1041 // is complete, because blink::shutdown destructs Blink Resources and they 1048 // is complete, because blink::shutdown destructs Blink Resources and they
1042 // may try to unlock their underlying discardable memory. 1049 // may try to unlock their underlying discardable memory.
1043 ChildThreadImpl::ShutdownDiscardableSharedMemoryManager(); 1050 discardable_shared_memory_manager_.reset();
1044 1051
1045 // The message loop must be cleared after shutting down 1052 // The message loop must be cleared after shutting down
1046 // the DiscardableSharedMemoryManager, which needs to send messages 1053 // the DiscardableSharedMemoryManager, which needs to send messages
1047 // to the browser process. 1054 // to the browser process.
1048 main_message_loop_.reset(); 1055 main_message_loop_.reset();
1049 1056
1050 lazy_tls.Pointer()->Set(nullptr); 1057 lazy_tls.Pointer()->Set(nullptr);
1051 1058
1052 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this); 1059 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this);
1053 } 1060 }
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
1860 #else 1867 #else
1861 size_t malloc_usage = minfo.hblkhd + minfo.arena; 1868 size_t malloc_usage = minfo.hblkhd + minfo.arena;
1862 #endif 1869 #endif
1863 #else 1870 #else
1864 size_t malloc_usage = GetMallocUsage(); 1871 size_t malloc_usage = GetMallocUsage();
1865 #endif 1872 #endif
1866 UMA_HISTOGRAM_MEMORY_MB("PurgeAndSuspend.Memory.MallocMB", 1873 UMA_HISTOGRAM_MEMORY_MB("PurgeAndSuspend.Memory.MallocMB",
1867 malloc_usage / 1024 / 1024); 1874 malloc_usage / 1024 / 1024);
1868 1875
1869 discardable_memory::ClientDiscardableSharedMemoryManager::Statistics 1876 discardable_memory::ClientDiscardableSharedMemoryManager::Statistics
1870 discardable_stats = 1877 discardable_stats = discardable_shared_memory_manager_->GetStatistics();
1871 ChildThreadImpl::discardable_shared_memory_manager()->GetStatistics();
1872 size_t discardable_usage = 1878 size_t discardable_usage =
1873 discardable_stats.total_size - discardable_stats.freelist_size; 1879 discardable_stats.total_size - discardable_stats.freelist_size;
1874 UMA_HISTOGRAM_MEMORY_KB("PurgeAndSuspend.Memory.DiscardableKB", 1880 UMA_HISTOGRAM_MEMORY_KB("PurgeAndSuspend.Memory.DiscardableKB",
1875 discardable_usage / 1024); 1881 discardable_usage / 1024);
1876 1882
1877 size_t v8_usage = 0; 1883 size_t v8_usage = 0;
1878 if (v8::Isolate* isolate = blink::mainThreadIsolate()) { 1884 if (v8::Isolate* isolate = blink::mainThreadIsolate()) {
1879 v8::HeapStatistics v8_heap_statistics; 1885 v8::HeapStatistics v8_heap_statistics;
1880 isolate->GetHeapStatistics(&v8_heap_statistics); 1886 isolate->GetHeapStatistics(&v8_heap_statistics);
1881 v8_usage = v8_heap_statistics.total_heap_size(); 1887 v8_usage = v8_heap_statistics.total_heap_size();
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
2436 2442
2437 void RenderThreadImpl::OnRendererVisible() { 2443 void RenderThreadImpl::OnRendererVisible() {
2438 blink::mainThreadIsolate()->IsolateInForegroundNotification(); 2444 blink::mainThreadIsolate()->IsolateInForegroundNotification();
2439 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) 2445 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden())
2440 return; 2446 return;
2441 ScheduleIdleHandler(kLongIdleHandlerDelayMs); 2447 ScheduleIdleHandler(kLongIdleHandlerDelayMs);
2442 } 2448 }
2443 2449
2444 void RenderThreadImpl::ReleaseFreeMemory() { 2450 void RenderThreadImpl::ReleaseFreeMemory() {
2445 base::allocator::ReleaseFreeMemory(); 2451 base::allocator::ReleaseFreeMemory();
2446 discardable_shared_memory_manager()->ReleaseFreeMemory(); 2452 discardable_shared_memory_manager_->ReleaseFreeMemory();
2447 2453
2448 if (blink_platform_impl_) 2454 if (blink_platform_impl_)
2449 blink::decommitFreeableMemory(); 2455 blink::decommitFreeableMemory();
2450 } 2456 }
2451 2457
2452 RenderThreadImpl::PendingFrameCreate::PendingFrameCreate( 2458 RenderThreadImpl::PendingFrameCreate::PendingFrameCreate(
2453 int routing_id, 2459 int routing_id,
2454 mojom::FrameRequest frame_request, 2460 mojom::FrameRequest frame_request,
2455 mojom::FrameHostPtr frame_host) 2461 mojom::FrameHostPtr frame_host)
2456 : routing_id_(routing_id), 2462 : routing_id_(routing_id),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2504 } 2510 }
2505 } 2511 }
2506 2512
2507 void RenderThreadImpl::OnRendererInterfaceRequest( 2513 void RenderThreadImpl::OnRendererInterfaceRequest(
2508 mojom::RendererAssociatedRequest request) { 2514 mojom::RendererAssociatedRequest request) {
2509 DCHECK(!renderer_binding_.is_bound()); 2515 DCHECK(!renderer_binding_.is_bound());
2510 renderer_binding_.Bind(std::move(request)); 2516 renderer_binding_.Bind(std::move(request));
2511 } 2517 }
2512 2518
2513 } // namespace content 2519 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/renderer/render_thread_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698