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

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: Use the new content handler mechanism for js 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..97210b87ed3e7a0695e93b448fd32eb073d83fb6
--- /dev/null
+++ b/mojo/application/content_handler.h
@@ -0,0 +1,48 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
Aaron Boodman 2014/10/31 08:24:01 I would expect this class to be in mojo/public/cpp
qsr 2014/10/31 12:10:44 That and because it depended on ApplicationImpl. W
+// 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/callback.h"
Aaron Boodman 2014/10/31 08:24:01 move this to cc file.
qsr 2014/10/31 12:10:44 Done.
+#include "mojo/public/c/system/core.h"
+#include "mojo/public/cpp/application/application_delegate.h"
+#include "mojo/public/interfaces/application/application.mojom.h"
+#include "mojo/public/interfaces/application/shell.mojom.h"
+#include "mojo/services/public/interfaces/network/url_loader.mojom.h"
+
+namespace mojo {
+
+class ContentHandlerDelegate : public ApplicationDelegate {
+ public:
+ ContentHandlerDelegate() {}
+ // Implement this method to create the ApplicationDelegate for the given
+ // content. The application will be run on its own thread.
+ virtual scoped_ptr<mojo::InterfaceImpl<mojo::Application>> CreateApplication(
+ ShellPtr shell,
+ URLResponsePtr response) = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ContentHandlerDelegate);
+};
+
+// A utility for running a chromium based mojo Application that expose a content
+// handler. The typical use case is to use when writing your MojoMain:
+//
+// MojoResult MojoMain(MojoHandle shell_handle) {
+// return mojo::ContentHandlerRunner::Run(shell_handle,
+// make_scoped_ptr(new MyDelegate));
+// }
+class ContentHandlerRunner {
+ public:
+ static MojoResult Run(MojoHandle shell_handle,
+ scoped_ptr<ContentHandlerDelegate> delegate);
+
+ private:
+ ContentHandlerRunner() {}
+};
+
+} // namespace mojo
+
+#endif // MOJO_APPLICATION_CONTENT_HANDLER_H_

Powered by Google App Engine
This is Rietveld 408576698