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_DYNAMIC_APPLICATION_LOADER_H_ | 5 #ifndef MOJO_SHELL_DYNAMIC_APPLICATION_LOADER_H_ |
6 #define MOJO_SHELL_DYNAMIC_APPLICATION_LOADER_H_ | 6 #define MOJO_SHELL_DYNAMIC_APPLICATION_LOADER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
| 10 #include "base/callback.h" |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
13 #include "mojo/application_manager/application_loader.h" | 14 #include "mojo/application_manager/application_loader.h" |
14 #include "mojo/public/cpp/system/core.h" | 15 #include "mojo/public/cpp/system/core.h" |
15 #include "mojo/services/public/interfaces/network/network_service.mojom.h" | 16 #include "mojo/services/public/interfaces/network/network_service.mojom.h" |
16 #include "mojo/shell/dynamic_service_runner.h" | 17 #include "mojo/shell/dynamic_service_runner.h" |
17 #include "url/gurl.h" | 18 #include "url/gurl.h" |
18 | 19 |
19 namespace mojo { | 20 namespace mojo { |
(...skipping 17 matching lines...) Expand all Loading... |
37 const GURL& content_handler_url); | 38 const GURL& content_handler_url); |
38 | 39 |
39 // ApplicationLoader methods: | 40 // ApplicationLoader methods: |
40 virtual void Load(ApplicationManager* manager, | 41 virtual void Load(ApplicationManager* manager, |
41 const GURL& url, | 42 const GURL& url, |
42 scoped_refptr<LoadCallbacks> callbacks) OVERRIDE; | 43 scoped_refptr<LoadCallbacks> callbacks) OVERRIDE; |
43 virtual void OnApplicationError(ApplicationManager* manager, | 44 virtual void OnApplicationError(ApplicationManager* manager, |
44 const GURL& url) OVERRIDE; | 45 const GURL& url) OVERRIDE; |
45 | 46 |
46 private: | 47 private: |
| 48 class Loader; |
| 49 class LocalLoader; |
| 50 class NetworkLoader; |
| 51 |
47 typedef std::map<std::string, GURL> MimeTypeToURLMap; | 52 typedef std::map<std::string, GURL> MimeTypeToURLMap; |
| 53 typedef base::Callback<void(Loader*)> LoaderCompleteCallback; |
48 | 54 |
49 void LoadLocalService(const GURL& resolved_url, | 55 void LoaderComplete(Loader* loader); |
50 scoped_refptr<LoadCallbacks> callbacks); | |
51 void LoadNetworkService(const GURL& resolved_url, | |
52 scoped_refptr<LoadCallbacks> callbacks); | |
53 void OnLoadNetworkServiceComplete(scoped_refptr<LoadCallbacks> callbacks, | |
54 URLResponsePtr url_response); | |
55 void RunLibrary(const base::FilePath& response_file, | |
56 scoped_refptr<LoadCallbacks> callbacks, | |
57 bool delete_file_after, | |
58 bool response_path_exists); | |
59 void OnRunLibraryComplete(DynamicServiceRunner* runner, | |
60 const base::FilePath& temp_file); | |
61 | 56 |
62 Context* const context_; | 57 Context* const context_; |
63 scoped_ptr<DynamicServiceRunnerFactory> runner_factory_; | 58 scoped_ptr<DynamicServiceRunnerFactory> runner_factory_; |
64 ScopedVector<DynamicServiceRunner> runners_; | |
65 NetworkServicePtr network_service_; | 59 NetworkServicePtr network_service_; |
66 URLLoaderPtr url_loader_; | |
67 MimeTypeToURLMap mime_type_to_url_; | 60 MimeTypeToURLMap mime_type_to_url_; |
68 base::WeakPtrFactory<DynamicApplicationLoader> weak_ptr_factory_; | 61 ScopedVector<Loader> loaders_; |
| 62 LoaderCompleteCallback loader_complete_callback_; |
69 | 63 |
70 DISALLOW_COPY_AND_ASSIGN(DynamicApplicationLoader); | 64 DISALLOW_COPY_AND_ASSIGN(DynamicApplicationLoader); |
71 }; | 65 }; |
72 | 66 |
73 } // namespace shell | 67 } // namespace shell |
74 } // namespace mojo | 68 } // namespace mojo |
75 | 69 |
76 #endif // MOJO_SHELL_DYNAMIC_APPLICATION_LOADER_H_ | 70 #endif // MOJO_SHELL_DYNAMIC_APPLICATION_LOADER_H_ |
OLD | NEW |