OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/blockfile/backend_impl.h" | 5 #include "net/disk_cache/blockfile/backend_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 next = NULL; | 403 next = NULL; |
404 SyncEndEnumeration(iterator.Pass()); | 404 SyncEndEnumeration(iterator.Pass()); |
405 } | 405 } |
406 | 406 |
407 node->Release(); | 407 node->Release(); |
408 } | 408 } |
409 | 409 |
410 return net::OK; | 410 return net::OK; |
411 } | 411 } |
412 | 412 |
| 413 int BackendImpl::SyncCalculateSizeOfAllEntries() { |
| 414 DCHECK_NE(net::APP_CACHE, cache_type_); |
| 415 if (disabled_) |
| 416 return net::ERR_FAILED; |
| 417 |
| 418 return data_->header.num_bytes; |
| 419 } |
| 420 |
413 // We use OpenNextEntryImpl to retrieve elements from the cache, until we get | 421 // We use OpenNextEntryImpl to retrieve elements from the cache, until we get |
414 // entries that are too old. | 422 // entries that are too old. |
415 int BackendImpl::SyncDoomEntriesSince(const base::Time initial_time) { | 423 int BackendImpl::SyncDoomEntriesSince(const base::Time initial_time) { |
416 DCHECK_NE(net::APP_CACHE, cache_type_); | 424 DCHECK_NE(net::APP_CACHE, cache_type_); |
417 if (disabled_) | 425 if (disabled_) |
418 return net::ERR_FAILED; | 426 return net::ERR_FAILED; |
419 | 427 |
420 stats_.OnEvent(Stats::DOOM_RECENT); | 428 stats_.OnEvent(Stats::DOOM_RECENT); |
421 for (;;) { | 429 for (;;) { |
422 scoped_ptr<Rankings::Iterator> iterator(new Rankings::Iterator()); | 430 scoped_ptr<Rankings::Iterator> iterator(new Rankings::Iterator()); |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 return net::ERR_IO_PENDING; | 1255 return net::ERR_IO_PENDING; |
1248 } | 1256 } |
1249 | 1257 |
1250 int BackendImpl::DoomEntriesSince(const base::Time initial_time, | 1258 int BackendImpl::DoomEntriesSince(const base::Time initial_time, |
1251 const CompletionCallback& callback) { | 1259 const CompletionCallback& callback) { |
1252 DCHECK(!callback.is_null()); | 1260 DCHECK(!callback.is_null()); |
1253 background_queue_.DoomEntriesSince(initial_time, callback); | 1261 background_queue_.DoomEntriesSince(initial_time, callback); |
1254 return net::ERR_IO_PENDING; | 1262 return net::ERR_IO_PENDING; |
1255 } | 1263 } |
1256 | 1264 |
| 1265 int BackendImpl::CalculateSizeOfAllEntries(const CompletionCallback& callback) { |
| 1266 DCHECK(!callback.is_null()); |
| 1267 background_queue_.CalculateSizeOfAllEntries(callback); |
| 1268 return net::ERR_IO_PENDING; |
| 1269 } |
| 1270 |
1257 class BackendImpl::IteratorImpl : public Backend::Iterator { | 1271 class BackendImpl::IteratorImpl : public Backend::Iterator { |
1258 public: | 1272 public: |
1259 explicit IteratorImpl(base::WeakPtr<InFlightBackendIO> background_queue) | 1273 explicit IteratorImpl(base::WeakPtr<InFlightBackendIO> background_queue) |
1260 : background_queue_(background_queue), | 1274 : background_queue_(background_queue), |
1261 iterator_(new Rankings::Iterator()) { | 1275 iterator_(new Rankings::Iterator()) { |
1262 } | 1276 } |
1263 | 1277 |
1264 ~IteratorImpl() override { | 1278 ~IteratorImpl() override { |
1265 if (background_queue_) | 1279 if (background_queue_) |
1266 background_queue_->EndEnumeration(iterator_.Pass()); | 1280 background_queue_->EndEnumeration(iterator_.Pass()); |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2091 if (total_memory > kMaxBuffersSize || total_memory <= 0) | 2105 if (total_memory > kMaxBuffersSize || total_memory <= 0) |
2092 total_memory = kMaxBuffersSize; | 2106 total_memory = kMaxBuffersSize; |
2093 | 2107 |
2094 done = true; | 2108 done = true; |
2095 } | 2109 } |
2096 | 2110 |
2097 return static_cast<int>(total_memory); | 2111 return static_cast<int>(total_memory); |
2098 } | 2112 } |
2099 | 2113 |
2100 } // namespace disk_cache | 2114 } // namespace disk_cache |
OLD | NEW |