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 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1099 // data during shutdown, so the blocking pool needs to be available. There | 1099 // data during shutdown, so the blocking pool needs to be available. There |
1100 // may also be slow operations pending that will blcok shutdown, so closing | 1100 // may also be slow operations pending that will blcok shutdown, so closing |
1101 // it here (which will block until required operations are complete) gives | 1101 // it here (which will block until required operations are complete) gives |
1102 // more head start for those operations to finish. | 1102 // more head start for those operations to finish. |
1103 { | 1103 { |
1104 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:ThreadPool"); | 1104 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:ThreadPool"); |
1105 BrowserThreadImpl::ShutdownThreadPool(); | 1105 BrowserThreadImpl::ShutdownThreadPool(); |
1106 } | 1106 } |
1107 // Must happen after the IO thread is shutdown since this may be accessed from | 1107 // Must happen after the IO thread is shutdown since this may be accessed from |
1108 // it. | 1108 // it. |
1109 { | 1109 if (!shell::ShellIsRemote()) { |
1110 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:GPUChannelFactory"); | 1110 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:GPUChannelFactory"); |
1111 if (BrowserGpuChannelHostFactory::instance()) | 1111 if (BrowserGpuChannelHostFactory::instance()) |
1112 BrowserGpuChannelHostFactory::Terminate(); | 1112 BrowserGpuChannelHostFactory::Terminate(); |
1113 } | 1113 } |
1114 | 1114 |
1115 // Must happen after the I/O thread is shutdown since this class lives on the | 1115 // Must happen after the I/O thread is shutdown since this class lives on the |
1116 // I/O thread and isn't threadsafe. | 1116 // I/O thread and isn't threadsafe. |
1117 { | 1117 { |
1118 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:GamepadService"); | 1118 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:GamepadService"); |
1119 GamepadService::GetInstance()->Terminate(); | 1119 GamepadService::GetInstance()->Terminate(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1168 } | 1168 } |
1169 | 1169 |
1170 mojo_ipc_support_.reset(new mojo::edk::ScopedIPCSupport( | 1170 mojo_ipc_support_.reset(new mojo::edk::ScopedIPCSupport( |
1171 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) | 1171 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) |
1172 ->task_runner())); | 1172 ->task_runner())); |
1173 | 1173 |
1174 mojo_shell_context_.reset(new MojoShellContext); | 1174 mojo_shell_context_.reset(new MojoShellContext); |
1175 #if defined(MOJO_SHELL_CLIENT) && defined(USE_AURA) | 1175 #if defined(MOJO_SHELL_CLIENT) && defined(USE_AURA) |
1176 // TODO(rockot): Remove the blocking wait for init. | 1176 // TODO(rockot): Remove the blocking wait for init. |
1177 // http://crbug.com/594852. | 1177 // http://crbug.com/594852. |
1178 if (shell::ShellIsRemote() && MojoShellConnection::GetForProcess()) | 1178 if (shell::ShellIsRemote() && MojoShellConnection::GetForProcess()) { |
| 1179 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1180 switches::kIsRunningInMash); |
1179 WaitForMojoShellInitialize(); | 1181 WaitForMojoShellInitialize(); |
| 1182 } |
1180 #endif | 1183 #endif |
1181 | 1184 |
1182 #if defined(OS_MACOSX) | 1185 #if defined(OS_MACOSX) |
1183 mojo::edk::SetMachPortProvider(MachBroker::GetInstance()); | 1186 mojo::edk::SetMachPortProvider(MachBroker::GetInstance()); |
1184 #endif // defined(OS_MACOSX) | 1187 #endif // defined(OS_MACOSX) |
1185 | 1188 |
1186 indexed_db_thread_.reset(new base::Thread("IndexedDB")); | 1189 indexed_db_thread_.reset(new base::Thread("IndexedDB")); |
1187 indexed_db_thread_->Start(); | 1190 indexed_db_thread_->Start(); |
1188 | 1191 |
1189 HistogramSynchronizer::GetInstance(); | 1192 HistogramSynchronizer::GetInstance(); |
(...skipping 12 matching lines...) Expand all Loading... |
1202 bool always_uses_gpu = true; | 1205 bool always_uses_gpu = true; |
1203 bool established_gpu_channel = false; | 1206 bool established_gpu_channel = false; |
1204 #if defined(OS_ANDROID) | 1207 #if defined(OS_ANDROID) |
1205 // TODO(crbug.com/439322): This should be set to |true|. | 1208 // TODO(crbug.com/439322): This should be set to |true|. |
1206 established_gpu_channel = false; | 1209 established_gpu_channel = false; |
1207 always_uses_gpu = ShouldStartGpuProcessOnBrowserStartup(); | 1210 always_uses_gpu = ShouldStartGpuProcessOnBrowserStartup(); |
1208 BrowserGpuChannelHostFactory::Initialize(established_gpu_channel); | 1211 BrowserGpuChannelHostFactory::Initialize(established_gpu_channel); |
1209 #elif defined(USE_AURA) || defined(OS_MACOSX) | 1212 #elif defined(USE_AURA) || defined(OS_MACOSX) |
1210 established_gpu_channel = true; | 1213 established_gpu_channel = true; |
1211 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor() || | 1214 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor() || |
1212 parsed_command_line_.HasSwitch(switches::kDisableGpuEarlyInit)) { | 1215 parsed_command_line_.HasSwitch(switches::kDisableGpuEarlyInit) || |
| 1216 shell::ShellIsRemote()) { |
1213 established_gpu_channel = always_uses_gpu = false; | 1217 established_gpu_channel = always_uses_gpu = false; |
1214 } | 1218 } |
1215 BrowserGpuChannelHostFactory::Initialize(established_gpu_channel); | 1219 BrowserGpuChannelHostFactory::Initialize(established_gpu_channel); |
1216 ImageTransportFactory::Initialize(); | 1220 ImageTransportFactory::Initialize(); |
1217 #if defined(USE_AURA) | 1221 #if defined(USE_AURA) |
1218 bool use_mus_in_renderer = false; | 1222 bool use_mus_in_renderer = false; |
1219 #if defined (MOJO_SHELL_CLIENT) | 1223 #if defined (MOJO_SHELL_CLIENT) |
1220 use_mus_in_renderer = base::CommandLine::ForCurrentProcess()->HasSwitch( | 1224 use_mus_in_renderer = base::CommandLine::ForCurrentProcess()->HasSwitch( |
1221 switches::kUseMusInRenderer); | 1225 switches::kUseMusInRenderer); |
1222 #endif // defined(MOJO_SHELL_CLIENT); | 1226 #endif // defined(MOJO_SHELL_CLIENT); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 // On Windows, clipboards are also used on the FILE or IO threads. | 1313 // On Windows, clipboards are also used on the FILE or IO threads. |
1310 allowed_clipboard_threads.push_back(file_thread_->GetThreadId()); | 1314 allowed_clipboard_threads.push_back(file_thread_->GetThreadId()); |
1311 allowed_clipboard_threads.push_back(io_thread_->GetThreadId()); | 1315 allowed_clipboard_threads.push_back(io_thread_->GetThreadId()); |
1312 #endif | 1316 #endif |
1313 ui::Clipboard::SetAllowedThreads(allowed_clipboard_threads); | 1317 ui::Clipboard::SetAllowedThreads(allowed_clipboard_threads); |
1314 | 1318 |
1315 // When running the GPU thread in-process, avoid optimistically starting it | 1319 // When running the GPU thread in-process, avoid optimistically starting it |
1316 // since creating the GPU thread races against creation of the one-and-only | 1320 // since creating the GPU thread races against creation of the one-and-only |
1317 // ChildProcess instance which is created by the renderer thread. | 1321 // ChildProcess instance which is created by the renderer thread. |
1318 if (GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(NULL) && | 1322 if (GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(NULL) && |
1319 !established_gpu_channel && | 1323 !established_gpu_channel && always_uses_gpu && !UsingInProcessGpu() && |
1320 always_uses_gpu && | 1324 !shell::ShellIsRemote()) { |
1321 !UsingInProcessGpu()) { | |
1322 TRACE_EVENT_INSTANT0("gpu", "Post task to launch GPU process", | 1325 TRACE_EVENT_INSTANT0("gpu", "Post task to launch GPU process", |
1323 TRACE_EVENT_SCOPE_THREAD); | 1326 TRACE_EVENT_SCOPE_THREAD); |
1324 BrowserThread::PostTask( | 1327 BrowserThread::PostTask( |
1325 BrowserThread::IO, FROM_HERE, | 1328 BrowserThread::IO, FROM_HERE, |
1326 base::Bind(base::IgnoreResult(&GpuProcessHost::Get), | 1329 base::Bind(base::IgnoreResult(&GpuProcessHost::Get), |
1327 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 1330 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
1328 CAUSE_FOR_GPU_LAUNCH_BROWSER_STARTUP)); | 1331 CAUSE_FOR_GPU_LAUNCH_BROWSER_STARTUP)); |
1329 } | 1332 } |
1330 | 1333 |
1331 #if defined(OS_MACOSX) | 1334 #if defined(OS_MACOSX) |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner = | 1507 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner = |
1505 audio_thread_->task_runner(); | 1508 audio_thread_->task_runner(); |
1506 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner), | 1509 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner), |
1507 std::move(worker_task_runner), | 1510 std::move(worker_task_runner), |
1508 MediaInternals::GetInstance()); | 1511 MediaInternals::GetInstance()); |
1509 } | 1512 } |
1510 CHECK(audio_manager_); | 1513 CHECK(audio_manager_); |
1511 } | 1514 } |
1512 | 1515 |
1513 } // namespace content | 1516 } // namespace content |
OLD | NEW |