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

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

Issue 2431753002: Mus experiment in content shell on Android.
Patch Set: Fixed gn check 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
« no previous file with comments | « no previous file | content/public/app/BUILD.gn » ('j') | content/shell/android/java/res/layout/shell_view.xml » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..8d4c310afe1a00affb4755d5772686712c56a0bd 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,30 +82,23 @@ 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));
- }
-
- void OnStop(service_manager::ServiceContext* connection) {
- DCHECK(task_runner_->BelongsToCurrentThread());
-
- for (auto it = service_manager_connections_.begin();
- it != service_manager_connections_.end(); ++it) {
- if (it->get() == connection) {
- service_manager_connections_.erase(it);
- break;
- }
+ 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));
+ new_connection->SetConnectionLostClosure(
+ base::Bind(&Instance::OnStop, base::Unretained(this)));
}
}
+ void OnStop() { DCHECK(task_runner_->BelongsToCurrentThread()); }
+
void Quit() {
DCHECK(task_runner_->BelongsToCurrentThread());
- service_manager_connections_.clear();
service_.reset();
if (quit_task_runner_->BelongsToCurrentThread()) {
QuitOnRunnerThread();
@@ -126,6 +120,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_;
@@ -141,8 +136,6 @@ class EmbeddedServiceRunner::Instance
// the destructor which may run on either the runner thread or the application
// thread.
std::unique_ptr<service_manager::Service> service_;
- std::vector<std::unique_ptr<service_manager::ServiceContext>>
- service_manager_connections_;
DISALLOW_COPY_AND_ASSIGN(Instance);
};
« no previous file with comments | « no previous file | content/public/app/BUILD.gn » ('j') | content/shell/android/java/res/layout/shell_view.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698