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

Side by Side Diff: examples/hello_mojo/hello_mojo_client.cc

Issue 1702103002: Add an even simpler standalone example. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « examples/hello_mojo/hello_mojo.mojom ('k') | examples/hello_mojo/hello_mojo_server.cc » ('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 2016 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 <stdio.h>
6
7 #include <memory>
8 #include <string>
9
10 #include "examples/hello_mojo/hello_mojo.mojom.h"
11 #include "mojo/public/c/system/main.h"
12 #include "mojo/public/cpp/application/application_delegate.h"
13 #include "mojo/public/cpp/application/application_impl.h"
14 #include "mojo/public/cpp/application/application_runner.h"
15 #include "mojo/public/cpp/system/macros.h"
16 #include "mojo/public/cpp/utility/run_loop.h"
17
18 using examples::HelloMojoPtr;
19
20 namespace {
21
22 class HelloMojoClientApp : public mojo::ApplicationDelegate {
23 public:
24 HelloMojoClientApp() {}
25 ~HelloMojoClientApp() override {}
26
27 void Initialize(mojo::ApplicationImpl* application) override {
28 application->ConnectToService("mojo:hello_mojo_server", &hello_mojo_);
29
30 DoIt("hello");
31 DoIt("goodbye");
32 }
33
34 private:
35 void DoIt(const std::string& request) {
36 hello_mojo_->Say(request, [request](const mojo::String& response) {
37 printf("%s --> %s\n", request.c_str(), response.get().c_str());
38 });
39 }
40
41 HelloMojoPtr hello_mojo_;
42
43 MOJO_DISALLOW_COPY_AND_ASSIGN(HelloMojoClientApp);
44 };
45
46 } // namespace
47
48 MojoResult MojoMain(MojoHandle application_request) {
49 return mojo::ApplicationRunner(std::unique_ptr<mojo::ApplicationDelegate>(
50 new HelloMojoClientApp()))
kulakowski 2016/02/16 18:35:54 clang format makes me happy
51 .Run(application_request);
52 }
OLDNEW
« no previous file with comments | « examples/hello_mojo/hello_mojo.mojom ('k') | examples/hello_mojo/hello_mojo_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698