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

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

Issue 423963004: First cut at "content handling" support in Mojo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use URLResponse with ContentHandler interface instead of data pipe Created 6 years, 4 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 | Annotate | Revision Log
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_SERVICE_LOADER_H_ 5 #ifndef MOJO_SHELL_DYNAMIC_SERVICE_LOADER_H_
6 #define MOJO_SHELL_DYNAMIC_SERVICE_LOADER_H_ 6 #define MOJO_SHELL_DYNAMIC_SERVICE_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/weak_ptr.h"
11 #include "mojo/public/cpp/system/core.h" 12 #include "mojo/public/cpp/system/core.h"
12 #include "mojo/service_manager/service_loader.h" 13 #include "mojo/service_manager/service_loader.h"
13 #include "mojo/services/public/interfaces/network/network_service.mojom.h" 14 #include "mojo/services/public/interfaces/network/network_service.mojom.h"
14 #include "mojo/shell/dynamic_service_runner.h" 15 #include "mojo/shell/dynamic_service_runner.h"
15 #include "mojo/shell/keep_alive.h" 16 #include "mojo/shell/keep_alive.h"
16 #include "url/gurl.h" 17 #include "url/gurl.h"
17 18
18 namespace mojo { 19 namespace mojo {
19 namespace shell { 20 namespace shell {
20 21
21 class Context; 22 class Context;
22 class DynamicServiceRunnerFactory; 23 class DynamicServiceRunnerFactory;
23 24
24 // An implementation of ServiceLoader that retrieves a dynamic library 25 // An implementation of ServiceLoader that retrieves a dynamic library
25 // containing the implementation of the service and loads/runs it (via a 26 // containing the implementation of the service and loads/runs it (via a
26 // DynamicServiceRunner). 27 // DynamicServiceRunner).
27 class DynamicServiceLoader : public ServiceLoader { 28 class DynamicServiceLoader : public ServiceLoader {
28 public: 29 public:
29 DynamicServiceLoader(Context* context, 30 DynamicServiceLoader(Context* context,
30 scoped_ptr<DynamicServiceRunnerFactory> runner_factory); 31 scoped_ptr<DynamicServiceRunnerFactory> runner_factory);
31 virtual ~DynamicServiceLoader(); 32 virtual ~DynamicServiceLoader();
32 33
34 void set_content_handler(const std::string& mime_type,
35 const GURL& content_handler_url);
36
33 // ServiceLoader methods: 37 // ServiceLoader methods:
34 virtual void LoadService(ServiceManager* manager, 38 virtual void LoadService(
35 const GURL& url, 39 ServiceManager* manager,
36 ScopedMessagePipeHandle service_handle) OVERRIDE; 40 const GURL& url,
41 scoped_refptr<LoadServiceCallbacks> callbacks) OVERRIDE;
37 virtual void OnServiceError(ServiceManager* manager, const GURL& url) 42 virtual void OnServiceError(ServiceManager* manager, const GURL& url)
38 OVERRIDE; 43 OVERRIDE;
39 44
40 private: 45 private:
46 typedef std::map<std::string, GURL> ContentHandlerMap;
DaveMoore 2014/08/04 21:50:52 Nit: MimeTypeToURLMap or MimeTypeToContentHandlerM
Aaron Boodman 2014/08/05 05:44:55 Done.
47
48 void LoadLocalService(const GURL& resolved_url,
49 scoped_refptr<LoadServiceCallbacks> callbacks);
50 void LoadNetworkService(const GURL& resolved_url,
51 scoped_refptr<LoadServiceCallbacks> callbacks);
52 void OnLoadNetworkServiceComplete(
53 scoped_refptr<LoadServiceCallbacks> callbacks,
54 URLResponsePtr url_response);
55 void RunLibrary(const base::FilePath& response_file,
56 scoped_refptr<LoadServiceCallbacks> callbacks,
57 bool response_path_exists);
58
41 Context* const context_; 59 Context* const context_;
42 scoped_ptr<DynamicServiceRunnerFactory> runner_factory_; 60 scoped_ptr<DynamicServiceRunnerFactory> runner_factory_;
43 NetworkServicePtr network_service_; 61 NetworkServicePtr network_service_;
62 URLLoaderPtr url_loader_;
63 ContentHandlerMap content_handler_map_;
64 base::WeakPtrFactory<DynamicServiceLoader> weak_ptr_factory_;
44 65
45 DISALLOW_COPY_AND_ASSIGN(DynamicServiceLoader); 66 DISALLOW_COPY_AND_ASSIGN(DynamicServiceLoader);
46 }; 67 };
47 68
48 } // namespace shell 69 } // namespace shell
49 } // namespace mojo 70 } // namespace mojo
50 71
51 #endif // MOJO_SHELL_DYNAMIC_SERVICE_LOADER_H_ 72 #endif // MOJO_SHELL_DYNAMIC_SERVICE_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698