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_v3.h" | 5 #include "net/disk_cache/blockfile/backend_impl_v3.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_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 SyncEndEnumeration(iter); | 653 SyncEndEnumeration(iter); |
654 return net::OK; | 654 return net::OK; |
655 } | 655 } |
656 | 656 |
657 entry->DoomImpl(); | 657 entry->DoomImpl(); |
658 entry->Release(); | 658 entry->Release(); |
659 SyncEndEnumeration(iter); // Dooming the entry invalidates the iterator. | 659 SyncEndEnumeration(iter); // Dooming the entry invalidates the iterator. |
660 } | 660 } |
661 } | 661 } |
662 | 662 |
663 class BackendImplV3::IteratorImpl : public Backend::Iterator { | 663 int BackendImplV3::OpenNextEntry(void** iter, Entry** next_entry, |
664 public: | 664 const CompletionCallback& callback) { |
665 explicit IteratorImpl(base::WeakPtr<InFlightBackendIO> background_queue) | 665 DCHECK(!callback.is_null()); |
666 : background_queue_(background_queue), data_(NULL) { | 666 background_queue_.OpenNextEntry(iter, next_entry, callback); |
667 } | 667 return net::ERR_IO_PENDING; |
| 668 } |
668 | 669 |
669 virtual int OpenNextEntry(Entry** next_entry, | 670 void BackendImplV3::EndEnumeration(void** iter) { |
670 const net::CompletionCallback& callback) OVERRIDE { | 671 scoped_ptr<IndexIterator> iterator( |
671 if (!background_queue_) | 672 reinterpret_cast<IndexIterator*>(*iter)); |
672 return net::ERR_FAILED; | 673 *iter = NULL; |
673 background_queue_->OpenNextEntry(&data_, next_entry, callback); | |
674 return net::ERR_IO_PENDING; | |
675 } | |
676 | |
677 private: | |
678 const base::WeakPtr<InFlightBackendIO> background_queue_; | |
679 void* data_; | |
680 }; | |
681 | |
682 scoped_ptr<Backend::Iterator> BackendImplV3::CreateIterator() { | |
683 return scoped_ptr<Backend::Iterator>(new IteratorImpl(GetBackgroundQueue())); | |
684 } | 674 } |
685 | 675 |
686 void BackendImplV3::GetStats(StatsItems* stats) { | 676 void BackendImplV3::GetStats(StatsItems* stats) { |
687 if (disabled_) | 677 if (disabled_) |
688 return; | 678 return; |
689 | 679 |
690 std::pair<std::string, std::string> item; | 680 std::pair<std::string, std::string> item; |
691 | 681 |
692 item.first = "Entries"; | 682 item.first = "Entries"; |
693 item.second = base::StringPrintf("%d", data_->header.num_entries); | 683 item.second = base::StringPrintf("%d", data_->header.num_entries); |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1500 base::Time end_time, | 1490 base::Time end_time, |
1501 const CompletionCallback& callback) { | 1491 const CompletionCallback& callback) { |
1502 return net::ERR_FAILED; | 1492 return net::ERR_FAILED; |
1503 } | 1493 } |
1504 | 1494 |
1505 int BackendImplV3::DoomEntriesSince(base::Time initial_time, | 1495 int BackendImplV3::DoomEntriesSince(base::Time initial_time, |
1506 const CompletionCallback& callback) { | 1496 const CompletionCallback& callback) { |
1507 return net::ERR_FAILED; | 1497 return net::ERR_FAILED; |
1508 } | 1498 } |
1509 | 1499 |
| 1500 int BackendImplV3::OpenNextEntry(void** iter, Entry** next_entry, |
| 1501 const CompletionCallback& callback) { |
| 1502 return net::ERR_FAILED; |
| 1503 } |
1510 | 1504 |
1511 class BackendImplV3::NotImplementedIterator : public Backend::Iterator { | 1505 void BackendImplV3::EndEnumeration(void** iter) { |
1512 public: | 1506 NOTIMPLEMENTED(); |
1513 virtual int OpenNextEntry(disk_cache::Entry** next_entry, | |
1514 const net::CompletionCallback& callback) OVERRIDE { | |
1515 return net::ERR_NOT_IMPLEMENTED; | |
1516 } | |
1517 }; | |
1518 | |
1519 scoped_ptr<Backend::Iterator> BackendImplV3::CreateIterator() { | |
1520 return scoped_ptr<Iterator>(new NotImplementedIterator()); | |
1521 } | 1507 } |
1522 | 1508 |
1523 void BackendImplV3::GetStats(StatsItems* stats) { | 1509 void BackendImplV3::GetStats(StatsItems* stats) { |
1524 NOTIMPLEMENTED(); | 1510 NOTIMPLEMENTED(); |
1525 } | 1511 } |
1526 | 1512 |
1527 void BackendImplV3::OnExternalCacheHit(const std::string& key) { | 1513 void BackendImplV3::OnExternalCacheHit(const std::string& key) { |
1528 NOTIMPLEMENTED(); | 1514 NOTIMPLEMENTED(); |
1529 } | 1515 } |
1530 | 1516 |
1531 void BackendImplV3::CleanupCache() { | 1517 void BackendImplV3::CleanupCache() { |
1532 } | 1518 } |
1533 | 1519 |
1534 } // namespace disk_cache | 1520 } // namespace disk_cache |
OLD | NEW |