OLD | NEW |
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 #include <memory> | |
6 | |
7 #include "examples/indirect_service/indirect_service_demo.mojom.h" | 5 #include "examples/indirect_service/indirect_service_demo.mojom.h" |
8 #include "mojo/public/c/system/main.h" | 6 #include "mojo/public/c/system/main.h" |
9 #include "mojo/public/cpp/application/application_delegate.h" | 7 #include "mojo/public/cpp/application/application_impl_base.h" |
10 #include "mojo/public/cpp/application/application_runner.h" | 8 #include "mojo/public/cpp/application/run_application.h" |
11 #include "mojo/public/cpp/application/service_provider_impl.h" | 9 #include "mojo/public/cpp/application/service_provider_impl.h" |
12 #include "mojo/public/cpp/bindings/binding.h" | 10 #include "mojo/public/cpp/bindings/binding.h" |
13 #include "mojo/public/cpp/bindings/strong_binding.h" | 11 #include "mojo/public/cpp/bindings/strong_binding.h" |
14 | 12 |
15 namespace mojo { | 13 namespace mojo { |
16 namespace examples { | 14 namespace examples { |
17 | 15 |
18 class IndirectIntegerServiceImpl : public IndirectIntegerService, | 16 class IndirectIntegerServiceImpl : public IndirectIntegerService, |
19 public IntegerService { | 17 public IntegerService { |
20 public: | 18 public: |
(...skipping 21 matching lines...) Expand all Loading... |
42 if (integer_service_.get()) | 40 if (integer_service_.get()) |
43 integer_service_->Increment(callback); | 41 integer_service_->Increment(callback); |
44 } | 42 } |
45 | 43 |
46 private: | 44 private: |
47 IntegerServicePtr integer_service_; | 45 IntegerServicePtr integer_service_; |
48 std::vector<Binding<IntegerService>*> bindings_; | 46 std::vector<Binding<IntegerService>*> bindings_; |
49 StrongBinding<IndirectIntegerService> binding_; | 47 StrongBinding<IndirectIntegerService> binding_; |
50 }; | 48 }; |
51 | 49 |
52 class IndirectIntegerServiceAppDelegate : public ApplicationDelegate { | 50 class IndirectIntegerServiceApp : public ApplicationImplBase { |
53 public: | 51 public: |
54 bool ConfigureIncomingConnection( | 52 bool OnAcceptConnection(ServiceProviderImpl* service_provider_impl) override { |
55 ServiceProviderImpl* service_provider_impl) override { | |
56 service_provider_impl->AddService<IndirectIntegerService>( | 53 service_provider_impl->AddService<IndirectIntegerService>( |
57 [](const ConnectionContext& connection_context, | 54 [](const ConnectionContext& connection_context, |
58 InterfaceRequest<IndirectIntegerService> request) { | 55 InterfaceRequest<IndirectIntegerService> request) { |
59 new IndirectIntegerServiceImpl(request.Pass()); | 56 new IndirectIntegerServiceImpl(request.Pass()); |
60 }); | 57 }); |
61 return true; | 58 return true; |
62 } | 59 } |
63 }; | 60 }; |
64 | 61 |
65 } // namespace examples | 62 } // namespace examples |
66 } // namespace mojo | 63 } // namespace mojo |
67 | 64 |
68 MojoResult MojoMain(MojoHandle application_request) { | 65 MojoResult MojoMain(MojoHandle application_request) { |
69 mojo::ApplicationRunner runner( | 66 mojo::examples::IndirectIntegerServiceApp indirect_integer_service_app; |
70 std::unique_ptr<mojo::examples::IndirectIntegerServiceAppDelegate>( | 67 return mojo::RunMainApplication(application_request, |
71 new mojo::examples::IndirectIntegerServiceAppDelegate())); | 68 &indirect_integer_service_app); |
72 return runner.Run(application_request); | |
73 } | 69 } |
OLD | NEW |