Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: mojo/shell/dynamic_application_loader.h

Issue 513573002: Mojo: Fix two bugs in content handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Darin comments, updates for Android toolchain Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "mojo/application_manager/application_loader.h" 13 #include "mojo/application_manager/application_loader.h"
14 #include "mojo/public/cpp/system/core.h" 14 #include "mojo/public/cpp/system/core.h"
15 #include "mojo/services/public/interfaces/network/network_service.mojom.h" 15 #include "mojo/services/public/interfaces/network/network_service.mojom.h"
16 #include "mojo/shell/dynamic_service_runner.h" 16 #include "mojo/shell/dynamic_service_runner.h"
17 #include "url/gurl.h" 17 #include "url/gurl.h"
18 18
19 namespace mojo { 19 namespace mojo {
20 namespace shell { 20 namespace shell {
21 21
22 class Context; 22 class Context;
23 class DynamicServiceRunnerFactory; 23 class DynamicServiceRunnerFactory;
24 class DynamicServiceRunner; 24 class DynamicServiceRunner;
25 class Loader;
26
27 namespace internal {
28
29 // Please do not use, this is an implementation detail.
darin (slow to review) 2014/08/27 06:34:19 it would be possible to hide this by moving most o
30 class LoaderDelegate {
31 public:
32 virtual void LoaderComplete(Loader* loader) = 0;
33 virtual scoped_ptr<DynamicServiceRunner> CreateRunner() = 0;
34 virtual void CreateURLLoader(InterfaceRequest<URLLoader> loader_request) = 0;
35 virtual const GURL& GetContentHandlerURL(const std::string& mime_type) = 0;
36 virtual base::SequencedWorkerPool* GetBlockingPool() = 0;
37 virtual ~LoaderDelegate() {
darin (slow to review) 2014/08/27 06:34:19 nit: list dtor first as that's pretty canonical.
Aaron Boodman 2014/08/27 18:26:13 irrelevant in latest patch.
38 }
39 };
40
41 } // namespace internal
25 42
26 // An implementation of ApplicationLoader that retrieves a dynamic library 43 // An implementation of ApplicationLoader that retrieves a dynamic library
27 // containing the implementation of the service and loads/runs it (via a 44 // containing the implementation of the service and loads/runs it (via a
28 // DynamicServiceRunner). 45 // DynamicServiceRunner).
29 class DynamicApplicationLoader : public ApplicationLoader { 46 class DynamicApplicationLoader : public ApplicationLoader,
47 public internal::LoaderDelegate {
30 public: 48 public:
31 DynamicApplicationLoader( 49 DynamicApplicationLoader(
32 Context* context, 50 Context* context,
33 scoped_ptr<DynamicServiceRunnerFactory> runner_factory); 51 scoped_ptr<DynamicServiceRunnerFactory> runner_factory);
34 virtual ~DynamicApplicationLoader(); 52 virtual ~DynamicApplicationLoader();
35 53
36 void RegisterContentHandler(const std::string& mime_type, 54 void RegisterContentHandler(const std::string& mime_type,
37 const GURL& content_handler_url); 55 const GURL& content_handler_url);
38 56
39 // ApplicationLoader methods: 57 // ApplicationLoader methods:
40 virtual void Load(ApplicationManager* manager, 58 virtual void Load(ApplicationManager* manager,
41 const GURL& url, 59 const GURL& url,
42 scoped_refptr<LoadCallbacks> callbacks) OVERRIDE; 60 scoped_refptr<LoadCallbacks> callbacks) OVERRIDE;
43 virtual void OnApplicationError(ApplicationManager* manager, 61 virtual void OnApplicationError(ApplicationManager* manager,
44 const GURL& url) OVERRIDE; 62 const GURL& url) OVERRIDE;
45 63
46 private: 64 private:
47 typedef std::map<std::string, GURL> MimeTypeToURLMap; 65 typedef std::map<std::string, GURL> MimeTypeToURLMap;
48 66
49 void LoadLocalService(const GURL& resolved_url, 67 // LoaderDelegate methods:
50 scoped_refptr<LoadCallbacks> callbacks); 68 virtual void LoaderComplete(Loader* loader) OVERRIDE;
51 void LoadNetworkService(const GURL& resolved_url, 69 virtual scoped_ptr<DynamicServiceRunner> CreateRunner() OVERRIDE;
52 scoped_refptr<LoadCallbacks> callbacks); 70 virtual void CreateURLLoader(
53 void OnLoadNetworkServiceComplete(scoped_refptr<LoadCallbacks> callbacks, 71 InterfaceRequest<URLLoader> loader_request) OVERRIDE;
54 URLResponsePtr url_response); 72 virtual const GURL& GetContentHandlerURL(
55 void RunLibrary(const base::FilePath& response_file, 73 const std::string& mime_type) OVERRIDE;
56 scoped_refptr<LoadCallbacks> callbacks, 74 virtual base::SequencedWorkerPool* GetBlockingPool() OVERRIDE;
57 bool delete_file_after,
58 bool response_path_exists);
59 void OnRunLibraryComplete(DynamicServiceRunner* runner,
60 const base::FilePath& temp_file);
61 75
62 Context* const context_; 76 Context* const context_;
63 scoped_ptr<DynamicServiceRunnerFactory> runner_factory_; 77 scoped_ptr<DynamicServiceRunnerFactory> runner_factory_;
64 ScopedVector<DynamicServiceRunner> runners_;
65 NetworkServicePtr network_service_; 78 NetworkServicePtr network_service_;
66 URLLoaderPtr url_loader_;
67 MimeTypeToURLMap mime_type_to_url_; 79 MimeTypeToURLMap mime_type_to_url_;
68 base::WeakPtrFactory<DynamicApplicationLoader> weak_ptr_factory_; 80 ScopedVector<Loader> loaders_;
69 81
70 DISALLOW_COPY_AND_ASSIGN(DynamicApplicationLoader); 82 DISALLOW_COPY_AND_ASSIGN(DynamicApplicationLoader);
71 }; 83 };
72 84
73 } // namespace shell 85 } // namespace shell
74 } // namespace mojo 86 } // namespace mojo
75 87
76 #endif // MOJO_SHELL_DYNAMIC_APPLICATION_LOADER_H_ 88 #endif // MOJO_SHELL_DYNAMIC_APPLICATION_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698