Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: net/disk_cache/blockfile/backend_impl.cc

Issue 542733002: Remove void** from disk_cache interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix EnumerateAndMatchKeys Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/disk_cache/blockfile/backend_impl.h ('k') | net/disk_cache/blockfile/backend_impl_v3.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 610
611 DCHECK(iter); 611 DCHECK(iter);
612 612
613 const int kListsToSearch = 3; 613 const int kListsToSearch = 3;
614 scoped_refptr<EntryImpl> entries[kListsToSearch]; 614 scoped_refptr<EntryImpl> entries[kListsToSearch];
615 scoped_ptr<Rankings::Iterator> iterator( 615 scoped_ptr<Rankings::Iterator> iterator(
616 reinterpret_cast<Rankings::Iterator*>(*iter)); 616 reinterpret_cast<Rankings::Iterator*>(*iter));
617 *iter = NULL; 617 *iter = NULL;
618 618
619 if (!iterator.get()) { 619 if (!iterator.get()) {
620 iterator.reset(new Rankings::Iterator(&rankings_)); 620 iterator.reset(new Rankings::Iterator(&rankings_));
gavinp 2014/09/19 16:09:35 Aha, the void** was really a scoped_ptr, very simi
621 bool ret = false; 621 bool ret = false;
622 622
623 // Get an entry from each list. 623 // Get an entry from each list.
624 for (int i = 0; i < kListsToSearch; i++) { 624 for (int i = 0; i < kListsToSearch; i++) {
625 EntryImpl* temp = NULL; 625 EntryImpl* temp = NULL;
626 ret |= OpenFollowingEntryFromList(static_cast<Rankings::List>(i), 626 ret |= OpenFollowingEntryFromList(static_cast<Rankings::List>(i),
627 &iterator->nodes[i], &temp); 627 &iterator->nodes[i], &temp);
628 entries[i].swap(&temp); // The entry was already addref'd. 628 entries[i].swap(&temp); // The entry was already addref'd.
629 } 629 }
630 if (!ret) 630 if (!ret)
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 return net::ERR_IO_PENDING; 1243 return net::ERR_IO_PENDING;
1244 } 1244 }
1245 1245
1246 int BackendImpl::DoomEntriesSince(const base::Time initial_time, 1246 int BackendImpl::DoomEntriesSince(const base::Time initial_time,
1247 const CompletionCallback& callback) { 1247 const CompletionCallback& callback) {
1248 DCHECK(!callback.is_null()); 1248 DCHECK(!callback.is_null());
1249 background_queue_.DoomEntriesSince(initial_time, callback); 1249 background_queue_.DoomEntriesSince(initial_time, callback);
1250 return net::ERR_IO_PENDING; 1250 return net::ERR_IO_PENDING;
1251 } 1251 }
1252 1252
1253 int BackendImpl::OpenNextEntry(void** iter, Entry** next_entry, 1253 class BackendImpl::IteratorImpl : public Backend::Iterator {
1254 const CompletionCallback& callback) { 1254 public:
1255 DCHECK(!callback.is_null()); 1255 explicit IteratorImpl(base::WeakPtr<InFlightBackendIO> background_queue)
1256 background_queue_.OpenNextEntry(iter, next_entry, callback); 1256 : background_queue_(background_queue), data_(NULL) {
1257 return net::ERR_IO_PENDING; 1257 }
1258 }
1259 1258
1260 void BackendImpl::EndEnumeration(void** iter) { 1259 virtual int OpenNextEntry(Entry** next_entry,
1261 background_queue_.EndEnumeration(*iter); 1260 const net::CompletionCallback& callback) OVERRIDE {
gavinp 2014/09/19 16:09:35 This turns out to be important.
1262 *iter = NULL; 1261 if (!background_queue_)
1262 return net::ERR_FAILED;
1263 background_queue_->OpenNextEntry(&data_, next_entry, callback);
1264 return net::ERR_IO_PENDING;
1265 }
1266
1267 private:
1268 const base::WeakPtr<InFlightBackendIO> background_queue_;
1269 void* data_;
1270 };
1271
1272 scoped_ptr<Backend::Iterator> BackendImpl::CreateIterator() {
1273 return scoped_ptr<Backend::Iterator>(new IteratorImpl(GetBackgroundQueue()));
1263 } 1274 }
1264 1275
1265 void BackendImpl::GetStats(StatsItems* stats) { 1276 void BackendImpl::GetStats(StatsItems* stats) {
1266 if (disabled_) 1277 if (disabled_)
1267 return; 1278 return;
1268 1279
1269 std::pair<std::string, std::string> item; 1280 std::pair<std::string, std::string> item;
1270 1281
1271 item.first = "Entries"; 1282 item.first = "Entries";
1272 item.second = base::StringPrintf("%d", data_->header.num_entries); 1283 item.second = base::StringPrintf("%d", data_->header.num_entries);
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
2066 if (total_memory > kMaxBuffersSize || total_memory <= 0) 2077 if (total_memory > kMaxBuffersSize || total_memory <= 0)
2067 total_memory = kMaxBuffersSize; 2078 total_memory = kMaxBuffersSize;
2068 2079
2069 done = true; 2080 done = true;
2070 } 2081 }
2071 2082
2072 return static_cast<int>(total_memory); 2083 return static_cast<int>(total_memory);
2073 } 2084 }
2074 2085
2075 } // namespace disk_cache 2086 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/blockfile/backend_impl.h ('k') | net/disk_cache/blockfile/backend_impl_v3.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698