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 |
7 namespace service_manager { | 9 namespace service_manager { |
8 | 10 |
9 Service::~Service() {} | 11 Service::Service() = default; |
10 | 12 |
11 void Service::OnStart(ServiceContext* context) {} | 13 Service::~Service() = default; |
| 14 |
| 15 void Service::OnStart() {} |
| 16 |
| 17 bool Service::OnConnect(const ServiceInfo& remote_info, |
| 18 InterfaceRegistry* registry) { |
| 19 return false; |
| 20 } |
12 | 21 |
13 bool Service::OnStop() { return true; } | 22 bool Service::OnStop() { return true; } |
14 | 23 |
| 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 |
15 } // namespace service_manager | 46 } // namespace service_manager |
OLD | NEW |