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

Unified Diff: content/common/mojo/embedded_application_runner.cc

Issue 1889253002: Remove uses of shell::Loader from content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « content/common/mojo/embedded_application_runner.h ('k') | content/common/mojo/static_loader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/mojo/embedded_application_runner.cc
diff --git a/content/common/mojo/embedded_application_runner.cc b/content/common/mojo/embedded_application_runner.cc
index 50d62a10738387d37e217c5fd15c1224f4c824fc..c220e9a43eb2e6e53afa6e56c6e359bc9e7f0e67 100644
--- a/content/common/mojo/embedded_application_runner.cc
+++ b/content/common/mojo/embedded_application_runner.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
+#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "base/threading/thread_checker.h"
#include "services/shell/public/cpp/shell_connection.h"
@@ -19,8 +20,11 @@ class EmbeddedApplicationRunner::Instance
: public base::RefCountedThreadSafe<Instance> {
public:
explicit Instance(
- const EmbeddedApplicationRunner::FactoryCallback& callback)
- : factory_callback_(callback) {
+ const EmbeddedApplicationRunner::FactoryCallback& callback,
+ const base::Closure& quit_closure)
+ : factory_callback_(callback),
+ quit_closure_(quit_closure),
+ quit_task_runner_(base::ThreadTaskRunnerHandle::Get()) {
// This object may be used exclusively from a single thread which may be
// different from the one that created it.
thread_checker_.DetachFromThread();
@@ -56,14 +60,18 @@ class EmbeddedApplicationRunner::Instance
}
}
- if (shell_connections_.empty())
+ if (shell_connections_.empty()) {
shell_client_.reset();
+ quit_task_runner_->PostTask(FROM_HERE, quit_closure_);
+ }
}
base::ThreadChecker thread_checker_;
const FactoryCallback factory_callback_;
std::unique_ptr<shell::ShellClient> shell_client_;
std::vector<std::unique_ptr<shell::ShellConnection>> shell_connections_;
+ const base::Closure quit_closure_;
+ const scoped_refptr<base::SingleThreadTaskRunner> quit_task_runner_;
DISALLOW_COPY_AND_ASSIGN(Instance);
};
@@ -73,7 +81,10 @@ EmbeddedApplicationRunner::EmbeddedApplicationRunner(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner)
: application_task_runner_(
task_runner ? task_runner : base::ThreadTaskRunnerHandle::Get()),
- instance_(new Instance(callback)) {
+ weak_factory_(this) {
+ instance_ = new Instance(callback,
+ base::Bind(&EmbeddedApplicationRunner::OnQuit,
+ weak_factory_.GetWeakPtr()));
}
EmbeddedApplicationRunner::~EmbeddedApplicationRunner() {
@@ -87,4 +98,13 @@ void EmbeddedApplicationRunner::BindShellClientRequest(
base::Passed(&request)));
}
+void EmbeddedApplicationRunner::SetQuitClosure(
+ const base::Closure& quit_closure) {
+ quit_closure_ = quit_closure;
+}
+
+void EmbeddedApplicationRunner::OnQuit() {
+ quit_closure_.Run();
+}
+
} // namespace content
« no previous file with comments | « content/common/mojo/embedded_application_runner.h ('k') | content/common/mojo/static_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698