| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MOJO_SHELL_DYNAMIC_APPLICATION_LOADER_H_ | |
| 6 #define MOJO_SHELL_DYNAMIC_APPLICATION_LOADER_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/scoped_vector.h" | |
| 13 #include "base/memory/weak_ptr.h" | |
| 14 #include "mojo/application_manager/application_loader.h" | |
| 15 #include "mojo/public/cpp/system/core.h" | |
| 16 #include "mojo/services/public/interfaces/network/network_service.mojom.h" | |
| 17 #include "mojo/shell/dynamic_service_runner.h" | |
| 18 #include "url/gurl.h" | |
| 19 | |
| 20 namespace mojo { | |
| 21 namespace shell { | |
| 22 | |
| 23 class Context; | |
| 24 class DynamicServiceRunnerFactory; | |
| 25 class DynamicServiceRunner; | |
| 26 | |
| 27 // An implementation of ApplicationLoader that retrieves a dynamic library | |
| 28 // containing the implementation of the service and loads/runs it (via a | |
| 29 // DynamicServiceRunner). | |
| 30 class DynamicApplicationLoader : public ApplicationLoader { | |
| 31 public: | |
| 32 DynamicApplicationLoader( | |
| 33 Context* context, | |
| 34 scoped_ptr<DynamicServiceRunnerFactory> runner_factory); | |
| 35 ~DynamicApplicationLoader() override; | |
| 36 | |
| 37 void RegisterContentHandler(const std::string& mime_type, | |
| 38 const GURL& content_handler_url); | |
| 39 | |
| 40 // ApplicationLoader methods: | |
| 41 void Load(ApplicationManager* manager, | |
| 42 const GURL& url, | |
| 43 scoped_refptr<LoadCallbacks> callbacks) override; | |
| 44 void OnApplicationError(ApplicationManager* manager, | |
| 45 const GURL& url) override; | |
| 46 | |
| 47 private: | |
| 48 class Loader; | |
| 49 class LocalLoader; | |
| 50 class NetworkLoader; | |
| 51 | |
| 52 typedef std::map<std::string, GURL> MimeTypeToURLMap; | |
| 53 typedef base::Callback<void(Loader*)> LoaderCompleteCallback; | |
| 54 | |
| 55 void LoaderComplete(Loader* loader); | |
| 56 | |
| 57 Context* const context_; | |
| 58 scoped_ptr<DynamicServiceRunnerFactory> runner_factory_; | |
| 59 NetworkServicePtr network_service_; | |
| 60 MimeTypeToURLMap mime_type_to_url_; | |
| 61 ScopedVector<Loader> loaders_; | |
| 62 LoaderCompleteCallback loader_complete_callback_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(DynamicApplicationLoader); | |
| 65 }; | |
| 66 | |
| 67 } // namespace shell | |
| 68 } // namespace mojo | |
| 69 | |
| 70 #endif // MOJO_SHELL_DYNAMIC_APPLICATION_LOADER_H_ | |
| OLD | NEW |