OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/disk_cache/disk_cache_test_util.h" | 5 #include "net/disk_cache/disk_cache_test_util.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 last_ = callbacks_called_; | 116 last_ = callbacks_called_; |
117 if (40 == num_iterations_) | 117 if (40 == num_iterations_) |
118 base::MessageLoop::current()->Quit(); | 118 base::MessageLoop::current()->Quit(); |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 // ----------------------------------------------------------------------- | 122 // ----------------------------------------------------------------------- |
123 | 123 |
124 CallbackTest::CallbackTest(MessageLoopHelper* helper, | 124 CallbackTest::CallbackTest(MessageLoopHelper* helper, |
125 bool reuse) | 125 bool reuse) |
126 : helper_(helper), | 126 : callback_(base::Bind(&CallbackTest::Run, base::Unretained(this))), |
| 127 helper_(helper), |
127 reuse_(reuse ? 0 : 1) { | 128 reuse_(reuse ? 0 : 1) { |
128 } | 129 } |
129 | 130 |
130 CallbackTest::~CallbackTest() { | 131 CallbackTest::~CallbackTest() { |
131 } | 132 } |
132 | 133 |
133 // On the actual callback, increase the number of tests received and check for | 134 // On the actual callback, increase the number of tests received and check for |
134 // errors (an unexpected test received) | 135 // errors (an unexpected test received) |
135 void CallbackTest::Run(int result) { | 136 void CallbackTest::Run(int result) { |
136 last_result_ = result; | 137 last_result_ = result; |
137 | 138 |
138 if (reuse_) { | 139 if (reuse_) { |
139 DCHECK_EQ(1, reuse_); | 140 DCHECK_EQ(1, reuse_); |
140 if (2 == reuse_) | 141 if (2 == reuse_) |
141 helper_->set_callback_reused_error(true); | 142 helper_->set_callback_reused_error(true); |
142 reuse_++; | 143 reuse_++; |
143 } | 144 } |
144 | 145 |
145 helper_->CallbackWasCalled(); | 146 helper_->CallbackWasCalled(); |
146 } | 147 } |
OLD | NEW |