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 int OpenNextEntry(Entry** next_entry, | 1260 void BackendImpl::EndEnumeration(void** iter) { |
1260 const net::CompletionCallback& callback) OVERRIDE { | 1261 background_queue_.EndEnumeration(*iter); |
1261 if (!background_queue_) | 1262 *iter = NULL; |
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())); | |
1274 } | 1263 } |
1275 | 1264 |
1276 void BackendImpl::GetStats(StatsItems* stats) { | 1265 void BackendImpl::GetStats(StatsItems* stats) { |
1277 if (disabled_) | 1266 if (disabled_) |
1278 return; | 1267 return; |
1279 | 1268 |
1280 std::pair<std::string, std::string> item; | 1269 std::pair<std::string, std::string> item; |
1281 | 1270 |
1282 item.first = "Entries"; | 1271 item.first = "Entries"; |
1283 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... |
2077 if (total_memory > kMaxBuffersSize || total_memory <= 0) | 2066 if (total_memory > kMaxBuffersSize || total_memory <= 0) |
2078 total_memory = kMaxBuffersSize; | 2067 total_memory = kMaxBuffersSize; |
2079 | 2068 |
2080 done = true; | 2069 done = true; |
2081 } | 2070 } |
2082 | 2071 |
2083 return static_cast<int>(total_memory); | 2072 return static_cast<int>(total_memory); |
2084 } | 2073 } |
2085 | 2074 |
2086 } // namespace disk_cache | 2075 } // namespace disk_cache |
OLD | NEW |