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

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: narrow given upstream 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
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 1232 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 int BackendImpl::OpenNextEntry(Iterator* iter, Entry** next_entry,
1254 const CompletionCallback& callback) { 1254 const CompletionCallback& callback) {
1255 // TODO(gavinp): Remove all void** iter from cache.
1255 DCHECK(!callback.is_null()); 1256 DCHECK(!callback.is_null());
1256 background_queue_.OpenNextEntry(iter, next_entry, callback); 1257
1258 class State : public EnumerationState {
1259 public:
1260 explicit State(base::WeakPtr<InFlightBackendIO> background_queue)
1261 : background_queue_(background_queue),
1262 data_(NULL) {}
1263
1264 virtual ~State() {
1265 if (background_queue_)
1266 background_queue_->EndEnumeration(*data());
1267 }
1268
1269 void** data() { return &data_; }
1270
1271 private:
1272 base::WeakPtr<InFlightBackendIO> background_queue_;
1273 void* data_;
1274 };
1275
1276 if (!*iter)
1277 iter->reset(new State(GetBackgroundQueue()));
1278 State* state = static_cast<State*>(iter->get());
1279
1280 background_queue_.OpenNextEntry(state->data(), next_entry, callback);
1257 return net::ERR_IO_PENDING; 1281 return net::ERR_IO_PENDING;
1258 } 1282 }
1259 1283
1260 void BackendImpl::EndEnumeration(void** iter) {
1261 background_queue_.EndEnumeration(*iter);
1262 *iter = NULL;
1263 }
1264
1265 void BackendImpl::GetStats(StatsItems* stats) { 1284 void BackendImpl::GetStats(StatsItems* stats) {
1266 if (disabled_) 1285 if (disabled_)
1267 return; 1286 return;
1268 1287
1269 std::pair<std::string, std::string> item; 1288 std::pair<std::string, std::string> item;
1270 1289
1271 item.first = "Entries"; 1290 item.first = "Entries";
1272 item.second = base::StringPrintf("%d", data_->header.num_entries); 1291 item.second = base::StringPrintf("%d", data_->header.num_entries);
1273 stats->push_back(item); 1292 stats->push_back(item);
1274 1293
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
2066 if (total_memory > kMaxBuffersSize || total_memory <= 0) 2085 if (total_memory > kMaxBuffersSize || total_memory <= 0)
2067 total_memory = kMaxBuffersSize; 2086 total_memory = kMaxBuffersSize;
2068 2087
2069 done = true; 2088 done = true;
2070 } 2089 }
2071 2090
2072 return static_cast<int>(total_memory); 2091 return static_cast<int>(total_memory);
2073 } 2092 }
2074 2093
2075 } // namespace disk_cache 2094 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698