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

Unified Diff: base/test/sequenced_worker_pool_owner.h

Issue 1417353006: Tests: Simplify SequencedWorkerPoolOwner, call Shutdown on destructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adjust formatting and rebase Created 5 years 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 | « base/test/launcher/test_launcher.cc ('k') | base/test/sequenced_worker_pool_owner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/sequenced_worker_pool_owner.h
diff --git a/base/test/sequenced_worker_pool_owner.h b/base/test/sequenced_worker_pool_owner.h
index bf5f2f766e151e29ff7b2a78780e01c5c5715fc4..20bffb1bc8dde9b217dec6719619dc40e833a604 100644
--- a/base/test/sequenced_worker_pool_owner.h
+++ b/base/test/sequenced_worker_pool_owner.h
@@ -12,6 +12,7 @@
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
+#include "base/run_loop.h"
#include "base/synchronization/lock.h"
#include "base/threading/sequenced_worker_pool.h"
@@ -25,6 +26,9 @@ class MessageLoop;
// strange races with other tests that touch global stuff (like histograms and
// logging). However, this requires that nothing else on this thread holds a
// ref to the pool when the SequencedWorkerPoolOwner is destroyed.
+//
+// This class calls Shutdown on the owned SequencedWorkerPool in the destructor.
+// Tests may themselves call Shutdown earlier to test shutdown behavior.
class SequencedWorkerPoolOwner : public SequencedWorkerPool::TestingObserver {
public:
SequencedWorkerPoolOwner(size_t max_threads,
@@ -46,7 +50,11 @@ class SequencedWorkerPoolOwner : public SequencedWorkerPool::TestingObserver {
void WillWaitForShutdown() override;
void OnDestruct() override;
+ // Used to run the current thread's message loop until the
+ // SequencedWorkerPool's destruction has been verified.
+ base::RunLoop exit_loop_;
MessageLoop* const constructor_message_loop_;
+
scoped_refptr<SequencedWorkerPool> pool_;
Closure will_wait_for_shutdown_callback_;
« no previous file with comments | « base/test/launcher/test_launcher.cc ('k') | base/test/sequenced_worker_pool_owner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698