Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 // Note that this file only tests the basic behavior of the cache counter, as in | 5 // Note that this file only tests the basic behavior of the cache counter, as in |
| 6 // when it counts and when not, when result is nonzero and when not. It does not | 6 // when it counts and when not, when result is nonzero and when not. It does not |
| 7 // test whether the result of the counting is correct. This is the | 7 // test whether the result of the counting is correct. This is the |
| 8 // responsibility of a lower layer, and is tested in | 8 // responsibility of a lower layer, and is tested in |
| 9 // DiskCacheBackendTest.CalculateSizeOfAllEntries in net_unittests. | 9 // DiskCacheBackendTest.CalculateSizeOfAllEntries in net_unittests. |
| 10 | 10 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 } | 122 } |
| 123 | 123 |
| 124 // General completion callback. | 124 // General completion callback. |
| 125 void Callback() { | 125 void Callback() { |
| 126 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 126 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 127 if (run_loop_) | 127 if (run_loop_) |
| 128 run_loop_->Quit(); | 128 run_loop_->Quit(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 // Callback from the counter. | 131 // Callback from the counter. |
| 132 void CountingCallback(bool finished, BrowsingDataCounter::ResultInt count) { | 132 void CountingCallback(scoped_ptr<BrowsingDataCounter::Result> result) { |
| 133 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 133 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 134 finished_ = finished; | 134 finished_ = result->Finished(); |
| 135 result_ = count; | 135 |
| 136 if (run_loop_ && finished) | 136 if (finished_) { |
| 137 result_ = static_cast<BrowsingDataCounter::FinishedResult*>( | |
|
Bernhard Bauer
2015/11/03 14:13:46
Basically, now anytime you call Value(), the call
msramek
2015/11/03 14:54:09
I'll leave it as it is now. We'd get rid of the ca
| |
| 138 result.get())->Value(); | |
| 139 } | |
| 140 | |
| 141 if (run_loop_ && finished_) | |
| 137 run_loop_->Quit(); | 142 run_loop_->Quit(); |
| 138 } | 143 } |
| 139 | 144 |
| 140 BrowsingDataCounter::ResultInt GetResult() { | 145 BrowsingDataCounter::ResultInt GetResult() { |
| 141 DCHECK(finished_); | 146 DCHECK(finished_); |
| 142 return result_; | 147 return result_; |
| 143 } | 148 } |
| 144 | 149 |
| 145 private: | 150 private: |
| 146 enum CacheEntryCreationStep { | 151 enum CacheEntryCreationStep { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 SetDeletionPeriodPref(BrowsingDataRemover::FOUR_WEEKS); | 267 SetDeletionPeriodPref(BrowsingDataRemover::FOUR_WEEKS); |
| 263 WaitForIOThread(); | 268 WaitForIOThread(); |
| 264 EXPECT_EQ(result, GetResult()); | 269 EXPECT_EQ(result, GetResult()); |
| 265 | 270 |
| 266 SetDeletionPeriodPref(BrowsingDataRemover::EVERYTHING); | 271 SetDeletionPeriodPref(BrowsingDataRemover::EVERYTHING); |
| 267 WaitForIOThread(); | 272 WaitForIOThread(); |
| 268 EXPECT_EQ(result, GetResult()); | 273 EXPECT_EQ(result, GetResult()); |
| 269 } | 274 } |
| 270 | 275 |
| 271 } // namespace | 276 } // namespace |
| OLD | NEW |