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

Side by Side Diff: net/base/test_completion_callback.cc

Issue 6341004: More net/ reordering. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Window gyp dependency Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/test_completion_callback.h ('k') | net/base/test_completion_callback_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/base/test_completion_callback.h"
6
7 #include "base/message_loop.h"
8 #include "net/base/net_errors.h"
9
10 TestCompletionCallback::TestCompletionCallback()
11 : result_(0),
12 have_result_(false),
13 waiting_for_result_(false) {
14 }
15
16 TestCompletionCallback::~TestCompletionCallback() {}
17
18 int TestCompletionCallback::WaitForResult() {
19 DCHECK(!waiting_for_result_);
20 while (!have_result_) {
21 waiting_for_result_ = true;
22 MessageLoop::current()->Run();
23 waiting_for_result_ = false;
24 }
25 have_result_ = false; // auto-reset for next callback
26 return result_;
27 }
28
29 int TestCompletionCallback::GetResult(int result) {
30 if (net::ERR_IO_PENDING != result)
31 return result;
32 return WaitForResult();
33 }
34
35 void TestCompletionCallback::RunWithParams(const Tuple1<int>& params) {
36 result_ = params.a;
37 have_result_ = true;
38 if (waiting_for_result_)
39 MessageLoop::current()->Quit();
40 }
OLDNEW
« no previous file with comments | « net/base/test_completion_callback.h ('k') | net/base/test_completion_callback_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698