| 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" | |
| 8 | |
| 9 namespace service_manager { | 7 namespace service_manager { |
| 10 | 8 |
| 11 Service::Service() = default; | 9 Service::~Service() {} |
| 12 | 10 |
| 13 Service::~Service() = default; | 11 void Service::OnStart(ServiceContext* context) {} |
| 14 | |
| 15 void Service::OnStart() {} | |
| 16 | |
| 17 bool Service::OnConnect(const ServiceInfo& remote_info, | |
| 18 InterfaceRegistry* registry) { | |
| 19 return false; | |
| 20 } | |
| 21 | 12 |
| 22 bool Service::OnStop() { return true; } | 13 bool Service::OnStop() { return true; } |
| 23 | 14 |
| 24 ServiceContext* Service::context() const { | |
| 25 DCHECK(service_context_) | |
| 26 << "Service::context() may only be called during or after OnStart()."; | |
| 27 return service_context_; | |
| 28 } | |
| 29 | |
| 30 ForwardingService::ForwardingService(Service* target) : target_(target) {} | |
| 31 | |
| 32 ForwardingService::~ForwardingService() {} | |
| 33 | |
| 34 void ForwardingService::OnStart() { | |
| 35 target_->set_context(context()); | |
| 36 target_->OnStart(); | |
| 37 } | |
| 38 | |
| 39 bool ForwardingService::OnConnect(const ServiceInfo& remote_info, | |
| 40 InterfaceRegistry* registry) { | |
| 41 return target_->OnConnect(remote_info, registry); | |
| 42 } | |
| 43 | |
| 44 bool ForwardingService::OnStop() { return target_->OnStop(); } | |
| 45 | |
| 46 } // namespace service_manager | 15 } // namespace service_manager |
| OLD | NEW |