OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "shell/context.h" | 5 #include "shell/context.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
| 9 #include "base/base_switches.h" |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
12 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
16 #include "base/strings/string_split.h" | 17 #include "base/strings/string_split.h" |
17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 136 |
136 Context::~Context() { | 137 Context::~Context() { |
137 DCHECK(!base::MessageLoop::current()); | 138 DCHECK(!base::MessageLoop::current()); |
138 } | 139 } |
139 | 140 |
140 void Context::EnsureEmbedderIsInitialized() { | 141 void Context::EnsureEmbedderIsInitialized() { |
141 setup.Get(); | 142 setup.Get(); |
142 } | 143 } |
143 | 144 |
144 bool Context::Init() { | 145 bool Context::Init() { |
| 146 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 147 |
| 148 if (command_line->HasSwitch(switches::kWaitForDebugger)) |
| 149 base::debug::WaitForDebugger(60, true); |
| 150 |
145 EnsureEmbedderIsInitialized(); | 151 EnsureEmbedderIsInitialized(); |
146 task_runners_.reset( | 152 task_runners_.reset( |
147 new TaskRunners(base::MessageLoop::current()->message_loop_proxy())); | 153 new TaskRunners(base::MessageLoop::current()->message_loop_proxy())); |
148 | 154 |
149 for (size_t i = 0; i < arraysize(kLocalMojoURLs); ++i) | 155 for (size_t i = 0; i < arraysize(kLocalMojoURLs); ++i) |
150 mojo_url_resolver_.AddLocalFileMapping(GURL(kLocalMojoURLs[i])); | 156 mojo_url_resolver_.AddLocalFileMapping(GURL(kLocalMojoURLs[i])); |
151 | 157 |
152 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
153 | |
154 if (command_line->HasSwitch(switches::kEnableExternalApplications)) { | 158 if (command_line->HasSwitch(switches::kEnableExternalApplications)) { |
155 listener_ = ExternalApplicationListener::Create( | 159 listener_ = ExternalApplicationListener::Create( |
156 task_runners_->shell_runner(), task_runners_->io_runner()); | 160 task_runners_->shell_runner(), task_runners_->io_runner()); |
157 | 161 |
158 base::FilePath socket_path = | 162 base::FilePath socket_path = |
159 command_line->GetSwitchValuePath(switches::kEnableExternalApplications); | 163 command_line->GetSwitchValuePath(switches::kEnableExternalApplications); |
160 if (socket_path.empty()) | 164 if (socket_path.empty()) |
161 socket_path = ExternalApplicationListener::ConstructDefaultSocketPath(); | 165 socket_path = ExternalApplicationListener::ConstructDefaultSocketPath(); |
162 | 166 |
163 listener_->ListenInBackground( | 167 listener_->ListenInBackground( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 ScopedMessagePipeHandle Context::ConnectToServiceByName( | 227 ScopedMessagePipeHandle Context::ConnectToServiceByName( |
224 const GURL& application_url, | 228 const GURL& application_url, |
225 const std::string& service_name) { | 229 const std::string& service_name) { |
226 app_urls_.insert(application_url); | 230 app_urls_.insert(application_url); |
227 return application_manager_.ConnectToServiceByName(application_url, | 231 return application_manager_.ConnectToServiceByName(application_url, |
228 service_name).Pass(); | 232 service_name).Pass(); |
229 } | 233 } |
230 | 234 |
231 } // namespace shell | 235 } // namespace shell |
232 } // namespace mojo | 236 } // namespace mojo |
OLD | NEW |