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

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

Issue 2431753002: Mus experiment in content shell on Android.
Patch Set: Addressed comments, fixed browser tests and deps. Created 4 years, 2 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: content/common/service_manager/embedded_service_runner.cc
diff --git a/content/common/service_manager/embedded_service_runner.cc b/content/common/service_manager/embedded_service_runner.cc
index 8578e6cb0e954f5ba00a78524cd8b155798ad60c..4d83530d44fe3d383877c603dfd42dbe8483e026 100644
--- a/content/common/service_manager/embedded_service_runner.cc
+++ b/content/common/service_manager/embedded_service_runner.cc
@@ -26,6 +26,7 @@ class EmbeddedServiceRunner::Instance
: name_(name.as_string()),
factory_callback_(info.factory),
use_own_thread_(!info.task_runner && info.use_own_thread),
+ service_owns_context_(info.service_owns_context),
quit_closure_(quit_closure),
quit_task_runner_(base::ThreadTaskRunnerHandle::Get()),
task_runner_(info.task_runner) {
@@ -81,12 +82,18 @@ class EmbeddedServiceRunner::Instance
base::Bind(&Instance::Quit, base::Unretained(this)));
}
- service_manager::ServiceContext* new_connection =
- new service_manager::ServiceContext(service_.get(), std::move(request));
- service_manager_connections_.push_back(base::WrapUnique(new_connection));
- new_connection->SetConnectionLostClosure(
- base::Bind(&Instance::OnStop, base::Unretained(this),
- new_connection));
+ if (service_owns_context_) {
+ service_->set_context(base::MakeUnique<service_manager::ServiceContext>(
+ service_.get(), std::move(request)));
+ } else {
+ service_manager::ServiceContext* new_connection =
+ new service_manager::ServiceContext(service_.get(),
+ std::move(request));
+ service_manager_connections_.push_back(base::WrapUnique(new_connection));
+ new_connection->SetConnectionLostClosure(
+ base::Bind(&Instance::OnStop, base::Unretained(this),
+ new_connection));
+ }
}
void OnStop(service_manager::ServiceContext* connection) {
@@ -126,6 +133,7 @@ class EmbeddedServiceRunner::Instance
const std::string name_;
const ServiceInfo::ServiceFactory factory_callback_;
const bool use_own_thread_;
+ const bool service_owns_context_;
const base::Closure quit_closure_;
const scoped_refptr<base::SingleThreadTaskRunner> quit_task_runner_;
@@ -142,7 +150,7 @@ class EmbeddedServiceRunner::Instance
// thread.
std::unique_ptr<service_manager::Service> service_;
std::vector<std::unique_ptr<service_manager::ServiceContext>>
- service_manager_connections_;
+ service_manager_connections_;
DISALLOW_COPY_AND_ASSIGN(Instance);
};

Powered by Google App Engine
This is Rietveld 408576698