| 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" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "mojo/public/interfaces/shell/shell.mojom.h" | 14 #include "mojo/public/interfaces/shell/shell.mojom.h" |
| 15 #include "mojo/service_manager/service_loader.h" | 15 #include "mojo/service_manager/service_loader.h" |
| 16 #include "mojo/service_manager/service_manager_export.h" | 16 #include "mojo/service_manager/service_manager_export.h" |
| 17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 18 | 18 |
| 19 namespace mojo { | 19 namespace mojo { |
| 20 | 20 |
| 21 class MOJO_SERVICE_MANAGER_EXPORT ServiceManager { | 21 class MOJO_SERVICE_MANAGER_EXPORT ServiceManager { |
| 22 public: | 22 public: |
| 23 // API for testing. | 23 // API for testing. |
| 24 class MOJO_SERVICE_MANAGER_EXPORT TestAPI { | 24 class MOJO_SERVICE_MANAGER_EXPORT TestAPI { |
| 25 public: | 25 public: |
| 26 explicit TestAPI(ServiceManager* manager); | 26 explicit TestAPI(ServiceManager* manager); |
| 27 ~TestAPI(); | 27 ~TestAPI(); |
| 28 | 28 |
| 29 // Returns a handle to the shell. | 29 // Returns a handle to the shell. |
| 30 ScopedShellHandle GetShellHandle(); | 30 ScopedMessagePipeHandle GetShellHandle(); |
| 31 | 31 |
| 32 // Returns true if the shared instance has been created. | 32 // Returns true if the shared instance has been created. |
| 33 static bool HasCreatedInstance(); | 33 static bool HasCreatedInstance(); |
| 34 // Returns true if there is a ServiceFactory for this URL. | 34 // Returns true if there is a ServiceFactory for this URL. |
| 35 bool HasFactoryForURL(const GURL& url) const; | 35 bool HasFactoryForURL(const GURL& url) const; |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 class TestShellConnection; | 38 class TestShellConnection; |
| 39 | 39 |
| 40 ServiceManager* manager_; | 40 ServiceManager* manager_; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 typedef std::map<std::string, ServiceLoader*> SchemeToLoaderMap; | 80 typedef std::map<std::string, ServiceLoader*> SchemeToLoaderMap; |
| 81 typedef std::map<GURL, ServiceLoader*> URLToLoaderMap; | 81 typedef std::map<GURL, ServiceLoader*> URLToLoaderMap; |
| 82 typedef std::map<GURL, ServiceFactory*> URLToServiceFactoryMap; | 82 typedef std::map<GURL, ServiceFactory*> URLToServiceFactoryMap; |
| 83 | 83 |
| 84 // Returns the Loader to use for a url (using default if not overridden.) | 84 // Returns the Loader to use for a url (using default if not overridden.) |
| 85 // The preference is to use a loader that's been specified for an url first, | 85 // The preference is to use a loader that's been specified for an url first, |
| 86 // then one that's been specified for a scheme, then the default. | 86 // then one that's been specified for a scheme, then the default. |
| 87 ServiceLoader* GetLoaderForURL(const GURL& url); | 87 ServiceLoader* GetLoaderForURL(const GURL& url); |
| 88 | 88 |
| 89 // Removes a ServiceFactory when it no longer has any connections. | 89 // Removes a ServiceFactory when it no longer has any connections. |
| 90 void OnServiceFactoryError(ServiceFactory* service_factory); | 90 void RemoveServiceFactory(ServiceFactory* service_factory); |
| 91 | 91 |
| 92 // Loader management. | 92 // Loader management. |
| 93 URLToLoaderMap url_to_loader_; | 93 URLToLoaderMap url_to_loader_; |
| 94 SchemeToLoaderMap scheme_to_loader_; | 94 SchemeToLoaderMap scheme_to_loader_; |
| 95 scoped_ptr<ServiceLoader> default_loader_; | 95 scoped_ptr<ServiceLoader> default_loader_; |
| 96 Interceptor* interceptor_; | 96 Interceptor* interceptor_; |
| 97 | 97 |
| 98 URLToServiceFactoryMap url_to_service_factory_; | 98 URLToServiceFactoryMap url_to_service_factory_; |
| 99 DISALLOW_COPY_AND_ASSIGN(ServiceManager); | 99 DISALLOW_COPY_AND_ASSIGN(ServiceManager); |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 } // namespace mojo | 102 } // namespace mojo |
| 103 | 103 |
| 104 #endif // MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_ | 104 #endif // MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_ |
| OLD | NEW |