Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(451)

Unified Diff: mojo/shell/application_manager.cc

Issue 1354813002: Revert of Don't use resolved url for instance identity in ApplicationManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/shell/application_manager.h ('k') | mojo/shell/application_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/application_manager.cc
diff --git a/mojo/shell/application_manager.cc b/mojo/shell/application_manager.cc
index 7ca0d392c2ea1c208f3ab120155761e7ab32f01e..715e6e77c7499a044ddefd538fefdd940354d6b7 100644
--- a/mojo/shell/application_manager.cc
+++ b/mojo/shell/application_manager.cc
@@ -73,23 +73,36 @@
void ApplicationManager::ConnectToApplication(
scoped_ptr<ConnectToApplicationParams> params) {
+ GURL original_url = params->app_url();
+ URLRequestPtr original_url_request = params->TakeAppURLRequest();
+
TRACE_EVENT_INSTANT1("mojo_shell", "ApplicationManager::ConnectToApplication",
TRACE_EVENT_SCOPE_THREAD, "original_url",
- params->app_url().spec());
- DCHECK(params->app_url().is_valid());
-
- // Connect to an existing matching instance, if possible.
+ original_url.spec());
+ DCHECK(original_url.is_valid());
+ DCHECK(original_url_request);
+
+ // We need to look for running instances based on both the unresolved and
+ // resolved urls.
if (ConnectToRunningApplication(&params))
return;
- ApplicationLoader* loader = GetLoaderForURL(params->app_url());
+ GURL resolved_url = package_manager_->ResolveURL(original_url);
+ params->SetURLInfo(resolved_url);
+ if (ConnectToRunningApplication(&params))
+ return;
+
+ // The application is not running, let's compute the parameters.
+ // NOTE: Set URL info using |original_url_request| instead of |original_url|
+ // because it may contain more information (e.g., it is a POST request).
+ params->SetURLInfo(original_url_request.Pass());
+ ApplicationLoader* loader = GetLoaderForURL(resolved_url);
if (loader) {
- GURL url = params->app_url();
- loader->Load(url, CreateInstance(params.Pass(), nullptr));
- return;
- }
-
- URLRequestPtr original_url_request = params->TakeAppURLRequest();
+ ConnectToApplicationWithLoader(&params, resolved_url, loader);
+ return;
+ }
+
+ original_url_request = params->TakeAppURLRequest();
auto callback =
base::Bind(&ApplicationManager::HandleFetchCallback,
weak_ptr_factory_.GetWeakPtr(), base::Passed(&params));
@@ -105,6 +118,16 @@
instance->ConnectToClient(params->Pass());
return true;
+}
+
+void ApplicationManager::ConnectToApplicationWithLoader(
+ scoped_ptr<ConnectToApplicationParams>* params,
+ const GURL& resolved_url,
+ ApplicationLoader* loader) {
+ if (!(*params)->app_url().SchemeIs("mojo"))
+ (*params)->SetURLInfo(resolved_url);
+
+ loader->Load(resolved_url, CreateInstance(params->Pass(), nullptr));
}
InterfaceRequest<Application> ApplicationManager::CreateInstance(
@@ -130,8 +153,10 @@
ApplicationInstance* ApplicationManager::GetApplicationInstance(
const Identity& identity) const {
- const auto& it = identity_to_instance_.find(identity);
- return it != identity_to_instance_.end() ? it->second : nullptr;
+ const auto& instance_it = identity_to_instance_.find(identity);
+ if (instance_it != identity_to_instance_.end())
+ return instance_it->second;
+ return nullptr;
}
void ApplicationManager::HandleFetchCallback(
@@ -161,8 +186,14 @@
// We already checked if the application was running before we fetched it, but
// it might have started while the fetch was outstanding. We don't want to
// have two copies of the app running, so check again.
+ //
+ // Also, it's possible the original URL was redirected to an app that is
+ // already running.
if (ConnectToRunningApplication(&params))
return;
+
+ if (params->app_url().scheme() != "mojo")
+ params->SetURLInfo(fetcher->GetURL());
Identity originator_identity = params->originator_identity();
CapabilityFilter originator_filter = params->originator_filter();
« no previous file with comments | « mojo/shell/application_manager.h ('k') | mojo/shell/application_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698