Chromium Code Reviews| Index: mojo/shell/application_manager.cc |
| diff --git a/mojo/shell/application_manager.cc b/mojo/shell/application_manager.cc |
| index 4602a68ad78860d45eaefb60270d9e4394e18c02..4dc965cb5d8cf438b1776d2ca3496cafbe1f9666 100644 |
| --- a/mojo/shell/application_manager.cc |
| +++ b/mojo/shell/application_manager.cc |
| @@ -290,22 +290,58 @@ void ApplicationManager::HandleFetchCallback( |
| RegisterShell(app_url, qualifier, requestor_url, services.Pass(), |
| exposed_services.Pass(), on_application_end)); |
| + // For resources that are loaded with content handlers, we group app instances |
| + // by site. |
| + |
| // If the response begins with a #!mojo <content-handler-url>, use it. |
| GURL content_handler_url; |
| std::string shebang; |
| if (fetcher->PeekContentHandler(&shebang, &content_handler_url)) { |
| - LoadWithContentHandler( |
| - content_handler_url, requestor_url, qualifier, request.Pass(), |
| - fetcher->AsURLResponse(blocking_pool_, |
| - static_cast<int>(shebang.size()))); |
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableMultiprocess)) { |
|
jam
2015/07/09 22:32:37
why should this behavior change with multiprocess?
|
| + if (!network_service_) |
| + ConnectToService(GURL("mojo:network_service"), &network_service_); |
| + network_service_->GetSiteForURL( |
| + fetcher->GetURL().spec(), |
| + base::Bind(&ApplicationManager::LoadWithContentHandler, |
| + weak_ptr_factory_.GetWeakPtr(), |
| + content_handler_url, |
| + requestor_url, |
| + base::Passed(request.Pass()), |
| + base::Passed(fetcher->AsURLResponse(blocking_pool_, 0)))); |
| + } else { |
| + LoadWithContentHandler( |
| + content_handler_url, requestor_url, |
| + request.Pass(), |
| + fetcher->AsURLResponse(blocking_pool_, |
| + static_cast<int>(shebang.size())), |
| + qualifier); |
| + } |
| return; |
| } |
| MimeTypeToURLMap::iterator iter = mime_type_to_url_.find(fetcher->MimeType()); |
| if (iter != mime_type_to_url_.end()) { |
| - LoadWithContentHandler(iter->second, requestor_url, qualifier, |
| - request.Pass(), |
| - fetcher->AsURLResponse(blocking_pool_, 0)); |
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableMultiprocess)) { |
| + if (!network_service_) |
| + ConnectToService(GURL("mojo:network_service"), &network_service_); |
| + network_service_->GetSiteForURL( |
| + fetcher->GetURL().spec(), |
| + base::Bind(&ApplicationManager::LoadWithContentHandler, |
| + weak_ptr_factory_.GetWeakPtr(), |
| + iter->second, |
| + requestor_url, |
| + base::Passed(request.Pass()), |
| + base::Passed(fetcher->AsURLResponse(blocking_pool_, 0)))); |
| + } else { |
| + LoadWithContentHandler( |
| + iter->second, requestor_url, |
| + request.Pass(), |
| + fetcher->AsURLResponse(blocking_pool_, |
| + static_cast<int>(shebang.size())), |
| + qualifier); |
| + } |
| return; |
| } |
| @@ -330,8 +366,8 @@ void ApplicationManager::HandleFetchCallback( |
| qualifier = alias_iter->second.second; |
| } |
| - LoadWithContentHandler(alias_iter->second.first, requestor_url, qualifier, |
| - request.Pass(), response.Pass()); |
| + LoadWithContentHandler(alias_iter->second.first, requestor_url, |
| + request.Pass(), response.Pass(), qualifier); |
| return; |
| } |
| @@ -403,9 +439,9 @@ void ApplicationManager::RegisterApplicationPackageAlias( |
| void ApplicationManager::LoadWithContentHandler( |
| const GURL& content_handler_url, |
| const GURL& requestor_url, |
| - const std::string& qualifier, |
| InterfaceRequest<Application> application_request, |
| - URLResponsePtr url_response) { |
| + URLResponsePtr url_response, |
| + const std::string& qualifier) { |
| ContentHandlerConnection* connection = nullptr; |
| std::pair<GURL, std::string> key(content_handler_url, qualifier); |
| URLToContentHandlerMap::iterator iter = url_to_content_handler_.find(key); |