| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 MessageLoopHelper::~MessageLoopHelper() { | 134 MessageLoopHelper::~MessageLoopHelper() { |
| 135 } | 135 } |
| 136 | 136 |
| 137 bool MessageLoopHelper::WaitUntilCacheIoFinished(int num_callbacks) { | 137 bool MessageLoopHelper::WaitUntilCacheIoFinished(int num_callbacks) { |
| 138 if (num_callbacks == callbacks_called_) | 138 if (num_callbacks == callbacks_called_) |
| 139 return true; | 139 return true; |
| 140 | 140 |
| 141 ExpectCallbacks(num_callbacks); | 141 ExpectCallbacks(num_callbacks); |
| 142 // Create a recurrent timer of 50 mS. | 142 // Create a recurrent timer of 50 mS. |
| 143 if (!timer_.IsRunning()) | 143 if (!timer_.IsRunning()) |
| 144 timer_.Start(FROM_HERE, TimeDelta::FromMilliseconds(50), this, | 144 timer_.Start(TimeDelta::FromMilliseconds(50), this, |
| 145 &MessageLoopHelper::TimerExpired); | 145 &MessageLoopHelper::TimerExpired); |
| 146 MessageLoop::current()->Run(); | 146 MessageLoop::current()->Run(); |
| 147 return completed_; | 147 return completed_; |
| 148 } | 148 } |
| 149 | 149 |
| 150 // Quits the message loop when all callbacks are called or we've been waiting | 150 // Quits the message loop when all callbacks are called or we've been waiting |
| 151 // too long for them (2 secs without a callback). | 151 // too long for them (2 secs without a callback). |
| 152 void MessageLoopHelper::TimerExpired() { | 152 void MessageLoopHelper::TimerExpired() { |
| 153 CHECK_LE(callbacks_called_, num_callbacks_); | 153 CHECK_LE(callbacks_called_, num_callbacks_); |
| 154 if (callbacks_called_ == num_callbacks_) { | 154 if (callbacks_called_ == num_callbacks_) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 181 void CallbackTest::RunWithParams(const Tuple1<int>& params) { | 181 void CallbackTest::RunWithParams(const Tuple1<int>& params) { |
| 182 if (reuse_) { | 182 if (reuse_) { |
| 183 DCHECK_EQ(1, reuse_); | 183 DCHECK_EQ(1, reuse_); |
| 184 if (2 == reuse_) | 184 if (2 == reuse_) |
| 185 helper_->set_callback_reused_error(true); | 185 helper_->set_callback_reused_error(true); |
| 186 reuse_++; | 186 reuse_++; |
| 187 } | 187 } |
| 188 | 188 |
| 189 helper_->CallbackWasCalled(); | 189 helper_->CallbackWasCalled(); |
| 190 } | 190 } |
| OLD | NEW |