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_SHELL_APPLICATION_MANAGER_H_ | 5 #ifndef MOJO_SHELL_APPLICATION_MANAGER_H_ |
6 #define MOJO_SHELL_APPLICATION_MANAGER_H_ | 6 #define MOJO_SHELL_APPLICATION_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 void TerminateShellConnections(); | 91 void TerminateShellConnections(); |
92 | 92 |
93 // Removes a ApplicationInstance when it encounters an error. | 93 // Removes a ApplicationInstance when it encounters an error. |
94 void OnApplicationInstanceError(ApplicationInstance* instance); | 94 void OnApplicationInstanceError(ApplicationInstance* instance); |
95 | 95 |
96 ApplicationInstance* GetApplicationInstance(const Identity& identity) const; | 96 ApplicationInstance* GetApplicationInstance(const Identity& identity) const; |
97 | 97 |
98 void CreateInstanceForHandle( | 98 void CreateInstanceForHandle( |
99 ScopedHandle channel, | 99 ScopedHandle channel, |
100 const GURL& url, | 100 const GURL& url, |
101 CapabilityFilterPtr filter, | 101 mojom::CapabilityFilterPtr filter, |
102 InterfaceRequest<mojom::PIDReceiver> pid_receiver); | 102 InterfaceRequest<mojom::PIDReceiver> pid_receiver); |
103 void AddListener(mojom::ApplicationManagerListenerPtr listener); | 103 void AddListener(mojom::ApplicationManagerListenerPtr listener); |
104 void GetRunningApplications( | 104 void GetRunningApplications( |
105 const Callback<void(Array<mojom::ApplicationInfoPtr>)>& callback); | 105 const Callback<void(Array<mojom::ApplicationInfoPtr>)>& callback); |
106 | 106 |
107 void ApplicationPIDAvailable(uint32_t id, base::ProcessId pid); | 107 void ApplicationPIDAvailable(uint32_t id, base::ProcessId pid); |
108 | 108 |
109 private: | 109 private: |
110 using IdentityToInstanceMap = std::map<Identity, ApplicationInstance*>; | 110 using IdentityToInstanceMap = std::map<Identity, ApplicationInstance*>; |
111 using URLToLoaderMap = std::map<GURL, ApplicationLoader*>; | 111 using URLToLoaderMap = std::map<GURL, ApplicationLoader*>; |
112 | 112 |
113 // Takes the contents of |params| only when it returns true. | 113 // Takes the contents of |params| only when it returns true. |
114 bool ConnectToRunningApplication( | 114 bool ConnectToRunningApplication( |
115 scoped_ptr<ConnectToApplicationParams>* params); | 115 scoped_ptr<ConnectToApplicationParams>* params); |
116 | 116 |
117 InterfaceRequest<Application> CreateAndConnectToInstance( | 117 InterfaceRequest<mojom::Application> CreateAndConnectToInstance( |
118 scoped_ptr<ConnectToApplicationParams> params, | 118 scoped_ptr<ConnectToApplicationParams> params, |
119 ApplicationInstance** instance); | 119 ApplicationInstance** instance); |
120 InterfaceRequest<Application> CreateInstance( | 120 InterfaceRequest<mojom::Application> CreateInstance( |
121 const Identity& target_id, | 121 const Identity& target_id, |
122 const base::Closure& on_application_end, | 122 const base::Closure& on_application_end, |
123 ApplicationInstance** resulting_instance); | 123 ApplicationInstance** resulting_instance); |
124 | 124 |
125 // Called once |fetcher| has found app. |params->app_url()| is the url of | 125 // Called once |fetcher| has found app. |params->app_url()| is the url of |
126 // the requested application before any mappings/resolution have been applied. | 126 // the requested application before any mappings/resolution have been applied. |
127 // The corresponding URLRequest struct in |params| has been taken. | 127 // The corresponding URLRequest struct in |params| has been taken. |
128 void HandleFetchCallback(scoped_ptr<ConnectToApplicationParams> params, | 128 void HandleFetchCallback(scoped_ptr<ConnectToApplicationParams> params, |
129 scoped_ptr<Fetcher> fetcher); | 129 scoped_ptr<Fetcher> fetcher); |
130 | 130 |
131 void RunNativeApplication(InterfaceRequest<Application> application_request, | 131 void RunNativeApplication( |
132 bool start_sandboxed, | 132 InterfaceRequest<mojom::Application> application_request, |
133 scoped_ptr<Fetcher> fetcher, | 133 bool start_sandboxed, |
134 ApplicationInstance* instance, | 134 scoped_ptr<Fetcher> fetcher, |
135 const base::FilePath& file_path, | 135 ApplicationInstance* instance, |
136 bool path_exists); | 136 const base::FilePath& file_path, |
| 137 bool path_exists); |
137 | 138 |
138 // Returns the appropriate loader for |url|, or the default loader if there is | 139 // Returns the appropriate loader for |url|, or the default loader if there is |
139 // no loader configured for the URL. | 140 // no loader configured for the URL. |
140 ApplicationLoader* GetLoaderForURL(const GURL& url); | 141 ApplicationLoader* GetLoaderForURL(const GURL& url); |
141 | 142 |
142 void CleanupRunner(NativeRunner* runner); | 143 void CleanupRunner(NativeRunner* runner); |
143 | 144 |
144 mojom::ApplicationInfoPtr CreateApplicationInfoForInstance( | 145 mojom::ApplicationInfoPtr CreateApplicationInfoForInstance( |
145 ApplicationInstance* instance) const; | 146 ApplicationInstance* instance) const; |
146 | 147 |
147 scoped_ptr<PackageManager> const package_manager_; | 148 scoped_ptr<PackageManager> const package_manager_; |
148 // Loader management. | 149 // Loader management. |
149 // Loaders are chosen in the order they are listed here. | 150 // Loaders are chosen in the order they are listed here. |
150 URLToLoaderMap url_to_loader_; | 151 URLToLoaderMap url_to_loader_; |
151 scoped_ptr<ApplicationLoader> default_loader_; | 152 scoped_ptr<ApplicationLoader> default_loader_; |
152 | 153 |
153 IdentityToInstanceMap identity_to_instance_; | 154 IdentityToInstanceMap identity_to_instance_; |
154 | 155 |
155 WeakInterfacePtrSet<mojom::ApplicationManagerListener> listeners_; | 156 WeakInterfacePtrSet<mojom::ApplicationManagerListener> listeners_; |
156 | 157 |
157 base::TaskRunner* task_runner_; | 158 base::TaskRunner* task_runner_; |
158 scoped_ptr<NativeRunnerFactory> native_runner_factory_; | 159 scoped_ptr<NativeRunnerFactory> native_runner_factory_; |
159 std::vector<scoped_ptr<NativeRunner>> native_runners_; | 160 std::vector<scoped_ptr<NativeRunner>> native_runners_; |
160 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; | 161 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; |
161 | 162 |
162 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); | 163 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); |
163 }; | 164 }; |
164 | 165 |
165 Shell::ConnectToApplicationCallback EmptyConnectCallback(); | 166 mojom::Shell::ConnectToApplicationCallback EmptyConnectCallback(); |
166 | 167 |
167 } // namespace shell | 168 } // namespace shell |
168 } // namespace mojo | 169 } // namespace mojo |
169 | 170 |
170 #endif // MOJO_SHELL_APPLICATION_MANAGER_H_ | 171 #endif // MOJO_SHELL_APPLICATION_MANAGER_H_ |
OLD | NEW |