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

Side by Side Diff: mojo/service_manager/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_SERVICE_MANAGER_SERVICE_LOADER_H_ 5 #ifndef MOJO_SERVICE_MANAGER_SERVICE_LOADER_H_
6 #define MOJO_SERVICE_MANAGER_SERVICE_LOADER_H_ 6 #define MOJO_SERVICE_MANAGER_SERVICE_LOADER_H_
7 7
8 #include "base/memory/ref_counted.h"
8 #include "mojo/public/cpp/system/core.h" 9 #include "mojo/public/cpp/system/core.h"
9 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" 10 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
10 #include "mojo/service_manager/service_manager_export.h" 11 #include "mojo/service_manager/service_manager_export.h"
12 #include "mojo/services/public/interfaces/network/url_loader.mojom.h"
11 #include "url/gurl.h" 13 #include "url/gurl.h"
12 14
13 namespace mojo { 15 namespace mojo {
14 16
15 class ServiceManager; 17 class ServiceManager;
16 18
17 // Interface to allowing loading behavior to be established for schemes, 19 // Interface to allowing loading behavior to be established for schemes,
18 // specific urls or as the default. 20 // specific urls or as the default.
19 // A ServiceLoader is responsible to using whatever mechanism is appropriate 21 // A ServiceLoader is responsible to using whatever mechanism is appropriate
20 // to load the application at url. 22 // to load the application at url.
21 // TODO(davemoore): change name to ApplicationLoader. 23 // TODO(davemoore): change name to ApplicationLoader.
22 // The handle to the shell is passed to that application so it can bind it to 24 // The handle to the shell is passed to that application so it can bind it to
23 // a Shell instance. This will give the Application a way to connect to other 25 // a Shell instance. This will give the Application a way to connect to other
24 // apps and services. 26 // apps and services.
25 class MOJO_SERVICE_MANAGER_EXPORT ServiceLoader { 27 class MOJO_SERVICE_MANAGER_EXPORT ServiceLoader {
26 public: 28 public:
29 class LoadServiceCallbacks : public base::RefCounted<LoadServiceCallbacks> {
30 public:
31 // Register the requested application with ServiceManager. If the returned
32 // handle is valid, it should be used to implement the mojo::Application
33 // interface.
34 virtual ScopedMessagePipeHandle RegisterApplication() = 0;
35
36 // Load the requested application with a content handler.
37 virtual void LoadWithContentHandler(const GURL& content_handler_url,
38 URLResponsePtr response) = 0;
39 protected:
40 friend base::RefCounted<LoadServiceCallbacks>;
41 virtual ~LoadServiceCallbacks() {}
42 };
43
44 // Implements RegisterApplication() by returning a handle that was specified
45 // at construction time. LoadWithContentHandler() is not supported.
46 class SimpleLoadServiceCallbacks : public LoadServiceCallbacks {
47 public:
48 SimpleLoadServiceCallbacks(ScopedMessagePipeHandle shell_handle);
49 virtual ScopedMessagePipeHandle RegisterApplication() OVERRIDE;
50 virtual void LoadWithContentHandler(const GURL& content_handler_url,
51 URLResponsePtr response) OVERRIDE;
52 private:
53 ScopedMessagePipeHandle shell_handle_;
54 virtual ~SimpleLoadServiceCallbacks();
55 };
56
27 virtual ~ServiceLoader() {} 57 virtual ~ServiceLoader() {}
28 virtual void LoadService(ServiceManager* manager, 58
59 // Load the application named |url|. Applications can be loaded two ways:
60 //
61 // 1. |url| can refer directly to a Mojo application. In this case, call
62 // callbacks->RegisterApplication(). The returned handle should be used to
63 // implement the mojo.Application interface. Note that the returned handle
64 // can be invalid in the case where the application has already been
65 // loaded.
66 //
67 // 2. |url| can refer to some content that can be handled by some other Mojo
68 // application. In this case, call callbacks->LoadWithContentHandler() and
69 // specify the URL of the application that should handle the content.
70 // The specified application must implement the mojo.ContentHandler
71 // interface.
72 virtual void LoadService(ServiceManager* service_manager,
29 const GURL& url, 73 const GURL& url,
30 ScopedMessagePipeHandle shell_handle) = 0; 74 scoped_refptr<LoadServiceCallbacks> callbacks) = 0;
75
31 virtual void OnServiceError(ServiceManager* manager, const GURL& url) = 0; 76 virtual void OnServiceError(ServiceManager* manager, const GURL& url) = 0;
32 77
33 protected: 78 protected:
34 ServiceLoader() {} 79 ServiceLoader() {}
35 }; 80 };
36 81
37 } // namespace mojo 82 } // namespace mojo
38 83
39 #endif // MOJO_SERVICE_MANAGER_SERVICE_LOADER_H_ 84 #endif // MOJO_SERVICE_MANAGER_SERVICE_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698