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

Unified Diff: mojo/application_manager/application_manager.cc

Issue 741453002: Make sure that Content Handled application can be connected multiple times. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
Index: mojo/application_manager/application_manager.cc
diff --git a/mojo/application_manager/application_manager.cc b/mojo/application_manager/application_manager.cc
index e99c627cf74cfeca6e60b1230856e23d25152136..494128f8239779cd0a9073ba48a1e5042f070f51 100644
--- a/mojo/application_manager/application_manager.cc
+++ b/mojo/application_manager/application_manager.cc
@@ -53,50 +53,22 @@ GURL ApplicationManager::Delegate::ResolveURL(const GURL& url) {
class ApplicationManager::LoadCallbacksImpl
: public ApplicationLoader::LoadCallbacks {
public:
- LoadCallbacksImpl(base::WeakPtr<ApplicationManager> manager,
- const GURL& requested_url,
- const GURL& resolved_url,
- const GURL& requestor_url,
- ServiceProviderPtr service_provider)
- : manager_(manager),
- requested_url_(requested_url),
- resolved_url_(resolved_url),
- requestor_url_(requestor_url),
- service_provider_(service_provider.Pass()) {}
+ LoadCallbacksImpl(base::WeakPtr<ApplicationManager> manager)
+ : manager_(manager) {}
DaveMoore 2014/11/18 17:00:45 The changes simplified the code in application_man
private:
~LoadCallbacksImpl() override {}
- // LoadCallbacks implementation
- ScopedMessagePipeHandle RegisterApplication() override {
- ScopedMessagePipeHandle shell_handle;
- if (manager_) {
- manager_->RegisterLoadedApplication(requested_url_,
- resolved_url_,
- requestor_url_,
- service_provider_.Pass(),
- &shell_handle);
- }
- return shell_handle.Pass();
- }
-
void LoadWithContentHandler(const GURL& content_handler_url,
+ ScopedMessagePipeHandle shell_handle,
URLResponsePtr url_response) override {
if (manager_) {
- manager_->LoadWithContentHandler(requested_url_,
- resolved_url_,
- requestor_url_,
- content_handler_url,
- url_response.Pass(),
- service_provider_.Pass());
+ manager_->LoadWithContentHandler(content_handler_url, shell_handle.Pass(),
+ url_response.Pass());
}
}
base::WeakPtr<ApplicationManager> manager_;
- GURL requested_url_;
- GURL resolved_url_;
- GURL requestor_url_;
- ServiceProviderPtr service_provider_;
};
class ApplicationManager::ShellImpl : public Shell, public ErrorHandler {
@@ -250,24 +222,28 @@ void ApplicationManager::ConnectToApplication(
}
void ApplicationManager::ConnectToApplicationImpl(
- const GURL& requested_url, const GURL& resolved_url,
- const GURL& requestor_url, ServiceProviderPtr service_provider,
+ const GURL& requested_url,
+ const GURL& resolved_url,
+ const GURL& requestor_url,
+ ServiceProviderPtr service_provider,
ApplicationLoader* loader) {
+ ShellImpl* shell = nullptr;
URLToShellImplMap::const_iterator shell_it =
url_to_shell_impl_.find(resolved_url);
if (shell_it != url_to_shell_impl_.end()) {
- ConnectToClient(shell_it->second, resolved_url, requestor_url,
- service_provider.Pass());
- return;
+ shell = shell_it->second;
+ } else {
+ MessagePipe pipe;
+ shell =
+ new ShellImpl(pipe.handle0.Pass(), this, requested_url, resolved_url);
Aaron Boodman 2014/11/19 01:47:24 Argh, I just realized we can't make this simplific
qsr 2014/11/19 13:42:37 I guess you mean it has to be treated identically
Aaron Boodman 2014/11/19 15:58:15 Yes.
qsr 2014/11/19 16:37:21 Only for content handled app. For usual app, we ha
Aaron Boodman 2014/11/20 00:59:01 OK, I don't follow exactly why this changes whethe
+ url_to_shell_impl_[resolved_url] = shell;
+ shell->client()->Initialize(GetArgsForURL(requested_url));
+
+ scoped_refptr<LoadCallbacksImpl> callbacks(
+ new LoadCallbacksImpl(weak_ptr_factory_.GetWeakPtr()));
+ loader->Load(this, resolved_url, pipe.handle1.Pass(), callbacks);
}
-
- scoped_refptr<LoadCallbacksImpl> callbacks(
- new LoadCallbacksImpl(weak_ptr_factory_.GetWeakPtr(),
- requested_url,
- resolved_url,
- requestor_url,
- service_provider.Pass()));
- loader->Load(this, resolved_url, callbacks);
+ ConnectToClient(shell, resolved_url, requestor_url, service_provider.Pass());
}
void ApplicationManager::ConnectToClient(ShellImpl* shell_impl,
@@ -296,39 +272,10 @@ void ApplicationManager::RegisterExternalApplication(
shell_impl->client()->Initialize(args.Pass());
}
-void ApplicationManager::RegisterLoadedApplication(
- const GURL& requested_url,
- const GURL& resolved_url,
- const GURL& requestor_url,
- ServiceProviderPtr service_provider,
- ScopedMessagePipeHandle* shell_handle) {
- ShellImpl* shell_impl = NULL;
- URLToShellImplMap::iterator iter = url_to_shell_impl_.find(resolved_url);
- if (iter != url_to_shell_impl_.end()) {
- // This can happen because services are loaded asynchronously. So if we get
- // two requests for the same service close to each other, we might get here
- // and find that we already have it.
- shell_impl = iter->second;
- } else {
- MessagePipe pipe;
- shell_impl =
- new ShellImpl(pipe.handle1.Pass(), this, requested_url, resolved_url);
- url_to_shell_impl_[resolved_url] = shell_impl;
- *shell_handle = pipe.handle0.Pass();
- shell_impl->client()->Initialize(GetArgsForURL(requested_url));
- }
-
- ConnectToClient(shell_impl, resolved_url, requestor_url,
- service_provider.Pass());
-}
-
void ApplicationManager::LoadWithContentHandler(
- const GURL& requested_url,
- const GURL& resolved_url,
- const GURL& requestor_url,
const GURL& content_handler_url,
- URLResponsePtr url_response,
- ServiceProviderPtr service_provider) {
+ ScopedMessagePipeHandle shell_handle,
+ URLResponsePtr url_response) {
ContentHandlerConnection* connection = NULL;
URLToContentHandlerMap::iterator iter =
url_to_content_handler_.find(content_handler_url);
@@ -339,16 +286,8 @@ void ApplicationManager::LoadWithContentHandler(
url_to_content_handler_[content_handler_url] = connection;
}
- ShellPtr shell_proxy;
- ShellImpl* shell_impl =
- new ShellImpl(&shell_proxy, this, requested_url, resolved_url);
- content_shell_impls_.insert(shell_impl);
- shell_impl->client()->Initialize(GetArgsForURL(requested_url));
-
- connection->content_handler()->StartApplication(shell_proxy.Pass(),
- url_response.Pass());
- ConnectToClient(
- shell_impl, resolved_url, requestor_url, service_provider.Pass());
+ connection->content_handler()->StartApplication(
+ MakeProxy<Shell>(shell_handle.Pass()), url_response.Pass());
}
void ApplicationManager::SetLoaderForURL(scoped_ptr<ApplicationLoader> loader,

Powered by Google App Engine
This is Rietveld 408576698