| 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/service_manager/public/c/main.h" | 13 #include "services/service_manager/public/c/main.h" |
| 14 #include "services/service_manager/public/cpp/connector.h" | 14 #include "services/service_manager/public/cpp/connector.h" |
| 15 #include "services/service_manager/public/cpp/interface_factory.h" | 15 #include "services/service_manager/public/cpp/interface_factory.h" |
| 16 #include "services/service_manager/public/cpp/interface_registry.h" | 16 #include "services/service_manager/public/cpp/interface_registry.h" |
| 17 #include "services/service_manager/public/cpp/service.h" | 17 #include "services/service_manager/public/cpp/service.h" |
| 18 #include "services/service_manager/public/cpp/service_runner.h" | 18 #include "services/service_manager/public/cpp/service_runner.h" |
| 19 #include "services/service_manager/public/interfaces/connector.mojom.h" | 19 #include "services/service_manager/public/interfaces/connector.mojom.h" |
| 20 #include "services/service_manager/tests/connect/connect_test.mojom.h" | 20 #include "services/service_manager/tests/connect/connect_test.mojom.h" |
| 21 | 21 |
| 22 namespace shell { | 22 namespace service_manager { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 void QuitLoop(base::RunLoop* loop) { | 26 void QuitLoop(base::RunLoop* loop) { |
| 27 loop->Quit(); | 27 loop->Quit(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void ReceiveString(std::string* string, | 30 void ReceiveString(std::string* string, |
| 31 base::RunLoop* loop, | 31 base::RunLoop* loop, |
| 32 const std::string& response) { | 32 const std::string& response) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 45 public InterfaceFactory<test::mojom::UserIdTest>, | 45 public InterfaceFactory<test::mojom::UserIdTest>, |
| 46 public test::mojom::ConnectTestService, | 46 public test::mojom::ConnectTestService, |
| 47 public test::mojom::StandaloneApp, | 47 public test::mojom::StandaloneApp, |
| 48 public test::mojom::BlockedInterface, | 48 public test::mojom::BlockedInterface, |
| 49 public test::mojom::UserIdTest { | 49 public test::mojom::UserIdTest { |
| 50 public: | 50 public: |
| 51 ConnectTestApp() {} | 51 ConnectTestApp() {} |
| 52 ~ConnectTestApp() override {} | 52 ~ConnectTestApp() override {} |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 // shell::Service: | 55 // service_manager::Service: |
| 56 void OnStart(const Identity& identity) override { | 56 void OnStart(const Identity& identity) override { |
| 57 identity_ = identity; | 57 identity_ = identity; |
| 58 bindings_.set_connection_error_handler( | 58 bindings_.set_connection_error_handler( |
| 59 base::Bind(&ConnectTestApp::OnConnectionError, | 59 base::Bind(&ConnectTestApp::OnConnectionError, |
| 60 base::Unretained(this))); | 60 base::Unretained(this))); |
| 61 standalone_bindings_.set_connection_error_handler( | 61 standalone_bindings_.set_connection_error_handler( |
| 62 base::Bind(&ConnectTestApp::OnConnectionError, | 62 base::Bind(&ConnectTestApp::OnConnectionError, |
| 63 base::Unretained(this))); | 63 base::Unretained(this))); |
| 64 } | 64 } |
| 65 bool OnConnect(const Identity& remote_identity, | 65 bool OnConnect(const Identity& remote_identity, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 callback.Run(ping_response, title_response); | 162 callback.Run(ping_response, title_response); |
| 163 } | 163 } |
| 164 | 164 |
| 165 // test::mojom::BlockedInterface: | 165 // test::mojom::BlockedInterface: |
| 166 void GetTitleBlocked(const GetTitleBlockedCallback& callback) override { | 166 void GetTitleBlocked(const GetTitleBlockedCallback& callback) override { |
| 167 callback.Run("Called Blocked Interface!"); | 167 callback.Run("Called Blocked Interface!"); |
| 168 } | 168 } |
| 169 | 169 |
| 170 // test::mojom::UserIdTest: | 170 // test::mojom::UserIdTest: |
| 171 void ConnectToClassAppAsDifferentUser( | 171 void ConnectToClassAppAsDifferentUser( |
| 172 const shell::Identity& target, | 172 const service_manager::Identity& target, |
| 173 const ConnectToClassAppAsDifferentUserCallback& callback) override { | 173 const ConnectToClassAppAsDifferentUserCallback& callback) override { |
| 174 Connector::ConnectParams params(target); | 174 Connector::ConnectParams params(target); |
| 175 std::unique_ptr<Connection> connection = | 175 std::unique_ptr<Connection> connection = |
| 176 connector()->Connect(¶ms); | 176 connector()->Connect(¶ms); |
| 177 { | 177 { |
| 178 base::RunLoop loop; | 178 base::RunLoop loop; |
| 179 connection->AddConnectionCompletedClosure(base::Bind(&QuitLoop, &loop)); | 179 connection->AddConnectionCompletedClosure(base::Bind(&QuitLoop, &loop)); |
| 180 base::MessageLoop::ScopedNestableTaskAllower allow( | 180 base::MessageLoop::ScopedNestableTaskAllower allow( |
| 181 base::MessageLoop::current()); | 181 base::MessageLoop::current()); |
| 182 loop.Run(); | 182 loop.Run(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 208 Identity identity_; | 208 Identity identity_; |
| 209 mojo::BindingSet<test::mojom::ConnectTestService> bindings_; | 209 mojo::BindingSet<test::mojom::ConnectTestService> bindings_; |
| 210 mojo::BindingSet<test::mojom::StandaloneApp> standalone_bindings_; | 210 mojo::BindingSet<test::mojom::StandaloneApp> standalone_bindings_; |
| 211 mojo::BindingSet<test::mojom::BlockedInterface> blocked_bindings_; | 211 mojo::BindingSet<test::mojom::BlockedInterface> blocked_bindings_; |
| 212 mojo::BindingSet<test::mojom::UserIdTest> user_id_test_bindings_; | 212 mojo::BindingSet<test::mojom::UserIdTest> user_id_test_bindings_; |
| 213 test::mojom::ExposedInterfacePtr caller_; | 213 test::mojom::ExposedInterfacePtr caller_; |
| 214 | 214 |
| 215 DISALLOW_COPY_AND_ASSIGN(ConnectTestApp); | 215 DISALLOW_COPY_AND_ASSIGN(ConnectTestApp); |
| 216 }; | 216 }; |
| 217 | 217 |
| 218 } // namespace shell | 218 } // namespace service_manager |
| 219 | 219 |
| 220 MojoResult ServiceMain(MojoHandle service_request_handle) { | 220 MojoResult ServiceMain(MojoHandle service_request_handle) { |
| 221 shell::ServiceRunner runner(new shell::ConnectTestApp); | 221 service_manager::ServiceRunner runner(new service_manager::ConnectTestApp); |
| 222 return runner.Run(service_request_handle); | 222 return runner.Run(service_request_handle); |
| 223 } | 223 } |
| OLD | NEW |