| 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.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 Loading... |
| 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 class BackendImpl::IteratorImpl : public Backend::Iterator { | 1253 int BackendImpl::OpenNextEntry(void** iter, Entry** next_entry, |
| 1254 public: | 1254 const CompletionCallback& callback) { |
| 1255 explicit IteratorImpl(base::WeakPtr<InFlightBackendIO> background_queue) | 1255 DCHECK(!callback.is_null()); |
| 1256 : background_queue_(background_queue), data_(NULL) { | 1256 background_queue_.OpenNextEntry(iter, next_entry, callback); |
| 1257 } | 1257 return net::ERR_IO_PENDING; |
| 1258 } |
| 1258 | 1259 |
| 1259 virtual ~IteratorImpl() { | 1260 void BackendImpl::EndEnumeration(void** iter) { |
| 1260 if (background_queue_) | 1261 background_queue_.EndEnumeration(*iter); |
| 1261 background_queue_->EndEnumeration(data_); | 1262 *iter = NULL; |
| 1262 } | |
| 1263 | |
| 1264 virtual int OpenNextEntry(Entry** next_entry, | |
| 1265 const net::CompletionCallback& callback) OVERRIDE { | |
| 1266 if (!background_queue_) | |
| 1267 return net::ERR_FAILED; | |
| 1268 background_queue_->OpenNextEntry(&data_, next_entry, callback); | |
| 1269 return net::ERR_IO_PENDING; | |
| 1270 } | |
| 1271 | |
| 1272 private: | |
| 1273 const base::WeakPtr<InFlightBackendIO> background_queue_; | |
| 1274 void* data_; | |
| 1275 }; | |
| 1276 | |
| 1277 scoped_ptr<Backend::Iterator> BackendImpl::CreateIterator() { | |
| 1278 return scoped_ptr<Backend::Iterator>(new IteratorImpl(GetBackgroundQueue())); | |
| 1279 } | 1263 } |
| 1280 | 1264 |
| 1281 void BackendImpl::GetStats(StatsItems* stats) { | 1265 void BackendImpl::GetStats(StatsItems* stats) { |
| 1282 if (disabled_) | 1266 if (disabled_) |
| 1283 return; | 1267 return; |
| 1284 | 1268 |
| 1285 std::pair<std::string, std::string> item; | 1269 std::pair<std::string, std::string> item; |
| 1286 | 1270 |
| 1287 item.first = "Entries"; | 1271 item.first = "Entries"; |
| 1288 item.second = base::StringPrintf("%d", data_->header.num_entries); | 1272 item.second = base::StringPrintf("%d", data_->header.num_entries); |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2082 if (total_memory > kMaxBuffersSize || total_memory <= 0) | 2066 if (total_memory > kMaxBuffersSize || total_memory <= 0) |
| 2083 total_memory = kMaxBuffersSize; | 2067 total_memory = kMaxBuffersSize; |
| 2084 | 2068 |
| 2085 done = true; | 2069 done = true; |
| 2086 } | 2070 } |
| 2087 | 2071 |
| 2088 return static_cast<int>(total_memory); | 2072 return static_cast<int>(total_memory); |
| 2089 } | 2073 } |
| 2090 | 2074 |
| 2091 } // namespace disk_cache | 2075 } // namespace disk_cache |
| OLD | NEW |