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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/process/process.h" | 10 #include "base/process/process.h" |
11 #include "mojo/public/cpp/bindings/binding_set.h" | 11 #include "mojo/public/cpp/bindings/binding_set.h" |
12 #include "services/shell/public/cpp/connection.h" | 12 #include "services/shell/public/cpp/connection.h" |
13 #include "services/shell/public/cpp/connector.h" | 13 #include "services/shell/public/cpp/connector.h" |
14 #include "services/shell/public/cpp/shell_client.h" | 14 #include "services/shell/public/cpp/service.h" |
15 #include "services/shell/runner/child/test_native_main.h" | 15 #include "services/shell/runner/child/test_native_main.h" |
16 #include "services/shell/runner/init.h" | 16 #include "services/shell/runner/init.h" |
17 #include "services/shell/tests/connect/connect_test.mojom.h" | 17 #include "services/shell/tests/connect/connect_test.mojom.h" |
18 #include "services/shell/tests/util.h" | 18 #include "services/shell/tests/util.h" |
19 | 19 |
20 using shell::test::mojom::ClientProcessTest; | 20 using shell::test::mojom::ClientProcessTest; |
21 using shell::test::mojom::ClientProcessTestRequest; | 21 using shell::test::mojom::ClientProcessTestRequest; |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 class Driver : public shell::ShellClient, | 25 class Driver : public shell::Service, |
26 public shell::InterfaceFactory<ClientProcessTest>, | 26 public shell::InterfaceFactory<ClientProcessTest>, |
27 public ClientProcessTest { | 27 public ClientProcessTest { |
28 public: | 28 public: |
29 Driver() {} | 29 Driver() {} |
30 ~Driver() override {} | 30 ~Driver() override {} |
31 | 31 |
32 private: | 32 private: |
33 // shell::ShellClient: | 33 // shell::Service: |
34 void Initialize(shell::Connector* connector, | 34 void OnStart(shell::Connector* connector, |
35 const shell::Identity& identity, | 35 const shell::Identity& identity, |
36 uint32_t id) override { | 36 uint32_t id) override { |
37 connector_ = connector; | 37 connector_ = connector; |
38 } | 38 } |
39 bool AcceptConnection(shell::Connection* connection) override { | 39 bool OnConnect(shell::Connection* connection) override { |
40 connection->AddInterface<ClientProcessTest>(this); | 40 connection->AddInterface<ClientProcessTest>(this); |
41 return true; | 41 return true; |
42 } | 42 } |
43 bool ShellConnectionLost() override { | 43 bool OnStop() override { |
44 // TODO(rockot): http://crbug.com/596621. Should be able to remove this | 44 // TODO(rockot): http://crbug.com/596621. Should be able to remove this |
45 // override entirely. | 45 // override entirely. |
46 _exit(1); | 46 _exit(1); |
47 } | 47 } |
48 | 48 |
49 // shell::InterfaceFactory<ConnectTestService>: | 49 // shell::InterfaceFactory<ConnectTestService>: |
50 void Create(shell::Connection* connection, | 50 void Create(shell::Connection* connection, |
51 ClientProcessTestRequest request) override { | 51 ClientProcessTestRequest request) override { |
52 bindings_.AddBinding(this, std::move(request)); | 52 bindings_.AddBinding(this, std::move(request)); |
53 } | 53 } |
(...skipping 26 matching lines...) Expand all Loading... |
80 | 80 |
81 int main(int argc, char** argv) { | 81 int main(int argc, char** argv) { |
82 base::AtExitManager at_exit; | 82 base::AtExitManager at_exit; |
83 base::CommandLine::Init(argc, argv); | 83 base::CommandLine::Init(argc, argv); |
84 | 84 |
85 shell::InitializeLogging(); | 85 shell::InitializeLogging(); |
86 | 86 |
87 Driver driver; | 87 Driver driver; |
88 return shell::TestNativeMain(&driver); | 88 return shell::TestNativeMain(&driver); |
89 } | 89 } |
OLD | NEW |