| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 default_loader_ = loader.Pass(); | 74 default_loader_ = loader.Pass(); |
| 75 } | 75 } |
| 76 // Sets a Loader to be used for a specific url. | 76 // Sets a Loader to be used for a specific url. |
| 77 void SetLoaderForURL(scoped_ptr<ServiceLoader> loader, const GURL& url); | 77 void SetLoaderForURL(scoped_ptr<ServiceLoader> loader, const GURL& url); |
| 78 // Sets a Loader to be used for a specific url scheme. | 78 // Sets a Loader to be used for a specific url scheme. |
| 79 void SetLoaderForScheme(scoped_ptr<ServiceLoader> loader, | 79 void SetLoaderForScheme(scoped_ptr<ServiceLoader> loader, |
| 80 const std::string& scheme); | 80 const std::string& scheme); |
| 81 // Allows to interpose a debugger to service connections. | 81 // Allows to interpose a debugger to service connections. |
| 82 void SetInterceptor(Interceptor* interceptor); | 82 void SetInterceptor(Interceptor* interceptor); |
| 83 | 83 |
| 84 // Destroys all Shell-ends of connections established with Applications. |
| 85 // Applications connected by this ServiceManager will observe pipe errors |
| 86 // and have a chance to shutdown. |
| 87 void TerminateShellConnections(); |
| 88 |
| 84 private: | 89 private: |
| 85 class ShellImpl; | 90 class ShellImpl; |
| 86 typedef std::map<std::string, ServiceLoader*> SchemeToLoaderMap; | 91 typedef std::map<std::string, ServiceLoader*> SchemeToLoaderMap; |
| 87 typedef std::map<GURL, ServiceLoader*> URLToLoaderMap; | 92 typedef std::map<GURL, ServiceLoader*> URLToLoaderMap; |
| 88 typedef std::map<GURL, ShellImpl*> URLToShellImplMap; | 93 typedef std::map<GURL, ShellImpl*> URLToShellImplMap; |
| 89 | 94 |
| 90 // 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.) |
| 91 // 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, |
| 92 // 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. |
| 93 ServiceLoader* GetLoaderForURL(const GURL& url); | 98 ServiceLoader* GetLoaderForURL(const GURL& url); |
| 94 | 99 |
| 95 // Removes a ShellImpl when it encounters an error. | 100 // Removes a ShellImpl when it encounters an error. |
| 96 void OnShellImplError(ShellImpl* shell_impl); | 101 void OnShellImplError(ShellImpl* shell_impl); |
| 97 | 102 |
| 98 // Loader management. | 103 // Loader management. |
| 99 URLToLoaderMap url_to_loader_; | 104 URLToLoaderMap url_to_loader_; |
| 100 SchemeToLoaderMap scheme_to_loader_; | 105 SchemeToLoaderMap scheme_to_loader_; |
| 101 scoped_ptr<ServiceLoader> default_loader_; | 106 scoped_ptr<ServiceLoader> default_loader_; |
| 102 Interceptor* interceptor_; | 107 Interceptor* interceptor_; |
| 103 | 108 |
| 104 URLToShellImplMap url_to_shell_impl_; | 109 URLToShellImplMap url_to_shell_impl_; |
| 105 | 110 |
| 106 DISALLOW_COPY_AND_ASSIGN(ServiceManager); | 111 DISALLOW_COPY_AND_ASSIGN(ServiceManager); |
| 107 }; | 112 }; |
| 108 | 113 |
| 109 } // namespace mojo | 114 } // namespace mojo |
| 110 | 115 |
| 111 #endif // MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_ | 116 #endif // MOJO_SERVICE_MANAGER_SERVICE_MANAGER_H_ |
| OLD | NEW |