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

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

Issue 1916233002: Mark ApplicationImpl::ConnectTo{Application,Service}() as deprecated. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 7 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/echo/echo_client_sync.cc ('k') | examples/http_handler/http_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdio.h> 5 #include <stdio.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "examples/hello_mojo/hello_mojo.mojom.h" 10 #include "examples/hello_mojo/hello_mojo.mojom.h"
11 #include "mojo/public/c/system/main.h" 11 #include "mojo/public/c/system/main.h"
12 #include "mojo/public/cpp/application/application_delegate.h" 12 #include "mojo/public/cpp/application/application_delegate.h"
13 #include "mojo/public/cpp/application/application_impl.h" 13 #include "mojo/public/cpp/application/application_impl.h"
14 #include "mojo/public/cpp/application/application_runner.h" 14 #include "mojo/public/cpp/application/application_runner.h"
15 #include "mojo/public/cpp/system/macros.h" 15 #include "mojo/public/cpp/system/macros.h"
16 #include "mojo/public/cpp/utility/run_loop.h" 16 #include "mojo/public/cpp/utility/run_loop.h"
17 17
18 using examples::HelloMojoPtr; 18 using examples::HelloMojoPtr;
19 19
20 namespace { 20 namespace {
21 21
22 class HelloMojoClientApp : public mojo::ApplicationDelegate { 22 class HelloMojoClientApp : public mojo::ApplicationDelegate {
23 public: 23 public:
24 HelloMojoClientApp() {} 24 HelloMojoClientApp() {}
25 ~HelloMojoClientApp() override {} 25 ~HelloMojoClientApp() override {}
26 26
27 void Initialize(mojo::ApplicationImpl* application) override { 27 void Initialize(mojo::ApplicationImpl* application) override {
28 application->ConnectToService("mojo:hello_mojo_server", &hello_mojo_); 28 application->ConnectToServiceDeprecated("mojo:hello_mojo_server",
29 &hello_mojo_);
29 30
30 DoIt("hello"); 31 DoIt("hello");
31 DoIt("goodbye"); 32 DoIt("goodbye");
32 } 33 }
33 34
34 private: 35 private:
35 void DoIt(const std::string& request) { 36 void DoIt(const std::string& request) {
36 hello_mojo_->Say(request, [request](const mojo::String& response) { 37 hello_mojo_->Say(request, [request](const mojo::String& response) {
37 printf("%s --> %s\n", request.c_str(), response.get().c_str()); 38 printf("%s --> %s\n", request.c_str(), response.get().c_str());
38 }); 39 });
39 } 40 }
40 41
41 HelloMojoPtr hello_mojo_; 42 HelloMojoPtr hello_mojo_;
42 43
43 MOJO_DISALLOW_COPY_AND_ASSIGN(HelloMojoClientApp); 44 MOJO_DISALLOW_COPY_AND_ASSIGN(HelloMojoClientApp);
44 }; 45 };
45 46
46 } // namespace 47 } // namespace
47 48
48 MojoResult MojoMain(MojoHandle application_request) { 49 MojoResult MojoMain(MojoHandle application_request) {
49 return mojo::ApplicationRunner(std::unique_ptr<mojo::ApplicationDelegate>( 50 return mojo::ApplicationRunner(std::unique_ptr<mojo::ApplicationDelegate>(
50 new HelloMojoClientApp())) 51 new HelloMojoClientApp()))
51 .Run(application_request); 52 .Run(application_request);
52 } 53 }
OLDNEW
« no previous file with comments | « examples/echo/echo_client_sync.cc ('k') | examples/http_handler/http_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698