| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "services/service_manager/public/cpp/service.h" | 5 #include "services/service_manager/public/cpp/service.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "services/service_manager/public/cpp/service_context.h" | 8 #include "services/service_manager/public/cpp/service_context.h" |
| 9 #include "services/service_manager/public/interfaces/interface_provider.mojom.h" | 9 #include "services/service_manager/public/interfaces/interface_provider.mojom.h" |
| 10 #include "services/service_manager/public/interfaces/interface_provider_spec.moj
om.h" | 10 #include "services/service_manager/public/interfaces/interface_provider_spec.moj
om.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 &target_spec); | 35 &target_spec); |
| 36 GetInterfaceProviderSpec( | 36 GetInterfaceProviderSpec( |
| 37 mojom::kServiceManager_ConnectorSpec, | 37 mojom::kServiceManager_ConnectorSpec, |
| 38 source_info.interface_provider_specs, | 38 source_info.interface_provider_specs, |
| 39 &source_spec); | 39 &source_spec); |
| 40 service_context_->CallOnConnect(source_info, source_spec, target_spec, | 40 service_context_->CallOnConnect(source_info, source_spec, target_spec, |
| 41 MakeRequest(&interface_provider)); | 41 MakeRequest(&interface_provider)); |
| 42 interface_provider->GetInterface(interface_name, std::move(interface_pipe)); | 42 interface_provider->GetInterface(interface_name, std::move(interface_pipe)); |
| 43 } | 43 } |
| 44 | 44 |
| 45 bool Service::OnStop() { return true; } | 45 bool Service::OnServiceManagerConnectionLost() { |
| 46 return true; |
| 47 } |
| 46 | 48 |
| 47 ServiceContext* Service::context() const { | 49 ServiceContext* Service::context() const { |
| 48 DCHECK(service_context_) | 50 DCHECK(service_context_) |
| 49 << "Service::context() may only be called during or after OnStart()."; | 51 << "Service::context() may only be called after the Service constructor."; |
| 50 return service_context_; | 52 return service_context_; |
| 51 } | 53 } |
| 52 | 54 |
| 55 void Service::SetContext(ServiceContext* context) { |
| 56 service_context_ = context; |
| 57 } |
| 58 |
| 53 ForwardingService::ForwardingService(Service* target) : target_(target) {} | 59 ForwardingService::ForwardingService(Service* target) : target_(target) {} |
| 54 | 60 |
| 55 ForwardingService::~ForwardingService() {} | 61 ForwardingService::~ForwardingService() {} |
| 56 | 62 |
| 57 void ForwardingService::OnStart() { | 63 void ForwardingService::OnStart() { |
| 58 target_->set_context(context()); | |
| 59 target_->OnStart(); | 64 target_->OnStart(); |
| 60 } | 65 } |
| 61 | 66 |
| 62 bool ForwardingService::OnConnect(const ServiceInfo& remote_info, | 67 bool ForwardingService::OnConnect(const ServiceInfo& remote_info, |
| 63 InterfaceRegistry* registry) { | 68 InterfaceRegistry* registry) { |
| 64 return target_->OnConnect(remote_info, registry); | 69 return target_->OnConnect(remote_info, registry); |
| 65 } | 70 } |
| 66 | 71 |
| 67 bool ForwardingService::OnStop() { return target_->OnStop(); } | 72 void ForwardingService::OnBindInterface( |
| 73 const ServiceInfo& remote_info, |
| 74 const std::string& interface_name, |
| 75 mojo::ScopedMessagePipeHandle interface_pipe) { |
| 76 target_->OnBindInterface(remote_info, interface_name, |
| 77 std::move(interface_pipe)); |
| 78 } |
| 79 |
| 80 bool ForwardingService::OnServiceManagerConnectionLost() { |
| 81 return target_->OnServiceManagerConnectionLost(); |
| 82 } |
| 83 |
| 84 void ForwardingService::SetContext(ServiceContext* context) { |
| 85 target_->SetContext(context); |
| 86 } |
| 68 | 87 |
| 69 } // namespace service_manager | 88 } // namespace service_manager |
| OLD | NEW |