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

Side by Side 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: . 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 unified diff | Download patch | Annotate | Revision Log
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/browser/browser_main_loop.h" 5 #include "content/browser/browser_main_loop.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/hi_res_timer_manager.h" 10 #include "base/hi_res_timer_manager.h"
(...skipping 28 matching lines...) Expand all
39 #include "content/public/common/content_switches.h" 39 #include "content/public/common/content_switches.h"
40 #include "content/public/common/main_function_params.h" 40 #include "content/public/common/main_function_params.h"
41 #include "content/public/common/result_codes.h" 41 #include "content/public/common/result_codes.h"
42 #include "crypto/nss_util.h" 42 #include "crypto/nss_util.h"
43 #include "media/audio/audio_manager.h" 43 #include "media/audio/audio_manager.h"
44 #include "net/base/network_change_notifier.h" 44 #include "net/base/network_change_notifier.h"
45 #include "net/base/ssl_config_service.h" 45 #include "net/base/ssl_config_service.h"
46 #include "net/socket/client_socket_factory.h" 46 #include "net/socket/client_socket_factory.h"
47 #include "net/socket/tcp_client_socket.h" 47 #include "net/socket/tcp_client_socket.h"
48 #include "ui/base/clipboard/clipboard.h" 48 #include "ui/base/clipboard/clipboard.h"
49 #include "webkit/glue/webkit_glue.h"
49 50
50 #if defined(USE_AURA) 51 #if defined(USE_AURA)
51 #include "content/browser/renderer_host/image_transport_factory.h" 52 #include "content/browser/renderer_host/image_transport_factory.h"
52 #endif 53 #endif
53 54
54 #if defined(OS_ANDROID) 55 #if defined(OS_ANDROID)
55 #include "base/android/jni_android.h" 56 #include "base/android/jni_android.h"
56 #include "content/browser/android/surface_texture_peer_browser_impl.h" 57 #include "content/browser/android/surface_texture_peer_browser_impl.h"
57 #include "content/browser/device_orientation/data_fetcher_impl_android.h" 58 #include "content/browser/device_orientation/data_fetcher_impl_android.h"
58 #endif 59 #endif
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 #else 216 #else
216 NOTIMPLEMENTED(); 217 NOTIMPLEMENTED();
217 #endif 218 #endif
218 } 219 }
219 }; 220 };
220 221
221 void ImmediateShutdownAndExitProcess() { 222 void ImmediateShutdownAndExitProcess() {
222 BrowserShutdownImpl::ImmediateShutdownAndExitProcess(); 223 BrowserShutdownImpl::ImmediateShutdownAndExitProcess();
223 } 224 }
224 225
226 // For measuring memory usage after each task. Behind a command line flag.
227 class BrowserMainLoop::MemoryObserver : public MessageLoop::TaskObserver {
228 public:
229 MemoryObserver() {}
jochen (gone - plz use gerrit) 2013/01/18 14:03:11 should have a virtual destructor
marja 2013/01/18 15:00:08 Done.
230
231 virtual void WillProcessTask(base::TimeTicks time_posted) OVERRIDE {}
232
233 virtual void DidProcessTask(base::TimeTicks time_posted) OVERRIDE {
234 LOG(WARNING) << "Adding to browserused " << webkit_glue::MemoryUsageKB();
jochen (gone - plz use gerrit) 2013/01/18 14:03:11 remove?
marja 2013/01/18 15:00:08 Oops.
235 HISTOGRAM_MEMORY_KB("Memory.BrowserUsed", webkit_glue::MemoryUsageKB());
236 }
237 private:
238 DISALLOW_COPY_AND_ASSIGN(MemoryObserver);
239 };
240
241
225 // static 242 // static
226 media::AudioManager* BrowserMainLoop::GetAudioManager() { 243 media::AudioManager* BrowserMainLoop::GetAudioManager() {
227 return g_current_browser_main_loop->audio_manager_.get(); 244 return g_current_browser_main_loop->audio_manager_.get();
228 } 245 }
229 246
230 // static 247 // static
231 AudioMirroringManager* BrowserMainLoop::GetAudioMirroringManager() { 248 AudioMirroringManager* BrowserMainLoop::GetAudioMirroringManager() {
232 return g_current_browser_main_loop->audio_mirroring_manager_.get(); 249 return g_current_browser_main_loop->audio_mirroring_manager_.get();
233 } 250 }
234 251
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 378
362 if (parts_.get()) 379 if (parts_.get())
363 parts_->PostMainMessageLoopStart(); 380 parts_->PostMainMessageLoopStart();
364 381
365 #if defined(OS_ANDROID) 382 #if defined(OS_ANDROID)
366 SurfaceTexturePeer::InitInstance(new SurfaceTexturePeerBrowserImpl( 383 SurfaceTexturePeer::InitInstance(new SurfaceTexturePeerBrowserImpl(
367 parameters_.command_line.HasSwitch( 384 parameters_.command_line.HasSwitch(
368 switches::kMediaPlayerInRenderProcess))); 385 switches::kMediaPlayerInRenderProcess)));
369 DataFetcherImplAndroid::Init(base::android::AttachCurrentThread()); 386 DataFetcherImplAndroid::Init(base::android::AttachCurrentThread());
370 #endif 387 #endif
388
389 if (parsed_command_line_.HasSwitch(switches::kMemoryMetrics)) {
390 memory_observer_.reset(new MemoryObserver());
391 main_message_loop_->AddTaskObserver(memory_observer_.get());
392 }
371 } 393 }
372 394
373 void BrowserMainLoop::CreateThreads() { 395 void BrowserMainLoop::CreateThreads() {
374 if (parts_.get()) 396 if (parts_.get())
375 result_code_ = parts_->PreCreateThreads(); 397 result_code_ = parts_->PreCreateThreads();
376 398
377 #if !defined(OS_IOS) && (!defined(GOOGLE_CHROME_BUILD) || defined(OS_ANDROID)) 399 #if !defined(OS_IOS) && (!defined(GOOGLE_CHROME_BUILD) || defined(OS_ANDROID))
378 // Single-process is an unsupported and not fully tested mode, so 400 // Single-process is an unsupported and not fully tested mode, so
379 // don't enable it for official Chrome builds (except on Android). 401 // don't enable it for official Chrome builds (except on Android).
380 if (parsed_command_line_.HasSwitch(switches::kSingleProcess)) 402 if (parsed_command_line_.HasSwitch(switches::kSingleProcess))
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); 765 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type());
744 if (parameters_.ui_task) 766 if (parameters_.ui_task)
745 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task); 767 MessageLoopForUI::current()->PostTask(FROM_HERE, *parameters_.ui_task);
746 768
747 base::RunLoop run_loop; 769 base::RunLoop run_loop;
748 run_loop.Run(); 770 run_loop.Run();
749 #endif 771 #endif
750 } 772 }
751 773
752 } // namespace content 774 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698