| 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 "mojo/public/c/system/main.h" | 5 #include "mojo/public/c/system/main.h" |
| 6 #include "mojo/public/cpp/bindings/binding_set.h" | 6 #include "mojo/public/cpp/bindings/binding_set.h" |
| 7 #include "services/shell/background/tests/test.mojom.h" | 7 #include "services/shell/background/tests/test.mojom.h" |
| 8 #include "services/shell/public/cpp/application_runner.h" | 8 #include "services/shell/public/cpp/application_runner.h" |
| 9 #include "services/shell/public/cpp/connection.h" | 9 #include "services/shell/public/cpp/connection.h" |
| 10 #include "services/shell/public/cpp/shell_client.h" | 10 #include "services/shell/public/cpp/shell_client.h" |
| 11 | 11 |
| 12 namespace mojo { | |
| 13 namespace shell { | 12 namespace shell { |
| 14 | 13 |
| 15 class TestClient : public ShellClient, | 14 class TestClient : public ShellClient, |
| 16 public InterfaceFactory<mojom::TestService>, | 15 public InterfaceFactory<mojom::TestService>, |
| 17 public mojom::TestService { | 16 public mojom::TestService { |
| 18 public: | 17 public: |
| 19 TestClient() {} | 18 TestClient() {} |
| 20 ~TestClient() override {} | 19 ~TestClient() override {} |
| 21 | 20 |
| 22 private: | 21 private: |
| 23 // ShellClient: | 22 // ShellClient: |
| 24 bool AcceptConnection(Connection* connection) override { | 23 bool AcceptConnection(Connection* connection) override { |
| 25 connection->AddInterface(this); | 24 connection->AddInterface(this); |
| 26 return true; | 25 return true; |
| 27 } | 26 } |
| 28 bool ShellConnectionLost() override { | 27 bool ShellConnectionLost() override { |
| 29 return true; | 28 return true; |
| 30 } | 29 } |
| 31 | 30 |
| 32 // InterfaceFactory<mojom::TestService>: | 31 // InterfaceFactory<mojom::TestService>: |
| 33 void Create(Connection* connection, | 32 void Create(Connection* connection, |
| 34 InterfaceRequest<mojom::TestService> request) override { | 33 mojo::InterfaceRequest<mojom::TestService> request) override { |
| 35 bindings_.AddBinding(this, std::move(request)); | 34 bindings_.AddBinding(this, std::move(request)); |
| 36 } | 35 } |
| 37 | 36 |
| 38 // mojom::TestService | 37 // mojom::TestService |
| 39 void Test(const TestCallback& callback) override { | 38 void Test(const TestCallback& callback) override { |
| 40 callback.Run(); | 39 callback.Run(); |
| 41 } | 40 } |
| 42 | 41 |
| 43 BindingSet<mojom::TestService> bindings_; | 42 mojo::BindingSet<mojom::TestService> bindings_; |
| 44 | 43 |
| 45 DISALLOW_COPY_AND_ASSIGN(TestClient); | 44 DISALLOW_COPY_AND_ASSIGN(TestClient); |
| 46 }; | 45 }; |
| 47 | 46 |
| 48 } // namespace shell | 47 } // namespace shell |
| 49 } // namespace mojo | |
| 50 | 48 |
| 51 MojoResult MojoMain(MojoHandle shell_handle) { | 49 MojoResult MojoMain(MojoHandle shell_handle) { |
| 52 mojo::ApplicationRunner runner(new mojo::shell::TestClient); | 50 shell::ApplicationRunner runner(new shell::TestClient); |
| 53 return runner.Run(shell_handle); | 51 return runner.Run(shell_handle); |
| 54 } | 52 } |
| OLD | NEW |