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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: mojo/service_manager/service_loader.h
diff --git a/mojo/service_manager/service_loader.h b/mojo/service_manager/service_loader.h
index 07be7d9a1bf0a314ce4f257bf045c2be2b6524af..9ea7f64a4311e03ed4b32b5aa65548518cbd84ba 100644
--- a/mojo/service_manager/service_loader.h
+++ b/mojo/service_manager/service_loader.h
@@ -5,8 +5,10 @@
#ifndef MOJO_SERVICE_MANAGER_SERVICE_LOADER_H_
#define MOJO_SERVICE_MANAGER_SERVICE_LOADER_H_
+#include "base/memory/ref_counted.h"
#include "mojo/public/cpp/system/core.h"
#include "mojo/service_manager/service_manager_export.h"
+#include "mojo/services/public/interfaces/network/url_loader.mojom.h"
#include "url/gurl.h"
namespace mojo {
@@ -23,10 +25,53 @@ class ServiceManager;
// apps and services.
class MOJO_SERVICE_MANAGER_EXPORT ServiceLoader {
public:
+ 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.
+ public:
+ // Register the requested application with ServiceManager. If the returned
+ // handle is valid, it should be used to implement the mojo::Application
+ // interface.
+ virtual ScopedMessagePipeHandle RegisterApplication() = 0;
+
+ // Load the requested application with a content handler.
+ virtual void LoadWithContentHandler(const GURL& content_handler_url,
+ URLResponsePtr response) = 0;
+ protected:
+ friend base::RefCounted<LoadServiceCallbacks>;
+ virtual ~LoadServiceCallbacks() {}
+ };
+
+ // Implements RegisterApplication() by returning a handle that was specified
+ // at construction time. LoadWithContentHandler() is not supported.
+ class SimpleLoadServiceCallbacks : public LoadServiceCallbacks {
+ public:
+ SimpleLoadServiceCallbacks(ScopedMessagePipeHandle shell_handle);
+ virtual ScopedMessagePipeHandle RegisterApplication() OVERRIDE;
+ virtual void LoadWithContentHandler(const GURL& content_handler_url,
+ URLResponsePtr response) OVERRIDE;
+ private:
+ ScopedMessagePipeHandle shell_handle_;
+ virtual ~SimpleLoadServiceCallbacks();
+ };
+
virtual ~ServiceLoader() {}
- virtual void LoadService(ServiceManager* manager,
+
+ // Load the application named |url|. Applications can be loaded two ways:
+ //
+ // 1. |url| can refer directly to a Mojo application. In this case, call
+ // callbacks->RegisterApplication(). The returned handle should be used to
+ // implement the mojo.Application interface. Note that the returned handle
+ // can be invalid in the case where the application has already been
+ // loaded.
+ //
+ // 2. |url| can refer to some content that can be handled by some other Mojo
+ // application. In this case, call callbacks->LoadWithContentHandler() and
+ // specify the URL of the application that should handle the content.
+ // The specified application must implement the mojo.ContentHandler
+ // interface.
+ 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.
const GURL& url,
- ScopedMessagePipeHandle shell_handle) = 0;
+ scoped_refptr<LoadServiceCallbacks> callbacks) = 0;
+
virtual void OnServiceError(ServiceManager* manager, const GURL& url) = 0;
protected:

Powered by Google App Engine
This is Rietveld 408576698