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 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 SyncEndEnumeration(iter); | 661 SyncEndEnumeration(iter); |
662 return net::OK; | 662 return net::OK; |
663 } | 663 } |
664 | 664 |
665 entry->DoomImpl(); | 665 entry->DoomImpl(); |
666 entry->Release(); | 666 entry->Release(); |
667 SyncEndEnumeration(iter); // Dooming the entry invalidates the iterator. | 667 SyncEndEnumeration(iter); // Dooming the entry invalidates the iterator. |
668 } | 668 } |
669 } | 669 } |
670 | 670 |
671 int BackendImplV3::OpenNextEntry(void** iter, Entry** next_entry, | 671 int BackendImplV3::OpenNextEntry(Iterator* iter, Entry** next_entry, |
672 const CompletionCallback& callback) { | 672 const CompletionCallback& callback) { |
| 673 // TODO(gavinp): Remove all void** iter from cache. |
673 DCHECK(!callback.is_null()); | 674 DCHECK(!callback.is_null()); |
674 background_queue_.OpenNextEntry(iter, next_entry, callback); | 675 class State : public EnumerationState { |
| 676 public: |
| 677 explicit State(base::WeakPtr<InFlightBackendIO> background_queue) |
| 678 : background_queue_(background_queue), |
| 679 data_(NULL) {} |
| 680 |
| 681 virtual ~State() { |
| 682 if (background_queue_) |
| 683 background_queue_->EndEnumeration(*iter()); |
| 684 } |
| 685 |
| 686 void** data() { return &data_; } |
| 687 |
| 688 private: |
| 689 base::WeakPtr<InFlightBackendIO> background_queue_; |
| 690 void* data_; |
| 691 }; |
| 692 if (!*iter) |
| 693 iter->reset(new State(GetBackgroundQueue())); |
| 694 State* state = static_cast<State*>(iter->get()); |
| 695 |
| 696 background_queue_.OpenNextEntry(state->data(), next_entry, callback); |
675 return net::ERR_IO_PENDING; | 697 return net::ERR_IO_PENDING; |
676 } | 698 } |
677 | 699 |
678 void BackendImplV3::EndEnumeration(void** iter) { | 700 void BackendImplV3::EndEnumeration(void** iter) { |
679 scoped_ptr<IndexIterator> iterator( | 701 scoped_ptr<IndexIterator> iterator( |
680 reinterpret_cast<IndexIterator*>(*iter)); | 702 reinterpret_cast<IndexIterator*>(*iter)); |
681 *iter = NULL; | 703 *iter = NULL; |
682 } | 704 } |
683 | 705 |
684 void BackendImplV3::GetStats(StatsItems* stats) { | 706 void BackendImplV3::GetStats(StatsItems* stats) { |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1578 base::Time end_time, | 1600 base::Time end_time, |
1579 const CompletionCallback& callback) { | 1601 const CompletionCallback& callback) { |
1580 return net::ERR_FAILED; | 1602 return net::ERR_FAILED; |
1581 } | 1603 } |
1582 | 1604 |
1583 int BackendImplV3::DoomEntriesSince(base::Time initial_time, | 1605 int BackendImplV3::DoomEntriesSince(base::Time initial_time, |
1584 const CompletionCallback& callback) { | 1606 const CompletionCallback& callback) { |
1585 return net::ERR_FAILED; | 1607 return net::ERR_FAILED; |
1586 } | 1608 } |
1587 | 1609 |
1588 int BackendImplV3::OpenNextEntry(void** iter, Entry** next_entry, | 1610 int BackendImplV3::OpenNextEntry(Iterator* iter, Entry** next_entry, |
1589 const CompletionCallback& callback) { | 1611 const CompletionCallback& callback) { |
1590 return net::ERR_FAILED; | 1612 return net::ERR_FAILED; |
1591 } | 1613 } |
1592 | 1614 |
1593 void BackendImplV3::EndEnumeration(void** iter) { | |
1594 NOTIMPLEMENTED(); | |
1595 } | |
1596 | |
1597 void BackendImplV3::GetStats(StatsItems* stats) { | 1615 void BackendImplV3::GetStats(StatsItems* stats) { |
1598 NOTIMPLEMENTED(); | 1616 NOTIMPLEMENTED(); |
1599 } | 1617 } |
1600 | 1618 |
1601 void BackendImplV3::OnExternalCacheHit(const std::string& key) { | 1619 void BackendImplV3::OnExternalCacheHit(const std::string& key) { |
1602 NOTIMPLEMENTED(); | 1620 NOTIMPLEMENTED(); |
1603 } | 1621 } |
1604 | 1622 |
1605 void BackendImplV3::CleanupCache() { | 1623 void BackendImplV3::CleanupCache() { |
1606 } | 1624 } |
1607 | 1625 |
1608 } // namespace disk_cache | 1626 } // namespace disk_cache |
OLD | NEW |