| 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 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 if (redirect_thread) { | 1042 if (redirect_thread) { |
| 1043 non_ui_non_io_task_runner_traits = kUserBlockingTraits; | 1043 non_ui_non_io_task_runner_traits = kUserBlockingTraits; |
| 1044 } else { | 1044 } else { |
| 1045 thread_to_start = &file_user_blocking_thread_; | 1045 thread_to_start = &file_user_blocking_thread_; |
| 1046 } | 1046 } |
| 1047 break; | 1047 break; |
| 1048 case BrowserThread::FILE: | 1048 case BrowserThread::FILE: |
| 1049 TRACE_EVENT_BEGIN1("startup", | 1049 TRACE_EVENT_BEGIN1("startup", |
| 1050 "BrowserMainLoop::CreateThreads:start", | 1050 "BrowserMainLoop::CreateThreads:start", |
| 1051 "Thread", "BrowserThread::FILE"); | 1051 "Thread", "BrowserThread::FILE"); |
| 1052 | |
| 1053 #if defined(OS_WIN) | |
| 1054 // On Windows, the FILE thread needs to have a UI message loop which | |
| 1055 // pumps messages in such a way that Google Update can communicate back | |
| 1056 // to us. | |
| 1057 // TODO(robliao): Need to support COM in TaskScheduler before | |
| 1058 // redirecting the FILE thread on Windows. http://crbug.com/662122 | |
| 1059 thread_to_start = &file_thread_; | |
| 1060 options = ui_message_loop_options; | |
| 1061 options.timer_slack = base::TIMER_SLACK_MAXIMUM; | |
| 1062 #else | |
| 1063 if (redirect_thread) { | 1052 if (redirect_thread) { |
| 1064 non_ui_non_io_task_runner_traits = kUserVisibleTraits; | 1053 non_ui_non_io_task_runner_traits = kUserVisibleTraits; |
| 1065 } else { | 1054 } else { |
| 1066 thread_to_start = &file_thread_; | 1055 thread_to_start = &file_thread_; |
| 1067 options = io_message_loop_options; | 1056 options = io_message_loop_options; |
| 1068 options.timer_slack = base::TIMER_SLACK_MAXIMUM; | 1057 options.timer_slack = base::TIMER_SLACK_MAXIMUM; |
| 1069 } | 1058 } |
| 1070 #endif | |
| 1071 break; | 1059 break; |
| 1072 case BrowserThread::PROCESS_LAUNCHER: | 1060 case BrowserThread::PROCESS_LAUNCHER: |
| 1073 TRACE_EVENT_BEGIN1("startup", | 1061 TRACE_EVENT_BEGIN1("startup", |
| 1074 "BrowserMainLoop::CreateThreads:start", | 1062 "BrowserMainLoop::CreateThreads:start", |
| 1075 "Thread", "BrowserThread::PROCESS_LAUNCHER"); | 1063 "Thread", "BrowserThread::PROCESS_LAUNCHER"); |
| 1076 #if defined(OS_ANDROID) | 1064 #if defined(OS_ANDROID) |
| 1077 // Android specializes Launcher thread so it is accessible in java. | 1065 // Android specializes Launcher thread so it is accessible in java. |
| 1078 // Note Android never does clean shutdown, so shutdown use-after-free | 1066 // Note Android never does clean shutdown, so shutdown use-after-free |
| 1079 // concerns are not a problem in practice. | 1067 // concerns are not a problem in practice. |
| 1080 redirect_thread = false; | 1068 redirect_thread = false; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1131 BrowserThread::ID id = static_cast<BrowserThread::ID>(thread_id); | 1119 BrowserThread::ID id = static_cast<BrowserThread::ID>(thread_id); |
| 1132 | 1120 |
| 1133 if (thread_to_start) { | 1121 if (thread_to_start) { |
| 1134 (*thread_to_start) | 1122 (*thread_to_start) |
| 1135 .reset(message_loop ? new BrowserProcessSubThread(id, message_loop) | 1123 .reset(message_loop ? new BrowserProcessSubThread(id, message_loop) |
| 1136 : new BrowserProcessSubThread(id)); | 1124 : new BrowserProcessSubThread(id)); |
| 1137 // Start the thread if an existing |message_loop| wasn't provided. | 1125 // Start the thread if an existing |message_loop| wasn't provided. |
| 1138 if (!message_loop && !(*thread_to_start)->StartWithOptions(options)) | 1126 if (!message_loop && !(*thread_to_start)->StartWithOptions(options)) |
| 1139 LOG(FATAL) << "Failed to start the browser thread: id == " << id; | 1127 LOG(FATAL) << "Failed to start the browser thread: id == " << id; |
| 1140 } else { | 1128 } else { |
| 1141 scoped_refptr<base::SingleThreadTaskRunner> redirection_task_runner = | 1129 scoped_refptr<base::SingleThreadTaskRunner> redirection_task_runner; |
| 1142 base::CreateSingleThreadTaskRunnerWithTraits( | 1130 #if defined(OS_WIN) |
| 1143 non_ui_non_io_task_runner_traits); | 1131 // On Windows, the FILE thread needs to have a UI message loop which |
| 1132 // pumps messages in such a way that Google Update can communicate back |
| 1133 // to us. The COM STA task runner provides this service. |
| 1134 redirection_task_runner = |
| 1135 (thread_id == BrowserThread::FILE) |
| 1136 ? base::CreateCOMSTATaskRunnerWithTraits( |
| 1137 non_ui_non_io_task_runner_traits) |
| 1138 : base::CreateSingleThreadTaskRunnerWithTraits( |
| 1139 non_ui_non_io_task_runner_traits); |
| 1140 #else // defined(OS_WIN) |
| 1141 redirection_task_runner = base::CreateSingleThreadTaskRunnerWithTraits( |
| 1142 non_ui_non_io_task_runner_traits); |
| 1143 #endif // defined(OS_WIN) |
| 1144 DCHECK(redirection_task_runner); | 1144 DCHECK(redirection_task_runner); |
| 1145 BrowserThreadImpl::RedirectThreadIDToTaskRunner( | 1145 BrowserThreadImpl::RedirectThreadIDToTaskRunner( |
| 1146 id, std::move(redirection_task_runner)); | 1146 id, std::move(redirection_task_runner)); |
| 1147 } | 1147 } |
| 1148 | 1148 |
| 1149 TRACE_EVENT_END0("startup", "BrowserMainLoop::CreateThreads:start"); | 1149 TRACE_EVENT_END0("startup", "BrowserMainLoop::CreateThreads:start"); |
| 1150 } | 1150 } |
| 1151 created_threads_ = true; | 1151 created_threads_ = true; |
| 1152 return result_code_; | 1152 return result_code_; |
| 1153 } | 1153 } |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1771 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), | 1771 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), |
| 1772 MediaInternals::GetInstance()); | 1772 MediaInternals::GetInstance()); |
| 1773 } | 1773 } |
| 1774 CHECK(audio_manager_); | 1774 CHECK(audio_manager_); |
| 1775 | 1775 |
| 1776 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get()); | 1776 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get()); |
| 1777 CHECK(audio_system_); | 1777 CHECK(audio_system_); |
| 1778 } | 1778 } |
| 1779 | 1779 |
| 1780 } // namespace content | 1780 } // namespace content |
| OLD | NEW |