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

Unified Diff: content/common/service_manager/service_manager_connection_impl.cc

Issue 2500683002: Revert of Service Manager: Remove ServiceContext* arg from Service::OnStart() (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « components/leveldb/leveldb_app.cc ('k') | mash/browser/browser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/service_manager/service_manager_connection_impl.cc
diff --git a/content/common/service_manager/service_manager_connection_impl.cc b/content/common/service_manager/service_manager_connection_impl.cc
index ac6d1f6fccbd57c79167662e0927ae1bdab0291a..971cfdd8f7323909ce82e951854a6a88bcc4b974 100644
--- a/content/common/service_manager/service_manager_connection_impl.cc
+++ b/content/common/service_manager/service_manager_connection_impl.cc
@@ -127,6 +127,34 @@
private:
friend class base::RefCountedThreadSafe<IOThreadContext>;
+ // A forwarding service_manager::Service implementation to account for the
+ // fact that IOThreadContext is a Service which owns its ServiceContext, but
+ // ServiceContext should own its Service.
+ //
+ // TODO(rockot): Clean this up.
+ class ForwardingServiceImpl : public service_manager::Service {
+ public:
+ explicit ForwardingServiceImpl(service_manager::Service* service)
+ : service_(service) {}
+ ~ForwardingServiceImpl() override {}
+
+ // service_manager::Service:
+ void OnStart(service_manager::ServiceContext* context) override {
+ service_->OnStart(context);
+ }
+
+ bool OnConnect(const service_manager::ServiceInfo& remote_info,
+ service_manager::InterfaceRegistry* registry) override {
+ return service_->OnConnect(remote_info, registry);
+ }
+
+ bool OnStop() override { return service_->OnStop(); }
+
+ private:
+ service_manager::Service* const service_;
+ DISALLOW_COPY_AND_ASSIGN(ForwardingServiceImpl);
+ };
+
class MessageLoopObserver : public base::MessageLoop::DestructionObserver {
public:
explicit MessageLoopObserver(base::WeakPtr<IOThreadContext> context)
@@ -169,7 +197,7 @@
// Should bind |io_thread_checker_| to the context's thread.
DCHECK(io_thread_checker_.CalledOnValidThread());
service_context_.reset(new service_manager::ServiceContext(
- base::MakeUnique<service_manager::ForwardingService>(this),
+ base::MakeUnique<ForwardingServiceImpl>(this),
std::move(pending_service_request_),
std::move(io_thread_connector_),
std::move(pending_connector_request_)));
@@ -223,10 +251,10 @@
/////////////////////////////////////////////////////////////////////////////
// service_manager::Service implementation
- void OnStart() override {
+ void OnStart(service_manager::ServiceContext* context) override {
DCHECK(io_thread_checker_.CalledOnValidThread());
DCHECK(!initialize_handler_.is_null());
- local_info_ = context()->local_info();
+ local_info_ = context->local_info();
InitializeCallback handler = base::ResetAndReturn(&initialize_handler_);
callback_task_runner_->PostTask(FROM_HERE,
« no previous file with comments | « components/leveldb/leveldb_app.cc ('k') | mash/browser/browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698