| 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/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | |
| 14 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 13 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
| 15 #include "mojo/service_manager/service_loader.h" | 14 #include "mojo/service_manager/service_loader.h" |
| 16 #include "mojo/service_manager/service_manager_export.h" | 15 #include "mojo/service_manager/service_manager_export.h" |
| 17 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 18 | 17 |
| 19 namespace mojo { | 18 namespace mojo { |
| 20 | 19 |
| 21 class MOJO_SERVICE_MANAGER_EXPORT ServiceManager { | 20 class MOJO_SERVICE_MANAGER_EXPORT ServiceManager { |
| 22 public: | 21 public: |
| 23 // API for testing. | 22 // API for testing. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 const std::string& scheme); | 80 const std::string& scheme); |
| 82 // Allows to interpose a debugger to service connections. | 81 // Allows to interpose a debugger to service connections. |
| 83 void SetInterceptor(Interceptor* interceptor); | 82 void SetInterceptor(Interceptor* interceptor); |
| 84 | 83 |
| 85 // Destroys all Shell-ends of connections established with Applications. | 84 // Destroys all Shell-ends of connections established with Applications. |
| 86 // Applications connected by this ServiceManager will observe pipe errors | 85 // Applications connected by this ServiceManager will observe pipe errors |
| 87 // and have a chance to shutdown. | 86 // and have a chance to shutdown. |
| 88 void TerminateShellConnections(); | 87 void TerminateShellConnections(); |
| 89 | 88 |
| 90 private: | 89 private: |
| 91 struct ContentHandlerConnection; | |
| 92 class LoadCallbacksImpl; | |
| 93 class ShellImpl; | 90 class ShellImpl; |
| 94 | |
| 95 typedef std::map<std::string, ServiceLoader*> SchemeToLoaderMap; | 91 typedef std::map<std::string, ServiceLoader*> SchemeToLoaderMap; |
| 96 typedef std::map<GURL, ServiceLoader*> URLToLoaderMap; | 92 typedef std::map<GURL, ServiceLoader*> URLToLoaderMap; |
| 97 typedef std::map<GURL, ShellImpl*> URLToShellImplMap; | 93 typedef std::map<GURL, ShellImpl*> URLToShellImplMap; |
| 98 typedef std::map<GURL, ContentHandlerConnection*> URLToContentHandlerMap; | |
| 99 | |
| 100 void ConnectToClient(ShellImpl* shell_impl, | |
| 101 const GURL& url, | |
| 102 const GURL& requestor_url, | |
| 103 ServiceProviderPtr service_provider); | |
| 104 | |
| 105 void RegisterLoadedApplication(const GURL& service_url, | |
| 106 const GURL& requestor_url, | |
| 107 ServiceProviderPtr service_provider, | |
| 108 ScopedMessagePipeHandle* shell_handle); | |
| 109 | |
| 110 void LoadWithContentHandler(const GURL& content_url, | |
| 111 const GURL& requestor_url, | |
| 112 const GURL& content_handler_url, | |
| 113 URLResponsePtr content, | |
| 114 ServiceProviderPtr service_provider); | |
| 115 | 94 |
| 116 // Returns the Loader to use for a url (using default if not overridden.) | 95 // Returns the Loader to use for a url (using default if not overridden.) |
| 117 // The preference is to use a loader that's been specified for an url first, | 96 // The preference is to use a loader that's been specified for an url first, |
| 118 // then one that's been specified for a scheme, then the default. | 97 // then one that's been specified for a scheme, then the default. |
| 119 ServiceLoader* GetLoaderForURL(const GURL& url); | 98 ServiceLoader* GetLoaderForURL(const GURL& url); |
| 120 | 99 |
| 121 // Removes a ShellImpl when it encounters an error. | 100 // Removes a ShellImpl when it encounters an error. |
| 122 void OnShellImplError(ShellImpl* shell_impl); | 101 void OnShellImplError(ShellImpl* shell_impl); |
| 123 | 102 |
| 124 // Loader management. | 103 // Loader management. |
| 125 URLToLoaderMap url_to_loader_; | 104 URLToLoaderMap url_to_loader_; |
| 126 SchemeToLoaderMap scheme_to_loader_; | 105 SchemeToLoaderMap scheme_to_loader_; |
| 127 scoped_ptr<ServiceLoader> default_loader_; | 106 scoped_ptr<ServiceLoader> default_loader_; |
| 128 Interceptor* interceptor_; | 107 Interceptor* interceptor_; |
| 129 | 108 |
| 130 URLToShellImplMap url_to_shell_impl_; | 109 URLToShellImplMap url_to_shell_impl_; |
| 131 URLToContentHandlerMap url_to_content_handler_; | |
| 132 | |
| 133 base::WeakPtrFactory<ServiceManager> weak_ptr_factory_; | |
| 134 | 110 |
| 135 DISALLOW_COPY_AND_ASSIGN(ServiceManager); | 111 DISALLOW_COPY_AND_ASSIGN(ServiceManager); |
| 136 }; | 112 }; |
| 137 | 113 |
| 138 } // namespace mojo | 114 } // namespace mojo |
| 139 | 115 |
| 140 #endif // MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_ | 116 #endif // MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_ |
| OLD | NEW |