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

Side by Side Diff: content/browser/browser_main_loop.cc

Issue 15418002: Record Chrome trace events in tcmalloc heap profiles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, cleanup Created 7 years, 6 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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:DataFetcher") 474 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:DataFetcher")
475 DataFetcherImplAndroid::Init(base::android::AttachCurrentThread()); 475 DataFetcherImplAndroid::Init(base::android::AttachCurrentThread());
476 } 476 }
477 #endif 477 #endif
478 478
479 if (parsed_command_line_.HasSwitch(switches::kMemoryMetrics)) { 479 if (parsed_command_line_.HasSwitch(switches::kMemoryMetrics)) {
480 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:MemoryObserver") 480 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:MemoryObserver")
481 memory_observer_.reset(new MemoryObserver()); 481 memory_observer_.reset(new MemoryObserver());
482 base::MessageLoop::current()->AddTaskObserver(memory_observer_.get()); 482 base::MessageLoop::current()->AddTaskObserver(memory_observer_.get());
483 } 483 }
484
485 // TODO(jamescook): Support all tcmalloc platforms, including Windows.
nduca 2013/06/20 20:09:29 How about always creating it, but have the observe
James Cook 2013/06/29 00:02:42 Done. Also consolidated all the macro craziness in
486 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID))
487 trace_memory_observer_.reset(new base::debug::TraceMemoryTraceLogObserver(
488 base::MessageLoop::current()->message_loop_proxy()));
489 #endif
dsinclair 2013/06/18 15:30:15 Does this also need to be done in places like the
James Cook 2013/06/29 00:02:42 Probably. I think I can shim this in around GpuMai
484 } 490 }
485 491
486 void BrowserMainLoop::CreateThreads() { 492 void BrowserMainLoop::CreateThreads() {
487 TRACE_EVENT0("startup", "BrowserMainLoop::CreateThreads") 493 TRACE_EVENT0("startup", "BrowserMainLoop::CreateThreads")
488 494
489 if (parts_) { 495 if (parts_) {
490 TRACE_EVENT0("startup", 496 TRACE_EVENT0("startup",
491 "BrowserMainLoop::MainMessageLoopStart:PreCreateThreads"); 497 "BrowserMainLoop::MainMessageLoopStart:PreCreateThreads");
492 result_code_ = parts_->PreCreateThreads(); 498 result_code_ = parts_->PreCreateThreads();
493 } 499 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 // need to be able to perform IO. 636 // need to be able to perform IO.
631 base::ThreadRestrictions::SetIOAllowed(true); 637 base::ThreadRestrictions::SetIOAllowed(true);
632 BrowserThread::PostTask( 638 BrowserThread::PostTask(
633 BrowserThread::IO, FROM_HERE, 639 BrowserThread::IO, FROM_HERE,
634 base::Bind(base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed), 640 base::Bind(base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed),
635 true)); 641 true));
636 642
637 if (parts_) 643 if (parts_)
638 parts_->PostMainMessageLoopRun(); 644 parts_->PostMainMessageLoopRun();
639 645
646 // TODO(jamescook): Support all tcmalloc platforms, including Windows.
647 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID))
648 trace_memory_observer_.reset();
649 #endif
650
640 #if !defined(OS_IOS) 651 #if !defined(OS_IOS)
641 // Destroying the GpuProcessHostUIShims on the UI thread posts a task to 652 // Destroying the GpuProcessHostUIShims on the UI thread posts a task to
642 // delete related objects on the GPU thread. This must be done before 653 // delete related objects on the GPU thread. This must be done before
643 // stopping the GPU thread. The GPU thread will close IPC channels to renderer 654 // stopping the GPU thread. The GPU thread will close IPC channels to renderer
644 // processes so this has to happen before stopping the IO thread. 655 // processes so this has to happen before stopping the IO thread.
645 GpuProcessHostUIShim::DestroyAll(); 656 GpuProcessHostUIShim::DestroyAll();
646 657
647 // Cancel pending requests and prevent new requests. 658 // Cancel pending requests and prevent new requests.
648 if (resource_dispatcher_host_) 659 if (resource_dispatcher_host_)
649 resource_dispatcher_host_.get()->Shutdown(); 660 resource_dispatcher_host_.get()->Shutdown();
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 if (parameters_.ui_task) 928 if (parameters_.ui_task)
918 base::MessageLoopForUI::current()->PostTask(FROM_HERE, 929 base::MessageLoopForUI::current()->PostTask(FROM_HERE,
919 *parameters_.ui_task); 930 *parameters_.ui_task);
920 931
921 base::RunLoop run_loop; 932 base::RunLoop run_loop;
922 run_loop.Run(); 933 run_loop.Run();
923 #endif 934 #endif
924 } 935 }
925 936
926 } // namespace content 937 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698