OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_ | 5 #ifndef MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_ |
6 #define MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_ | 6 #define MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 27 matching lines...) Expand all Loading... | |
38 | 38 |
39 ServiceManager* manager_; | 39 ServiceManager* manager_; |
40 }; | 40 }; |
41 | 41 |
42 ServiceManager(); | 42 ServiceManager(); |
43 ~ServiceManager(); | 43 ~ServiceManager(); |
44 | 44 |
45 // Returns a shared instance, creating it if necessary. | 45 // Returns a shared instance, creating it if necessary. |
46 static ServiceManager* GetInstance(); | 46 static ServiceManager* GetInstance(); |
47 | 47 |
48 // Sets the default Loader to be used if not overridden by SetLoaderForURL(). | 48 // Sets the default Loader to be used if not overridden by |
49 // SetLoaderForScheme(). | |
49 // Does not take ownership of |loader|. | 50 // Does not take ownership of |loader|. |
50 void set_default_loader(ServiceLoader* loader) { default_loader_ = loader; } | 51 void set_default_loader(ServiceLoader* loader) { default_loader_ = loader; } |
51 // Sets a Loader to be used for a specific url. | 52 // Sets a Loader to be used for a specific scheme. |
darin (slow to review)
2014/03/27 23:33:41
nit: you probably want to say "URL scheme" in the
| |
52 // Does not take ownership of |loader|. | 53 // Does not take ownership of |loader|. |
53 void SetLoaderForURL(ServiceLoader* loader, const GURL& gurl); | 54 void SetLoaderForScheme(ServiceLoader* loader, const std::string& scheme); |
54 // Returns the Loader to use for a url (using default if not overridden.) | 55 // Returns the Loader to use for a url (using default if not overridden.) |
55 ServiceLoader* GetLoaderForURL(const GURL& gurl); | 56 ServiceLoader* GetLoaderForURL(const GURL& gurl); |
56 // Loads a service if necessary and establishes a new client connection. | 57 // Loads a service if necessary and establishes a new client connection. |
57 void Connect(const GURL& url, ScopedMessagePipeHandle client_handle); | 58 void Connect(const GURL& url, ScopedMessagePipeHandle client_handle); |
58 | 59 |
59 private: | 60 private: |
60 class ServiceFactory; | 61 class ServiceFactory; |
61 | 62 |
62 // Removes a ServiceFactory when it no longer has any connections. | 63 // Removes a ServiceFactory when it no longer has any connections. |
63 void OnServiceFactoryError(ServiceFactory* service_factory); | 64 void OnServiceFactoryError(ServiceFactory* service_factory); |
64 | 65 |
65 ServiceLoader* default_loader_; | 66 ServiceLoader* default_loader_; |
66 typedef std::map<GURL, ServiceFactory*> ServiceFactoryMap; | 67 typedef std::map<GURL, ServiceFactory*> ServiceFactoryMap; |
67 ServiceFactoryMap url_to_service_factory_; | 68 ServiceFactoryMap url_to_service_factory_; |
68 typedef std::map<GURL, ServiceLoader*> LoaderMap; | 69 typedef std::map<std::string, ServiceLoader*> LoaderMap; |
69 LoaderMap url_to_loader_; | 70 LoaderMap scheme_to_loader_; |
70 DISALLOW_COPY_AND_ASSIGN(ServiceManager); | 71 DISALLOW_COPY_AND_ASSIGN(ServiceManager); |
71 }; | 72 }; |
72 | 73 |
73 } // namespace mojo | 74 } // namespace mojo |
74 | 75 |
75 #endif // MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_ | 76 #endif // MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_ |
OLD | NEW |