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/memory/mem_backend_impl.h" | 5 #include "net/disk_cache/memory/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 return net::ERR_FAILED; | 181 return net::ERR_FAILED; |
182 } | 182 } |
183 | 183 |
184 class MemBackendImpl::MemIterator : public Backend::Iterator { | 184 class MemBackendImpl::MemIterator : public Backend::Iterator { |
185 public: | 185 public: |
186 explicit MemIterator(base::WeakPtr<MemBackendImpl> backend) | 186 explicit MemIterator(base::WeakPtr<MemBackendImpl> backend) |
187 : backend_(backend), current_(NULL) { | 187 : backend_(backend), current_(NULL) { |
188 } | 188 } |
189 | 189 |
190 virtual int OpenNextEntry(Entry** next_entry, | 190 virtual int OpenNextEntry(Entry** next_entry, |
191 const CompletionCallback& callback) OVERRIDE { | 191 const CompletionCallback& callback) override { |
192 if (!backend_) | 192 if (!backend_) |
193 return net::ERR_FAILED; | 193 return net::ERR_FAILED; |
194 | 194 |
195 MemEntryImpl* node = backend_->rankings_.GetNext(current_); | 195 MemEntryImpl* node = backend_->rankings_.GetNext(current_); |
196 // We should never return a child entry so iterate until we hit a parent | 196 // We should never return a child entry so iterate until we hit a parent |
197 // entry. | 197 // entry. |
198 while (node && node->type() != MemEntryImpl::kParentEntry) | 198 while (node && node->type() != MemEntryImpl::kParentEntry) |
199 node = backend_->rankings_.GetNext(node); | 199 node = backend_->rankings_.GetNext(node); |
200 *next_entry = node; | 200 *next_entry = node; |
201 current_ = node; | 201 current_ = node; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 if (current_size_ > max_size_) | 336 if (current_size_ > max_size_) |
337 TrimCache(false); | 337 TrimCache(false); |
338 } | 338 } |
339 | 339 |
340 void MemBackendImpl::SubstractStorageSize(int32 bytes) { | 340 void MemBackendImpl::SubstractStorageSize(int32 bytes) { |
341 current_size_ -= bytes; | 341 current_size_ -= bytes; |
342 DCHECK_GE(current_size_, 0); | 342 DCHECK_GE(current_size_, 0); |
343 } | 343 } |
344 | 344 |
345 } // namespace disk_cache | 345 } // namespace disk_cache |
OLD | NEW |