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

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

Issue 1654863003: Kill --memory-metrics and on-demand Memory.Browser/RenderUsed histograms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 10 months 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
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | tools/perf/measurements/memory.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "components/scheduler/child/webthread_base.h" 49 #include "components/scheduler/child/webthread_base.h"
50 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h" 50 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h"
51 #include "components/scheduler/renderer/renderer_scheduler.h" 51 #include "components/scheduler/renderer/renderer_scheduler.h"
52 #include "content/child/appcache/appcache_dispatcher.h" 52 #include "content/child/appcache/appcache_dispatcher.h"
53 #include "content/child/appcache/appcache_frontend_impl.h" 53 #include "content/child/appcache/appcache_frontend_impl.h"
54 #include "content/child/child_discardable_shared_memory_manager.h" 54 #include "content/child/child_discardable_shared_memory_manager.h"
55 #include "content/child/child_gpu_memory_buffer_manager.h" 55 #include "content/child/child_gpu_memory_buffer_manager.h"
56 #include "content/child/child_histogram_message_filter.h" 56 #include "content/child/child_histogram_message_filter.h"
57 #include "content/child/child_resource_message_filter.h" 57 #include "content/child/child_resource_message_filter.h"
58 #include "content/child/child_shared_bitmap_manager.h" 58 #include "content/child/child_shared_bitmap_manager.h"
59 #include "content/child/content_child_helpers.h"
60 #include "content/child/db_message_filter.h" 59 #include "content/child/db_message_filter.h"
61 #include "content/child/indexed_db/indexed_db_dispatcher.h" 60 #include "content/child/indexed_db/indexed_db_dispatcher.h"
62 #include "content/child/indexed_db/indexed_db_message_filter.h" 61 #include "content/child/indexed_db/indexed_db_message_filter.h"
63 #include "content/child/npapi/npobject_util.h" 62 #include "content/child/npapi/npobject_util.h"
64 #include "content/child/plugin_messages.h" 63 #include "content/child/plugin_messages.h"
65 #include "content/child/resource_dispatcher.h" 64 #include "content/child/resource_dispatcher.h"
66 #include "content/child/resource_scheduling_filter.h" 65 #include "content/child/resource_scheduling_filter.h"
67 #include "content/child/runtime_features.h" 66 #include "content/child/runtime_features.h"
68 #include "content/child/thread_safe_sender.h" 67 #include "content/child/thread_safe_sender.h"
69 #include "content/child/web_database_observer_impl.h" 68 #include "content/child/web_database_observer_impl.h"
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 for (size_t i = 0; i < pieces.size(); ++i) { 459 for (size_t i = 0; i < pieces.size(); ++i) {
461 unsigned number = 0; 460 unsigned number = 0;
462 bool succeed = base::StringToUint(pieces[i], &number); 461 bool succeed = base::StringToUint(pieces[i], &number);
463 DCHECK(succeed); 462 DCHECK(succeed);
464 vector->push_back(number); 463 vector->push_back(number);
465 } 464 }
466 } 465 }
467 466
468 } // namespace 467 } // namespace
469 468
470 // For measuring memory usage after each task. Behind a command line flag.
471 class MemoryObserver : public base::MessageLoop::TaskObserver {
472 public:
473 MemoryObserver() {}
474 ~MemoryObserver() override {}
475
476 void WillProcessTask(const base::PendingTask& pending_task) override {}
477
478 void DidProcessTask(const base::PendingTask& pending_task) override {
479 LOCAL_HISTOGRAM_MEMORY_KB("Memory.RendererUsed", GetMemoryUsageKB());
480 }
481
482 private:
483 DISALLOW_COPY_AND_ASSIGN(MemoryObserver);
484 };
485
486 RenderThreadImpl::HistogramCustomizer::HistogramCustomizer() { 469 RenderThreadImpl::HistogramCustomizer::HistogramCustomizer() {
487 custom_histograms_.insert("V8.MemoryExternalFragmentationTotal"); 470 custom_histograms_.insert("V8.MemoryExternalFragmentationTotal");
488 custom_histograms_.insert("V8.MemoryHeapSampleTotalCommitted"); 471 custom_histograms_.insert("V8.MemoryHeapSampleTotalCommitted");
489 custom_histograms_.insert("V8.MemoryHeapSampleTotalUsed"); 472 custom_histograms_.insert("V8.MemoryHeapSampleTotalUsed");
490 custom_histograms_.insert("V8.MemoryHeapUsed"); 473 custom_histograms_.insert("V8.MemoryHeapUsed");
491 custom_histograms_.insert("V8.MemoryHeapCommitted"); 474 custom_histograms_.insert("V8.MemoryHeapCommitted");
492 } 475 }
493 476
494 RenderThreadImpl::HistogramCustomizer::~HistogramCustomizer() {} 477 RenderThreadImpl::HistogramCustomizer::~HistogramCustomizer() {}
495 478
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 #endif 840 #endif
858 } 841 }
859 842
860 RenderThreadImpl::~RenderThreadImpl() { 843 RenderThreadImpl::~RenderThreadImpl() {
861 } 844 }
862 845
863 void RenderThreadImpl::Shutdown() { 846 void RenderThreadImpl::Shutdown() {
864 FOR_EACH_OBSERVER( 847 FOR_EACH_OBSERVER(
865 RenderProcessObserver, observers_, OnRenderProcessShutdown()); 848 RenderProcessObserver, observers_, OnRenderProcessShutdown());
866 849
867 if (memory_observer_) {
868 message_loop()->RemoveTaskObserver(memory_observer_.get());
869 memory_observer_.reset();
870 }
871
872 // Wait for all databases to be closed. 850 // Wait for all databases to be closed.
873 if (blink_platform_impl_) { 851 if (blink_platform_impl_) {
874 // Crash the process if they fail to close after a generous amount of time. 852 // Crash the process if they fail to close after a generous amount of time.
875 bool all_closed = blink_platform_impl_->web_database_observer_impl() 853 bool all_closed = blink_platform_impl_->web_database_observer_impl()
876 ->WaitForAllDatabasesToClose(base::TimeDelta::FromSeconds(60)); 854 ->WaitForAllDatabasesToClose(base::TimeDelta::FromSeconds(60));
877 CHECK(all_closed); 855 CHECK(all_closed);
878 } 856 }
879 857
880 // Shutdown in reverse of the initialization order. 858 // Shutdown in reverse of the initialization order.
881 if (devtools_agent_message_filter_.get()) { 859 if (devtools_agent_message_filter_.get()) {
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 1286
1309 cc_blink::SetSharedBitmapAllocationFunction(AllocateSharedBitmapFunction); 1287 cc_blink::SetSharedBitmapAllocationFunction(AllocateSharedBitmapFunction);
1310 1288
1311 SkGraphics::SetResourceCacheSingleAllocationByteLimit( 1289 SkGraphics::SetResourceCacheSingleAllocationByteLimit(
1312 kImageCacheSingleAllocationByteLimit); 1290 kImageCacheSingleAllocationByteLimit);
1313 1291
1314 // Hook up blink's codecs so skia can call them 1292 // Hook up blink's codecs so skia can call them
1315 SkGraphics::SetImageGeneratorFromEncodedFactory( 1293 SkGraphics::SetImageGeneratorFromEncodedFactory(
1316 blink::WebImageGenerator::create); 1294 blink::WebImageGenerator::create);
1317 1295
1318 if (command_line.HasSwitch(switches::kMemoryMetrics)) {
1319 memory_observer_.reset(new MemoryObserver());
1320 message_loop()->AddTaskObserver(memory_observer_.get());
1321 }
1322
1323 if (command_line.HasSwitch(switches::kExplicitlyAllowedPorts)) { 1296 if (command_line.HasSwitch(switches::kExplicitlyAllowedPorts)) {
1324 std::string allowed_ports = 1297 std::string allowed_ports =
1325 command_line.GetSwitchValueASCII(switches::kExplicitlyAllowedPorts); 1298 command_line.GetSwitchValueASCII(switches::kExplicitlyAllowedPorts);
1326 net::SetExplicitlyAllowedPorts(allowed_ports); 1299 net::SetExplicitlyAllowedPorts(allowed_ports);
1327 } 1300 }
1328 } 1301 }
1329 1302
1330 void RenderThreadImpl::RegisterSchemes() { 1303 void RenderThreadImpl::RegisterSchemes() {
1331 // swappedout: 1304 // swappedout:
1332 WebString swappedout_scheme(base::ASCIIToUTF16(kSwappedOutScheme)); 1305 WebString swappedout_scheme(base::ASCIIToUTF16(kSwappedOutScheme));
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
2171 } 2144 }
2172 2145
2173 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { 2146 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() {
2174 size_t erased = 2147 size_t erased =
2175 RenderThreadImpl::current()->pending_render_frame_connects_.erase( 2148 RenderThreadImpl::current()->pending_render_frame_connects_.erase(
2176 routing_id_); 2149 routing_id_);
2177 DCHECK_EQ(1u, erased); 2150 DCHECK_EQ(1u, erased);
2178 } 2151 }
2179 2152
2180 } // namespace content 2153 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | tools/perf/measurements/memory.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698