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

Unified Diff: mojo/examples/html_viewer/html_viewer.cc

Issue 337563002: Launcher flow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 6 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/examples/html_viewer/html_viewer.cc
diff --git a/mojo/examples/html_viewer/html_viewer.cc b/mojo/examples/html_viewer/html_viewer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ab41d95c93f4617d93090f182731cb50ac027380
--- /dev/null
+++ b/mojo/examples/html_viewer/html_viewer.cc
@@ -0,0 +1,66 @@
+// 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.
+
+#include "mojo/public/cpp/application/application.h"
+#include "mojo/services/public/interfaces/launcher/launcher.mojom.h"
+
+namespace mojo {
+namespace examples {
+
+class HTMLViewer;
+
+class LaunchableConnection : public InterfaceImpl<launcher::Launchable> {
+ public:
+ LaunchableConnection() {}
+ virtual ~LaunchableConnection() {}
+
+ private:
+ // Overridden from launcher::Launchable:
+ virtual void OnLaunch(
+ URLResponsePtr response,
+ ScopedDataPipeConsumerHandle response_body_stream) MOJO_OVERRIDE {
+ printf("In HTMLViewer, rendering url: %s\n", response->url.data());
+ printf("HTML: \n");
+ for (;;) {
+ char buf[512];
+ uint32_t num_bytes = sizeof(buf);
+ MojoResult result = ReadDataRaw(
+ response_body_stream.get(),
+ buf,
+ &num_bytes,
+ MOJO_READ_DATA_FLAG_NONE);
+ if (result == MOJO_RESULT_SHOULD_WAIT) {
+ Wait(response_body_stream.get(),
+ MOJO_WAIT_FLAG_READABLE,
+ MOJO_DEADLINE_INDEFINITE);
+ } else if (result == MOJO_RESULT_OK) {
+ fwrite(buf, num_bytes, 1, stdout);
+ } else {
+ break;
+ }
+ }
+ printf("\n>>>> EOF <<<<\n\n");
+ }
+};
+
+class HTMLViewer : public Application {
+ public:
+ HTMLViewer() {}
+ virtual ~HTMLViewer() {}
+
+ private:
+ // Overridden from Application:
+ virtual void Initialize() MOJO_OVERRIDE {
+ AddService<LaunchableConnection>();
+ }
+};
+
+}
+
+// static
+Application* Application::Create() {
+ return new examples::HTMLViewer;
+}
+
+}
« no previous file with comments | « mojo/examples/browser/browser.cc ('k') | mojo/mojo.gyp » ('j') | mojo/mojo.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698