| 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 ScopedMessagePipeHandle shell_handle, | |
| 44 LoadCallback callback) override; | |
| 45 void OnApplicationError(ApplicationManager* manager, | |
| 46 const GURL& url) override; | |
| 47 | |
| 48 private: | |
| 49 class Loader; | |
| 50 class LocalLoader; | |
| 51 class NetworkLoader; | |
| 52 | |
| 53 typedef std::map<std::string, GURL> MimeTypeToURLMap; | |
| 54 typedef base::Callback<void(Loader*)> LoaderCompleteCallback; | |
| 55 | |
| 56 void LoaderComplete(Loader* loader); | |
| 57 | |
| 58 Context* const context_; | |
| 59 scoped_ptr<DynamicServiceRunnerFactory> runner_factory_; | |
| 60 NetworkServicePtr network_service_; | |
| 61 MimeTypeToURLMap mime_type_to_url_; | |
| 62 ScopedVector<Loader> loaders_; | |
| 63 LoaderCompleteCallback loader_complete_callback_; | |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(DynamicApplicationLoader); | |
| 66 }; | |
| 67 | |
| 68 } // namespace shell | |
| 69 } // namespace mojo | |
| 70 | |
| 71 #endif // MOJO_SHELL_DYNAMIC_APPLICATION_LOADER_H_ | |
| OLD | NEW |