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/macros.h" | 10 #include "base/macros.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 class Context; | 22 class Context; |
23 class DynamicServiceRunnerFactory; | 23 class DynamicServiceRunnerFactory; |
24 class DynamicServiceRunner; | 24 class DynamicServiceRunner; |
25 | 25 |
26 // An implementation of ApplicationLoader that retrieves a dynamic library | 26 // An implementation of ApplicationLoader that retrieves a dynamic library |
27 // containing the implementation of the service and loads/runs it (via a | 27 // containing the implementation of the service and loads/runs it (via a |
28 // DynamicServiceRunner). | 28 // DynamicServiceRunner). |
29 class DynamicApplicationLoader : public ApplicationLoader { | 29 class DynamicApplicationLoader : public ApplicationLoader { |
30 public: | 30 public: |
| 31 typedef std::map<std::string, GURL> MimeTypeToURLMap; |
| 32 |
31 DynamicApplicationLoader( | 33 DynamicApplicationLoader( |
32 Context* context, | 34 Context* context, |
33 scoped_ptr<DynamicServiceRunnerFactory> runner_factory); | 35 scoped_ptr<DynamicServiceRunnerFactory> runner_factory); |
34 virtual ~DynamicApplicationLoader(); | 36 virtual ~DynamicApplicationLoader(); |
35 | 37 |
36 void RegisterContentHandler(const std::string& mime_type, | 38 void RegisterContentHandler(const std::string& mime_type, |
37 const GURL& content_handler_url); | 39 const GURL& content_handler_url); |
38 | 40 |
39 // ApplicationLoader methods: | 41 // ApplicationLoader methods: |
40 virtual void Load(ApplicationManager* manager, | 42 virtual void Load(ApplicationManager* manager, |
41 const GURL& url, | 43 const GURL& url, |
42 scoped_refptr<LoadCallbacks> callbacks) OVERRIDE; | 44 scoped_refptr<LoadCallbacks> callbacks) OVERRIDE; |
43 virtual void OnServiceError(ApplicationManager* manager, | 45 virtual void OnServiceError(ApplicationManager* manager, |
44 const GURL& url) OVERRIDE; | 46 const GURL& url) OVERRIDE; |
45 | 47 |
46 private: | 48 private: |
47 typedef std::map<std::string, GURL> MimeTypeToURLMap; | |
48 | |
49 void LoadLocalService(const GURL& resolved_url, | 49 void LoadLocalService(const GURL& resolved_url, |
50 scoped_refptr<LoadCallbacks> callbacks); | 50 scoped_refptr<LoadCallbacks> callbacks); |
51 void LoadNetworkService(const GURL& resolved_url, | 51 void LoadNetworkService(const GURL& resolved_url, |
52 scoped_refptr<LoadCallbacks> callbacks); | 52 scoped_refptr<LoadCallbacks> callbacks); |
53 void OnLoadNetworkServiceComplete(scoped_refptr<LoadCallbacks> callbacks, | 53 void OnLoadNetworkServiceComplete(scoped_refptr<LoadCallbacks> callbacks, |
| 54 URLLoaderPtr url_loader, |
54 URLResponsePtr url_response); | 55 URLResponsePtr url_response); |
55 void RunLibrary(const base::FilePath& response_file, | 56 void RunLibrary(const base::FilePath& response_file, |
56 scoped_refptr<LoadCallbacks> callbacks, | 57 scoped_refptr<LoadCallbacks> callbacks, |
57 bool delete_file_after, | 58 bool delete_file_after, |
58 bool response_path_exists); | 59 bool response_path_exists); |
59 void OnRunLibraryComplete(DynamicServiceRunner* runner, | 60 void OnRunLibraryComplete(DynamicServiceRunner* runner, |
60 const base::FilePath& temp_file); | 61 const base::FilePath& temp_file); |
61 | 62 |
62 Context* const context_; | 63 Context* const context_; |
63 scoped_ptr<DynamicServiceRunnerFactory> runner_factory_; | 64 scoped_ptr<DynamicServiceRunnerFactory> runner_factory_; |
64 ScopedVector<DynamicServiceRunner> runners_; | |
65 NetworkServicePtr network_service_; | 65 NetworkServicePtr network_service_; |
66 URLLoaderPtr url_loader_; | |
67 MimeTypeToURLMap mime_type_to_url_; | 66 MimeTypeToURLMap mime_type_to_url_; |
68 base::WeakPtrFactory<DynamicApplicationLoader> weak_ptr_factory_; | 67 base::WeakPtrFactory<DynamicApplicationLoader> weak_ptr_factory_; |
69 | 68 |
70 DISALLOW_COPY_AND_ASSIGN(DynamicApplicationLoader); | 69 DISALLOW_COPY_AND_ASSIGN(DynamicApplicationLoader); |
71 }; | 70 }; |
72 | 71 |
73 } // namespace shell | 72 } // namespace shell |
74 } // namespace mojo | 73 } // namespace mojo |
75 | 74 |
76 #endif // MOJO_SHELL_DYNAMIC_APPLICATION_LOADER_H_ | 75 #endif // MOJO_SHELL_DYNAMIC_APPLICATION_LOADER_H_ |
OLD | NEW |