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

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: blech 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 LoadServiceCallbacks : public base::RefCounted<LoadServiceCallbacks> {
darin (slow to review) 2014/08/06 23:10:02 nit: you might consider just naming this class Cal
Aaron Boodman 2014/08/07 00:03:12 I like the second idea. Done.
29 public:
30 // Register the requested application with ServiceManager. If the returned
31 // handle is valid, it should be used to implement the mojo::Application
32 // interface.
33 virtual ScopedMessagePipeHandle RegisterApplication() = 0;
34
35 // Load the requested application with a content handler.
36 virtual void LoadWithContentHandler(const GURL& content_handler_url,
37 URLResponsePtr response) = 0;
38 protected:
39 friend base::RefCounted<LoadServiceCallbacks>;
40 virtual ~LoadServiceCallbacks() {}
41 };
42
43 // Implements RegisterApplication() by returning a handle that was specified
44 // at construction time. LoadWithContentHandler() is not supported.
45 class SimpleLoadServiceCallbacks : public LoadServiceCallbacks {
46 public:
47 SimpleLoadServiceCallbacks(ScopedMessagePipeHandle shell_handle);
48 virtual ScopedMessagePipeHandle RegisterApplication() OVERRIDE;
49 virtual void LoadWithContentHandler(const GURL& content_handler_url,
50 URLResponsePtr response) OVERRIDE;
51 private:
52 ScopedMessagePipeHandle shell_handle_;
53 virtual ~SimpleLoadServiceCallbacks();
54 };
55
26 virtual ~ServiceLoader() {} 56 virtual ~ServiceLoader() {}
27 virtual void LoadService(ServiceManager* manager, 57
58 // Load the application named |url|. Applications can be loaded two ways:
59 //
60 // 1. |url| can refer directly to a Mojo application. In this case, call
61 // callbacks->RegisterApplication(). The returned handle should be used to
62 // implement the mojo.Application interface. Note that the returned handle
63 // can be invalid in the case where the application has already been
64 // loaded.
65 //
66 // 2. |url| can refer to some content that can be handled by some other Mojo
67 // application. In this case, call callbacks->LoadWithContentHandler() and
68 // specify the URL of the application that should handle the content.
69 // The specified application must implement the mojo.ContentHandler
70 // interface.
71 virtual void LoadService(ServiceManager* service_manager,
darin (slow to review) 2014/08/06 23:10:01 nit: this method could just be called Load
Aaron Boodman 2014/08/07 00:03:12 Done.
28 const GURL& url, 72 const GURL& url,
29 ScopedMessagePipeHandle shell_handle) = 0; 73 scoped_refptr<LoadServiceCallbacks> callbacks) = 0;
74
30 virtual void OnServiceError(ServiceManager* manager, const GURL& url) = 0; 75 virtual void OnServiceError(ServiceManager* manager, const GURL& url) = 0;
31 76
32 protected: 77 protected:
33 ServiceLoader() {} 78 ServiceLoader() {}
34 }; 79 };
35 80
36 } // namespace mojo 81 } // namespace mojo
37 82
38 #endif // MOJO_SERVICE_MANAGER_SERVICE_LOADER_H_ 83 #endif // MOJO_SERVICE_MANAGER_SERVICE_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698