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_DYNAMIC_APPLICATION_LOADER_H_ | 5 #ifndef SHELL_NATIVE_APPLICATION_LOADER_H_ |
6 #define SHELL_DYNAMIC_APPLICATION_LOADER_H_ | 6 #define SHELL_NATIVE_APPLICATION_LOADER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "mojo/public/cpp/system/core.h" | 14 #include "mojo/public/cpp/system/core.h" |
15 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | 15 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
16 #include "shell/application_manager/application_loader.h" | 16 #include "shell/application_manager/application_loader.h" |
17 #include "shell/dynamic_service_runner.h" | 17 #include "shell/dynamic_service_runner.h" |
18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
19 | 19 |
20 namespace mojo { | 20 namespace mojo { |
21 namespace shell { | 21 namespace shell { |
22 | 22 |
23 class Context; | 23 class Context; |
24 class DynamicServiceRunnerFactory; | 24 class DynamicServiceRunnerFactory; |
25 class DynamicServiceRunner; | 25 class DynamicServiceRunner; |
26 | 26 |
27 // An implementation of ApplicationLoader that retrieves a dynamic library | 27 // Loads applications that might be either DSOs or content applications. |
28 // containing the implementation of the service and loads/runs it (via a | 28 // TODO(aa): Tear this apart into: |
29 // DynamicServiceRunner). | 29 // - fetching urls (probably two sublcasses for http/file) |
30 class DynamicApplicationLoader : public ApplicationLoader { | 30 // - detecting type of response (dso, content, nacl (future)) |
| 31 // - executing response (either via DynamicServiceRunner or a content handler) |
| 32 class NativeApplicationLoader : public mojo::NativeApplicationLoader { |
31 public: | 33 public: |
32 DynamicApplicationLoader( | 34 NativeApplicationLoader( |
33 Context* context, | 35 Context* context, |
34 scoped_ptr<DynamicServiceRunnerFactory> runner_factory); | 36 scoped_ptr<DynamicServiceRunnerFactory> runner_factory); |
35 ~DynamicApplicationLoader() override; | 37 ~NativeApplicationLoader() override; |
36 | 38 |
37 void RegisterContentHandler(const std::string& mime_type, | 39 void RegisterContentHandler(const std::string& mime_type, |
38 const GURL& content_handler_url); | 40 const GURL& content_handler_url); |
39 | 41 |
40 // ApplicationLoader methods: | 42 void Load(const GURL& url, |
41 void Load(ApplicationManager* manager, | |
42 const GURL& url, | |
43 InterfaceRequest<Application> application_request, | 43 InterfaceRequest<Application> application_request, |
44 LoadCallback callback) override; | 44 LoadCallback callback) override; |
45 void OnApplicationError(ApplicationManager* manager, | |
46 const GURL& url) override; | |
47 | 45 |
48 private: | 46 private: |
49 class Loader; | 47 class Loader; |
50 class LocalLoader; | 48 class LocalLoader; |
51 class NetworkLoader; | 49 class NetworkLoader; |
52 | 50 |
53 typedef std::map<std::string, GURL> MimeTypeToURLMap; | 51 typedef std::map<std::string, GURL> MimeTypeToURLMap; |
54 typedef base::Callback<void(Loader*)> LoaderCompleteCallback; | 52 typedef base::Callback<void(Loader*)> LoaderCompleteCallback; |
55 | 53 |
56 void LoaderComplete(Loader* loader); | 54 void LoaderComplete(Loader* loader); |
57 | 55 |
58 Context* const context_; | 56 Context* const context_; |
59 scoped_ptr<DynamicServiceRunnerFactory> runner_factory_; | 57 scoped_ptr<DynamicServiceRunnerFactory> runner_factory_; |
60 NetworkServicePtr network_service_; | 58 NetworkServicePtr network_service_; |
61 MimeTypeToURLMap mime_type_to_url_; | 59 MimeTypeToURLMap mime_type_to_url_; |
62 ScopedVector<Loader> loaders_; | 60 ScopedVector<Loader> loaders_; |
63 LoaderCompleteCallback loader_complete_callback_; | 61 LoaderCompleteCallback loader_complete_callback_; |
64 | 62 |
65 DISALLOW_COPY_AND_ASSIGN(DynamicApplicationLoader); | 63 DISALLOW_COPY_AND_ASSIGN(NativeApplicationLoader); |
66 }; | 64 }; |
67 | 65 |
68 } // namespace shell | 66 } // namespace shell |
69 } // namespace mojo | 67 } // namespace mojo |
70 | 68 |
71 #endif // SHELL_DYNAMIC_APPLICATION_LOADER_H_ | 69 #endif // SHELL_NATIVE_APPLICATION_LOADER_H_ |
OLD | NEW |