| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/shell/application_manager.h" | 5 #include "mojo/shell/application_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 return; | 283 return; |
| 284 } | 284 } |
| 285 | 285 |
| 286 const GURL app_url = | 286 const GURL app_url = |
| 287 requested_url.scheme() == "mojo" ? requested_url : fetcher->GetURL(); | 287 requested_url.scheme() == "mojo" ? requested_url : fetcher->GetURL(); |
| 288 | 288 |
| 289 InterfaceRequest<Application> request( | 289 InterfaceRequest<Application> request( |
| 290 RegisterShell(app_url, qualifier, requestor_url, services.Pass(), | 290 RegisterShell(app_url, qualifier, requestor_url, services.Pass(), |
| 291 exposed_services.Pass(), on_application_end)); | 291 exposed_services.Pass(), on_application_end)); |
| 292 | 292 |
| 293 // For resources that are loaded with content handlers, we group app instances |
| 294 // by site. |
| 295 |
| 293 // If the response begins with a #!mojo <content-handler-url>, use it. | 296 // If the response begins with a #!mojo <content-handler-url>, use it. |
| 294 GURL content_handler_url; | 297 GURL content_handler_url; |
| 295 std::string shebang; | 298 std::string shebang; |
| 299 bool enable_multi_process = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 300 switches::kEnableMultiprocess); |
| 301 |
| 296 if (fetcher->PeekContentHandler(&shebang, &content_handler_url)) { | 302 if (fetcher->PeekContentHandler(&shebang, &content_handler_url)) { |
| 297 LoadWithContentHandler( | 303 URLResponsePtr response(fetcher->AsURLResponse( |
| 298 content_handler_url, requestor_url, qualifier, request.Pass(), | 304 blocking_pool_, static_cast<int>(shebang.size()))); |
| 299 fetcher->AsURLResponse(blocking_pool_, | 305 std::string site = |
| 300 static_cast<int>(shebang.size()))); | 306 enable_multi_process ? response->site.To<std::string>() : std::string(); |
| 307 LoadWithContentHandler(content_handler_url, requestor_url, site, |
| 308 request.Pass(), response.Pass()); |
| 301 return; | 309 return; |
| 302 } | 310 } |
| 303 | 311 |
| 304 MimeTypeToURLMap::iterator iter = mime_type_to_url_.find(fetcher->MimeType()); | 312 MimeTypeToURLMap::iterator iter = mime_type_to_url_.find(fetcher->MimeType()); |
| 305 if (iter != mime_type_to_url_.end()) { | 313 if (iter != mime_type_to_url_.end()) { |
| 306 LoadWithContentHandler(iter->second, requestor_url, qualifier, | 314 URLResponsePtr response(fetcher->AsURLResponse(blocking_pool_, 0)); |
| 307 request.Pass(), | 315 std::string site = |
| 308 fetcher->AsURLResponse(blocking_pool_, 0)); | 316 enable_multi_process ? response->site.To<std::string>() : std::string(); |
| 317 LoadWithContentHandler(iter->second, requestor_url, site, request.Pass(), |
| 318 response.Pass()); |
| 309 return; | 319 return; |
| 310 } | 320 } |
| 311 | 321 |
| 312 auto alias_iter = application_package_alias_.find(app_url); | 322 auto alias_iter = application_package_alias_.find(app_url); |
| 313 if (alias_iter != application_package_alias_.end()) { | 323 if (alias_iter != application_package_alias_.end()) { |
| 314 // We replace the qualifier with the one our package alias requested. | 324 // We replace the qualifier with the one our package alias requested. |
| 315 URLResponsePtr response(URLResponse::New()); | 325 URLResponsePtr response(URLResponse::New()); |
| 316 response->url = String::From(app_url.spec()); | 326 response->url = String::From(app_url.spec()); |
| 317 | 327 |
| 318 std::string qualifier; | 328 std::string qualifier; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 return pipe.handle0.Pass(); | 509 return pipe.handle0.Pass(); |
| 500 } | 510 } |
| 501 | 511 |
| 502 void ApplicationManager::CleanupRunner(NativeRunner* runner) { | 512 void ApplicationManager::CleanupRunner(NativeRunner* runner) { |
| 503 native_runners_.erase( | 513 native_runners_.erase( |
| 504 std::find(native_runners_.begin(), native_runners_.end(), runner)); | 514 std::find(native_runners_.begin(), native_runners_.end(), runner)); |
| 505 } | 515 } |
| 506 | 516 |
| 507 } // namespace shell | 517 } // namespace shell |
| 508 } // namespace mojo | 518 } // namespace mojo |
| OLD | NEW |