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

Side by Side Diff: examples/echo/echo_client_sync.cc

Issue 2012873003: More ApplicationDelegate/ApplicationRunner[Chromium] conversion. (Closed) Base URL: https://github.com/domokit/mojo.git@work791_run_app_options
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/indirect_service/indirect_service_demo.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>
10 #include <utility>
11
12 #include "examples/echo/echo.mojom-sync.h" 9 #include "examples/echo/echo.mojom-sync.h"
13 #include "mojo/public/c/system/main.h" 10 #include "mojo/public/c/system/main.h"
14 #include "mojo/public/cpp/application/application_delegate.h" 11 #include "mojo/public/cpp/application/application_impl_base.h"
15 #include "mojo/public/cpp/application/application_impl.h"
16 #include "mojo/public/cpp/application/application_runner.h"
17 #include "mojo/public/cpp/application/connect.h" 12 #include "mojo/public/cpp/application/connect.h"
13 #include "mojo/public/cpp/application/run_application.h"
18 #include "mojo/public/cpp/bindings/synchronous_interface_ptr.h" 14 #include "mojo/public/cpp/bindings/synchronous_interface_ptr.h"
19 #include "mojo/public/cpp/environment/logging.h" 15 #include "mojo/public/cpp/environment/logging.h"
20 #include "mojo/public/cpp/utility/run_loop.h" 16 #include "mojo/public/cpp/utility/run_loop.h"
21 17
22 namespace mojo { 18 namespace mojo {
23 namespace examples { 19 namespace examples {
24 20
25 class EchoClientDelegate : public ApplicationDelegate { 21 class EchoClientApp : public ApplicationImplBase {
26 public: 22 public:
27 void Initialize(ApplicationImpl* app) override { 23 void OnInitialize() override {
28 SynchronousInterfacePtr<Echo> echo; 24 SynchronousInterfacePtr<Echo> echo;
29 ConnectToService(app->shell(), "mojo:echo_server", 25 ConnectToService(shell(), "mojo:echo_server", GetSynchronousProxy(&echo));
30 GetSynchronousProxy(&echo));
31 26
32 mojo::String out = "yo!"; 27 mojo::String out = "yo!";
33 MOJO_CHECK(echo->EchoString("hello", &out)); 28 MOJO_CHECK(echo->EchoString("hello", &out));
34 MOJO_LOG(INFO) << "Got response: " << out; 29 MOJO_LOG(INFO) << "Got response: " << out;
35 RunLoop::current()->Quit(); 30 RunLoop::current()->Quit();
36 } 31 }
37 }; 32 };
38 33
39 } // namespace examples 34 } // namespace examples
40 } // namespace mojo 35 } // namespace mojo
41 36
42 MojoResult MojoMain(MojoHandle application_request) { 37 MojoResult MojoMain(MojoHandle application_request) {
43 mojo::ApplicationRunner runner( 38 mojo::examples::EchoClientApp echo_client_app;
44 std::unique_ptr<mojo::examples::EchoClientDelegate>( 39 return mojo::RunMainApplication(application_request, &echo_client_app);
45 new mojo::examples::EchoClientDelegate()));
46 return runner.Run(application_request);
47 } 40 }
OLDNEW
« no previous file with comments | « examples/echo/echo_client.cc ('k') | examples/indirect_service/indirect_service_demo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698