| 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/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/pending_task.h" | 16 #include "base/pending_task.h" |
| 17 #include "base/power_monitor/power_monitor.h" | 17 #include "base/power_monitor/power_monitor.h" |
| 18 #include "base/power_monitor/power_monitor_device_source.h" | 18 #include "base/power_monitor/power_monitor_device_source.h" |
| 19 #include "base/process/process_metrics.h" | 19 #include "base/process/process_metrics.h" |
| 20 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
| 21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| 22 #include "base/system_monitor/system_monitor.h" | 22 #include "base/system_monitor/system_monitor.h" |
| 23 #include "base/thread_task_runner_handle.h" |
| 23 #include "base/threading/thread_restrictions.h" | 24 #include "base/threading/thread_restrictions.h" |
| 24 #include "base/timer/hi_res_timer_manager.h" | 25 #include "base/timer/hi_res_timer_manager.h" |
| 25 #include "content/browser/browser_thread_impl.h" | 26 #include "content/browser/browser_thread_impl.h" |
| 26 #include "content/browser/device_orientation/device_inertial_sensor_service.h" | 27 #include "content/browser/device_orientation/device_inertial_sensor_service.h" |
| 27 #include "content/browser/download/save_file_manager.h" | 28 #include "content/browser/download/save_file_manager.h" |
| 28 #include "content/browser/gamepad/gamepad_service.h" | 29 #include "content/browser/gamepad/gamepad_service.h" |
| 29 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 30 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 30 #include "content/browser/gpu/compositor_util.h" | 31 #include "content/browser/gpu/compositor_util.h" |
| 31 #include "content/browser/gpu/gpu_data_manager_impl.h" | 32 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 32 #include "content/browser/gpu/gpu_process_host.h" | 33 #include "content/browser/gpu/gpu_process_host.h" |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 base::MessageLoop::current()->AddTaskObserver(memory_observer_.get()); | 489 base::MessageLoop::current()->AddTaskObserver(memory_observer_.get()); |
| 489 } | 490 } |
| 490 | 491 |
| 491 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) | 492 #if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) |
| 492 trace_memory_controller_.reset(new base::debug::TraceMemoryController( | 493 trace_memory_controller_.reset(new base::debug::TraceMemoryController( |
| 493 base::MessageLoop::current()->message_loop_proxy(), | 494 base::MessageLoop::current()->message_loop_proxy(), |
| 494 ::HeapProfilerWithPseudoStackStart, | 495 ::HeapProfilerWithPseudoStackStart, |
| 495 ::HeapProfilerStop, | 496 ::HeapProfilerStop, |
| 496 ::GetHeapProfile)); | 497 ::GetHeapProfile)); |
| 497 #endif | 498 #endif |
| 499 |
| 500 system_stats_monitor_.reset(new base::debug::TraceEventSystemStatsMonitor( |
| 501 base::ThreadTaskRunnerHandle::Get())); |
| 498 } | 502 } |
| 499 | 503 |
| 500 int BrowserMainLoop::PreCreateThreads() { | 504 int BrowserMainLoop::PreCreateThreads() { |
| 501 | 505 |
| 502 if (parts_) { | 506 if (parts_) { |
| 503 TRACE_EVENT0("startup", | 507 TRACE_EVENT0("startup", |
| 504 "BrowserMainLoop::CreateThreads:PreCreateThreads"); | 508 "BrowserMainLoop::CreateThreads:PreCreateThreads"); |
| 505 result_code_ = parts_->PreCreateThreads(); | 509 result_code_ = parts_->PreCreateThreads(); |
| 506 } | 510 } |
| 507 | 511 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 base::Bind(base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed), | 712 base::Bind(base::IgnoreResult(&base::ThreadRestrictions::SetIOAllowed), |
| 709 true)); | 713 true)); |
| 710 | 714 |
| 711 if (parts_) { | 715 if (parts_) { |
| 712 TRACE_EVENT0("shutdown", | 716 TRACE_EVENT0("shutdown", |
| 713 "BrowserMainLoop::Subsystem:PostMainMessageLoopRun"); | 717 "BrowserMainLoop::Subsystem:PostMainMessageLoopRun"); |
| 714 parts_->PostMainMessageLoopRun(); | 718 parts_->PostMainMessageLoopRun(); |
| 715 } | 719 } |
| 716 | 720 |
| 717 trace_memory_controller_.reset(); | 721 trace_memory_controller_.reset(); |
| 722 system_stats_monitor_.reset(); |
| 718 | 723 |
| 719 #if !defined(OS_IOS) | 724 #if !defined(OS_IOS) |
| 720 // Destroying the GpuProcessHostUIShims on the UI thread posts a task to | 725 // Destroying the GpuProcessHostUIShims on the UI thread posts a task to |
| 721 // delete related objects on the GPU thread. This must be done before | 726 // delete related objects on the GPU thread. This must be done before |
| 722 // stopping the GPU thread. The GPU thread will close IPC channels to renderer | 727 // stopping the GPU thread. The GPU thread will close IPC channels to renderer |
| 723 // processes so this has to happen before stopping the IO thread. | 728 // processes so this has to happen before stopping the IO thread. |
| 724 { | 729 { |
| 725 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:GPUProcessHostShim"); | 730 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:GPUProcessHostShim"); |
| 726 GpuProcessHostUIShim::DestroyAll(); | 731 GpuProcessHostUIShim::DestroyAll(); |
| 727 } | 732 } |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 if (parameters_.ui_task) | 1040 if (parameters_.ui_task) |
| 1036 base::MessageLoopForUI::current()->PostTask(FROM_HERE, | 1041 base::MessageLoopForUI::current()->PostTask(FROM_HERE, |
| 1037 *parameters_.ui_task); | 1042 *parameters_.ui_task); |
| 1038 | 1043 |
| 1039 base::RunLoop run_loop; | 1044 base::RunLoop run_loop; |
| 1040 run_loop.Run(); | 1045 run_loop.Run(); |
| 1041 #endif | 1046 #endif |
| 1042 } | 1047 } |
| 1043 | 1048 |
| 1044 } // namespace content | 1049 } // namespace content |
| OLD | NEW |