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 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 12 matching lines...) Expand all Loading... | |
23 #include "base/metrics/histogram_macros.h" | 23 #include "base/metrics/histogram_macros.h" |
24 #include "base/metrics/user_metrics.h" | 24 #include "base/metrics/user_metrics.h" |
25 #include "base/pending_task.h" | 25 #include "base/pending_task.h" |
26 #include "base/power_monitor/power_monitor.h" | 26 #include "base/power_monitor/power_monitor.h" |
27 #include "base/power_monitor/power_monitor_device_source.h" | 27 #include "base/power_monitor/power_monitor_device_source.h" |
28 #include "base/process/process_metrics.h" | 28 #include "base/process/process_metrics.h" |
29 #include "base/run_loop.h" | 29 #include "base/run_loop.h" |
30 #include "base/single_thread_task_runner.h" | 30 #include "base/single_thread_task_runner.h" |
31 #include "base/strings/string_number_conversions.h" | 31 #include "base/strings/string_number_conversions.h" |
32 #include "base/strings/string_split.h" | 32 #include "base/strings/string_split.h" |
33 #include "base/synchronization/waitable_event.h" | |
33 #include "base/system_monitor/system_monitor.h" | 34 #include "base/system_monitor/system_monitor.h" |
35 #include "base/task_scheduler/post_task.h" | |
36 #include "base/task_scheduler/task_traits.h" | |
34 #include "base/threading/sequenced_worker_pool.h" | 37 #include "base/threading/sequenced_worker_pool.h" |
35 #include "base/threading/thread_restrictions.h" | 38 #include "base/threading/thread_restrictions.h" |
36 #include "base/threading/thread_task_runner_handle.h" | 39 #include "base/threading/thread_task_runner_handle.h" |
37 #include "base/timer/hi_res_timer_manager.h" | 40 #include "base/timer/hi_res_timer_manager.h" |
38 #include "base/trace_event/memory_dump_manager.h" | 41 #include "base/trace_event/memory_dump_manager.h" |
39 #include "base/trace_event/trace_event.h" | 42 #include "base/trace_event/trace_event.h" |
40 #include "build/build_config.h" | 43 #include "build/build_config.h" |
41 #include "components/discardable_memory/service/discardable_shared_memory_manage r.h" | 44 #include "components/discardable_memory/service/discardable_shared_memory_manage r.h" |
42 #include "components/tracing/browser/trace_config_file.h" | 45 #include "components/tracing/browser/trace_config_file.h" |
43 #include "components/tracing/common/process_metrics_memory_dump_provider.h" | 46 #include "components/tracing/common/process_metrics_memory_dump_provider.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 void OnStoppedStartupTracing(const base::FilePath& trace_file) { | 297 void OnStoppedStartupTracing(const base::FilePath& trace_file) { |
295 VLOG(0) << "Completed startup tracing to " << trace_file.value(); | 298 VLOG(0) << "Completed startup tracing to " << trace_file.value(); |
296 } | 299 } |
297 | 300 |
298 // Disable optimizations for this block of functions so the compiler doesn't | 301 // Disable optimizations for this block of functions so the compiler doesn't |
299 // merge them all together. This makes it possible to tell what thread was | 302 // merge them all together. This makes it possible to tell what thread was |
300 // unresponsive by inspecting the callstack. | 303 // unresponsive by inspecting the callstack. |
301 MSVC_DISABLE_OPTIMIZE() | 304 MSVC_DISABLE_OPTIMIZE() |
302 MSVC_PUSH_DISABLE_WARNING(4748) | 305 MSVC_PUSH_DISABLE_WARNING(4748) |
303 | 306 |
304 NOINLINE void ResetThread_DB(std::unique_ptr<BrowserProcessSubThread> thread) { | 307 // Takes ownership of |task_runner| and blocks until it's empty. |
308 void FlushThreadTaskRunner( | |
309 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | |
310 base::WaitableEvent thread_terminated( | |
311 base::WaitableEvent::ResetPolicy::MANUAL, | |
312 base::WaitableEvent::InitialState::NOT_SIGNALED); | |
313 task_runner->PostTask(FROM_HERE, | |
314 base::Bind(&base::WaitableEvent::Signal, | |
315 base::Unretained(&thread_terminated))); | |
316 thread_terminated.Wait(); | |
317 } | |
318 | |
319 NOINLINE void ResetThread_DB( | |
320 std::unique_ptr<BrowserProcessSubThread> thread, | |
321 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | |
322 DCHECK((thread && !task_runner) || (!thread && task_runner)); | |
305 volatile int inhibit_comdat = __LINE__; | 323 volatile int inhibit_comdat = __LINE__; |
306 ALLOW_UNUSED_LOCAL(inhibit_comdat); | 324 ALLOW_UNUSED_LOCAL(inhibit_comdat); |
307 thread.reset(); | 325 if (thread) { |
326 thread.reset(); | |
327 } else { | |
fdoray
2016/12/01 15:15:21
You could avoid keeping SingleThreadTaskRunners re
gab
2016/12/07 19:15:27
I was inspired by this and went a step further, th
| |
328 BrowserThreadImpl::RedirectThreadIDToTaskRunner(BrowserThread::DB, nullptr); | |
fdoray
2016/12/01 15:15:21
Without redirection:
1. Main thread: ~BrowserProce
gab
2016/12/07 19:15:26
The thing is we have to change the state to SHUTDO
| |
329 FlushThreadTaskRunner(std::move(task_runner)); | |
330 } | |
308 } | 331 } |
309 | 332 |
310 NOINLINE void ResetThread_FILE( | 333 NOINLINE void ResetThread_FILE( |
311 std::unique_ptr<BrowserProcessSubThread> thread) { | 334 std::unique_ptr<BrowserProcessSubThread> thread, |
335 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | |
336 DCHECK((thread && !task_runner) || (!thread && task_runner)); | |
312 volatile int inhibit_comdat = __LINE__; | 337 volatile int inhibit_comdat = __LINE__; |
313 ALLOW_UNUSED_LOCAL(inhibit_comdat); | 338 ALLOW_UNUSED_LOCAL(inhibit_comdat); |
314 thread.reset(); | 339 if (thread) { |
340 thread.reset(); | |
341 } else { | |
342 BrowserThreadImpl::RedirectThreadIDToTaskRunner(BrowserThread::FILE, | |
343 nullptr); | |
344 FlushThreadTaskRunner(std::move(task_runner)); | |
345 } | |
315 } | 346 } |
316 | 347 |
317 NOINLINE void ResetThread_FILE_USER_BLOCKING( | 348 NOINLINE void ResetThread_FILE_USER_BLOCKING( |
318 std::unique_ptr<BrowserProcessSubThread> thread) { | 349 std::unique_ptr<BrowserProcessSubThread> thread, |
350 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | |
351 DCHECK((thread && !task_runner) || (!thread && task_runner)); | |
319 volatile int inhibit_comdat = __LINE__; | 352 volatile int inhibit_comdat = __LINE__; |
320 ALLOW_UNUSED_LOCAL(inhibit_comdat); | 353 ALLOW_UNUSED_LOCAL(inhibit_comdat); |
321 thread.reset(); | 354 if (thread) { |
355 thread.reset(); | |
356 } else { | |
357 BrowserThreadImpl::RedirectThreadIDToTaskRunner( | |
358 BrowserThread::FILE_USER_BLOCKING, nullptr); | |
359 FlushThreadTaskRunner(std::move(task_runner)); | |
360 } | |
322 } | 361 } |
323 | 362 |
324 NOINLINE void ResetThread_PROCESS_LAUNCHER( | 363 NOINLINE void ResetThread_PROCESS_LAUNCHER( |
325 std::unique_ptr<BrowserProcessSubThread> thread) { | 364 std::unique_ptr<BrowserProcessSubThread> thread, |
365 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | |
366 DCHECK((thread && !task_runner) || (!thread && task_runner)); | |
326 volatile int inhibit_comdat = __LINE__; | 367 volatile int inhibit_comdat = __LINE__; |
327 ALLOW_UNUSED_LOCAL(inhibit_comdat); | 368 ALLOW_UNUSED_LOCAL(inhibit_comdat); |
328 thread.reset(); | 369 if (thread) { |
370 thread.reset(); | |
371 } else { | |
372 BrowserThreadImpl::RedirectThreadIDToTaskRunner( | |
373 BrowserThread::PROCESS_LAUNCHER, nullptr); | |
374 FlushThreadTaskRunner(std::move(task_runner)); | |
375 } | |
329 } | 376 } |
330 | 377 |
331 NOINLINE void ResetThread_CACHE( | 378 NOINLINE void ResetThread_CACHE( |
332 std::unique_ptr<BrowserProcessSubThread> thread) { | 379 std::unique_ptr<BrowserProcessSubThread> thread, |
380 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | |
381 DCHECK((thread && !task_runner) || (!thread && task_runner)); | |
333 volatile int inhibit_comdat = __LINE__; | 382 volatile int inhibit_comdat = __LINE__; |
334 ALLOW_UNUSED_LOCAL(inhibit_comdat); | 383 ALLOW_UNUSED_LOCAL(inhibit_comdat); |
335 thread.reset(); | 384 if (thread) { |
385 thread.reset(); | |
386 } else { | |
387 BrowserThreadImpl::RedirectThreadIDToTaskRunner(BrowserThread::CACHE, | |
388 nullptr); | |
389 FlushThreadTaskRunner(std::move(task_runner)); | |
390 } | |
336 } | 391 } |
337 | 392 |
338 NOINLINE void ResetThread_IO(std::unique_ptr<BrowserProcessSubThread> thread) { | 393 NOINLINE void ResetThread_IO(std::unique_ptr<BrowserProcessSubThread> thread) { |
339 volatile int inhibit_comdat = __LINE__; | 394 volatile int inhibit_comdat = __LINE__; |
340 ALLOW_UNUSED_LOCAL(inhibit_comdat); | 395 ALLOW_UNUSED_LOCAL(inhibit_comdat); |
341 thread.reset(); | 396 thread.reset(); |
342 } | 397 } |
343 | 398 |
344 NOINLINE void ResetThread_IndexedDb(std::unique_ptr<base::Thread> thread) { | 399 NOINLINE void ResetThread_IndexedDb(std::unique_ptr<base::Thread> thread) { |
345 volatile int inhibit_comdat = __LINE__; | 400 volatile int inhibit_comdat = __LINE__; |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
876 ui_message_loop_options.message_loop_type = base::MessageLoop::TYPE_UI; | 931 ui_message_loop_options.message_loop_type = base::MessageLoop::TYPE_UI; |
877 | 932 |
878 // Start threads in the order they occur in the BrowserThread::ID | 933 // Start threads in the order they occur in the BrowserThread::ID |
879 // enumeration, except for BrowserThread::UI which is the main | 934 // enumeration, except for BrowserThread::UI which is the main |
880 // thread. | 935 // thread. |
881 // | 936 // |
882 // Must be size_t so we can increment it. | 937 // Must be size_t so we can increment it. |
883 for (size_t thread_id = BrowserThread::UI + 1; | 938 for (size_t thread_id = BrowserThread::UI + 1; |
884 thread_id < BrowserThread::ID_COUNT; | 939 thread_id < BrowserThread::ID_COUNT; |
885 ++thread_id) { | 940 ++thread_id) { |
886 std::unique_ptr<BrowserProcessSubThread>* thread_to_start = NULL; | 941 // If this thread ID is backed by a real thread, |thread_to_start| will be |
942 // set to the appropriate |BrowserProcessSubThread*|. And |options| can be | |
fdoray
2016/12/01 15:15:21
s/|BrowserProcessSubThread*|/BrowserProcessSubThre
gab
2016/12/07 19:15:26
Done.
| |
943 // updated away from its default. | |
944 std::unique_ptr<BrowserProcessSubThread>* thread_to_start = nullptr; | |
887 base::Thread::Options options; | 945 base::Thread::Options options; |
888 | 946 |
947 // Otherwise this thread ID will be backed by a SingleThreadTaskRunner in | |
948 // which case |task_runner_to_create| will be set to the appropriate | |
949 // |SingleThreadTaskRunner*| and |task_runner_traits| can be updated away | |
fdoray
2016/12/01 15:15:21
s/|SingleThreadTaskRunner*|/SingleThreadTaskRunner
gab
2016/12/07 19:15:26
Done.
| |
950 // from its default. |execution_mode| defaults to |SINGLE_THREADED| as-is | |
fdoray
2016/12/01 15:15:21
No more |execution_mode|.
gab
2016/12/07 19:15:26
Done.
| |
951 // appropriate to map most old browser threads but can also be updated in | |
952 // the switch statement below if a thread has specific requirements. | |
953 scoped_refptr<base::SingleThreadTaskRunner>* task_runner_to_create = | |
954 nullptr; | |
955 base::TaskTraits task_runner_traits; | |
956 | |
957 const bool redirect_nonUInonIO_browser_threads = | |
fdoray
2016/12/01 15:15:21
Move outside the loop.
gab
2016/12/07 19:15:27
Done.
| |
958 GetContentClient() | |
959 ->browser() | |
960 ->RedirectNonUINonIOBrowserThreadsToTaskScheduler(); | |
961 | |
889 switch (thread_id) { | 962 switch (thread_id) { |
890 case BrowserThread::DB: | 963 case BrowserThread::DB: |
891 TRACE_EVENT_BEGIN1("startup", | 964 TRACE_EVENT_BEGIN1("startup", |
892 "BrowserMainLoop::CreateThreads:start", | 965 "BrowserMainLoop::CreateThreads:start", |
893 "Thread", "BrowserThread::DB"); | 966 "Thread", "BrowserThread::DB"); |
894 thread_to_start = &db_thread_; | 967 if (redirect_nonUInonIO_browser_threads) { |
895 options.timer_slack = base::TIMER_SLACK_MAXIMUM; | 968 task_runner_to_create = &db_task_runner_; |
969 task_runner_traits.WithFileIO() | |
fdoray
2016/12/01 15:15:21
Add WithWait() to allow AssertIOAllowed()?
gab
2016/12/07 19:15:27
Assuming you mean "to allow AssertWaitAllowed()".
| |
970 .WithPriority(base::TaskPriority::USER_VISIBLE) | |
971 .WithShutdownBehavior(base::TaskShutdownBehavior::BLOCK_SHUTDOWN); | |
972 } else { | |
973 thread_to_start = &db_thread_; | |
974 options.timer_slack = base::TIMER_SLACK_MAXIMUM; | |
975 } | |
896 break; | 976 break; |
897 case BrowserThread::FILE_USER_BLOCKING: | 977 case BrowserThread::FILE_USER_BLOCKING: |
898 TRACE_EVENT_BEGIN1("startup", | 978 TRACE_EVENT_BEGIN1("startup", |
899 "BrowserMainLoop::CreateThreads:start", | 979 "BrowserMainLoop::CreateThreads:start", |
900 "Thread", "BrowserThread::FILE_USER_BLOCKING"); | 980 "Thread", "BrowserThread::FILE_USER_BLOCKING"); |
901 thread_to_start = &file_user_blocking_thread_; | 981 if (redirect_nonUInonIO_browser_threads) { |
982 task_runner_to_create = &file_user_blocking_task_runner_; | |
983 task_runner_traits.WithFileIO() | |
984 .WithPriority(base::TaskPriority::USER_BLOCKING) | |
985 .WithShutdownBehavior(base::TaskShutdownBehavior::BLOCK_SHUTDOWN); | |
986 } else { | |
987 thread_to_start = &file_user_blocking_thread_; | |
988 } | |
902 break; | 989 break; |
903 case BrowserThread::FILE: | 990 case BrowserThread::FILE: |
904 TRACE_EVENT_BEGIN1("startup", | 991 TRACE_EVENT_BEGIN1("startup", |
905 "BrowserMainLoop::CreateThreads:start", | 992 "BrowserMainLoop::CreateThreads:start", |
906 "Thread", "BrowserThread::FILE"); | 993 "Thread", "BrowserThread::FILE"); |
994 | |
995 #if defined(OS_WIN) | |
996 // On Windows, the FILE thread needs to be have a UI message loop which | |
997 // pumps messages in such a way that Google Update can communicate back | |
998 // to us. | |
999 // TODO(robliao): Need to support COM in TaskScheduler before | |
1000 // redirecting the FILE thread on Windows. http://crbug.com/662122 | |
907 thread_to_start = &file_thread_; | 1001 thread_to_start = &file_thread_; |
908 #if defined(OS_WIN) | |
909 // On Windows, the FILE thread needs to be have a UI message loop | |
910 // which pumps messages in such a way that Google Update can | |
911 // communicate back to us. | |
912 options = ui_message_loop_options; | 1002 options = ui_message_loop_options; |
913 #else | 1003 #else |
914 options = io_message_loop_options; | 1004 if (redirect_nonUInonIO_browser_threads) { |
1005 task_runner_to_create = &file_task_runner_; | |
1006 task_runner_traits.WithFileIO() | |
1007 .WithPriority(base::TaskPriority::BACKGROUND) | |
1008 .WithShutdownBehavior(base::TaskShutdownBehavior::BLOCK_SHUTDOWN); | |
1009 } else { | |
1010 thread_to_start = &file_thread_; | |
1011 options = io_message_loop_options; | |
1012 options.timer_slack = base::TIMER_SLACK_MAXIMUM; | |
1013 } | |
915 #endif | 1014 #endif |
916 options.timer_slack = base::TIMER_SLACK_MAXIMUM; | |
917 break; | 1015 break; |
918 case BrowserThread::PROCESS_LAUNCHER: | 1016 case BrowserThread::PROCESS_LAUNCHER: |
919 TRACE_EVENT_BEGIN1("startup", | 1017 TRACE_EVENT_BEGIN1("startup", |
920 "BrowserMainLoop::CreateThreads:start", | 1018 "BrowserMainLoop::CreateThreads:start", |
921 "Thread", "BrowserThread::PROCESS_LAUNCHER"); | 1019 "Thread", "BrowserThread::PROCESS_LAUNCHER"); |
922 thread_to_start = &process_launcher_thread_; | 1020 if (redirect_nonUInonIO_browser_threads) { |
923 options.timer_slack = base::TIMER_SLACK_MAXIMUM; | 1021 task_runner_to_create = &process_launcher_task_runner_; |
1022 task_runner_traits.WithFileIO() | |
1023 .WithPriority(base::TaskPriority::USER_BLOCKING) | |
1024 .WithShutdownBehavior(base::TaskShutdownBehavior::BLOCK_SHUTDOWN); | |
1025 } else { | |
1026 thread_to_start = &process_launcher_thread_; | |
1027 options.timer_slack = base::TIMER_SLACK_MAXIMUM; | |
1028 } | |
924 break; | 1029 break; |
925 case BrowserThread::CACHE: | 1030 case BrowserThread::CACHE: |
926 TRACE_EVENT_BEGIN1("startup", | 1031 TRACE_EVENT_BEGIN1("startup", |
927 "BrowserMainLoop::CreateThreads:start", | 1032 "BrowserMainLoop::CreateThreads:start", |
928 "Thread", "BrowserThread::CACHE"); | 1033 "Thread", "BrowserThread::CACHE"); |
1034 #if defined(OS_WIN) | |
1035 // TaskScheduler doesn't support async I/O on Windows as CACHE thread is | |
1036 // the only user and this use case is going away in | |
1037 // https://codereview.chromium.org/2216583003/. TODO(gavinp): Remove | |
1038 // this ifdef (and thus enable redirection of the CACHE thread on | |
1039 // Windows) once that CL lands. | |
929 thread_to_start = &cache_thread_; | 1040 thread_to_start = &cache_thread_; |
930 #if defined(OS_WIN) | |
931 options = io_message_loop_options; | 1041 options = io_message_loop_options; |
932 #endif // defined(OS_WIN) | |
933 options.timer_slack = base::TIMER_SLACK_MAXIMUM; | 1042 options.timer_slack = base::TIMER_SLACK_MAXIMUM; |
1043 #else // OS_WIN | |
1044 if (redirect_nonUInonIO_browser_threads) { | |
1045 task_runner_to_create = &cache_task_runner_; | |
1046 task_runner_traits.WithFileIO() | |
1047 .WithPriority(base::TaskPriority::USER_BLOCKING) | |
1048 .WithShutdownBehavior(base::TaskShutdownBehavior::BLOCK_SHUTDOWN); | |
1049 } else { | |
1050 thread_to_start = &cache_thread_; | |
1051 options.timer_slack = base::TIMER_SLACK_MAXIMUM; | |
1052 } | |
1053 #endif // OS_WIN | |
934 break; | 1054 break; |
935 case BrowserThread::IO: | 1055 case BrowserThread::IO: |
936 TRACE_EVENT_BEGIN1("startup", | 1056 TRACE_EVENT_BEGIN1("startup", |
937 "BrowserMainLoop::CreateThreads:start", | 1057 "BrowserMainLoop::CreateThreads:start", |
938 "Thread", "BrowserThread::IO"); | 1058 "Thread", "BrowserThread::IO"); |
939 thread_to_start = &io_thread_; | 1059 thread_to_start = &io_thread_; |
940 options = io_message_loop_options; | 1060 options = io_message_loop_options; |
941 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | 1061 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
942 // Up the priority of the |io_thread_| as some of its IPCs relate to | 1062 // Up the priority of the |io_thread_| as some of its IPCs relate to |
943 // display tasks. | 1063 // display tasks. |
944 options.priority = base::ThreadPriority::DISPLAY; | 1064 options.priority = base::ThreadPriority::DISPLAY; |
945 #endif | 1065 #endif |
946 break; | 1066 break; |
947 case BrowserThread::UI: | 1067 case BrowserThread::UI: // Falls through. |
948 case BrowserThread::ID_COUNT: | 1068 case BrowserThread::ID_COUNT: // Falls through. |
949 default: | |
950 NOTREACHED(); | 1069 NOTREACHED(); |
951 break; | 1070 break; |
952 } | 1071 } |
953 | 1072 |
954 BrowserThread::ID id = static_cast<BrowserThread::ID>(thread_id); | 1073 BrowserThread::ID id = static_cast<BrowserThread::ID>(thread_id); |
955 | 1074 |
956 if (thread_to_start) { | 1075 if (thread_to_start) { |
1076 DCHECK(!task_runner_to_create); | |
957 (*thread_to_start).reset(new BrowserProcessSubThread(id)); | 1077 (*thread_to_start).reset(new BrowserProcessSubThread(id)); |
958 if (!(*thread_to_start)->StartWithOptions(options)) { | 1078 if (!(*thread_to_start)->StartWithOptions(options)) { |
959 LOG(FATAL) << "Failed to start the browser thread: id == " << id; | 1079 LOG(FATAL) << "Failed to start the browser thread: id == " << id; |
960 } | 1080 } |
1081 } else if (task_runner_to_create) { | |
fdoray
2016/12/01 15:15:21
DCHECK(!thread_to_start);
gab
2016/12/07 19:15:27
This is implicit in else block of if (thread_to_st
| |
1082 *task_runner_to_create = | |
1083 base::CreateSingleThreadTaskRunnerWithTraits(task_runner_traits); | |
1084 DCHECK(*task_runner_to_create); | |
1085 BrowserThreadImpl::RedirectThreadIDToTaskRunner( | |
1086 id, task_runner_to_create->get()); | |
961 } else { | 1087 } else { |
962 NOTREACHED(); | 1088 NOTREACHED(); |
963 } | 1089 } |
964 | 1090 |
965 TRACE_EVENT_END0("startup", "BrowserMainLoop::CreateThreads:start"); | 1091 TRACE_EVENT_END0("startup", "BrowserMainLoop::CreateThreads:start"); |
966 } | 1092 } |
967 created_threads_ = true; | 1093 created_threads_ = true; |
968 return result_code_; | 1094 return result_code_; |
969 } | 1095 } |
970 | 1096 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1103 // - The IO thread is the only user of the CACHE thread. | 1229 // - The IO thread is the only user of the CACHE thread. |
1104 // | 1230 // |
1105 // - The PROCESS_LAUNCHER thread must be stopped after IO in case | 1231 // - The PROCESS_LAUNCHER thread must be stopped after IO in case |
1106 // the IO thread posted a task to terminate a process on the | 1232 // the IO thread posted a task to terminate a process on the |
1107 // process launcher thread. | 1233 // process launcher thread. |
1108 // | 1234 // |
1109 // - (Not sure why DB stops last.) | 1235 // - (Not sure why DB stops last.) |
1110 switch (thread_id) { | 1236 switch (thread_id) { |
1111 case BrowserThread::DB: { | 1237 case BrowserThread::DB: { |
1112 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:DBThread"); | 1238 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:DBThread"); |
1113 ResetThread_DB(std::move(db_thread_)); | 1239 ResetThread_DB(std::move(db_thread_), std::move(db_task_runner_)); |
1114 break; | 1240 break; |
1115 } | 1241 } |
1116 case BrowserThread::FILE: { | 1242 case BrowserThread::FILE: { |
1117 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:FileThread"); | 1243 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:FileThread"); |
1118 // Clean up state that lives on or uses the file_thread_ before | 1244 // Clean up state that lives on or uses the file_thread_ before it goes |
fdoray
2016/12/01 15:15:21
the FILE thread
gab
2016/12/07 19:15:26
Done.
| |
1119 // it goes away. | 1245 // away. |
1120 save_file_manager_->Shutdown(); | 1246 save_file_manager_->Shutdown(); |
1121 ResetThread_FILE(std::move(file_thread_)); | 1247 ResetThread_FILE(std::move(file_thread_), std::move(file_task_runner_)); |
1122 break; | 1248 break; |
1123 } | 1249 } |
1124 case BrowserThread::FILE_USER_BLOCKING: { | 1250 case BrowserThread::FILE_USER_BLOCKING: { |
1125 TRACE_EVENT0("shutdown", | 1251 TRACE_EVENT0("shutdown", |
1126 "BrowserMainLoop::Subsystem:FileUserBlockingThread"); | 1252 "BrowserMainLoop::Subsystem:FileUserBlockingThread"); |
1127 ResetThread_FILE_USER_BLOCKING(std::move(file_user_blocking_thread_)); | 1253 ResetThread_FILE_USER_BLOCKING( |
1254 std::move(file_user_blocking_thread_), | |
1255 std::move(file_user_blocking_task_runner_)); | |
1128 break; | 1256 break; |
1129 } | 1257 } |
1130 case BrowserThread::PROCESS_LAUNCHER: { | 1258 case BrowserThread::PROCESS_LAUNCHER: { |
1131 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:LauncherThread"); | 1259 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:LauncherThread"); |
1132 ResetThread_PROCESS_LAUNCHER(std::move(process_launcher_thread_)); | 1260 ResetThread_PROCESS_LAUNCHER(std::move(process_launcher_thread_), |
1261 std::move(process_launcher_task_runner_)); | |
1133 break; | 1262 break; |
1134 } | 1263 } |
1135 case BrowserThread::CACHE: { | 1264 case BrowserThread::CACHE: { |
1136 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:CacheThread"); | 1265 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:CacheThread"); |
1137 ResetThread_CACHE(std::move(cache_thread_)); | 1266 ResetThread_CACHE(std::move(cache_thread_), |
1267 std::move(cache_task_runner_)); | |
1138 break; | 1268 break; |
1139 } | 1269 } |
1140 case BrowserThread::IO: { | 1270 case BrowserThread::IO: { |
1141 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:IOThread"); | 1271 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:IOThread"); |
1142 ResetThread_IO(std::move(io_thread_)); | 1272 ResetThread_IO(std::move(io_thread_)); |
1143 break; | 1273 break; |
1144 } | 1274 } |
1145 case BrowserThread::UI: | 1275 case BrowserThread::UI: |
1146 case BrowserThread::ID_COUNT: | 1276 case BrowserThread::ID_COUNT: |
1147 default: | |
1148 NOTREACHED(); | 1277 NOTREACHED(); |
1149 break; | 1278 break; |
1150 } | 1279 } |
1151 } | 1280 } |
1152 { | 1281 { |
1153 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:IndexedDBThread"); | 1282 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:IndexedDBThread"); |
1154 ResetThread_IndexedDb(std::move(indexed_db_thread_)); | 1283 ResetThread_IndexedDb(std::move(indexed_db_thread_)); |
1155 } | 1284 } |
1156 | 1285 |
1157 // Close the blocking I/O pool after the other threads. Other threads such | 1286 // Close the blocking I/O pool after the other threads. Other threads such |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1626 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner = | 1755 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner = |
1627 audio_thread_->task_runner(); | 1756 audio_thread_->task_runner(); |
1628 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner), | 1757 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner), |
1629 std::move(worker_task_runner), | 1758 std::move(worker_task_runner), |
1630 MediaInternals::GetInstance()); | 1759 MediaInternals::GetInstance()); |
1631 } | 1760 } |
1632 CHECK(audio_manager_); | 1761 CHECK(audio_manager_); |
1633 } | 1762 } |
1634 | 1763 |
1635 } // namespace content | 1764 } // namespace content |
OLD | NEW |