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

Side by Side Diff: examples/echo/echo_client_sync.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.cc ('k') | examples/hello_mojo/hello_mojo_client.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 2014 The Chromium Authors. All rights reserved. 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 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 // This example demonstrates the simple use of SynchronousInterfacePtr<>, which 5 // This example demonstrates the simple use of SynchronousInterfacePtr<>, which
6 // is the blocking, synchronous version of mojom interface calls (typically used 6 // is the blocking, synchronous version of mojom interface calls (typically used
7 // via InterfacePtr<>). 7 // via InterfacePtr<>).
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 11
12 #include "examples/echo/echo.mojom-sync.h" 12 #include "examples/echo/echo.mojom-sync.h"
13 #include "examples/echo/echo.mojom.h" 13 #include "examples/echo/echo.mojom.h"
14 #include "mojo/public/c/system/main.h" 14 #include "mojo/public/c/system/main.h"
15 #include "mojo/public/cpp/application/application_delegate.h" 15 #include "mojo/public/cpp/application/application_delegate.h"
16 #include "mojo/public/cpp/application/application_impl.h" 16 #include "mojo/public/cpp/application/application_impl.h"
17 #include "mojo/public/cpp/application/application_runner.h" 17 #include "mojo/public/cpp/application/application_runner.h"
18 #include "mojo/public/cpp/bindings/synchronous_interface_ptr.h" 18 #include "mojo/public/cpp/bindings/synchronous_interface_ptr.h"
19 #include "mojo/public/cpp/environment/logging.h" 19 #include "mojo/public/cpp/environment/logging.h"
20 #include "mojo/public/cpp/utility/run_loop.h" 20 #include "mojo/public/cpp/utility/run_loop.h"
21 21
22 namespace mojo { 22 namespace mojo {
23 namespace examples { 23 namespace examples {
24 24
25 class EchoClientDelegate : public ApplicationDelegate { 25 class EchoClientDelegate : public ApplicationDelegate {
26 public: 26 public:
27 void Initialize(ApplicationImpl* app) override { 27 void Initialize(ApplicationImpl* app) override {
28 EchoPtr echo; 28 EchoPtr echo;
29 app->ConnectToService("mojo:echo_server", &echo); 29 app->ConnectToServiceDeprecated("mojo:echo_server", &echo);
30 30
31 mojo::String out = "yo!"; 31 mojo::String out = "yo!";
32 auto echo_proxy = 32 auto echo_proxy =
33 SynchronousInterfacePtr<Echo>::Create(echo.PassInterfaceHandle()); 33 SynchronousInterfacePtr<Echo>::Create(echo.PassInterfaceHandle());
34 MOJO_CHECK(echo_proxy->EchoString("hello", &out)); 34 MOJO_CHECK(echo_proxy->EchoString("hello", &out));
35 MOJO_LOG(INFO) << "Got response: " << out; 35 MOJO_LOG(INFO) << "Got response: " << out;
36 RunLoop::current()->Quit(); 36 RunLoop::current()->Quit();
37 } 37 }
38 }; 38 };
39 39
40 } // namespace examples 40 } // namespace examples
41 } // namespace mojo 41 } // namespace mojo
42 42
43 MojoResult MojoMain(MojoHandle application_request) { 43 MojoResult MojoMain(MojoHandle application_request) {
44 mojo::ApplicationRunner runner( 44 mojo::ApplicationRunner runner(
45 std::unique_ptr<mojo::examples::EchoClientDelegate>( 45 std::unique_ptr<mojo::examples::EchoClientDelegate>(
46 new mojo::examples::EchoClientDelegate())); 46 new mojo::examples::EchoClientDelegate()));
47 return runner.Run(application_request); 47 return runner.Run(application_request);
48 } 48 }
OLDNEW
« no previous file with comments | « examples/echo/echo_client.cc ('k') | examples/hello_mojo/hello_mojo_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698