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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
11 #include "base/feature_list.h" | 12 #include "base/feature_list.h" |
12 #include "base/location.h" | 13 #include "base/location.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/memory_pressure_monitor.h" | 16 #include "base/memory/memory_pressure_monitor.h" |
16 #include "base/metrics/field_trial.h" | 17 #include "base/metrics/field_trial.h" |
17 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 | 549 |
549 void BrowserMainLoop::PostMainMessageLoopStart() { | 550 void BrowserMainLoop::PostMainMessageLoopStart() { |
550 { | 551 { |
551 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:SystemMonitor"); | 552 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:SystemMonitor"); |
552 system_monitor_.reset(new base::SystemMonitor); | 553 system_monitor_.reset(new base::SystemMonitor); |
553 } | 554 } |
554 { | 555 { |
555 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:PowerMonitor"); | 556 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:PowerMonitor"); |
556 scoped_ptr<base::PowerMonitorSource> power_monitor_source( | 557 scoped_ptr<base::PowerMonitorSource> power_monitor_source( |
557 new base::PowerMonitorDeviceSource()); | 558 new base::PowerMonitorDeviceSource()); |
558 power_monitor_.reset(new base::PowerMonitor(power_monitor_source.Pass())); | 559 power_monitor_.reset( |
| 560 new base::PowerMonitor(std::move(power_monitor_source))); |
559 } | 561 } |
560 { | 562 { |
561 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:HighResTimerManager"); | 563 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:HighResTimerManager"); |
562 hi_res_timer_manager_.reset(new base::HighResolutionTimerManager); | 564 hi_res_timer_manager_.reset(new base::HighResolutionTimerManager); |
563 } | 565 } |
564 { | 566 { |
565 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:NetworkChangeNotifier"); | 567 TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:NetworkChangeNotifier"); |
566 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); | 568 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); |
567 } | 569 } |
568 | 570 |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 // - The IO thread is the only user of the CACHE thread. | 1073 // - The IO thread is the only user of the CACHE thread. |
1072 // | 1074 // |
1073 // - The PROCESS_LAUNCHER thread must be stopped after IO in case | 1075 // - The PROCESS_LAUNCHER thread must be stopped after IO in case |
1074 // the IO thread posted a task to terminate a process on the | 1076 // the IO thread posted a task to terminate a process on the |
1075 // process launcher thread. | 1077 // process launcher thread. |
1076 // | 1078 // |
1077 // - (Not sure why DB stops last.) | 1079 // - (Not sure why DB stops last.) |
1078 switch (thread_id) { | 1080 switch (thread_id) { |
1079 case BrowserThread::DB: { | 1081 case BrowserThread::DB: { |
1080 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:DBThread"); | 1082 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:DBThread"); |
1081 ResetThread_DB(db_thread_.Pass()); | 1083 ResetThread_DB(std::move(db_thread_)); |
1082 break; | 1084 break; |
1083 } | 1085 } |
1084 case BrowserThread::FILE: { | 1086 case BrowserThread::FILE: { |
1085 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:FileThread"); | 1087 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:FileThread"); |
1086 #if !defined(OS_IOS) | 1088 #if !defined(OS_IOS) |
1087 // Clean up state that lives on or uses the file_thread_ before | 1089 // Clean up state that lives on or uses the file_thread_ before |
1088 // it goes away. | 1090 // it goes away. |
1089 if (resource_dispatcher_host_) | 1091 if (resource_dispatcher_host_) |
1090 resource_dispatcher_host_.get()->save_file_manager()->Shutdown(); | 1092 resource_dispatcher_host_.get()->save_file_manager()->Shutdown(); |
1091 #endif // !defined(OS_IOS) | 1093 #endif // !defined(OS_IOS) |
1092 ResetThread_FILE(file_thread_.Pass()); | 1094 ResetThread_FILE(std::move(file_thread_)); |
1093 break; | 1095 break; |
1094 } | 1096 } |
1095 case BrowserThread::FILE_USER_BLOCKING: { | 1097 case BrowserThread::FILE_USER_BLOCKING: { |
1096 TRACE_EVENT0("shutdown", | 1098 TRACE_EVENT0("shutdown", |
1097 "BrowserMainLoop::Subsystem:FileUserBlockingThread"); | 1099 "BrowserMainLoop::Subsystem:FileUserBlockingThread"); |
1098 ResetThread_FILE_USER_BLOCKING(file_user_blocking_thread_.Pass()); | 1100 ResetThread_FILE_USER_BLOCKING(std::move(file_user_blocking_thread_)); |
1099 break; | 1101 break; |
1100 } | 1102 } |
1101 case BrowserThread::PROCESS_LAUNCHER: { | 1103 case BrowserThread::PROCESS_LAUNCHER: { |
1102 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:LauncherThread"); | 1104 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:LauncherThread"); |
1103 ResetThread_PROCESS_LAUNCHER(process_launcher_thread_.Pass()); | 1105 ResetThread_PROCESS_LAUNCHER(std::move(process_launcher_thread_)); |
1104 break; | 1106 break; |
1105 } | 1107 } |
1106 case BrowserThread::CACHE: { | 1108 case BrowserThread::CACHE: { |
1107 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:CacheThread"); | 1109 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:CacheThread"); |
1108 ResetThread_CACHE(cache_thread_.Pass()); | 1110 ResetThread_CACHE(std::move(cache_thread_)); |
1109 break; | 1111 break; |
1110 } | 1112 } |
1111 case BrowserThread::IO: { | 1113 case BrowserThread::IO: { |
1112 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:IOThread"); | 1114 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:IOThread"); |
1113 ResetThread_IO(io_thread_.Pass()); | 1115 ResetThread_IO(std::move(io_thread_)); |
1114 break; | 1116 break; |
1115 } | 1117 } |
1116 case BrowserThread::UI: | 1118 case BrowserThread::UI: |
1117 case BrowserThread::ID_COUNT: | 1119 case BrowserThread::ID_COUNT: |
1118 default: | 1120 default: |
1119 NOTREACHED(); | 1121 NOTREACHED(); |
1120 break; | 1122 break; |
1121 } | 1123 } |
1122 } | 1124 } |
1123 | 1125 |
1124 #if !defined(OS_IOS) | 1126 #if !defined(OS_IOS) |
1125 { | 1127 { |
1126 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:IndexedDBThread"); | 1128 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:IndexedDBThread"); |
1127 ResetThread_IndexedDb(indexed_db_thread_.Pass()); | 1129 ResetThread_IndexedDb(std::move(indexed_db_thread_)); |
1128 } | 1130 } |
1129 #endif | 1131 #endif |
1130 | 1132 |
1131 // Close the blocking I/O pool after the other threads. Other threads such | 1133 // Close the blocking I/O pool after the other threads. Other threads such |
1132 // as the I/O thread may need to schedule work like closing files or flushing | 1134 // as the I/O thread may need to schedule work like closing files or flushing |
1133 // data during shutdown, so the blocking pool needs to be available. There | 1135 // data during shutdown, so the blocking pool needs to be available. There |
1134 // may also be slow operations pending that will blcok shutdown, so closing | 1136 // may also be slow operations pending that will blcok shutdown, so closing |
1135 // it here (which will block until required operations are complete) gives | 1137 // it here (which will block until required operations are complete) gives |
1136 // more head start for those operations to finish. | 1138 // more head start for those operations to finish. |
1137 { | 1139 { |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1477 DCHECK(is_tracing_startup_for_duration_); | 1479 DCHECK(is_tracing_startup_for_duration_); |
1478 | 1480 |
1479 is_tracing_startup_for_duration_ = false; | 1481 is_tracing_startup_for_duration_ = false; |
1480 TracingController::GetInstance()->StopTracing( | 1482 TracingController::GetInstance()->StopTracing( |
1481 TracingController::CreateFileSink( | 1483 TracingController::CreateFileSink( |
1482 startup_trace_file_, | 1484 startup_trace_file_, |
1483 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); | 1485 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); |
1484 } | 1486 } |
1485 | 1487 |
1486 } // namespace content | 1488 } // namespace content |
OLD | NEW |