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

Unified Diff: net/base/test_completion_callback.cc

Issue 8898036: base::Bind: Convert proxy_resolving_client_socket.[cc,h] and deps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Possible test fix. Created 9 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 | « net/base/test_completion_callback.h ('k') | net/http/http_network_transaction_unittest.cc » ('j') | 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 6851a7c2873eefa4a69aa4e78a002dd7ba7bb9d5..aa04d22a50dd97262c40f7fa3f9d2f3cf3c3fa4b 100644
--- a/net/base/test_completion_callback.cc
+++ b/net/base/test_completion_callback.cc
@@ -5,54 +5,57 @@
#include "net/base/test_completion_callback.h"
#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/compiler_specific.h"
#include "base/message_loop.h"
#include "net/base/net_errors.h"
-TestOldCompletionCallback::TestOldCompletionCallback()
- : result_(0),
- have_result_(false),
- waiting_for_result_(false) {
+void TestCompletionCallbackBase::SetResult(int result) {
+ result_ = result;
+ have_result_ = true;
+ if (waiting_for_result_)
+ MessageLoop::current()->Quit();
}
-TestOldCompletionCallback::~TestOldCompletionCallback() {}
-
-int TestOldCompletionCallback::WaitForResult() {
+int TestCompletionCallbackBase::WaitForResult() {
DCHECK(!waiting_for_result_);
+
while (!have_result_) {
waiting_for_result_ = true;
MessageLoop::current()->Run();
waiting_for_result_ = false;
}
- have_result_ = false; // auto-reset for next callback
+
+ have_result_ = false; // Auto-reset for next callback.
return result_;
}
-int TestOldCompletionCallback::GetResult(int result) {
+int TestCompletionCallbackBase::GetResult(int result) {
if (net::ERR_IO_PENDING != result)
return result;
+
return WaitForResult();
}
+TestCompletionCallbackBase::TestCompletionCallbackBase()
+ : result_(0),
+ have_result_(false),
+ waiting_for_result_(false) {
+}
+
void TestOldCompletionCallback::RunWithParams(const Tuple1<int>& params) {
- result_ = params.a;
- have_result_ = true;
- if (waiting_for_result_)
- MessageLoop::current()->Quit();
+ SetResult(params.a);
}
namespace net {
TestCompletionCallback::TestCompletionCallback()
: ALLOW_THIS_IN_INITIALIZER_LIST(callback_(
- base::Bind(&TestCompletionCallback::OnComplete,
+ base::Bind(&TestCompletionCallback::SetResult,
base::Unretained(this)))) {
}
TestCompletionCallback::~TestCompletionCallback() {}
-void TestCompletionCallback::OnComplete(int result) {
- old_callback_impl_.RunWithParams(Tuple1<int>(result));
-}
} // namespace net
« no previous file with comments | « net/base/test_completion_callback.h ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698