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 |
| 135 result_ = count; | 135 finished_ = result->Finished(); |
| 136 if (run_loop_ && finished) | 136 result_ = result->Value(); |
|
Bernhard Bauer
2015/11/03 11:37:02
...aand this would crash now, no?
msramek
2015/11/03 11:57:06
Hm :/ If I need to guard access to Value() with Fi
Bernhard Bauer
2015/11/03 12:07:08
Or store the result instead of the two values.
msramek
2015/11/03 13:15:39
If I store it as a Result, I'll still have to do t
| |
| 137 | |
| 138 if (run_loop_ && finished_) | |
| 137 run_loop_->Quit(); | 139 run_loop_->Quit(); |
| 138 } | 140 } |
| 139 | 141 |
| 140 BrowsingDataCounter::ResultInt GetResult() { | 142 BrowsingDataCounter::ResultInt GetResult() { |
| 141 DCHECK(finished_); | 143 DCHECK(finished_); |
| 142 return result_; | 144 return result_; |
| 143 } | 145 } |
| 144 | 146 |
| 145 private: | 147 private: |
| 146 enum CacheEntryCreationStep { | 148 enum CacheEntryCreationStep { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 SetDeletionPeriodPref(BrowsingDataRemover::FOUR_WEEKS); | 264 SetDeletionPeriodPref(BrowsingDataRemover::FOUR_WEEKS); |
| 263 WaitForIOThread(); | 265 WaitForIOThread(); |
| 264 EXPECT_EQ(result, GetResult()); | 266 EXPECT_EQ(result, GetResult()); |
| 265 | 267 |
| 266 SetDeletionPeriodPref(BrowsingDataRemover::EVERYTHING); | 268 SetDeletionPeriodPref(BrowsingDataRemover::EVERYTHING); |
| 267 WaitForIOThread(); | 269 WaitForIOThread(); |
| 268 EXPECT_EQ(result, GetResult()); | 270 EXPECT_EQ(result, GetResult()); |
| 269 } | 271 } |
| 270 | 272 |
| 271 } // namespace | 273 } // namespace |
| OLD | NEW |