| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/public/test/test_service.h" | 5 #include "content/public/test/test_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "services/service_manager/public/cpp/connection.h" | 11 #include "services/service_manager/public/cpp/connection.h" |
| 12 #include "services/service_manager/public/cpp/connector.h" | 12 #include "services/service_manager/public/cpp/connector.h" |
| 13 #include "services/service_manager/public/cpp/interface_registry.h" | |
| 14 | 13 |
| 15 namespace content { | 14 namespace content { |
| 16 | 15 |
| 17 const char kTestServiceUrl[] = "system:content_test_service"; | 16 const char kTestServiceUrl[] = "system:content_test_service"; |
| 18 | 17 |
| 19 TestService::TestService() : service_binding_(this) { | 18 TestService::TestService() : service_binding_(this) { |
| 19 registry_.AddInterface<mojom::TestService>(this); |
| 20 } | 20 } |
| 21 | 21 |
| 22 TestService::~TestService() { | 22 TestService::~TestService() { |
| 23 } | 23 } |
| 24 | 24 |
| 25 bool TestService::OnConnect(const service_manager::ServiceInfo& remote_info, | 25 void TestService::OnBindInterface( |
| 26 service_manager::InterfaceRegistry* registry) { | 26 const service_manager::ServiceInfo& source_info, |
| 27 requestor_name_ = remote_info.identity.name(); | 27 const std::string& interface_name, |
| 28 registry->AddInterface<mojom::TestService>(this); | 28 mojo::ScopedMessagePipeHandle interface_pipe) { |
| 29 return true; | 29 requestor_name_ = source_info.identity.name(); |
| 30 registry_.BindInterface(source_info.identity, interface_name, |
| 31 std::move(interface_pipe)); |
| 30 } | 32 } |
| 31 | 33 |
| 32 void TestService::Create(const service_manager::Identity& remote_identity, | 34 void TestService::Create(const service_manager::Identity& remote_identity, |
| 33 mojom::TestServiceRequest request) { | 35 mojom::TestServiceRequest request) { |
| 34 DCHECK(!service_binding_.is_bound()); | 36 DCHECK(!service_binding_.is_bound()); |
| 35 service_binding_.Bind(std::move(request)); | 37 service_binding_.Bind(std::move(request)); |
| 36 } | 38 } |
| 37 | 39 |
| 38 void TestService::DoSomething(const DoSomethingCallback& callback) { | 40 void TestService::DoSomething(const DoSomethingCallback& callback) { |
| 39 callback.Run(); | 41 callback.Run(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 53 callback.Run(requestor_name_); | 55 callback.Run(requestor_name_); |
| 54 } | 56 } |
| 55 | 57 |
| 56 void TestService::CreateSharedBuffer( | 58 void TestService::CreateSharedBuffer( |
| 57 const std::string& message, | 59 const std::string& message, |
| 58 const CreateSharedBufferCallback& callback) { | 60 const CreateSharedBufferCallback& callback) { |
| 59 NOTREACHED(); | 61 NOTREACHED(); |
| 60 } | 62 } |
| 61 | 63 |
| 62 } // namespace content | 64 } // namespace content |
| OLD | NEW |