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

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: rebased 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
« no previous file with comments | « net/base/test_completion_callback.h ('k') | net/base/upload_data.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 d68678b8ce8e4f9b7e2020120423776b1b3a8a65..c22647871ed24783a071db4e13447557c02d04c9 100644
--- a/net/base/test_completion_callback.cc
+++ b/net/base/test_completion_callback.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,42 +8,33 @@
#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 net {
+
+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_) {
waiting_for_result_ = true;
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 net {
+} // namespace internal
TestCompletionCallback::TestCompletionCallback()
: ALLOW_THIS_IN_INITIALIZER_LIST(callback_(
@@ -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
« no previous file with comments | « net/base/test_completion_callback.h ('k') | net/base/upload_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698