Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Unified Diff: services/service_manager/public/cpp/lib/service.cc

Issue 2701883002: service_manager: More consistent Service lifecycle API (Closed)
Patch Set: . Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/service_manager/public/cpp/lib/service.cc
diff --git a/services/service_manager/public/cpp/lib/service.cc b/services/service_manager/public/cpp/lib/service.cc
index 72222efac5352fd48fb510ba9ee9a67fd2418cfe..2b40a6c68132b3da8236b64005a6c01dc519f344 100644
--- a/services/service_manager/public/cpp/lib/service.cc
+++ b/services/service_manager/public/cpp/lib/service.cc
@@ -42,20 +42,25 @@ void Service::OnBindInterface(const ServiceInfo& source_info,
interface_provider->GetInterface(interface_name, std::move(interface_pipe));
}
-bool Service::OnStop() { return true; }
+bool Service::OnServiceManagerConnectionLost() {
+ return true;
+}
ServiceContext* Service::context() const {
DCHECK(service_context_)
- << "Service::context() may only be called during or after OnStart().";
+ << "Service::context() may only be called after the Service constructor.";
return service_context_;
}
+void Service::SetContext(ServiceContext* context) {
+ service_context_ = context;
+}
+
ForwardingService::ForwardingService(Service* target) : target_(target) {}
ForwardingService::~ForwardingService() {}
void ForwardingService::OnStart() {
- target_->set_context(context());
target_->OnStart();
}
@@ -64,6 +69,20 @@ bool ForwardingService::OnConnect(const ServiceInfo& remote_info,
return target_->OnConnect(remote_info, registry);
}
-bool ForwardingService::OnStop() { return target_->OnStop(); }
+void ForwardingService::OnBindInterface(
+ const ServiceInfo& remote_info,
+ const std::string& interface_name,
+ mojo::ScopedMessagePipeHandle interface_pipe) {
+ target_->OnBindInterface(remote_info, interface_name,
+ std::move(interface_pipe));
+}
+
+bool ForwardingService::OnServiceManagerConnectionLost() {
+ return target_->OnServiceManagerConnectionLost();
+}
+
+void ForwardingService::SetContext(ServiceContext* context) {
+ target_->SetContext(context);
+}
} // namespace service_manager
« no previous file with comments | « services/service_manager/background/tests/test_service.cc ('k') | services/service_manager/public/cpp/lib/service_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698