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

Unified Diff: net/base/test_completion_callback.cc

Issue 9949011: Make FileStream::Seek async and add FileStream::SeekSync for sync operation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments + added tests Created 8 years, 8 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
Index: net/base/test_completion_callback.cc
diff --git a/net/base/test_completion_callback.cc b/net/base/test_completion_callback.cc
index d68678b8ce8e4f9b7e2020120423776b1b3a8a65..0d4b833684731b1108fed0b8ed89a48a671d779b 100644
--- a/net/base/test_completion_callback.cc
+++ b/net/base/test_completion_callback.cc
@@ -8,16 +8,16 @@
#include "base/bind_helpers.h"
#include "base/compiler_specific.h"
#include "base/message_loop.h"
-#include "net/base/net_errors.h"
-void TestCompletionCallbackBase::SetResult(int result) {
- result_ = result;
+namespace internal {
+
+void TestCompletionCallbackBaseInternal::DidSetResult() {
have_result_ = true;
if (waiting_for_result_)
MessageLoop::current()->Quit();
}
-int TestCompletionCallbackBase::WaitForResult() {
+void TestCompletionCallbackBaseInternal::WaitForResult() {
DCHECK(!waiting_for_result_);
while (!have_result_) {
@@ -25,24 +25,15 @@ int TestCompletionCallbackBase::WaitForResult() {
MessageLoop::current()->Run();
waiting_for_result_ = false;
}
-
- have_result_ = false; // Auto-reset for next callback.
- return result_;
-}
-
-int TestCompletionCallbackBase::GetResult(int result) {
- if (net::ERR_IO_PENDING != result)
- return result;
-
- return WaitForResult();
}
-TestCompletionCallbackBase::TestCompletionCallbackBase()
- : result_(0),
- have_result_(false),
+TestCompletionCallbackBaseInternal::TestCompletionCallbackBaseInternal()
+ : have_result_(false),
waiting_for_result_(false) {
}
+} // namespace internal
+
namespace net {
TestCompletionCallback::TestCompletionCallback()
@@ -53,5 +44,12 @@ TestCompletionCallback::TestCompletionCallback()
TestCompletionCallback::~TestCompletionCallback() {}
+TestInt64CompletionCallback::TestInt64CompletionCallback()
+ : ALLOW_THIS_IN_INITIALIZER_LIST(callback_(
+ base::Bind(&TestInt64CompletionCallback::SetResult,
+ base::Unretained(this)))) {
+}
+
+TestInt64CompletionCallback::~TestInt64CompletionCallback() {}
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698