| 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 "mojo/public/cpp/bindings/binding_set.h" | 6 #include "mojo/public/cpp/bindings/binding_set.h" |
| 7 #include "services/shell/public/c/main.h" | 7 #include "services/shell/public/c/main.h" |
| 8 #include "services/shell/public/cpp/interface_factory.h" |
| 9 #include "services/shell/public/cpp/interface_registry.h" |
| 8 #include "services/shell/public/cpp/service.h" | 10 #include "services/shell/public/cpp/service.h" |
| 9 #include "services/shell/public/cpp/service_runner.h" | 11 #include "services/shell/public/cpp/service_runner.h" |
| 10 #include "services/shell/tests/shutdown/shutdown_unittest.mojom.h" | 12 #include "services/shell/tests/shutdown/shutdown_unittest.mojom.h" |
| 11 | 13 |
| 12 namespace shell { | 14 namespace shell { |
| 13 namespace { | 15 namespace { |
| 14 | 16 |
| 15 shell::ServiceRunner* g_app = nullptr; | 17 shell::ServiceRunner* g_app = nullptr; |
| 16 | 18 |
| 17 class ShutdownServiceApp | 19 class ShutdownServiceApp |
| 18 : public Service, | 20 : public Service, |
| 19 public InterfaceFactory<mojom::ShutdownTestService>, | 21 public InterfaceFactory<mojom::ShutdownTestService>, |
| 20 public mojom::ShutdownTestService { | 22 public mojom::ShutdownTestService { |
| 21 public: | 23 public: |
| 22 ShutdownServiceApp() {} | 24 ShutdownServiceApp() {} |
| 23 ~ShutdownServiceApp() override {} | 25 ~ShutdownServiceApp() override {} |
| 24 | 26 |
| 25 private: | 27 private: |
| 26 // shell::Service: | 28 // shell::Service: |
| 27 bool OnConnect(Connection* connection) override { | 29 bool OnConnect(const Identity& remote_identity, |
| 28 connection->AddInterface<mojom::ShutdownTestService>(this); | 30 InterfaceRegistry* registry) override { |
| 31 registry->AddInterface<mojom::ShutdownTestService>(this); |
| 29 return true; | 32 return true; |
| 30 } | 33 } |
| 31 | 34 |
| 32 // InterfaceFactory<mojom::ShutdownTestService>: | 35 // InterfaceFactory<mojom::ShutdownTestService>: |
| 33 void Create(const Identity& remote_identity, | 36 void Create(const Identity& remote_identity, |
| 34 mojom::ShutdownTestServiceRequest request) override { | 37 mojom::ShutdownTestServiceRequest request) override { |
| 35 bindings_.AddBinding(this, std::move(request)); | 38 bindings_.AddBinding(this, std::move(request)); |
| 36 } | 39 } |
| 37 | 40 |
| 38 // mojom::ShutdownTestService: | 41 // mojom::ShutdownTestService: |
| 39 void SetClient(mojom::ShutdownTestClientPtr client) override {} | 42 void SetClient(mojom::ShutdownTestClientPtr client) override {} |
| 40 void ShutDown() override { g_app->Quit(); } | 43 void ShutDown() override { g_app->Quit(); } |
| 41 | 44 |
| 42 mojo::BindingSet<mojom::ShutdownTestService> bindings_; | 45 mojo::BindingSet<mojom::ShutdownTestService> bindings_; |
| 43 | 46 |
| 44 DISALLOW_COPY_AND_ASSIGN(ShutdownServiceApp); | 47 DISALLOW_COPY_AND_ASSIGN(ShutdownServiceApp); |
| 45 }; | 48 }; |
| 46 | 49 |
| 47 } // namespace | 50 } // namespace |
| 48 } // namespace shell | 51 } // namespace shell |
| 49 | 52 |
| 50 | 53 |
| 51 MojoResult ServiceMain(MojoHandle service_request_handle) { | 54 MojoResult ServiceMain(MojoHandle service_request_handle) { |
| 52 shell::ServiceRunner runner(new shell::ShutdownServiceApp); | 55 shell::ServiceRunner runner(new shell::ShutdownServiceApp); |
| 53 shell::g_app = &runner; | 56 shell::g_app = &runner; |
| 54 return runner.Run(service_request_handle); | 57 return runner.Run(service_request_handle); |
| 55 } | 58 } |
| OLD | NEW |