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

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: more gn 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/service_manager/service_manager_export.h" 10 #include "mojo/service_manager/service_manager_export.h"
11 #include "mojo/services/public/interfaces/network/url_loader.mojom.h"
10 #include "url/gurl.h" 12 #include "url/gurl.h"
11 13
12 namespace mojo { 14 namespace mojo {
13 15
14 class ServiceManager; 16 class ServiceManager;
15 17
16 // Interface to allowing loading behavior to be established for schemes, 18 // Interface to allowing loading behavior to be established for schemes,
17 // specific urls or as the default. 19 // specific urls or as the default.
18 // A ServiceLoader is responsible to using whatever mechanism is appropriate 20 // A ServiceLoader is responsible to using whatever mechanism is appropriate
19 // to load the application at url. 21 // to load the application at url.
20 // TODO(davemoore): change name to ApplicationLoader. 22 // TODO(davemoore): change name to ApplicationLoader.
21 // The handle to the shell is passed to that application so it can bind it to 23 // The handle to the shell is passed to that application so it can bind it to
22 // a Shell instance. This will give the Application a way to connect to other 24 // a Shell instance. This will give the Application a way to connect to other
23 // apps and services. 25 // apps and services.
24 class MOJO_SERVICE_MANAGER_EXPORT ServiceLoader { 26 class MOJO_SERVICE_MANAGER_EXPORT ServiceLoader {
25 public: 27 public:
28 class MOJO_SERVICE_MANAGER_EXPORT LoadCallbacks
29 : public base::RefCounted<LoadCallbacks> {
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<LoadCallbacks>;
41 virtual ~LoadCallbacks() {}
42 };
43
44 // Implements RegisterApplication() by returning a handle that was specified
45 // at construction time. LoadWithContentHandler() is not supported.
46 class MOJO_SERVICE_MANAGER_EXPORT SimpleLoadCallbacks : public LoadCallbacks {
47 public:
48 SimpleLoadCallbacks(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 ~SimpleLoadCallbacks();
55 };
56
26 virtual ~ServiceLoader() {} 57 virtual ~ServiceLoader() {}
27 virtual void LoadService(ServiceManager* manager, 58
28 const GURL& url, 59 // Load the application named |url|. Applications can be loaded two ways:
29 ScopedMessagePipeHandle shell_handle) = 0; 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 Load(ServiceManager* service_manager,
73 const GURL& url,
74 scoped_refptr<LoadCallbacks> callbacks) = 0;
75
30 virtual void OnServiceError(ServiceManager* manager, const GURL& url) = 0; 76 virtual void OnServiceError(ServiceManager* manager, const GURL& url) = 0;
31 77
32 protected: 78 protected:
33 ServiceLoader() {} 79 ServiceLoader() {}
34 }; 80 };
35 81
36 } // namespace mojo 82 } // namespace mojo
37 83
38 #endif // MOJO_SERVICE_MANAGER_SERVICE_LOADER_H_ 84 #endif // MOJO_SERVICE_MANAGER_SERVICE_LOADER_H_
OLDNEW
« no previous file with comments | « mojo/service_manager/background_shell_service_loader_unittest.cc ('k') | mojo/service_manager/service_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698