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 int BackendImplV3::OpenNextEntry(void** iter, Entry** next_entry, | 663 int BackendImplV3::OpenNextEntry(Iterator* iter, Entry** next_entry, |
664 const CompletionCallback& callback) { | 664 const CompletionCallback& callback) { |
| 665 // TODO(gavinp): Remove all void** iter from cache. |
665 DCHECK(!callback.is_null()); | 666 DCHECK(!callback.is_null()); |
666 background_queue_.OpenNextEntry(iter, next_entry, callback); | 667 class State : public EnumerationState { |
| 668 public: |
| 669 explicit State(base::WeakPtr<InFlightBackendIO> background_queue) |
| 670 : background_queue_(background_queue), |
| 671 data_(NULL) {} |
| 672 |
| 673 virtual ~State() { |
| 674 if (background_queue_) |
| 675 background_queue_->EndEnumeration(*iter()); |
| 676 } |
| 677 |
| 678 void** data() { return &data_; } |
| 679 |
| 680 private: |
| 681 base::WeakPtr<InFlightBackendIO> background_queue_; |
| 682 void* data_; |
| 683 }; |
| 684 if (!*iter) |
| 685 iter->reset(new State(GetBackgroundQueue())); |
| 686 State* state = static_cast<State*>(iter->get()); |
| 687 |
| 688 background_queue_.OpenNextEntry(state->data(), next_entry, callback); |
667 return net::ERR_IO_PENDING; | 689 return net::ERR_IO_PENDING; |
668 } | 690 } |
669 | 691 |
670 void BackendImplV3::EndEnumeration(void** iter) { | 692 void BackendImplV3::EndEnumeration(void** iter) { |
671 scoped_ptr<IndexIterator> iterator( | 693 scoped_ptr<IndexIterator> iterator( |
672 reinterpret_cast<IndexIterator*>(*iter)); | 694 reinterpret_cast<IndexIterator*>(*iter)); |
673 *iter = NULL; | 695 *iter = NULL; |
674 } | 696 } |
675 | 697 |
676 void BackendImplV3::GetStats(StatsItems* stats) { | 698 void BackendImplV3::GetStats(StatsItems* stats) { |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 base::Time end_time, | 1512 base::Time end_time, |
1491 const CompletionCallback& callback) { | 1513 const CompletionCallback& callback) { |
1492 return net::ERR_FAILED; | 1514 return net::ERR_FAILED; |
1493 } | 1515 } |
1494 | 1516 |
1495 int BackendImplV3::DoomEntriesSince(base::Time initial_time, | 1517 int BackendImplV3::DoomEntriesSince(base::Time initial_time, |
1496 const CompletionCallback& callback) { | 1518 const CompletionCallback& callback) { |
1497 return net::ERR_FAILED; | 1519 return net::ERR_FAILED; |
1498 } | 1520 } |
1499 | 1521 |
1500 int BackendImplV3::OpenNextEntry(void** iter, Entry** next_entry, | 1522 int BackendImplV3::OpenNextEntry(Iterator* iter, Entry** next_entry, |
1501 const CompletionCallback& callback) { | 1523 const CompletionCallback& callback) { |
1502 return net::ERR_FAILED; | 1524 return net::ERR_FAILED; |
1503 } | 1525 } |
1504 | 1526 |
1505 void BackendImplV3::EndEnumeration(void** iter) { | |
1506 NOTIMPLEMENTED(); | |
1507 } | |
1508 | |
1509 void BackendImplV3::GetStats(StatsItems* stats) { | 1527 void BackendImplV3::GetStats(StatsItems* stats) { |
1510 NOTIMPLEMENTED(); | 1528 NOTIMPLEMENTED(); |
1511 } | 1529 } |
1512 | 1530 |
1513 void BackendImplV3::OnExternalCacheHit(const std::string& key) { | 1531 void BackendImplV3::OnExternalCacheHit(const std::string& key) { |
1514 NOTIMPLEMENTED(); | 1532 NOTIMPLEMENTED(); |
1515 } | 1533 } |
1516 | 1534 |
1517 void BackendImplV3::CleanupCache() { | 1535 void BackendImplV3::CleanupCache() { |
1518 } | 1536 } |
1519 | 1537 |
1520 } // namespace disk_cache | 1538 } // namespace disk_cache |
OLD | NEW |