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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mojo/examples/browser/browser.cc ('k') | mojo/mojo.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "mojo/public/cpp/application/application.h"
6 #include "mojo/services/public/interfaces/launcher/launcher.mojom.h"
7
8 namespace mojo {
9 namespace examples {
10
11 class HTMLViewer;
12
13 class LaunchableConnection : public InterfaceImpl<launcher::Launchable> {
14 public:
15 LaunchableConnection() {}
16 virtual ~LaunchableConnection() {}
17
18 private:
19 // Overridden from launcher::Launchable:
20 virtual void OnLaunch(
21 URLResponsePtr response,
22 ScopedDataPipeConsumerHandle response_body_stream) MOJO_OVERRIDE {
23 printf("In HTMLViewer, rendering url: %s\n", response->url.data());
24 printf("HTML: \n");
25 for (;;) {
26 char buf[512];
27 uint32_t num_bytes = sizeof(buf);
28 MojoResult result = ReadDataRaw(
29 response_body_stream.get(),
30 buf,
31 &num_bytes,
32 MOJO_READ_DATA_FLAG_NONE);
33 if (result == MOJO_RESULT_SHOULD_WAIT) {
34 Wait(response_body_stream.get(),
35 MOJO_WAIT_FLAG_READABLE,
36 MOJO_DEADLINE_INDEFINITE);
37 } else if (result == MOJO_RESULT_OK) {
38 fwrite(buf, num_bytes, 1, stdout);
39 } else {
40 break;
41 }
42 }
43 printf("\n>>>> EOF <<<<\n\n");
44 }
45 };
46
47 class HTMLViewer : public Application {
48 public:
49 HTMLViewer() {}
50 virtual ~HTMLViewer() {}
51
52 private:
53 // Overridden from Application:
54 virtual void Initialize() MOJO_OVERRIDE {
55 AddService<LaunchableConnection>();
56 }
57 };
58
59 }
60
61 // static
62 Application* Application::Create() {
63 return new examples::HTMLViewer;
64 }
65
66 }
OLDNEW
« no previous file with comments | « mojo/examples/browser/browser.cc ('k') | mojo/mojo.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698