Chromium Code Reviews| 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 SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ | 5 #ifndef SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ |
| 6 #define SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ | 6 #define SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/macros.h" |
| 11 #include "base/callback.h" | |
| 12 #include "base/gtest_prod_util.h" | |
| 13 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 15 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 16 #include "mojo/public/cpp/bindings/interface_request.h" | 14 #include "mojo/public/cpp/bindings/interface_request.h" |
| 15 #include "mojo/public/interfaces/application/application.mojom.h" | |
| 17 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 16 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
| 18 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | 17 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
| 19 #include "shell/application_manager/application_loader.h" | 18 #include "shell/application_manager/application_loader.h" |
| 20 #include "shell/application_manager/fetcher.h" | 19 #include "shell/application_manager/native_runner.h" |
| 21 #include "shell/application_manager/shell_impl.h" | |
| 22 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 23 | 21 |
| 24 namespace base { | 22 namespace base { |
| 25 class FilePath; | 23 class FilePath; |
| 26 class SequencedWorkerPool; | 24 class SequencedWorkerPool; |
| 27 } | 25 } |
| 28 | 26 |
| 29 namespace mojo { | 27 namespace mojo { |
| 30 namespace shell { | 28 namespace shell { |
| 31 | 29 |
| 32 // ApplicationManager requires implementations of NativeRunner and | 30 class Fetcher; |
| 33 // NativeRunnerFactory to run native applications. | 31 class ShellImpl; |
| 34 class NativeRunner { | |
| 35 public: | |
| 36 // Parameter for |Start()| to specify its cleanup behavior. | |
| 37 enum CleanupBehavior { DeleteAppPath, DontDeleteAppPath }; | |
| 38 | |
| 39 virtual ~NativeRunner() {} | |
| 40 | |
| 41 // Loads the app in the file at |app_path| and runs it on some other | |
| 42 // thread/process. If |cleanup_behavior| is |true|, takes ownership of the | |
| 43 // file. |app_completed_callback| is posted (to the thread on which |Start()| | |
| 44 // was called) after |MojoMain()| completes. | |
| 45 // TODO(vtl): |app_path| and |cleanup_behavior| should probably be moved to | |
| 46 // the factory's Create(). Rationale: The factory may need information from | |
| 47 // the file to decide what kind of NativeRunner to make. | |
| 48 virtual void Start(const base::FilePath& app_path, | |
| 49 CleanupBehavior cleanup_behavior, | |
| 50 InterfaceRequest<Application> application_request, | |
| 51 const base::Closure& app_completed_callback) = 0; | |
| 52 }; | |
| 53 | |
| 54 class NativeRunnerFactory { | |
| 55 public: | |
| 56 // Options for running the native app. (This will contain, e.g., information | |
| 57 // about the sandbox profile, etc.) | |
| 58 struct Options { | |
| 59 // Constructs with default options. | |
| 60 Options() : force_in_process(false) {} | |
| 61 | |
| 62 bool force_in_process; | |
| 63 }; | |
| 64 | |
| 65 virtual ~NativeRunnerFactory() {} | |
| 66 virtual scoped_ptr<NativeRunner> Create(const Options& options) = 0; | |
| 67 }; | |
| 68 | 32 |
| 69 class ApplicationManager { | 33 class ApplicationManager { |
| 70 public: | 34 public: |
| 71 class Delegate { | 35 class Delegate { |
| 72 public: | 36 public: |
| 73 virtual ~Delegate(); | 37 virtual ~Delegate(); |
| 74 // Send when the Application holding the handle on the other end of the | 38 // Send when the Application holding the handle on the other end of the |
| 75 // Shell pipe goes away. | 39 // Shell pipe goes away. |
| 76 virtual void OnApplicationError(const GURL& url); | 40 virtual void OnApplicationError(const GURL& url); |
| 77 virtual GURL ResolveURL(const GURL& url); | 41 virtual GURL ResolveURL(const GURL& url); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 const GURL& resolved_url, | 168 const GURL& resolved_url, |
| 205 const GURL& requestor_url, | 169 const GURL& requestor_url, |
| 206 InterfaceRequest<ServiceProvider> services, | 170 InterfaceRequest<ServiceProvider> services, |
| 207 ServiceProviderPtr exposed_services); | 171 ServiceProviderPtr exposed_services); |
| 208 | 172 |
| 209 void HandleFetchCallback(const GURL& requested_url, | 173 void HandleFetchCallback(const GURL& requested_url, |
| 210 const GURL& requestor_url, | 174 const GURL& requestor_url, |
| 211 InterfaceRequest<ServiceProvider> services, | 175 InterfaceRequest<ServiceProvider> services, |
| 212 ServiceProviderPtr exposed_services, | 176 ServiceProviderPtr exposed_services, |
| 213 NativeRunner::CleanupBehavior cleanup_behavior, | 177 NativeRunner::CleanupBehavior cleanup_behavior, |
| 214 scoped_ptr<Fetcher> fetcher); | 178 scoped_ptr<Fetcher> fetcher); |
|
qsr
2015/03/05 14:13:19
I though scoped_ptr needed the full implementation
jamesr
2015/03/05 17:36:12
scoped_ptr<T>::reset() (which is called by ~scoped
| |
| 215 | 179 |
| 216 void RunNativeApplication(InterfaceRequest<Application> application_request, | 180 void RunNativeApplication(InterfaceRequest<Application> application_request, |
| 217 const NativeRunnerFactory::Options& options, | 181 const NativeRunnerFactory::Options& options, |
| 218 NativeRunner::CleanupBehavior cleanup_behavior, | 182 NativeRunner::CleanupBehavior cleanup_behavior, |
| 219 scoped_ptr<Fetcher> fetcher, | 183 scoped_ptr<Fetcher> fetcher, |
| 220 const base::FilePath& file_path, | 184 const base::FilePath& file_path, |
| 221 bool path_exists); | 185 bool path_exists); |
| 222 | 186 |
| 223 void LoadWithContentHandler(const GURL& content_handler_url, | 187 void LoadWithContentHandler(const GURL& content_handler_url, |
| 224 InterfaceRequest<Application> application_request, | 188 InterfaceRequest<Application> application_request, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 ScopedVector<NativeRunner> native_runners_; | 222 ScopedVector<NativeRunner> native_runners_; |
| 259 bool disable_cache_; | 223 bool disable_cache_; |
| 260 | 224 |
| 261 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); | 225 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); |
| 262 }; | 226 }; |
| 263 | 227 |
| 264 } // namespace shell | 228 } // namespace shell |
| 265 } // namespace mojo | 229 } // namespace mojo |
| 266 | 230 |
| 267 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ | 231 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ |
| OLD | NEW |