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

Unified Diff: mojo/application/content_handler.h

Issue 687273002: mojo: Update content handler API (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Follow review Created 6 years, 2 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/application/content_handler.h
diff --git a/mojo/application/content_handler.h b/mojo/application/content_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..5173f8cf96a496d6a91ed53070801387680db7c7
--- /dev/null
+++ b/mojo/application/content_handler.h
@@ -0,0 +1,65 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_APPLICATION_CONTENT_HANDLER_H_
+#define MOJO_APPLICATION_CONTENT_HANDLER_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "mojo/public/cpp/application/interface_factory.h"
+#include "mojo/public/interfaces/application/shell.mojom.h"
+#include "mojo/services/public/interfaces/content_handler/content_handler.mojom.h"
+#include "mojo/services/public/interfaces/network/url_loader.mojom.h"
+
+namespace mojo {
+
+class ContentHandlerFactory : public InterfaceFactory<ContentHandler> {
+ public:
+ class HandledApplicationHolder {
qsr 2014/10/31 12:10:44 I don't really like this, but I'm a little bit out
Aaron Boodman 2014/10/31 16:40:46 You could have apps be responsible for deleting th
+ public:
+ virtual ~HandledApplicationHolder() {}
+ };
+
+ class Delegate {
+ public:
+ virtual ~Delegate() {}
+ // Implement this method to create the Application for the given
+ // content. The application will be run on its own thread, and the returned
+ // value will be kept alive until the application ends.
+ virtual scoped_ptr<HandledApplicationHolder> CreateApplication(
+ ShellPtr shell,
+ URLResponsePtr response) = 0;
+ };
+
+ explicit ContentHandlerFactory(Delegate* delegate);
+ virtual ~ContentHandlerFactory();
+
+ private:
+ // From InterfaceFactory:
+ virtual void Create(ApplicationConnection* connection,
+ InterfaceRequest<ContentHandler> request) override;
+
+ Delegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(ContentHandlerFactory);
+};
+
+template <class A>
+class HandledApplicationHolderImpl
+ : public ContentHandlerFactory::HandledApplicationHolder {
+ public:
+ explicit HandledApplicationHolderImpl(A* value) : value_(value) {}
+
+ private:
+ scoped_ptr<A> value_;
+};
+
+template <class A>
+scoped_ptr<ContentHandlerFactory::HandledApplicationHolder>
+make_handled_factory_holder(A* value) {
+ return make_scoped_ptr(new HandledApplicationHolderImpl<A>(value));
+}
+
+} // namespace mojo
+
+#endif // MOJO_APPLICATION_CONTENT_HANDLER_H_

Powered by Google App Engine
This is Rietveld 408576698