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

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

Issue 2419723002: Move services/shell to services/service_manager (Closed)
Patch Set: rebase Created 4 years, 2 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/macros.h"
6 #include "base/run_loop.h"
7 #include "mojo/public/cpp/bindings/binding_set.h"
8 #include "services/shell/public/c/main.h"
9 #include "services/shell/public/cpp/connector.h"
10 #include "services/shell/public/cpp/interface_factory.h"
11 #include "services/shell/public/cpp/interface_registry.h"
12 #include "services/shell/public/cpp/service.h"
13 #include "services/shell/public/cpp/service_runner.h"
14 #include "services/shell/tests/shutdown/shutdown_unittest.mojom.h"
15
16 namespace shell {
17
18 class ShutdownClientApp
19 : public Service,
20 public InterfaceFactory<mojom::ShutdownTestClientController>,
21 public mojom::ShutdownTestClientController,
22 public mojom::ShutdownTestClient {
23 public:
24 ShutdownClientApp() {}
25 ~ShutdownClientApp() override {}
26
27 private:
28 // shell::Service:
29 bool OnConnect(const Identity& remote_identity,
30 InterfaceRegistry* registry) override {
31 registry->AddInterface<mojom::ShutdownTestClientController>(this);
32 return true;
33 }
34
35 // InterfaceFactory<mojom::ShutdownTestClientController>:
36 void Create(const Identity& remote_identity,
37 mojom::ShutdownTestClientControllerRequest request) override {
38 bindings_.AddBinding(this, std::move(request));
39 }
40
41 // mojom::ShutdownTestClientController:
42 void ConnectAndWait(const ConnectAndWaitCallback& callback) override {
43 mojom::ShutdownTestServicePtr service;
44 connector()->ConnectToInterface("service:shutdown_service", &service);
45
46 mojo::Binding<mojom::ShutdownTestClient> client_binding(this);
47
48 mojom::ShutdownTestClientPtr client_ptr =
49 client_binding.CreateInterfacePtrAndBind();
50
51 service->SetClient(std::move(client_ptr));
52
53 base::MessageLoop::ScopedNestableTaskAllower nestable_allower(
54 base::MessageLoop::current());
55 base::RunLoop run_loop;
56 client_binding.set_connection_error_handler(run_loop.QuitClosure());
57 run_loop.Run();
58
59 callback.Run();
60 }
61
62 mojo::BindingSet<mojom::ShutdownTestClientController> bindings_;
63
64 DISALLOW_COPY_AND_ASSIGN(ShutdownClientApp);
65 };
66
67 } // namespace shell
68
69
70 MojoResult ServiceMain(MojoHandle service_request_handle) {
71 shell::ServiceRunner runner(new shell::ShutdownClientApp);
72 return runner.Run(service_request_handle);
73 }
OLDNEW
« no previous file with comments | « services/shell/tests/shutdown/OWNERS ('k') | services/shell/tests/shutdown/shutdown_client_manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698