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

Side by Side Diff: services/service_manager/tests/shutdown/shutdown_client_app.cc

Issue 2617883002: Add a new BindInterface() method to Connector. (Closed)
Patch Set: . Created 3 years, 11 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
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « services/service_manager/tests/service_manager/target.cc ('k') | services/service_manager/tests/shutdown/shutdown_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698