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