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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/guid.h" | 8 #include "base/guid.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "mojo/public/cpp/bindings/binding_set.h" | 12 #include "mojo/public/cpp/bindings/binding_set.h" |
13 #include "services/shell/public/c/main.h" | 13 #include "services/shell/public/c/main.h" |
14 #include "services/shell/public/cpp/connector.h" | 14 #include "services/shell/public/cpp/connector.h" |
15 #include "services/shell/public/cpp/interface_factory.h" | 15 #include "services/shell/public/cpp/interface_factory.h" |
| 16 #include "services/shell/public/cpp/interface_registry.h" |
16 #include "services/shell/public/cpp/service.h" | 17 #include "services/shell/public/cpp/service.h" |
17 #include "services/shell/public/cpp/service_runner.h" | 18 #include "services/shell/public/cpp/service_runner.h" |
18 #include "services/shell/public/interfaces/connector.mojom.h" | 19 #include "services/shell/public/interfaces/connector.mojom.h" |
19 #include "services/shell/tests/connect/connect_test.mojom.h" | 20 #include "services/shell/tests/connect/connect_test.mojom.h" |
20 | 21 |
21 namespace shell { | 22 namespace shell { |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 void QuitLoop(base::RunLoop* loop) { | 26 void QuitLoop(base::RunLoop* loop) { |
(...skipping 28 matching lines...) Expand all Loading... |
54 // shell::Service: | 55 // shell::Service: |
55 void OnStart(const Identity& identity) override { | 56 void OnStart(const Identity& identity) override { |
56 identity_ = identity; | 57 identity_ = identity; |
57 bindings_.set_connection_error_handler( | 58 bindings_.set_connection_error_handler( |
58 base::Bind(&ConnectTestApp::OnConnectionError, | 59 base::Bind(&ConnectTestApp::OnConnectionError, |
59 base::Unretained(this))); | 60 base::Unretained(this))); |
60 standalone_bindings_.set_connection_error_handler( | 61 standalone_bindings_.set_connection_error_handler( |
61 base::Bind(&ConnectTestApp::OnConnectionError, | 62 base::Bind(&ConnectTestApp::OnConnectionError, |
62 base::Unretained(this))); | 63 base::Unretained(this))); |
63 } | 64 } |
64 bool OnConnect(Connection* connection) override { | 65 bool OnConnect(const Identity& remote_identity, |
65 connection->AddInterface<test::mojom::ConnectTestService>(this); | 66 InterfaceRegistry* registry) override { |
66 connection->AddInterface<test::mojom::StandaloneApp>(this); | 67 registry->AddInterface<test::mojom::ConnectTestService>(this); |
67 connection->AddInterface<test::mojom::BlockedInterface>(this); | 68 registry->AddInterface<test::mojom::StandaloneApp>(this); |
68 connection->AddInterface<test::mojom::UserIdTest>(this); | 69 registry->AddInterface<test::mojom::BlockedInterface>(this); |
| 70 registry->AddInterface<test::mojom::UserIdTest>(this); |
69 | 71 |
70 test::mojom::ConnectionStatePtr state(test::mojom::ConnectionState::New()); | 72 test::mojom::ConnectionStatePtr state(test::mojom::ConnectionState::New()); |
71 state->connection_remote_name = connection->GetRemoteIdentity().name(); | 73 state->connection_remote_name = remote_identity.name(); |
72 state->connection_remote_userid = connection->GetRemoteIdentity().user_id(); | 74 state->connection_remote_userid = remote_identity.user_id(); |
73 state->initialize_local_name = identity_.name(); | 75 state->initialize_local_name = identity_.name(); |
74 state->initialize_userid = identity_.user_id(); | 76 state->initialize_userid = identity_.user_id(); |
75 | 77 |
76 connector()->ConnectToInterface(connection->GetRemoteIdentity(), &caller_); | 78 connector()->ConnectToInterface(remote_identity, &caller_); |
77 caller_->ConnectionAccepted(std::move(state)); | 79 caller_->ConnectionAccepted(std::move(state)); |
78 | 80 |
79 return true; | 81 return true; |
80 } | 82 } |
81 | 83 |
82 // InterfaceFactory<test::mojom::ConnectTestService>: | 84 // InterfaceFactory<test::mojom::ConnectTestService>: |
83 void Create(const Identity& remote_identity, | 85 void Create(const Identity& remote_identity, |
84 test::mojom::ConnectTestServiceRequest request) override { | 86 test::mojom::ConnectTestServiceRequest request) override { |
85 bindings_.AddBinding(this, std::move(request)); | 87 bindings_.AddBinding(this, std::move(request)); |
86 } | 88 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 214 |
213 DISALLOW_COPY_AND_ASSIGN(ConnectTestApp); | 215 DISALLOW_COPY_AND_ASSIGN(ConnectTestApp); |
214 }; | 216 }; |
215 | 217 |
216 } // namespace shell | 218 } // namespace shell |
217 | 219 |
218 MojoResult ServiceMain(MojoHandle service_request_handle) { | 220 MojoResult ServiceMain(MojoHandle service_request_handle) { |
219 shell::ServiceRunner runner(new shell::ConnectTestApp); | 221 shell::ServiceRunner runner(new shell::ConnectTestApp); |
220 return runner.Run(service_request_handle); | 222 return runner.Run(service_request_handle); |
221 } | 223 } |
OLD | NEW |