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/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1192 return net::ERR_IO_PENDING; | 1192 return net::ERR_IO_PENDING; |
1193 } | 1193 } |
1194 | 1194 |
1195 int BackendImpl::DoomEntriesSince(const base::Time initial_time, | 1195 int BackendImpl::DoomEntriesSince(const base::Time initial_time, |
1196 const CompletionCallback& callback) { | 1196 const CompletionCallback& callback) { |
1197 DCHECK(!callback.is_null()); | 1197 DCHECK(!callback.is_null()); |
1198 background_queue_.DoomEntriesSince(initial_time, callback); | 1198 background_queue_.DoomEntriesSince(initial_time, callback); |
1199 return net::ERR_IO_PENDING; | 1199 return net::ERR_IO_PENDING; |
1200 } | 1200 } |
1201 | 1201 |
1202 int BackendImpl::OpenNextEntry(void** iter, Entry** next_entry, | 1202 int BackendImpl::OpenNextEntry(Iterator* iter, Entry** next_entry, |
1203 const CompletionCallback& callback) { | 1203 const CompletionCallback& callback) { |
1204 // TODO(gavinp): Remove all void** iter from cache. | |
1204 DCHECK(!callback.is_null()); | 1205 DCHECK(!callback.is_null()); |
1205 background_queue_.OpenNextEntry(iter, next_entry, callback); | 1206 class State : public EnumerationState { |
clamy
2014/09/04 18:22:01
Maybe it's just me, but I find class definitions i
gavinp
2014/09/04 18:31:46
As it happens, I had to move this out of the funct
clamy
2014/09/04 19:01:37
Yes the version with "data" is easier to follow. I
| |
1207 public: | |
1208 explicit State(base::WeakPtr<InFlightBackendIO> background_queue) | |
1209 : background_queue_(background_queue), | |
1210 iter_(NULL) {} | |
1211 | |
1212 virtual ~State() { | |
1213 if (background_queue_) | |
1214 background_queue_->EndEnumeration(*iter()); | |
1215 } | |
1216 | |
1217 void** iter() { return &iter_; } | |
1218 | |
1219 private: | |
1220 base::WeakPtr<InFlightBackendIO> background_queue_; | |
1221 void* iter_; | |
1222 }; | |
1223 if (!*iter) | |
1224 iter->reset(new State(GetBackgroundQueue())); | |
1225 State* state = static_cast<State*>(iter->get()); | |
1226 | |
1227 background_queue_.OpenNextEntry(state->iter(), next_entry, callback); | |
1206 return net::ERR_IO_PENDING; | 1228 return net::ERR_IO_PENDING; |
1207 } | 1229 } |
1208 | 1230 |
1209 void BackendImpl::EndEnumeration(void** iter) { | |
1210 background_queue_.EndEnumeration(*iter); | |
1211 *iter = NULL; | |
1212 } | |
1213 | |
1214 void BackendImpl::GetStats(StatsItems* stats) { | 1231 void BackendImpl::GetStats(StatsItems* stats) { |
1215 if (disabled_) | 1232 if (disabled_) |
1216 return; | 1233 return; |
1217 | 1234 |
1218 std::pair<std::string, std::string> item; | 1235 std::pair<std::string, std::string> item; |
1219 | 1236 |
1220 item.first = "Entries"; | 1237 item.first = "Entries"; |
1221 item.second = base::StringPrintf("%d", data_->header.num_entries); | 1238 item.second = base::StringPrintf("%d", data_->header.num_entries); |
1222 stats->push_back(item); | 1239 stats->push_back(item); |
1223 | 1240 |
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2095 if (total_memory > kMaxBuffersSize || total_memory <= 0) | 2112 if (total_memory > kMaxBuffersSize || total_memory <= 0) |
2096 total_memory = kMaxBuffersSize; | 2113 total_memory = kMaxBuffersSize; |
2097 | 2114 |
2098 done = true; | 2115 done = true; |
2099 } | 2116 } |
2100 | 2117 |
2101 return static_cast<int>(total_memory); | 2118 return static_cast<int>(total_memory); |
2102 } | 2119 } |
2103 | 2120 |
2104 } // namespace disk_cache | 2121 } // namespace disk_cache |
OLD | NEW |