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

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

Issue 2690183002: RedirectNonUINonIOBrowserThreads to TaskScheduler by default on trunk.
Patch Set: update dependency Created 3 years, 8 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
« no previous file with comments | « base/threading/thread_restrictions.h ('k') | testing/variations/fieldtrial_testing_config.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 #endif 1267 #endif
1268 1268
1269 if (BrowserGpuChannelHostFactory::instance()) { 1269 if (BrowserGpuChannelHostFactory::instance()) {
1270 BrowserGpuChannelHostFactory::instance()->CloseChannel(); 1270 BrowserGpuChannelHostFactory::instance()->CloseChannel();
1271 } 1271 }
1272 1272
1273 // Shutdown the Service Manager and IPC. 1273 // Shutdown the Service Manager and IPC.
1274 service_manager_context_.reset(); 1274 service_manager_context_.reset();
1275 mojo_ipc_support_.reset(); 1275 mojo_ipc_support_.reset();
1276 1276
1277 // Must be size_t so we can subtract from it. 1277 {
1278 for (size_t thread_id = BrowserThread::ID_COUNT - 1; 1278 base::ThreadRestrictions::ScopedAllowWait allow_wait_for_join;
1279 thread_id >= (BrowserThread::UI + 1); 1279
1280 --thread_id) { 1280 // Must be size_t so we can subtract from it.
1281 // Find the thread object we want to stop. Looping over all valid 1281 for (size_t thread_id = BrowserThread::ID_COUNT - 1;
1282 // BrowserThread IDs and DCHECKing on a missing case in the switch 1282 thread_id >= (BrowserThread::UI + 1); --thread_id) {
1283 // statement helps avoid a mismatch between this code and the 1283 // Find the thread object we want to stop. Looping over all valid
1284 // BrowserThread::ID enumeration. 1284 // BrowserThread IDs and DCHECKing on a missing case in the switch
1285 // 1285 // statement helps avoid a mismatch between this code and the
1286 // The destruction order is the reverse order of occurrence in the 1286 // BrowserThread::ID enumeration.
1287 // BrowserThread::ID list. The rationale for the order is as 1287 //
1288 // follows (need to be filled in a bit): 1288 // The destruction order is the reverse order of occurrence in the
1289 // 1289 // BrowserThread::ID list. The rationale for the order is as follows (need
1290 // 1290 // to be filled in a bit):
1291 // - The IO thread is the only user of the CACHE thread. 1291 //
1292 // 1292 // - The IO thread is the only user of the CACHE thread.
1293 // - The PROCESS_LAUNCHER thread must be stopped after IO in case 1293 //
1294 // the IO thread posted a task to terminate a process on the 1294 // - The PROCESS_LAUNCHER thread must be stopped after IO in case
1295 // process launcher thread. 1295 // the IO thread posted a task to terminate a process on the
1296 // 1296 // process launcher thread.
1297 // - (Not sure why DB stops last.) 1297 //
1298 switch (thread_id) { 1298 // - (Not sure why DB stops last.)
1299 case BrowserThread::DB: { 1299 switch (thread_id) {
1300 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:DBThread"); 1300 case BrowserThread::DB: {
1301 ResetThread_DB(std::move(db_thread_)); 1301 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:DBThread");
1302 break; 1302 ResetThread_DB(std::move(db_thread_));
1303 break;
1304 }
1305 case BrowserThread::FILE: {
1306 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:FileThread");
1307 // Clean up state that lives on or uses the FILE thread before it goes
1308 // away.
1309 save_file_manager_->Shutdown();
1310 ResetThread_FILE(std::move(file_thread_));
1311 break;
1312 }
1313 case BrowserThread::FILE_USER_BLOCKING: {
1314 TRACE_EVENT0("shutdown",
1315 "BrowserMainLoop::Subsystem:FileUserBlockingThread");
1316 ResetThread_FILE_USER_BLOCKING(std::move(file_user_blocking_thread_));
1317 break;
1318 }
1319 case BrowserThread::PROCESS_LAUNCHER: {
1320 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:LauncherThread");
1321 ResetThread_PROCESS_LAUNCHER(std::move(process_launcher_thread_));
1322 break;
1323 }
1324 case BrowserThread::CACHE: {
1325 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:CacheThread");
1326 ResetThread_CACHE(std::move(cache_thread_));
1327 break;
1328 }
1329 case BrowserThread::IO: {
1330 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:IOThread");
1331 ResetThread_IO(std::move(io_thread_));
1332 break;
1333 }
1334 case BrowserThread::UI:
1335 case BrowserThread::ID_COUNT:
1336 NOTREACHED();
1337 break;
1303 } 1338 }
1304 case BrowserThread::FILE: {
1305 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:FileThread");
1306 // Clean up state that lives on or uses the FILE thread before it goes
1307 // away.
1308 save_file_manager_->Shutdown();
1309 ResetThread_FILE(std::move(file_thread_));
1310 break;
1311 }
1312 case BrowserThread::FILE_USER_BLOCKING: {
1313 TRACE_EVENT0("shutdown",
1314 "BrowserMainLoop::Subsystem:FileUserBlockingThread");
1315 ResetThread_FILE_USER_BLOCKING(std::move(file_user_blocking_thread_));
1316 break;
1317 }
1318 case BrowserThread::PROCESS_LAUNCHER: {
1319 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:LauncherThread");
1320 ResetThread_PROCESS_LAUNCHER(std::move(process_launcher_thread_));
1321 break;
1322 }
1323 case BrowserThread::CACHE: {
1324 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:CacheThread");
1325 ResetThread_CACHE(std::move(cache_thread_));
1326 break;
1327 }
1328 case BrowserThread::IO: {
1329 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:IOThread");
1330 ResetThread_IO(std::move(io_thread_));
1331 break;
1332 }
1333 case BrowserThread::UI:
1334 case BrowserThread::ID_COUNT:
1335 NOTREACHED();
1336 break;
1337 } 1339 }
1338 } 1340 {
1339 { 1341 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:IndexedDBThread");
1340 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:IndexedDBThread"); 1342 ResetThread_IndexedDb(std::move(indexed_db_thread_));
1341 ResetThread_IndexedDb(std::move(indexed_db_thread_)); 1343 }
1342 }
1343 1344
1344 // Close the blocking I/O pool after the other threads. Other threads such 1345 // Close the blocking I/O pool after the other threads. Other threads such
1345 // as the I/O thread may need to schedule work like closing files or flushing 1346 // as the I/O thread may need to schedule work like closing files or
1346 // data during shutdown, so the blocking pool needs to be available. There 1347 // flushing data during shutdown, so the blocking pool needs to be
1347 // may also be slow operations pending that will blcok shutdown, so closing 1348 // available. There may also be slow operations pending that will blcok
1348 // it here (which will block until required operations are complete) gives 1349 // shutdown, so closing it here (which will block until required operations
1349 // more head start for those operations to finish. 1350 // are complete) gives more head start for those operations to finish.
1350 { 1351 {
1351 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:ThreadPool"); 1352 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:ThreadPool");
1352 BrowserThreadImpl::ShutdownThreadPool(); 1353 BrowserThreadImpl::ShutdownThreadPool();
1353 } 1354 }
1354 { 1355 {
1355 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:TaskScheduler"); 1356 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:TaskScheduler");
1356 base::TaskScheduler::GetInstance()->Shutdown(); 1357 base::TaskScheduler::GetInstance()->Shutdown();
1358 }
1357 } 1359 }
1358 1360
1359 // Must happen after the IO thread is shutdown since this may be accessed from 1361 // Must happen after the IO thread is shutdown since this may be accessed from
1360 // it. 1362 // it.
1361 { 1363 {
1362 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:GPUChannelFactory"); 1364 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:GPUChannelFactory");
1363 if (BrowserGpuChannelHostFactory::instance()) { 1365 if (BrowserGpuChannelHostFactory::instance()) {
1364 BrowserGpuChannelHostFactory::Terminate(); 1366 BrowserGpuChannelHostFactory::Terminate();
1365 } 1367 }
1366 } 1368 }
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1773 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), 1775 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE),
1774 MediaInternals::GetInstance()); 1776 MediaInternals::GetInstance());
1775 } 1777 }
1776 CHECK(audio_manager_); 1778 CHECK(audio_manager_);
1777 1779
1778 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get()); 1780 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get());
1779 CHECK(audio_system_); 1781 CHECK(audio_system_);
1780 } 1782 }
1781 1783
1782 } // namespace content 1784 } // namespace content
OLDNEW
« no previous file with comments | « base/threading/thread_restrictions.h ('k') | testing/variations/fieldtrial_testing_config.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698