OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ | 5 #ifndef MOJO_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ |
6 #define MOJO_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ | 6 #define MOJO_APPLICATION_MANAGER_APPLICATION_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 "base/memory/weak_ptr.h" |
14 #include "mojo/application_manager/application_loader.h" | 14 #include "mojo/application_manager/application_loader.h" |
15 #include "mojo/application_manager/application_manager_export.h" | 15 #include "mojo/application_manager/application_manager_export.h" |
16 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 16 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
18 | 18 |
19 namespace mojo { | 19 namespace mojo { |
20 | 20 |
21 class MOJO_APPLICATION_MANAGER_EXPORT ApplicationManager { | 21 class MOJO_APPLICATION_MANAGER_EXPORT ApplicationManager { |
22 public: | 22 public: |
23 class MOJO_APPLICATION_MANAGER_EXPORT Delegate { | 23 class MOJO_APPLICATION_MANAGER_EXPORT Delegate { |
24 public: | 24 public: |
25 virtual ~Delegate(); | 25 virtual ~Delegate(); |
26 // Send when the Application holding the handle on the other end of the | 26 // Send when the Application holding the handle on the other end of the |
27 // Shell pipe goes away. | 27 // Shell pipe goes away. |
28 virtual void OnApplicationError(const GURL& url) = 0; | 28 virtual void OnApplicationError(const GURL& url); |
29 virtual GURL ResolveURL(const GURL& url); | |
29 }; | 30 }; |
30 | 31 |
31 // API for testing. | 32 // API for testing. |
32 class MOJO_APPLICATION_MANAGER_EXPORT TestAPI { | 33 class MOJO_APPLICATION_MANAGER_EXPORT TestAPI { |
33 public: | 34 public: |
34 explicit TestAPI(ApplicationManager* manager); | 35 explicit TestAPI(ApplicationManager* manager); |
35 ~TestAPI(); | 36 ~TestAPI(); |
36 | 37 |
37 // Returns true if the shared instance has been created. | 38 // Returns true if the shared instance has been created. |
38 static bool HasCreatedInstance(); | 39 static bool HasCreatedInstance(); |
39 // Returns true if there is a ShellImpl for this URL. | 40 // Returns true if there is a ShellImpl for this URL. |
40 bool HasFactoryForURL(const GURL& url) const; | 41 bool HasFactoryForURL(const GURL& url) const; |
41 | 42 |
42 private: | 43 private: |
43 ApplicationManager* manager_; | 44 ApplicationManager* manager_; |
44 | 45 |
45 DISALLOW_COPY_AND_ASSIGN(TestAPI); | 46 DISALLOW_COPY_AND_ASSIGN(TestAPI); |
46 }; | 47 }; |
47 | 48 |
48 // Interface class for debugging only. | 49 // Interface class for debugging only. |
49 class Interceptor { | 50 class Interceptor { |
50 public: | 51 public: |
51 virtual ~Interceptor() {} | 52 virtual ~Interceptor() {} |
52 // Called when ApplicationManager::Connect is called. | 53 // Called when ApplicationManager::Connect is called. |
53 virtual ServiceProviderPtr OnConnectToClient( | 54 virtual ServiceProviderPtr OnConnectToClient( |
54 const GURL& url, | 55 const GURL& url, |
55 ServiceProviderPtr service_provider) = 0; | 56 ServiceProviderPtr service_provider) = 0; |
56 }; | 57 }; |
57 | 58 |
58 ApplicationManager(); | 59 ApplicationManager(Delegate* delegate); |
59 ~ApplicationManager(); | 60 ~ApplicationManager(); |
60 | 61 |
61 // Returns a shared instance, creating it if necessary. | |
Aaron Boodman
2014/10/31 05:26:17
Neither of these were called from anywhere.
| |
62 static ApplicationManager* GetInstance(); | |
63 | |
64 void SetDelegate(Delegate* delegate) { delegate_ = delegate; } | |
65 | |
66 // Loads a service if necessary and establishes a new client connection. | 62 // Loads a service if necessary and establishes a new client connection. |
67 void ConnectToApplication(const GURL& application_url, | 63 void ConnectToApplication(const GURL& application_url, |
68 const GURL& requestor_url, | 64 const GURL& requestor_url, |
69 ServiceProviderPtr service_provider); | 65 ServiceProviderPtr service_provider); |
70 | 66 |
71 template <typename Interface> | 67 template <typename Interface> |
72 inline void ConnectToService(const GURL& application_url, | 68 inline void ConnectToService(const GURL& application_url, |
73 InterfacePtr<Interface>* ptr) { | 69 InterfacePtr<Interface>* ptr) { |
74 ScopedMessagePipeHandle service_handle = | 70 ScopedMessagePipeHandle service_handle = |
75 ConnectToServiceByName(application_url, Interface::Name_); | 71 ConnectToServiceByName(application_url, Interface::Name_); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 typedef std::map<GURL, ApplicationLoader*> URLToLoaderMap; | 112 typedef std::map<GURL, ApplicationLoader*> URLToLoaderMap; |
117 typedef std::map<GURL, ShellImpl*> URLToShellImplMap; | 113 typedef std::map<GURL, ShellImpl*> URLToShellImplMap; |
118 typedef std::map<GURL, ContentHandlerConnection*> URLToContentHandlerMap; | 114 typedef std::map<GURL, ContentHandlerConnection*> URLToContentHandlerMap; |
119 typedef std::map<GURL, std::vector<std::string> > URLToArgsMap; | 115 typedef std::map<GURL, std::vector<std::string> > URLToArgsMap; |
120 | 116 |
121 void ConnectToClient(ShellImpl* shell_impl, | 117 void ConnectToClient(ShellImpl* shell_impl, |
122 const GURL& url, | 118 const GURL& url, |
123 const GURL& requestor_url, | 119 const GURL& requestor_url, |
124 ServiceProviderPtr service_provider); | 120 ServiceProviderPtr service_provider); |
125 | 121 |
126 void RegisterLoadedApplication(const GURL& service_url, | 122 void RegisterLoadedApplication(const GURL& requested_url, |
123 const GURL& resolved_url, | |
127 const GURL& requestor_url, | 124 const GURL& requestor_url, |
128 ServiceProviderPtr service_provider, | 125 ServiceProviderPtr service_provider, |
129 ScopedMessagePipeHandle* shell_handle); | 126 ScopedMessagePipeHandle* shell_handle); |
130 | 127 |
131 void LoadWithContentHandler(const GURL& content_url, | 128 void LoadWithContentHandler(const GURL& content_url, |
132 const GURL& requestor_url, | 129 const GURL& requestor_url, |
133 const GURL& content_handler_url, | 130 const GURL& content_handler_url, |
134 URLResponsePtr url_response, | 131 URLResponsePtr url_response, |
135 ServiceProviderPtr service_provider); | 132 ServiceProviderPtr service_provider); |
136 | 133 |
(...skipping 17 matching lines...) Expand all Loading... | |
154 URLToArgsMap url_to_args_; | 151 URLToArgsMap url_to_args_; |
155 | 152 |
156 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; | 153 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; |
157 | 154 |
158 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); | 155 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); |
159 }; | 156 }; |
160 | 157 |
161 } // namespace mojo | 158 } // namespace mojo |
162 | 159 |
163 #endif // MOJO_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ | 160 #endif // MOJO_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ |
OLD | NEW |