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

Side by Side Diff: services/service_manager/background/tests/test_service.cc

Issue 2646033002: mash: Exit the root process if the window manager service crashes (Closed)
Patch Set: review comments Created 3 years, 10 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 "mojo/public/cpp/bindings/binding_set.h" 5 #include "mojo/public/cpp/bindings/binding_set.h"
6 #include "services/service_manager/background/tests/test.mojom.h" 6 #include "services/service_manager/background/tests/test.mojom.h"
7 #include "services/service_manager/public/c/main.h" 7 #include "services/service_manager/public/c/main.h"
8 #include "services/service_manager/public/cpp/interface_registry.h" 8 #include "services/service_manager/public/cpp/interface_registry.h"
9 #include "services/service_manager/public/cpp/service.h" 9 #include "services/service_manager/public/cpp/service.h"
10 #include "services/service_manager/public/cpp/service_context.h"
10 #include "services/service_manager/public/cpp/service_runner.h" 11 #include "services/service_manager/public/cpp/service_runner.h"
11 12
12 namespace service_manager { 13 namespace service_manager {
13 14
15 // A service that exports a simple interface for testing. Used to test the
16 // parent background service manager.
14 class TestClient : public Service, 17 class TestClient : public Service,
15 public InterfaceFactory<mojom::TestService>, 18 public InterfaceFactory<mojom::TestService>,
16 public mojom::TestService { 19 public mojom::TestService {
17 public: 20 public:
18 TestClient() {} 21 TestClient() {}
19 ~TestClient() override {} 22 ~TestClient() override {}
20 23
21 private: 24 private:
22 // Service: 25 // Service:
23 bool OnConnect(const ServiceInfo& remote_info, 26 bool OnConnect(const ServiceInfo& remote_info,
24 InterfaceRegistry* registry) override { 27 InterfaceRegistry* registry) override {
25 registry->AddInterface(this); 28 registry->AddInterface(this);
26 return true; 29 return true;
27 } 30 }
28 bool OnStop() override { 31 bool OnStop() override {
29 return true; 32 return true;
30 } 33 }
31 34
32 // InterfaceFactory<mojom::TestService>: 35 // InterfaceFactory<mojom::TestService>:
33 void Create(const Identity& remote_identity, 36 void Create(const Identity& remote_identity,
34 mojo::InterfaceRequest<mojom::TestService> request) override { 37 mojo::InterfaceRequest<mojom::TestService> request) override {
35 bindings_.AddBinding(this, std::move(request)); 38 bindings_.AddBinding(this, std::move(request));
36 } 39 }
37 40
38 // mojom::TestService 41 // mojom::TestService
39 void Test(const TestCallback& callback) override { 42 void Test(const TestCallback& callback) override {
40 callback.Run(); 43 callback.Run();
41 } 44 }
42 45
46 void Quit() override { context()->RequestQuit(); }
47
43 mojo::BindingSet<mojom::TestService> bindings_; 48 mojo::BindingSet<mojom::TestService> bindings_;
44 49
45 DISALLOW_COPY_AND_ASSIGN(TestClient); 50 DISALLOW_COPY_AND_ASSIGN(TestClient);
46 }; 51 };
47 52
48 } // namespace service_manager 53 } // namespace service_manager
49 54
50 MojoResult ServiceMain(MojoHandle service_request_handle) { 55 MojoResult ServiceMain(MojoHandle service_request_handle) {
51 service_manager::ServiceRunner runner(new service_manager::TestClient); 56 service_manager::ServiceRunner runner(new service_manager::TestClient);
52 return runner.Run(service_request_handle); 57 return runner.Run(service_request_handle);
53 } 58 }
OLDNEW
« no previous file with comments | « services/service_manager/background/tests/test.mojom ('k') | services/service_manager/public/cpp/service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698