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

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

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« 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) 2012 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/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/compiler_specific.h"
10 #include "base/message_loop/message_loop.h"
11 #include "net/base/io_buffer.h"
12
13 namespace net {
14
15 namespace internal {
16
17 void TestCompletionCallbackBaseInternal::DidSetResult() {
18 have_result_ = true;
19 if (waiting_for_result_)
20 base::MessageLoop::current()->Quit();
21 }
22
23 void TestCompletionCallbackBaseInternal::WaitForResult() {
24 DCHECK(!waiting_for_result_);
25 while (!have_result_) {
26 waiting_for_result_ = true;
27 base::MessageLoop::current()->Run();
28 waiting_for_result_ = false;
29 }
30 have_result_ = false; // Auto-reset for next callback.
31 }
32
33 TestCompletionCallbackBaseInternal::TestCompletionCallbackBaseInternal()
34 : have_result_(false),
35 waiting_for_result_(false) {
36 }
37
38 TestCompletionCallbackBaseInternal::~TestCompletionCallbackBaseInternal() {
39 }
40
41 } // namespace internal
42
43 TestClosure::TestClosure()
44 : closure_(base::Bind(&TestClosure::DidSetResult, base::Unretained(this))) {
45 }
46
47 TestClosure::~TestClosure() {
48 }
49
50 TestCompletionCallback::TestCompletionCallback()
51 : callback_(base::Bind(&TestCompletionCallback::SetResult,
52 base::Unretained(this))) {
53 }
54
55 TestCompletionCallback::~TestCompletionCallback() {
56 }
57
58 TestInt64CompletionCallback::TestInt64CompletionCallback()
59 : callback_(base::Bind(&TestInt64CompletionCallback::SetResult,
60 base::Unretained(this))) {
61 }
62
63 TestInt64CompletionCallback::~TestInt64CompletionCallback() {
64 }
65
66 ReleaseBufferCompletionCallback::ReleaseBufferCompletionCallback(
67 IOBuffer* buffer) : buffer_(buffer) {
68 }
69
70 ReleaseBufferCompletionCallback::~ReleaseBufferCompletionCallback() {
71 }
72
73 void ReleaseBufferCompletionCallback::SetResult(int result) {
74 if (!buffer_->HasOneRef())
75 result = net::ERR_FAILED;
76 TestCompletionCallback::SetResult(result);
77 }
78
79 } // namespace net
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