| OLD | NEW |
| 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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:DataFetcher") | 466 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:DataFetcher") |
| 467 DataFetcherImplAndroid::Init(base::android::AttachCurrentThread()); | 467 DataFetcherImplAndroid::Init(base::android::AttachCurrentThread()); |
| 468 } | 468 } |
| 469 #endif | 469 #endif |
| 470 | 470 |
| 471 if (parsed_command_line_.HasSwitch(switches::kMemoryMetrics)) { | 471 if (parsed_command_line_.HasSwitch(switches::kMemoryMetrics)) { |
| 472 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:MemoryObserver") | 472 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:MemoryObserver") |
| 473 memory_observer_.reset(new MemoryObserver()); | 473 memory_observer_.reset(new MemoryObserver()); |
| 474 base::MessageLoop::current()->AddTaskObserver(memory_observer_.get()); | 474 base::MessageLoop::current()->AddTaskObserver(memory_observer_.get()); |
| 475 } | 475 } |
| 476 |
| 477 trace_memory_controller_.reset(new base::debug::TraceMemoryController( |
| 478 base::MessageLoop::current()->message_loop_proxy())); |
| 476 } | 479 } |
| 477 | 480 |
| 478 void BrowserMainLoop::CreateThreads() { | 481 void BrowserMainLoop::CreateThreads() { |
| 479 TRACE_EVENT0("startup", "BrowserMainLoop::CreateThreads") | 482 TRACE_EVENT0("startup", "BrowserMainLoop::CreateThreads") |
| 480 | 483 |
| 481 if (parts_) { | 484 if (parts_) { |
| 482 TRACE_EVENT0("startup", | 485 TRACE_EVENT0("startup", |
| 483 "BrowserMainLoop::CreateThreads:PreCreateThreads"); | 486 "BrowserMainLoop::CreateThreads:PreCreateThreads"); |
| 484 result_code_ = parts_->PreCreateThreads(); | 487 result_code_ = parts_->PreCreateThreads(); |
| 485 } | 488 } |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 // need to be able to perform IO. | 641 // need to be able to perform IO. |
| 639 base::ThreadRestrictions::SetIOAllowed(true); | 642 base::ThreadRestrictions::SetIOAllowed(true); |
| 640 BrowserThread::PostTask( | 643 BrowserThread::PostTask( |
| 641 BrowserThread::IO, FROM_HERE, | 644 BrowserThread::IO, FROM_HERE, |
| 642 base::Bind(base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed), | 645 base::Bind(base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed), |
| 643 true)); | 646 true)); |
| 644 | 647 |
| 645 if (parts_) | 648 if (parts_) |
| 646 parts_->PostMainMessageLoopRun(); | 649 parts_->PostMainMessageLoopRun(); |
| 647 | 650 |
| 651 trace_memory_controller_.reset(); |
| 652 |
| 648 #if !defined(OS_IOS) | 653 #if !defined(OS_IOS) |
| 649 // Destroying the GpuProcessHostUIShims on the UI thread posts a task to | 654 // Destroying the GpuProcessHostUIShims on the UI thread posts a task to |
| 650 // delete related objects on the GPU thread. This must be done before | 655 // delete related objects on the GPU thread. This must be done before |
| 651 // stopping the GPU thread. The GPU thread will close IPC channels to renderer | 656 // stopping the GPU thread. The GPU thread will close IPC channels to renderer |
| 652 // processes so this has to happen before stopping the IO thread. | 657 // processes so this has to happen before stopping the IO thread. |
| 653 GpuProcessHostUIShim::DestroyAll(); | 658 GpuProcessHostUIShim::DestroyAll(); |
| 654 | 659 |
| 655 // Cancel pending requests and prevent new requests. | 660 // Cancel pending requests and prevent new requests. |
| 656 if (resource_dispatcher_host_) | 661 if (resource_dispatcher_host_) |
| 657 resource_dispatcher_host_.get()->Shutdown(); | 662 resource_dispatcher_host_.get()->Shutdown(); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 if (parameters_.ui_task) | 935 if (parameters_.ui_task) |
| 931 base::MessageLoopForUI::current()->PostTask(FROM_HERE, | 936 base::MessageLoopForUI::current()->PostTask(FROM_HERE, |
| 932 *parameters_.ui_task); | 937 *parameters_.ui_task); |
| 933 | 938 |
| 934 base::RunLoop run_loop; | 939 base::RunLoop run_loop; |
| 935 run_loop.Run(); | 940 run_loop.Run(); |
| 936 #endif | 941 #endif |
| 937 } | 942 } |
| 938 | 943 |
| 939 } // namespace content | 944 } // namespace content |
| OLD | NEW |