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 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1104 // data during shutdown, so the blocking pool needs to be available. There | 1104 // data during shutdown, so the blocking pool needs to be available. There |
1105 // may also be slow operations pending that will blcok shutdown, so closing | 1105 // may also be slow operations pending that will blcok shutdown, so closing |
1106 // it here (which will block until required operations are complete) gives | 1106 // it here (which will block until required operations are complete) gives |
1107 // more head start for those operations to finish. | 1107 // more head start for those operations to finish. |
1108 { | 1108 { |
1109 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:ThreadPool"); | 1109 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:ThreadPool"); |
1110 BrowserThreadImpl::ShutdownThreadPool(); | 1110 BrowserThreadImpl::ShutdownThreadPool(); |
1111 } | 1111 } |
1112 // Must happen after the IO thread is shutdown since this may be accessed from | 1112 // Must happen after the IO thread is shutdown since this may be accessed from |
1113 // it. | 1113 // it. |
1114 { | 1114 if (!shell::ShellIsRemote()) { |
1115 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:GPUChannelFactory"); | 1115 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:GPUChannelFactory"); |
1116 if (BrowserGpuChannelHostFactory::instance()) | 1116 if (BrowserGpuChannelHostFactory::instance()) |
1117 BrowserGpuChannelHostFactory::Terminate(); | 1117 BrowserGpuChannelHostFactory::Terminate(); |
1118 } | 1118 } |
1119 | 1119 |
1120 // Must happen after the I/O thread is shutdown since this class lives on the | 1120 // Must happen after the I/O thread is shutdown since this class lives on the |
1121 // I/O thread and isn't threadsafe. | 1121 // I/O thread and isn't threadsafe. |
1122 { | 1122 { |
1123 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:GamepadService"); | 1123 TRACE_EVENT0("shutdown", "BrowserMainLoop::Subsystem:GamepadService"); |
1124 GamepadService::GetInstance()->Terminate(); | 1124 GamepadService::GetInstance()->Terminate(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1168 MOJO_PROPERTY_TYPE_SYNC_CALL_ALLOWED, &sync_call_allowed); | 1168 MOJO_PROPERTY_TYPE_SYNC_CALL_ALLOWED, &sync_call_allowed); |
1169 DCHECK_EQ(MOJO_RESULT_OK, result); | 1169 DCHECK_EQ(MOJO_RESULT_OK, result); |
1170 | 1170 |
1171 mojo_ipc_support_.reset(new mojo::edk::ScopedIPCSupport( | 1171 mojo_ipc_support_.reset(new mojo::edk::ScopedIPCSupport( |
1172 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) | 1172 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) |
1173 ->task_runner())); | 1173 ->task_runner())); |
1174 | 1174 |
1175 mojo_shell_context_.reset(new MojoShellContext); | 1175 mojo_shell_context_.reset(new MojoShellContext); |
1176 if (shell::ShellIsRemote()) { | 1176 if (shell::ShellIsRemote()) { |
1177 #if defined(MOJO_SHELL_CLIENT) && defined(USE_AURA) | 1177 #if defined(MOJO_SHELL_CLIENT) && defined(USE_AURA) |
| 1178 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1179 switches::kIsRunningInMash); |
1178 // TODO(rockot): Remove the blocking wait for init. | 1180 // TODO(rockot): Remove the blocking wait for init. |
1179 // http://crbug.com/594852. | 1181 // http://crbug.com/594852. |
1180 auto connection = MojoShellConnection::GetForProcess(); | 1182 auto connection = MojoShellConnection::GetForProcess(); |
1181 if (connection) { | 1183 if (connection) { |
1182 WaitForMojoShellInitialize(); | 1184 WaitForMojoShellInitialize(); |
1183 ui::GpuService::Initialize(connection->GetConnector()); | 1185 ui::GpuService::Initialize(connection->GetConnector()); |
1184 } | 1186 } |
1185 #endif | 1187 #endif |
1186 } | 1188 } |
1187 | 1189 |
(...skipping 20 matching lines...) Expand all Loading... |
1208 bool always_uses_gpu = true; | 1210 bool always_uses_gpu = true; |
1209 bool established_gpu_channel = false; | 1211 bool established_gpu_channel = false; |
1210 #if defined(OS_ANDROID) | 1212 #if defined(OS_ANDROID) |
1211 // TODO(crbug.com/439322): This should be set to |true|. | 1213 // TODO(crbug.com/439322): This should be set to |true|. |
1212 established_gpu_channel = false; | 1214 established_gpu_channel = false; |
1213 always_uses_gpu = ShouldStartGpuProcessOnBrowserStartup(); | 1215 always_uses_gpu = ShouldStartGpuProcessOnBrowserStartup(); |
1214 BrowserGpuChannelHostFactory::Initialize(established_gpu_channel); | 1216 BrowserGpuChannelHostFactory::Initialize(established_gpu_channel); |
1215 #elif defined(USE_AURA) || defined(OS_MACOSX) | 1217 #elif defined(USE_AURA) || defined(OS_MACOSX) |
1216 established_gpu_channel = true; | 1218 established_gpu_channel = true; |
1217 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor() || | 1219 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor() || |
1218 parsed_command_line_.HasSwitch(switches::kDisableGpuEarlyInit)) { | 1220 parsed_command_line_.HasSwitch(switches::kDisableGpuEarlyInit) || |
| 1221 shell::ShellIsRemote()) { |
1219 established_gpu_channel = always_uses_gpu = false; | 1222 established_gpu_channel = always_uses_gpu = false; |
1220 } | 1223 } |
1221 BrowserGpuChannelHostFactory::Initialize(established_gpu_channel); | 1224 BrowserGpuChannelHostFactory::Initialize(established_gpu_channel); |
1222 ImageTransportFactory::Initialize(); | 1225 ImageTransportFactory::Initialize(); |
1223 #if defined(USE_AURA) | 1226 #if defined(USE_AURA) |
1224 bool use_mus_in_renderer = false; | 1227 bool use_mus_in_renderer = false; |
1225 #if defined (MOJO_SHELL_CLIENT) | 1228 #if defined (MOJO_SHELL_CLIENT) |
1226 use_mus_in_renderer = base::CommandLine::ForCurrentProcess()->HasSwitch( | 1229 use_mus_in_renderer = base::CommandLine::ForCurrentProcess()->HasSwitch( |
1227 switches::kUseMusInRenderer); | 1230 switches::kUseMusInRenderer); |
1228 #endif // defined(MOJO_SHELL_CLIENT); | 1231 #endif // defined(MOJO_SHELL_CLIENT); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1315 // On Windows, clipboards are also used on the FILE or IO threads. | 1318 // On Windows, clipboards are also used on the FILE or IO threads. |
1316 allowed_clipboard_threads.push_back(file_thread_->GetThreadId()); | 1319 allowed_clipboard_threads.push_back(file_thread_->GetThreadId()); |
1317 allowed_clipboard_threads.push_back(io_thread_->GetThreadId()); | 1320 allowed_clipboard_threads.push_back(io_thread_->GetThreadId()); |
1318 #endif | 1321 #endif |
1319 ui::Clipboard::SetAllowedThreads(allowed_clipboard_threads); | 1322 ui::Clipboard::SetAllowedThreads(allowed_clipboard_threads); |
1320 | 1323 |
1321 // When running the GPU thread in-process, avoid optimistically starting it | 1324 // When running the GPU thread in-process, avoid optimistically starting it |
1322 // since creating the GPU thread races against creation of the one-and-only | 1325 // since creating the GPU thread races against creation of the one-and-only |
1323 // ChildProcess instance which is created by the renderer thread. | 1326 // ChildProcess instance which is created by the renderer thread. |
1324 if (GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(NULL) && | 1327 if (GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(NULL) && |
1325 !established_gpu_channel && | 1328 !established_gpu_channel && always_uses_gpu && !UsingInProcessGpu() && |
1326 always_uses_gpu && | 1329 !shell::ShellIsRemote()) { |
1327 !UsingInProcessGpu()) { | |
1328 TRACE_EVENT_INSTANT0("gpu", "Post task to launch GPU process", | 1330 TRACE_EVENT_INSTANT0("gpu", "Post task to launch GPU process", |
1329 TRACE_EVENT_SCOPE_THREAD); | 1331 TRACE_EVENT_SCOPE_THREAD); |
1330 BrowserThread::PostTask( | 1332 BrowserThread::PostTask( |
1331 BrowserThread::IO, FROM_HERE, | 1333 BrowserThread::IO, FROM_HERE, |
1332 base::Bind(base::IgnoreResult(&GpuProcessHost::Get), | 1334 base::Bind(base::IgnoreResult(&GpuProcessHost::Get), |
1333 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 1335 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
1334 CAUSE_FOR_GPU_LAUNCH_BROWSER_STARTUP)); | 1336 CAUSE_FOR_GPU_LAUNCH_BROWSER_STARTUP)); |
1335 } | 1337 } |
1336 | 1338 |
1337 #if defined(OS_MACOSX) | 1339 #if defined(OS_MACOSX) |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 std::move(worker_task_runner), | 1519 std::move(worker_task_runner), |
1518 MediaInternals::GetInstance()); | 1520 MediaInternals::GetInstance()); |
1519 } | 1521 } |
1520 CHECK(audio_manager_); | 1522 CHECK(audio_manager_); |
1521 | 1523 |
1522 if (use_hang_monitor) | 1524 if (use_hang_monitor) |
1523 media::AudioManager::StartHangMonitor(io_thread_->task_runner()); | 1525 media::AudioManager::StartHangMonitor(io_thread_->task_runner()); |
1524 } | 1526 } |
1525 | 1527 |
1526 } // namespace content | 1528 } // namespace content |
OLD | NEW |