| Index: content/browser/browser_main_loop.cc
|
| diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc
|
| index b58a2cb2267779a56d004a1b0aa6ba3c07f5f733..da71a3a429fd2496212c7f565997ef764ad722af 100644
|
| --- a/content/browser/browser_main_loop.cc
|
| +++ b/content/browser/browser_main_loop.cc
|
| @@ -46,6 +46,7 @@
|
| #include "net/socket/client_socket_factory.h"
|
| #include "net/socket/tcp_client_socket.h"
|
| #include "ui/base/clipboard/clipboard.h"
|
| +#include "webkit/glue/webkit_glue.h"
|
|
|
| #if defined(USE_AURA)
|
| #include "content/browser/renderer_host/image_transport_factory.h"
|
| @@ -222,6 +223,22 @@ 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 {
|
| + HISTOGRAM_MEMORY_KB("Memory.BrowserUsed", webkit_glue::MemoryUsageKB());
|
| + }
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(MemoryObserver);
|
| +};
|
| +
|
| +
|
| // static
|
| media::AudioManager* BrowserMainLoop::GetAudioManager() {
|
| return g_current_browser_main_loop->audio_manager_.get();
|
| @@ -368,6 +385,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() {
|
|
|