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