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

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

Issue 2215353004: content: Let embedders know when MojoShellConnection is initialized. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 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 | « content/browser/browser_main_loop.h ('k') | content/public/browser/browser_main_parts.h » ('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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 G_LOG_FLAG_FATAL | 270 G_LOG_FLAG_FATAL |
271 G_LOG_LEVEL_ERROR | 271 G_LOG_LEVEL_ERROR |
272 G_LOG_LEVEL_CRITICAL | 272 G_LOG_LEVEL_CRITICAL |
273 G_LOG_LEVEL_WARNING), 273 G_LOG_LEVEL_WARNING),
274 GLibLogHandler, 274 GLibLogHandler,
275 NULL); 275 NULL);
276 } 276 }
277 } 277 }
278 #endif // defined(USE_GLIB) 278 #endif // defined(USE_GLIB)
279 279
280 #if defined(USE_AURA)
281 void WaitForMojoShellInitialize() {
282 // TODO(rockot): Remove this. http://crbug.com/594852.
283 base::RunLoop wait_loop;
284 MojoShellConnection::GetForProcess()->SetInitializeHandler(
285 wait_loop.QuitClosure());
286 wait_loop.Run();
287 }
288 #endif // defined(USE_AURA)
289
290 void OnStoppedStartupTracing(const base::FilePath& trace_file) { 280 void OnStoppedStartupTracing(const base::FilePath& trace_file) {
291 VLOG(0) << "Completed startup tracing to " << trace_file.value(); 281 VLOG(0) << "Completed startup tracing to " << trace_file.value();
292 } 282 }
293 283
294 // Disable optimizations for this block of functions so the compiler doesn't 284 // Disable optimizations for this block of functions so the compiler doesn't
295 // merge them all together. This makes it possible to tell what thread was 285 // merge them all together. This makes it possible to tell what thread was
296 // unresponsive by inspecting the callstack. 286 // unresponsive by inspecting the callstack.
297 MSVC_DISABLE_OPTIMIZE() 287 MSVC_DISABLE_OPTIMIZE()
298 MSVC_PUSH_DISABLE_WARNING(4748) 288 MSVC_PUSH_DISABLE_WARNING(4748)
299 289
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 base::PlatformThread::SetName("CrBrowserMain"); 1162 base::PlatformThread::SetName("CrBrowserMain");
1173 1163
1174 // Register the main thread by instantiating it, but don't call any methods. 1164 // Register the main thread by instantiating it, but don't call any methods.
1175 main_thread_.reset( 1165 main_thread_.reset(
1176 new BrowserThreadImpl(BrowserThread::UI, base::MessageLoop::current())); 1166 new BrowserThreadImpl(BrowserThread::UI, base::MessageLoop::current()));
1177 } 1167 }
1178 1168
1179 int BrowserMainLoop::BrowserThreadsStarted() { 1169 int BrowserMainLoop::BrowserThreadsStarted() {
1180 TRACE_EVENT0("startup", "BrowserMainLoop::BrowserThreadsStarted"); 1170 TRACE_EVENT0("startup", "BrowserMainLoop::BrowserThreadsStarted");
1181 1171
1182 // Bring up Mojo IPC and shell as early as possible. 1172 // Bring up Mojo IPC and shell as early as possible. Initializaing mojo
1173 // requires the IO thread to have been initialized first. So this cannot
1174 // happen any earlier than this.
1175 InitializeMojo();
1183 1176
1184 if (!parsed_command_line_.HasSwitch(switches::kSingleProcess)) {
1185 // Disallow mojo sync calls in the browser process. Note that we allow sync
1186 // calls in single-process mode since renderer IPCs are made from a browser
1187 // thread.
1188 bool sync_call_allowed = false;
1189 MojoResult result = mojo::edk::SetProperty(
1190 MOJO_PROPERTY_TYPE_SYNC_CALL_ALLOWED, &sync_call_allowed);
1191 DCHECK_EQ(MOJO_RESULT_OK, result);
1192 }
1193
1194 mojo_ipc_support_.reset(new mojo::edk::ScopedIPCSupport(
1195 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO)
1196 ->task_runner()));
1197
1198 mojo_shell_context_.reset(new MojoShellContext);
1199 #if defined(USE_AURA) 1177 #if defined(USE_AURA)
1200 // TODO(rockot): Remove the blocking wait for init. 1178 if (shell::ShellIsRemote()) {
1201 // http://crbug.com/594852.
1202 if (shell::ShellIsRemote() && MojoShellConnection::GetForProcess()) {
1203 base::CommandLine::ForCurrentProcess()->AppendSwitch( 1179 base::CommandLine::ForCurrentProcess()->AppendSwitch(
1204 switches::kIsRunningInMash); 1180 switches::kIsRunningInMash);
1205 WaitForMojoShellInitialize();
1206 } 1181 }
1207 #endif 1182 #endif
1208 1183
1209 #if defined(OS_MACOSX)
1210 mojo::edk::SetMachPortProvider(MachBroker::GetInstance());
1211 #endif // defined(OS_MACOSX)
1212
1213 indexed_db_thread_.reset(new base::Thread("IndexedDB")); 1184 indexed_db_thread_.reset(new base::Thread("IndexedDB"));
1214 indexed_db_thread_->Start(); 1185 indexed_db_thread_->Start();
1215 1186
1216 HistogramSynchronizer::GetInstance(); 1187 HistogramSynchronizer::GetInstance();
1217 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) 1188 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
1218 // Up the priority of the UI thread. 1189 // Up the priority of the UI thread.
1219 base::PlatformThread::SetCurrentThreadPriority(base::ThreadPriority::DISPLAY); 1190 base::PlatformThread::SetCurrentThreadPriority(base::ThreadPriority::DISPLAY);
1220 #endif 1191 #endif
1221 1192
1222 #if defined(ENABLE_VULKAN) 1193 #if defined(ENABLE_VULKAN)
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1417 if (parameters_.ui_task) { 1388 if (parameters_.ui_task) {
1418 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 1389 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
1419 *parameters_.ui_task); 1390 *parameters_.ui_task);
1420 } 1391 }
1421 1392
1422 base::RunLoop run_loop; 1393 base::RunLoop run_loop;
1423 run_loop.Run(); 1394 run_loop.Run();
1424 #endif 1395 #endif
1425 } 1396 }
1426 1397
1398 void BrowserMainLoop::InitializeMojo() {
1399 if (!parsed_command_line_.HasSwitch(switches::kSingleProcess)) {
1400 // Disallow mojo sync calls in the browser process. Note that we allow sync
1401 // calls in single-process mode since renderer IPCs are made from a browser
1402 // thread.
1403 bool sync_call_allowed = false;
1404 MojoResult result = mojo::edk::SetProperty(
1405 MOJO_PROPERTY_TYPE_SYNC_CALL_ALLOWED, &sync_call_allowed);
1406 DCHECK_EQ(MOJO_RESULT_OK, result);
1407 }
1408
1409 mojo_ipc_support_.reset(new mojo::edk::ScopedIPCSupport(
1410 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO)
1411 ->task_runner()));
1412
1413 mojo_shell_context_.reset(new MojoShellContext);
1414 #if defined(OS_MACOSX)
1415 mojo::edk::SetMachPortProvider(MachBroker::GetInstance());
1416 #endif // defined(OS_MACOSX)
1417 if (parts_)
1418 parts_->MojoShellConnectionStarted(MojoShellConnection::GetForProcess());
1419 }
1420
1427 base::FilePath BrowserMainLoop::GetStartupTraceFileName( 1421 base::FilePath BrowserMainLoop::GetStartupTraceFileName(
1428 const base::CommandLine& command_line) const { 1422 const base::CommandLine& command_line) const {
1429 base::FilePath trace_file; 1423 base::FilePath trace_file;
1430 if (command_line.HasSwitch(switches::kTraceStartup)) { 1424 if (command_line.HasSwitch(switches::kTraceStartup)) {
1431 trace_file = command_line.GetSwitchValuePath( 1425 trace_file = command_line.GetSwitchValuePath(
1432 switches::kTraceStartupFile); 1426 switches::kTraceStartupFile);
1433 // trace_file = "none" means that startup events will show up for the next 1427 // trace_file = "none" means that startup events will show up for the next
1434 // begin/end tracing (via about:tracing or AutomationProxy::BeginTracing/ 1428 // begin/end tracing (via about:tracing or AutomationProxy::BeginTracing/
1435 // EndTracing, for example). 1429 // EndTracing, for example).
1436 if (trace_file == base::FilePath().AppendASCII("none")) 1430 if (trace_file == base::FilePath().AppendASCII("none"))
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner = 1508 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner =
1515 audio_thread_->task_runner(); 1509 audio_thread_->task_runner();
1516 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner), 1510 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner),
1517 std::move(worker_task_runner), 1511 std::move(worker_task_runner),
1518 MediaInternals::GetInstance()); 1512 MediaInternals::GetInstance());
1519 } 1513 }
1520 CHECK(audio_manager_); 1514 CHECK(audio_manager_);
1521 } 1515 }
1522 1516
1523 } // namespace content 1517 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | content/public/browser/browser_main_parts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698