| 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 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_H_ | 5 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_H_ |
| 6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_H_ | 6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | |
| 9 | |
| 10 namespace service_manager { | 8 namespace service_manager { |
| 11 | 9 |
| 12 class InterfaceRegistry; | 10 class InterfaceRegistry; |
| 13 class ServiceContext; | 11 class ServiceContext; |
| 14 struct ServiceInfo; | 12 struct ServiceInfo; |
| 15 | 13 |
| 16 // The primary contract between a Service and the Service Manager, receiving | 14 // The primary contract between a Service and the Service Manager, receiving |
| 17 // lifecycle notifications and connection requests. | 15 // lifecycle notifications and connection requests. |
| 18 class Service { | 16 class Service { |
| 19 public: | 17 public: |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 ServiceContext* context() const; | 58 ServiceContext* context() const; |
| 61 | 59 |
| 62 private: | 60 private: |
| 63 friend class ForwardingService; | 61 friend class ForwardingService; |
| 64 friend class ServiceContext; | 62 friend class ServiceContext; |
| 65 | 63 |
| 66 // NOTE: This is guaranteed to be called before OnStart(). | 64 // NOTE: This is guaranteed to be called before OnStart(). |
| 67 void set_context(ServiceContext* context) { service_context_ = context; } | 65 void set_context(ServiceContext* context) { service_context_ = context; } |
| 68 | 66 |
| 69 ServiceContext* service_context_ = nullptr; | 67 ServiceContext* service_context_ = nullptr; |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(Service); | |
| 72 }; | 68 }; |
| 73 | 69 |
| 74 // TODO(rockot): Remove this. It's here to satisfy a few remaining use cases | 70 // TODO(rockot): Remove this. It's here to satisfy a few remaining use cases |
| 75 // where a Service impl is owned by something other than its ServiceContext. | 71 // where a Service impl is owned by something other than its ServiceContext. |
| 76 class ForwardingService : public Service { | 72 class ForwardingService : public Service { |
| 77 public: | 73 public: |
| 78 // |target| must outlive this object. | 74 // |target| must outlive this object. |
| 79 explicit ForwardingService(Service* target); | 75 explicit ForwardingService(Service* target); |
| 80 ~ForwardingService() override; | 76 ~ForwardingService() override; |
| 81 | 77 |
| 78 private: |
| 82 // Service: | 79 // Service: |
| 83 void OnStart() override; | 80 void OnStart() override; |
| 84 bool OnConnect(const ServiceInfo& remote_info, | 81 bool OnConnect(const ServiceInfo& remote_info, |
| 85 InterfaceRegistry* registry) override; | 82 InterfaceRegistry* registry) override; |
| 86 bool OnStop() override; | 83 bool OnStop() override; |
| 87 | 84 |
| 88 private: | |
| 89 Service* const target_ = nullptr; | 85 Service* const target_ = nullptr; |
| 90 | |
| 91 DISALLOW_COPY_AND_ASSIGN(ForwardingService); | |
| 92 }; | 86 }; |
| 93 | 87 |
| 94 } // namespace service_manager | 88 } // namespace service_manager |
| 95 | 89 |
| 96 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_H_ | 90 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_SERVICE_H_ |
| OLD | NEW |