| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/mem_backend_impl.h" | 5 #include "net/disk_cache/mem_backend_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
| 9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "net/disk_cache/cache_util.h" | 10 #include "net/disk_cache/cache_util.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 if (OpenNextEntry(iter, next_entry)) | 181 if (OpenNextEntry(iter, next_entry)) |
| 182 return net::OK; | 182 return net::OK; |
| 183 | 183 |
| 184 return net::ERR_FAILED; | 184 return net::ERR_FAILED; |
| 185 } | 185 } |
| 186 | 186 |
| 187 void MemBackendImpl::EndEnumeration(void** iter) { | 187 void MemBackendImpl::EndEnumeration(void** iter) { |
| 188 *iter = NULL; | 188 *iter = NULL; |
| 189 } | 189 } |
| 190 | 190 |
| 191 void MemBackendImpl::OnExternalCacheHit(const std::string& key) { |
| 192 EntryMap::iterator it = entries_.find(key); |
| 193 if (it != entries_.end()) { |
| 194 UpdateRank(it->second); |
| 195 } |
| 196 } |
| 197 |
| 191 bool MemBackendImpl::OpenEntry(const std::string& key, Entry** entry) { | 198 bool MemBackendImpl::OpenEntry(const std::string& key, Entry** entry) { |
| 192 EntryMap::iterator it = entries_.find(key); | 199 EntryMap::iterator it = entries_.find(key); |
| 193 if (it == entries_.end()) | 200 if (it == entries_.end()) |
| 194 return false; | 201 return false; |
| 195 | 202 |
| 196 it->second->Open(); | 203 it->second->Open(); |
| 197 | 204 |
| 198 *entry = it->second; | 205 *entry = it->second; |
| 199 return true; | 206 return true; |
| 200 } | 207 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 if (current_size_ > max_size_) | 318 if (current_size_ > max_size_) |
| 312 TrimCache(false); | 319 TrimCache(false); |
| 313 } | 320 } |
| 314 | 321 |
| 315 void MemBackendImpl::SubstractStorageSize(int32 bytes) { | 322 void MemBackendImpl::SubstractStorageSize(int32 bytes) { |
| 316 current_size_ -= bytes; | 323 current_size_ -= bytes; |
| 317 DCHECK_GE(current_size_, 0); | 324 DCHECK_GE(current_size_, 0); |
| 318 } | 325 } |
| 319 | 326 |
| 320 } // namespace disk_cache | 327 } // namespace disk_cache |
| OLD | NEW |