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

Unified Diff: mojo/shell/application_manager.cc

Issue 1351963002: Some more minor cleanup to 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 d52030476cf3fddbc84b25274257c547d6d30c3b..715e6e77c7499a044ddefd538fefdd940354d6b7 100644
--- a/mojo/shell/application_manager.cc
+++ b/mojo/shell/application_manager.cc
@@ -59,8 +59,9 @@ ApplicationManager::ApplicationManager(
}
ApplicationManager::~ApplicationManager() {
- URLToContentHandlerMap url_to_content_handler(url_to_content_handler_);
- for (auto& pair : url_to_content_handler)
+ IdentityToContentHandlerMap identity_to_content_handler(
+ identity_to_content_handler_);
+ for (auto& pair : identity_to_content_handler)
pair.second->CloseConnection();
TerminateShellConnections();
STLDeleteValues(&url_to_loader_);
@@ -71,28 +72,6 @@ void ApplicationManager::TerminateShellConnections() {
}
void ApplicationManager::ConnectToApplication(
- ApplicationInstance* originator,
- URLRequestPtr app_url_request,
- const std::string& qualifier,
- InterfaceRequest<ServiceProvider> services,
- ServiceProviderPtr exposed_services,
- const CapabilityFilter& filter,
- const base::Closure& on_application_end,
- const Shell::ConnectToApplicationCallback& connect_callback) {
- scoped_ptr<ConnectToApplicationParams> params(new ConnectToApplicationParams);
- params->SetOriginatorInfo(originator);
- params->SetURLInfo(app_url_request.Pass());
- params->set_qualifier(qualifier);
- params->set_services(services.Pass());
- params->set_exposed_services(exposed_services.Pass());
- params->set_filter(filter);
- params->set_on_application_end(on_application_end);
- params->set_connect_callback(connect_callback);
-
- ConnectToApplication(params.Pass());
-}
-
-void ApplicationManager::ConnectToApplication(
scoped_ptr<ConnectToApplicationParams> params) {
GURL original_url = params->app_url();
URLRequestPtr original_url_request = params->TakeAppURLRequest();
@@ -148,10 +127,10 @@ void ApplicationManager::ConnectToApplicationWithLoader(
if (!(*params)->app_url().SchemeIs("mojo"))
(*params)->SetURLInfo(resolved_url);
- loader->Load(resolved_url, RegisterInstance(params->Pass(), nullptr));
+ loader->Load(resolved_url, CreateInstance(params->Pass(), nullptr));
}
-InterfaceRequest<Application> ApplicationManager::RegisterInstance(
+InterfaceRequest<Application> ApplicationManager::CreateInstance(
scoped_ptr<ConnectToApplicationParams> params,
ApplicationInstance** resulting_instance) {
Identity app_identity(params->app_url(), params->qualifier());
@@ -225,7 +204,7 @@ void ApplicationManager::HandleFetchCallback(
params->connect_callback();
params->set_connect_callback(EmptyConnectCallback());
ApplicationInstance* app = nullptr;
- InterfaceRequest<Application> request(RegisterInstance(params.Pass(), &app));
+ InterfaceRequest<Application> request(CreateInstance(params.Pass(), &app));
GURL content_handler_url;
@@ -299,17 +278,18 @@ void ApplicationManager::LoadWithContentHandler(
InterfaceRequest<Application> application_request,
URLResponsePtr url_response) {
ContentHandlerConnection* connection = nullptr;
- std::pair<GURL, std::string> key(content_handler_url, qualifier);
+ Identity content_handler_identity(content_handler_url, qualifier);
// TODO(beng): Figure out the extent to which capability filter should be
// factored into handler identity.
- URLToContentHandlerMap::iterator iter = url_to_content_handler_.find(key);
- if (iter != url_to_content_handler_.end()) {
+ IdentityToContentHandlerMap::iterator iter =
+ identity_to_content_handler_.find(content_handler_identity);
+ if (iter != identity_to_content_handler_.end()) {
connection = iter->second;
} else {
connection = new ContentHandlerConnection(
this, originator_identity, originator_filter, content_handler_url,
qualifier, filter, ++content_handler_id_counter_);
- url_to_content_handler_[key] = connection;
+ identity_to_content_handler_[content_handler_identity] = connection;
}
app->set_requesting_content_handler_id(connection->id());
@@ -350,11 +330,11 @@ void ApplicationManager::OnApplicationInstanceError(
void ApplicationManager::OnContentHandlerConnectionClosed(
ContentHandlerConnection* content_handler) {
// Remove the mapping to the content handler.
- auto it = url_to_content_handler_.find(
- std::make_pair(content_handler->content_handler_url(),
- content_handler->content_handler_qualifier()));
- DCHECK(it != url_to_content_handler_.end());
- url_to_content_handler_.erase(it);
+ auto it = identity_to_content_handler_.find(
+ Identity(content_handler->content_handler_url(),
+ content_handler->content_handler_qualifier()));
+ DCHECK(it != identity_to_content_handler_.end());
+ identity_to_content_handler_.erase(it);
}
void ApplicationManager::CleanupRunner(NativeRunner* runner) {
@@ -362,20 +342,6 @@ void ApplicationManager::CleanupRunner(NativeRunner* runner) {
std::find(native_runners_.begin(), native_runners_.end(), runner));
}
-ScopedMessagePipeHandle ApplicationManager::ConnectToServiceByName(
- const GURL& application_url,
- const std::string& interface_name) {
- ServiceProviderPtr services;
- scoped_ptr<ConnectToApplicationParams> params(new ConnectToApplicationParams);
- params->SetURLInfo(application_url);
- params->set_services(GetProxy(&services));
- params->set_filter(GetPermissiveCapabilityFilter());
- ConnectToApplication(params.Pass());
- MessagePipe pipe;
- services->ConnectToService(interface_name, pipe.handle1.Pass());
- return pipe.handle0.Pass();
-}
-
Shell::ConnectToApplicationCallback EmptyConnectCallback() {
return base::Bind(&OnEmptyOnConnectCallback);
}
« 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