| 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 <utility> | 10 #include <utility> |
| 11 #include <vector> |
| 10 | 12 |
| 11 #include "base/bind.h" | 13 #include "base/bind.h" |
| 12 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 13 #include "base/feature_list.h" | 15 #include "base/feature_list.h" |
| 14 #include "base/location.h" | 16 #include "base/location.h" |
| 15 #include "base/logging.h" | 17 #include "base/logging.h" |
| 16 #include "base/macros.h" | 18 #include "base/macros.h" |
| 17 #include "base/memory/memory_pressure_monitor.h" | 19 #include "base/memory/memory_pressure_monitor.h" |
| 18 #include "base/memory/ptr_util.h" | 20 #include "base/memory/ptr_util.h" |
| 19 #include "base/metrics/field_trial.h" | 21 #include "base/metrics/field_trial.h" |
| (...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 NOTREACHED(); | 903 NOTREACHED(); |
| 902 } | 904 } |
| 903 | 905 |
| 904 TRACE_EVENT_END0("startup", "BrowserMainLoop::CreateThreads:start"); | 906 TRACE_EVENT_END0("startup", "BrowserMainLoop::CreateThreads:start"); |
| 905 } | 907 } |
| 906 created_threads_ = true; | 908 created_threads_ = true; |
| 907 return result_code_; | 909 return result_code_; |
| 908 } | 910 } |
| 909 | 911 |
| 910 int BrowserMainLoop::PreMainMessageLoopRun() { | 912 int BrowserMainLoop::PreMainMessageLoopRun() { |
| 911 if (IsRunningInMojoShell()) { | |
| 912 if (!MojoShellConnectionImpl::CreateUsingFactory()) { | |
| 913 mojo::edk::SetParentPipeHandleFromCommandLine(); | |
| 914 MojoShellConnectionImpl::Create(); | |
| 915 MojoShellConnectionImpl::Get()->BindToRequestFromCommandLine(); | |
| 916 } | |
| 917 #if defined(MOJO_SHELL_CLIENT) && defined(USE_AURA) | |
| 918 if (MojoShellConnection::Get()) { | |
| 919 views::WindowManagerConnection::Create( | |
| 920 MojoShellConnection::Get()->GetConnector()); | |
| 921 } | |
| 922 #endif | |
| 923 } | |
| 924 | |
| 925 if (parts_) { | 913 if (parts_) { |
| 926 TRACE_EVENT0("startup", | 914 TRACE_EVENT0("startup", |
| 927 "BrowserMainLoop::CreateThreads:PreMainMessageLoopRun"); | 915 "BrowserMainLoop::CreateThreads:PreMainMessageLoopRun"); |
| 928 TRACK_SCOPED_REGION( | 916 TRACK_SCOPED_REGION( |
| 929 "Startup", "BrowserMainLoop::PreMainMessageLoopRun"); | 917 "Startup", "BrowserMainLoop::PreMainMessageLoopRun"); |
| 930 | 918 |
| 931 parts_->PreMainMessageLoopRun(); | 919 parts_->PreMainMessageLoopRun(); |
| 932 } | 920 } |
| 933 | 921 |
| 934 // If the UI thread blocks, the whole UI is unresponsive. | 922 // If the UI thread blocks, the whole UI is unresponsive. |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 new BrowserThreadImpl(BrowserThread::UI, base::MessageLoop::current())); | 1153 new BrowserThreadImpl(BrowserThread::UI, base::MessageLoop::current())); |
| 1166 } | 1154 } |
| 1167 | 1155 |
| 1168 int BrowserMainLoop::BrowserThreadsStarted() { | 1156 int BrowserMainLoop::BrowserThreadsStarted() { |
| 1169 TRACE_EVENT0("startup", "BrowserMainLoop::BrowserThreadsStarted"); | 1157 TRACE_EVENT0("startup", "BrowserMainLoop::BrowserThreadsStarted"); |
| 1170 | 1158 |
| 1171 // Bring up Mojo IPC and shell as early as possible. | 1159 // Bring up Mojo IPC and shell as early as possible. |
| 1172 mojo_ipc_support_.reset(new IPC::ScopedIPCSupport( | 1160 mojo_ipc_support_.reset(new IPC::ScopedIPCSupport( |
| 1173 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) | 1161 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO) |
| 1174 ->task_runner())); | 1162 ->task_runner())); |
| 1163 |
| 1164 if (IsRunningInMojoShell()) { |
| 1165 if (!MojoShellConnectionImpl::CreateUsingFactory()) { |
| 1166 mojo::edk::SetParentPipeHandleFromCommandLine(); |
| 1167 MojoShellConnectionImpl::Create(); |
| 1168 MojoShellConnectionImpl::Get()->BindToRequestFromCommandLine(); |
| 1169 } |
| 1170 #if defined(MOJO_SHELL_CLIENT) && defined(USE_AURA) |
| 1171 if (MojoShellConnection::Get()) { |
| 1172 views::WindowManagerConnection::Create( |
| 1173 MojoShellConnection::Get()->GetConnector()); |
| 1174 } |
| 1175 #endif |
| 1176 } |
| 1177 |
| 1175 mojo_shell_context_.reset(new MojoShellContext); | 1178 mojo_shell_context_.reset(new MojoShellContext); |
| 1176 #if defined(OS_MACOSX) | 1179 #if defined(OS_MACOSX) |
| 1177 mojo::edk::SetMachPortProvider(MachBroker::GetInstance()); | 1180 mojo::edk::SetMachPortProvider(MachBroker::GetInstance()); |
| 1178 #endif // defined(OS_MACOSX) | 1181 #endif // defined(OS_MACOSX) |
| 1179 | 1182 |
| 1180 indexed_db_thread_.reset(new base::Thread("IndexedDB")); | 1183 indexed_db_thread_.reset(new base::Thread("IndexedDB")); |
| 1181 indexed_db_thread_->Start(); | 1184 indexed_db_thread_->Start(); |
| 1182 | 1185 |
| 1183 HistogramSynchronizer::GetInstance(); | 1186 HistogramSynchronizer::GetInstance(); |
| 1184 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | 1187 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1449 DCHECK(is_tracing_startup_for_duration_); | 1452 DCHECK(is_tracing_startup_for_duration_); |
| 1450 | 1453 |
| 1451 is_tracing_startup_for_duration_ = false; | 1454 is_tracing_startup_for_duration_ = false; |
| 1452 TracingController::GetInstance()->StopTracing( | 1455 TracingController::GetInstance()->StopTracing( |
| 1453 TracingController::CreateFileSink( | 1456 TracingController::CreateFileSink( |
| 1454 startup_trace_file_, | 1457 startup_trace_file_, |
| 1455 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); | 1458 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); |
| 1456 } | 1459 } |
| 1457 | 1460 |
| 1458 } // namespace content | 1461 } // namespace content |
| OLD | NEW |