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

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: 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
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..9d1de1a932ec2abe5bbb01921879e7e486e0ed50 100644
--- a/net/base/test_completion_callback.cc
+++ b/net/base/test_completion_callback.cc
@@ -9,50 +9,53 @@
#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_) {
+ printf("waiting\n");
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

Powered by Google App Engine
This is Rietveld 408576698