| OLD | NEW |
| 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "mojo/public/cpp/bindings/binding_set.h" | 7 #include "mojo/public/cpp/bindings/binding_set.h" |
| 8 #include "services/service_manager/public/c/main.h" | 8 #include "services/service_manager/public/c/main.h" |
| 9 #include "services/service_manager/public/cpp/connector.h" | 9 #include "services/service_manager/public/cpp/connector.h" |
| 10 #include "services/service_manager/public/cpp/interface_factory.h" | 10 #include "services/service_manager/public/cpp/interface_factory.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 // InterfaceFactory<mojom::ShutdownTestClientController>: | 36 // InterfaceFactory<mojom::ShutdownTestClientController>: |
| 37 void Create(const Identity& remote_identity, | 37 void Create(const Identity& remote_identity, |
| 38 mojom::ShutdownTestClientControllerRequest request) override { | 38 mojom::ShutdownTestClientControllerRequest request) override { |
| 39 bindings_.AddBinding(this, std::move(request)); | 39 bindings_.AddBinding(this, std::move(request)); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // mojom::ShutdownTestClientController: | 42 // mojom::ShutdownTestClientController: |
| 43 void ConnectAndWait(const ConnectAndWaitCallback& callback) override { | 43 void ConnectAndWait(const ConnectAndWaitCallback& callback) override { |
| 44 mojom::ShutdownTestServicePtr service; | 44 mojom::ShutdownTestServicePtr service; |
| 45 context()->connector()->ConnectToInterface( | 45 context()->connector()->BindInterface("shutdown_service", &service); |
| 46 "shutdown_service", &service); | |
| 47 | 46 |
| 48 mojo::Binding<mojom::ShutdownTestClient> client_binding(this); | 47 mojo::Binding<mojom::ShutdownTestClient> client_binding(this); |
| 49 | 48 |
| 50 mojom::ShutdownTestClientPtr client_ptr = | 49 mojom::ShutdownTestClientPtr client_ptr = |
| 51 client_binding.CreateInterfacePtrAndBind(); | 50 client_binding.CreateInterfacePtrAndBind(); |
| 52 | 51 |
| 53 service->SetClient(std::move(client_ptr)); | 52 service->SetClient(std::move(client_ptr)); |
| 54 | 53 |
| 55 base::MessageLoop::ScopedNestableTaskAllower nestable_allower( | 54 base::MessageLoop::ScopedNestableTaskAllower nestable_allower( |
| 56 base::MessageLoop::current()); | 55 base::MessageLoop::current()); |
| 57 base::RunLoop run_loop; | 56 base::RunLoop run_loop; |
| 58 client_binding.set_connection_error_handler(run_loop.QuitClosure()); | 57 client_binding.set_connection_error_handler(run_loop.QuitClosure()); |
| 59 run_loop.Run(); | 58 run_loop.Run(); |
| 60 | 59 |
| 61 callback.Run(); | 60 callback.Run(); |
| 62 } | 61 } |
| 63 | 62 |
| 64 mojo::BindingSet<mojom::ShutdownTestClientController> bindings_; | 63 mojo::BindingSet<mojom::ShutdownTestClientController> bindings_; |
| 65 | 64 |
| 66 DISALLOW_COPY_AND_ASSIGN(ShutdownClientApp); | 65 DISALLOW_COPY_AND_ASSIGN(ShutdownClientApp); |
| 67 }; | 66 }; |
| 68 | 67 |
| 69 } // namespace service_manager | 68 } // namespace service_manager |
| 70 | 69 |
| 71 MojoResult ServiceMain(MojoHandle service_request_handle) { | 70 MojoResult ServiceMain(MojoHandle service_request_handle) { |
| 72 service_manager::ServiceRunner runner(new service_manager::ShutdownClientApp); | 71 service_manager::ServiceRunner runner(new service_manager::ShutdownClientApp); |
| 73 return runner.Run(service_request_handle); | 72 return runner.Run(service_request_handle); |
| 74 } | 73 } |
| OLD | NEW |