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

Unified Diff: content/browser/browser_main_loop.cc

Issue 11975048: Native memory histograms for the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ios build fix Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | content/browser/histogram_message_filter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/browser_main_loop.cc
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc
index 2f1e99493cb25c867cd897622833f682d288b6e8..16be82b8a143b3e9c66436b7bfb7950064e282e4 100644
--- a/content/browser/browser_main_loop.cc
+++ b/content/browser/browser_main_loop.cc
@@ -98,6 +98,10 @@
#include <X11/Xlib.h>
#endif
+#if !defined(OS_IOS)
+#include "webkit/glue/webkit_glue.h"
+#endif
+
// One of the linux specific headers defines this as a macro.
#ifdef DestroyAll
#undef DestroyAll
@@ -226,6 +230,24 @@ void ImmediateShutdownAndExitProcess() {
BrowserShutdownImpl::ImmediateShutdownAndExitProcess();
}
+// For measuring memory usage after each task. Behind a command line flag.
+class BrowserMainLoop::MemoryObserver : public MessageLoop::TaskObserver {
+ public:
+ MemoryObserver() {}
+ virtual ~MemoryObserver() {}
+
+ virtual void WillProcessTask(base::TimeTicks time_posted) OVERRIDE {}
+
+ virtual void DidProcessTask(base::TimeTicks time_posted) OVERRIDE {
+#if !defined(OS_IOS)
+ HISTOGRAM_MEMORY_KB("Memory.BrowserUsed", webkit_glue::MemoryUsageKB());
+#endif
+ }
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MemoryObserver);
+};
+
+
// static
media::AudioManager* BrowserMainLoop::GetAudioManager() {
return g_current_browser_main_loop->audio_manager_.get();
@@ -374,6 +396,11 @@ void BrowserMainLoop::MainMessageLoopStart() {
switches::kMediaPlayerInRenderProcess)));
DataFetcherImplAndroid::Init(base::android::AttachCurrentThread());
#endif
+
+ if (parsed_command_line_.HasSwitch(switches::kMemoryMetrics)) {
+ memory_observer_.reset(new MemoryObserver());
+ main_message_loop_->AddTaskObserver(memory_observer_.get());
+ }
}
void BrowserMainLoop::CreateThreads() {
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | content/browser/histogram_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698