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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 130 |
130 Context::~Context() { | 131 Context::~Context() { |
131 DCHECK(!base::MessageLoop::current()); | 132 DCHECK(!base::MessageLoop::current()); |
132 } | 133 } |
133 | 134 |
134 void Context::EnsureEmbedderIsInitialized() { | 135 void Context::EnsureEmbedderIsInitialized() { |
135 setup.Get(); | 136 setup.Get(); |
136 } | 137 } |
137 | 138 |
138 bool Context::Init() { | 139 bool Context::Init() { |
| 140 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 141 |
| 142 if (command_line->HasSwitch(switches::kWaitForDebugger)) |
| 143 base::debug::WaitForDebugger(60, true); |
| 144 |
139 EnsureEmbedderIsInitialized(); | 145 EnsureEmbedderIsInitialized(); |
140 task_runners_.reset( | 146 task_runners_.reset( |
141 new TaskRunners(base::MessageLoop::current()->message_loop_proxy())); | 147 new TaskRunners(base::MessageLoop::current()->message_loop_proxy())); |
142 | 148 |
143 for (size_t i = 0; i < arraysize(kLocalMojoURLs); ++i) | 149 for (size_t i = 0; i < arraysize(kLocalMojoURLs); ++i) |
144 mojo_url_resolver_.AddLocalFileMapping(GURL(kLocalMojoURLs[i])); | 150 mojo_url_resolver_.AddLocalFileMapping(GURL(kLocalMojoURLs[i])); |
145 | 151 |
146 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
147 | |
148 if (command_line->HasSwitch(switches::kEnableExternalApplications)) { | 152 if (command_line->HasSwitch(switches::kEnableExternalApplications)) { |
149 listener_ = ExternalApplicationListener::Create( | 153 listener_ = ExternalApplicationListener::Create( |
150 task_runners_->shell_runner(), task_runners_->io_runner()); | 154 task_runners_->shell_runner(), task_runners_->io_runner()); |
151 | 155 |
152 base::FilePath socket_path = | 156 base::FilePath socket_path = |
153 command_line->GetSwitchValuePath(switches::kEnableExternalApplications); | 157 command_line->GetSwitchValuePath(switches::kEnableExternalApplications); |
154 if (socket_path.empty()) | 158 if (socket_path.empty()) |
155 socket_path = ExternalApplicationListener::ConstructDefaultSocketPath(); | 159 socket_path = ExternalApplicationListener::ConstructDefaultSocketPath(); |
156 | 160 |
157 listener_->ListenInBackground( | 161 listener_->ListenInBackground( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 ScopedMessagePipeHandle Context::ConnectToServiceByName( | 221 ScopedMessagePipeHandle Context::ConnectToServiceByName( |
218 const GURL& application_url, | 222 const GURL& application_url, |
219 const std::string& service_name) { | 223 const std::string& service_name) { |
220 app_urls_.insert(application_url); | 224 app_urls_.insert(application_url); |
221 return application_manager_.ConnectToServiceByName(application_url, | 225 return application_manager_.ConnectToServiceByName(application_url, |
222 service_name).Pass(); | 226 service_name).Pass(); |
223 } | 227 } |
224 | 228 |
225 } // namespace shell | 229 } // namespace shell |
226 } // namespace mojo | 230 } // namespace mojo |
OLD | NEW |