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

Unified Diff: net/base/test_completion_callback.cc

Issue 1142843002: net: Make TestCompletionCallback use RunLoops. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reuploading to re-run tests Created 5 years, 7 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 | « net/base/test_completion_callback.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/test_completion_callback.cc
diff --git a/net/base/test_completion_callback.cc b/net/base/test_completion_callback.cc
index ba4421109b20720108429b57eb764ff6ccbdca7a..0765850367389f1390e8c9365da56897435f70c6 100644
--- a/net/base/test_completion_callback.cc
+++ b/net/base/test_completion_callback.cc
@@ -7,7 +7,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/compiler_specific.h"
-#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
#include "net/base/io_buffer.h"
namespace net {
@@ -16,23 +16,27 @@ namespace internal {
void TestCompletionCallbackBaseInternal::DidSetResult() {
have_result_ = true;
- if (waiting_for_result_)
- base::MessageLoop::current()->Quit();
+ if (run_loop_)
+ run_loop_->Quit();
}
void TestCompletionCallbackBaseInternal::WaitForResult() {
- DCHECK(!waiting_for_result_);
- while (!have_result_) {
- waiting_for_result_ = true;
- base::MessageLoop::current()->Run();
- waiting_for_result_ = false;
+ DCHECK(!run_loop_);
+ if (!have_result_) {
+ run_loop_.reset(new base::RunLoop());
+ run_loop_->Run();
+ run_loop_.reset();
+ DCHECK(have_result_);
+ // A huge number of tests depend on this class running events after the
+ // result is set.
+ // TODO(mmenke): We really should fix this.
mmenke 2015/05/20 17:37:05 Note that 300+ tests depend on this - mostly SPDY
Ryan Hamilton 2015/05/20 22:43:48 Oy!
+ base::RunLoop().RunUntilIdle();
}
have_result_ = false; // Auto-reset for next callback.
}
TestCompletionCallbackBaseInternal::TestCompletionCallbackBaseInternal()
- : have_result_(false),
- waiting_for_result_(false) {
+ : have_result_(false) {
}
TestCompletionCallbackBaseInternal::~TestCompletionCallbackBaseInternal() {
« no previous file with comments | « net/base/test_completion_callback.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698