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

Unified Diff: ipc/mojo/scoped_ipc_support.cc

Issue 1412733006: Fold IPCSupportInitializer::ForceShutdown() with ShutDown(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add myself and Ken to owners. Created 5 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 | « ipc/mojo/OWNERS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/mojo/scoped_ipc_support.cc
diff --git a/ipc/mojo/scoped_ipc_support.cc b/ipc/mojo/scoped_ipc_support.cc
index 572946373e343958638898b56704ae983534d85d..2465aa299a1b746fcac376d67f51ff176192450e 100644
--- a/ipc/mojo/scoped_ipc_support.cc
+++ b/ipc/mojo/scoped_ipc_support.cc
@@ -31,10 +31,7 @@ class IPCSupportInitializer : public mojo::embedder::ProcessDelegate {
~IPCSupportInitializer() override { DCHECK(!observer_); }
void Init(scoped_refptr<base::TaskRunner> io_thread_task_runner);
- void ShutDown();
-
- // Forces the initializer to shut down even if scopers are still holding it.
- void ForceShutdown();
+ void ShutDown(bool force);
private:
// This watches for destruction of the MessageLoop that IPCSupportInitializer
@@ -52,7 +49,7 @@ class IPCSupportInitializer : public mojo::embedder::ProcessDelegate {
private:
// base::MessageLoop::DestructionObserver:
void WillDestroyCurrentMessageLoop() override {
- initializer_->ForceShutdown();
+ initializer_->ShutDown(true);
}
IPCSupportInitializer* initializer_;
@@ -112,24 +109,16 @@ void IPCSupportInitializer::Init(
}
}
-void IPCSupportInitializer::ShutDown() {
- {
- base::AutoLock locker(lock_);
- if (shutting_down_ || was_shut_down_)
- return;
- DCHECK(init_count_ > 0);
- if (init_count_ > 1) {
- init_count_--;
- return;
- }
- }
- ForceShutdown();
-}
-
-void IPCSupportInitializer::ForceShutdown() {
+void IPCSupportInitializer::ShutDown(bool force) {
base::AutoLock locker(lock_);
if (shutting_down_ || was_shut_down_)
return;
+ DCHECK(init_count_ > 0);
+ if (init_count_ > 1 && !force) {
+ init_count_--;
+ return;
+ }
+
shutting_down_ = true;
if (base::MessageLoop::current() &&
base::MessageLoop::current()->task_runner() == io_thread_task_runner_) {
@@ -173,7 +162,7 @@ ScopedIPCSupport::ScopedIPCSupport(
}
ScopedIPCSupport::~ScopedIPCSupport() {
- ipc_support_initializer.Get().ShutDown();
+ ipc_support_initializer.Get().ShutDown(false);
}
} // namespace IPC
« no previous file with comments | « ipc/mojo/OWNERS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698