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

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

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