summaryrefslogtreecommitdiffstats
path: root/net/base/test_completion_callback.cc
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-21 18:40:55 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-21 18:40:55 +0000
commitad74a59d383e658187ae48d084c7a65145d84449 (patch)
treea60b8e2f9abf54efab891fcb589c7c865ecc7a17 /net/base/test_completion_callback.cc
parent9cf72aecda4f6c4279cbe397e6c133bbebb8c642 (diff)
downloadchromium_src-ad74a59d383e658187ae48d084c7a65145d84449.zip
chromium_src-ad74a59d383e658187ae48d084c7a65145d84449.tar.gz
chromium_src-ad74a59d383e658187ae48d084c7a65145d84449.tar.bz2
More net/ reordering.
In addition to the normal method reordering, this patch also deinlines net/base/test_completion_callback.h and places the compiled code in the net_test_support target. Minimization of that header also required adding includes in a few unit tests. BUG=68682 TEST=compiles Review URL: http://codereview.chromium.org/6341004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72162 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/test_completion_callback.cc')
-rw-r--r--net/base/test_completion_callback.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/net/base/test_completion_callback.cc b/net/base/test_completion_callback.cc
new file mode 100644
index 0000000..999a71e
--- /dev/null
+++ b/net/base/test_completion_callback.cc
@@ -0,0 +1,40 @@
+// Copyright (c) 2011 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.
+
+#include "net/base/test_completion_callback.h"
+
+#include "base/message_loop.h"
+#include "net/base/net_errors.h"
+
+TestCompletionCallback::TestCompletionCallback()
+ : result_(0),
+ have_result_(false),
+ waiting_for_result_(false) {
+}
+
+TestCompletionCallback::~TestCompletionCallback() {}
+
+int TestCompletionCallback::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 TestCompletionCallback::GetResult(int result) {
+ if (net::ERR_IO_PENDING != result)
+ return result;
+ return WaitForResult();
+}
+
+void TestCompletionCallback::RunWithParams(const Tuple1<int>& params) {
+ result_ = params.a;
+ have_result_ = true;
+ if (waiting_for_result_)
+ MessageLoop::current()->Quit();
+}