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 "mojo/runner/context.h" | 5 #include "mojo/runner/context.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 else | 202 else |
203 runner_factory.reset(new InProcessNativeRunnerFactory(this)); | 203 runner_factory.reset(new InProcessNativeRunnerFactory(this)); |
204 application_manager_->set_blocking_pool(task_runners_->blocking_pool()); | 204 application_manager_->set_blocking_pool(task_runners_->blocking_pool()); |
205 application_manager_->set_native_runner_factory(runner_factory.Pass()); | 205 application_manager_->set_native_runner_factory(runner_factory.Pass()); |
206 | 206 |
207 ServiceProviderPtr service_provider_ptr; | 207 ServiceProviderPtr service_provider_ptr; |
208 ServiceProviderPtr tracing_service_provider_ptr; | 208 ServiceProviderPtr tracing_service_provider_ptr; |
209 new TracingServiceProvider(GetProxy(&tracing_service_provider_ptr)); | 209 new TracingServiceProvider(GetProxy(&tracing_service_provider_ptr)); |
210 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 210 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
211 request->url = mojo::String::From("mojo:tracing"); | 211 request->url = mojo::String::From("mojo:tracing"); |
212 | 212 application_manager_->ConnectToApplication( |
213 scoped_ptr<shell::ConnectToApplicationParams> params( | 213 nullptr, request.Pass(), std::string(), GetProxy(&service_provider_ptr), |
214 new shell::ConnectToApplicationParams); | 214 tracing_service_provider_ptr.Pass(), |
215 params->SetURLInfo(request.Pass()); | 215 shell::GetPermissiveCapabilityFilter(), base::Closure(), |
216 params->set_services(GetProxy(&service_provider_ptr)); | 216 shell::EmptyConnectCallback()); |
217 params->set_exposed_services(tracing_service_provider_ptr.Pass()); | |
218 params->set_filter(shell::GetPermissiveCapabilityFilter()); | |
219 application_manager_->ConnectToApplication(params.Pass()); | |
220 | 217 |
221 // Record the shell startup metrics used for performance testing. | 218 // Record the shell startup metrics used for performance testing. |
222 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 219 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
223 tracing::kEnableStatsCollectionBindings)) { | 220 tracing::kEnableStatsCollectionBindings)) { |
224 tracing::StartupPerformanceDataCollectorPtr collector; | 221 tracing::StartupPerformanceDataCollectorPtr collector; |
225 service_provider_ptr->ConnectToService( | 222 service_provider_ptr->ConnectToService( |
226 tracing::StartupPerformanceDataCollector::Name_, | 223 tracing::StartupPerformanceDataCollector::Name_, |
227 GetProxy(&collector).PassMessagePipe()); | 224 GetProxy(&collector).PassMessagePipe()); |
228 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) | 225 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) |
229 // CurrentProcessInfo::CreationTime is only defined on some platforms. | 226 // CurrentProcessInfo::CreationTime is only defined on some platforms. |
(...skipping 29 matching lines...) Expand all Loading... |
259 } | 256 } |
260 | 257 |
261 void Context::Run(const GURL& url) { | 258 void Context::Run(const GURL& url) { |
262 DCHECK(app_complete_callback_.is_null()); | 259 DCHECK(app_complete_callback_.is_null()); |
263 ServiceProviderPtr services; | 260 ServiceProviderPtr services; |
264 ServiceProviderPtr exposed_services; | 261 ServiceProviderPtr exposed_services; |
265 | 262 |
266 app_urls_.insert(url); | 263 app_urls_.insert(url); |
267 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 264 mojo::URLRequestPtr request(mojo::URLRequest::New()); |
268 request->url = mojo::String::From(url.spec()); | 265 request->url = mojo::String::From(url.spec()); |
269 | 266 application_manager_->ConnectToApplication( |
270 scoped_ptr<shell::ConnectToApplicationParams> params( | 267 nullptr, request.Pass(), std::string(), GetProxy(&services), |
271 new shell::ConnectToApplicationParams); | 268 exposed_services.Pass(), shell::GetPermissiveCapabilityFilter(), |
272 params->SetURLInfo(request.Pass()); | 269 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url), |
273 params->set_services(GetProxy(&services)); | 270 shell::EmptyConnectCallback()); |
274 params->set_exposed_services(exposed_services.Pass()); | |
275 params->set_filter(shell::GetPermissiveCapabilityFilter()); | |
276 params->set_on_application_end( | |
277 base::Bind(&Context::OnApplicationEnd, base::Unretained(this), url)); | |
278 application_manager_->ConnectToApplication(params.Pass()); | |
279 } | 271 } |
280 | 272 |
281 void Context::RunCommandLineApplication(const base::Closure& callback) { | 273 void Context::RunCommandLineApplication(const base::Closure& callback) { |
282 DCHECK(app_urls_.empty()); | 274 DCHECK(app_urls_.empty()); |
283 DCHECK(app_complete_callback_.is_null()); | 275 DCHECK(app_complete_callback_.is_null()); |
284 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 276 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
285 base::CommandLine::StringVector args = command_line->GetArgs(); | 277 base::CommandLine::StringVector args = command_line->GetArgs(); |
286 for (size_t i = 0; i < args.size(); ++i) { | 278 for (size_t i = 0; i < args.size(); ++i) { |
287 GURL possible_app(args[i]); | 279 GURL possible_app(args[i]); |
288 if (possible_app.SchemeIs("mojo")) { | 280 if (possible_app.SchemeIs("mojo")) { |
(...skipping 14 matching lines...) Expand all Loading... |
303 base::MessageLoop::current()->Quit(); | 295 base::MessageLoop::current()->Quit(); |
304 } else { | 296 } else { |
305 app_complete_callback_.Run(); | 297 app_complete_callback_.Run(); |
306 } | 298 } |
307 } | 299 } |
308 } | 300 } |
309 } | 301 } |
310 | 302 |
311 } // namespace runner | 303 } // namespace runner |
312 } // namespace mojo | 304 } // namespace mojo |
OLD | NEW |