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

Unified Diff: mojo/service_manager/service_manager.cc

Issue 214513009: Change ServiceManager::SetLoaderForUrl() to SetLoaderForScheme() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Keep both SetLoaderForURL() and SetLoaderForScheme() Created 6 years, 9 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/service_manager/service_manager.h ('k') | mojo/service_manager/service_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/service_manager/service_manager.cc
diff --git a/mojo/service_manager/service_manager.cc b/mojo/service_manager/service_manager.cc
index fe8575dc75543cdd18c5e89f1e22bff1c38dd255..8b80825c8cea1256dee86e58be262af511450fe5 100644
--- a/mojo/service_manager/service_manager.cc
+++ b/mojo/service_manager/service_manager.cc
@@ -32,6 +32,7 @@ class ServiceManager::ServiceFactory : public Shell, public ErrorHandler {
url,
pipe.handle_to_self.Pass());
}
+
virtual ~ServiceFactory() {}
void ConnectToClient(ScopedMessagePipeHandle handle) {
@@ -73,7 +74,7 @@ ServiceManager::ServiceManager() : default_loader_(NULL) {
}
ServiceManager::~ServiceManager() {
- for (ServiceFactoryMap::iterator it = url_to_service_factory_.begin();
+ for (URLToServiceFactoryMap::iterator it = url_to_service_factory_.begin();
it != url_to_service_factory_.end(); ++it) {
delete it->second;
}
@@ -88,22 +89,9 @@ ServiceManager* ServiceManager::GetInstance() {
return &instance.Get();
}
-void ServiceManager::SetLoaderForURL(ServiceLoader* loader, const GURL& gurl) {
- DCHECK(url_to_loader_.find(gurl) == url_to_loader_.end());
- url_to_loader_[gurl] = loader;
-}
-
-ServiceLoader* ServiceManager::GetLoaderForURL(const GURL& gurl) {
- LoaderMap::const_iterator it = url_to_loader_.find(gurl);
- if (it != url_to_loader_.end())
- return it->second;
- DCHECK(default_loader_);
- return default_loader_;
-}
-
void ServiceManager::Connect(const GURL& url,
ScopedMessagePipeHandle client_handle) {
- ServiceFactoryMap::const_iterator service_it =
+ URLToServiceFactoryMap::const_iterator service_it =
url_to_service_factory_.find(url);
ServiceFactory* service_factory;
if (service_it != url_to_service_factory_.end()) {
@@ -115,9 +103,32 @@ void ServiceManager::Connect(const GURL& url,
service_factory->ConnectToClient(client_handle.Pass());
}
+void ServiceManager::SetLoaderForURL(ServiceLoader* loader, const GURL& url) {
+ DCHECK(url_to_loader_.find(url) == url_to_loader_.end());
+ url_to_loader_[url] = loader;
+}
+
+void ServiceManager::SetLoaderForScheme(ServiceLoader* loader,
+ const std::string& scheme) {
+ DCHECK(scheme_to_loader_.find(scheme) == scheme_to_loader_.end());
+ scheme_to_loader_[scheme] = loader;
+}
+
+ServiceLoader* ServiceManager::GetLoaderForURL(const GURL& url) {
+ URLToLoaderMap::const_iterator url_it = url_to_loader_.find(url);
+ if (url_it != url_to_loader_.end())
+ return url_it->second;
+ SchemeToLoaderMap::const_iterator scheme_it =
+ scheme_to_loader_.find(url.scheme());
+ if (scheme_it != scheme_to_loader_.end())
+ return scheme_it->second;
+ DCHECK(default_loader_);
+ return default_loader_;
+}
+
void ServiceManager::OnServiceFactoryError(ServiceFactory* service_factory) {
const GURL url = service_factory->url();
- ServiceFactoryMap::iterator it = url_to_service_factory_.find(url);
+ URLToServiceFactoryMap::iterator it = url_to_service_factory_.find(url);
DCHECK(it != url_to_service_factory_.end());
delete it->second;
url_to_service_factory_.erase(it);
« no previous file with comments | « mojo/service_manager/service_manager.h ('k') | mojo/service_manager/service_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698