| 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/backend_impl.h" | 5 #include "net/disk_cache/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_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 } | 805 } |
| 806 | 806 |
| 807 // Link this entry through the lists. | 807 // Link this entry through the lists. |
| 808 eviction_.OnCreateEntry(cache_entry); | 808 eviction_.OnCreateEntry(cache_entry); |
| 809 | 809 |
| 810 CACHE_UMA(AGE_MS, "CreateTime", 0, start); | 810 CACHE_UMA(AGE_MS, "CreateTime", 0, start); |
| 811 stats_.OnEvent(Stats::CREATE_HIT); | 811 stats_.OnEvent(Stats::CREATE_HIT); |
| 812 SIMPLE_STATS_COUNTER("disk_cache.miss"); | 812 SIMPLE_STATS_COUNTER("disk_cache.miss"); |
| 813 Trace("create entry hit "); | 813 Trace("create entry hit "); |
| 814 FlushIndex(); | 814 FlushIndex(); |
| 815 return cache_entry.release(); | 815 cache_entry->AddRef(); |
| 816 return cache_entry.get(); |
| 816 } | 817 } |
| 817 | 818 |
| 818 EntryImpl* BackendImpl::OpenNextEntryImpl(void** iter) { | 819 EntryImpl* BackendImpl::OpenNextEntryImpl(void** iter) { |
| 819 return OpenFollowingEntry(true, iter); | 820 return OpenFollowingEntry(true, iter); |
| 820 } | 821 } |
| 821 | 822 |
| 822 EntryImpl* BackendImpl::OpenPrevEntryImpl(void** iter) { | 823 EntryImpl* BackendImpl::OpenPrevEntryImpl(void** iter) { |
| 823 return OpenFollowingEntry(false, iter); | 824 return OpenFollowingEntry(false, iter); |
| 824 } | 825 } |
| 825 | 826 |
| (...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1817 if (access_times[i] < access_times[oldest]) | 1818 if (access_times[i] < access_times[oldest]) |
| 1818 oldest = i; | 1819 oldest = i; |
| 1819 } | 1820 } |
| 1820 } | 1821 } |
| 1821 | 1822 |
| 1822 if (newest < 0 || oldest < 0) | 1823 if (newest < 0 || oldest < 0) |
| 1823 return NULL; | 1824 return NULL; |
| 1824 | 1825 |
| 1825 EntryImpl* next_entry; | 1826 EntryImpl* next_entry; |
| 1826 if (forward) { | 1827 if (forward) { |
| 1827 next_entry = entries[newest].release(); | 1828 next_entry = entries[newest].get(); |
| 1828 iterator->list = static_cast<Rankings::List>(newest); | 1829 iterator->list = static_cast<Rankings::List>(newest); |
| 1829 } else { | 1830 } else { |
| 1830 next_entry = entries[oldest].release(); | 1831 next_entry = entries[oldest].get(); |
| 1831 iterator->list = static_cast<Rankings::List>(oldest); | 1832 iterator->list = static_cast<Rankings::List>(oldest); |
| 1832 } | 1833 } |
| 1833 | 1834 |
| 1834 *iter = iterator.release(); | 1835 *iter = iterator.release(); |
| 1836 next_entry->AddRef(); |
| 1835 return next_entry; | 1837 return next_entry; |
| 1836 } | 1838 } |
| 1837 | 1839 |
| 1838 bool BackendImpl::OpenFollowingEntryFromList(bool forward, Rankings::List list, | 1840 bool BackendImpl::OpenFollowingEntryFromList(bool forward, Rankings::List list, |
| 1839 CacheRankingsBlock** from_entry, | 1841 CacheRankingsBlock** from_entry, |
| 1840 EntryImpl** next_entry) { | 1842 EntryImpl** next_entry) { |
| 1841 if (disabled_) | 1843 if (disabled_) |
| 1842 return false; | 1844 return false; |
| 1843 | 1845 |
| 1844 if (!new_eviction_ && Rankings::NO_USE != list) | 1846 if (!new_eviction_ && Rankings::NO_USE != list) |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2232 if (total_memory > kMaxBuffersSize || total_memory <= 0) | 2234 if (total_memory > kMaxBuffersSize || total_memory <= 0) |
| 2233 total_memory = kMaxBuffersSize; | 2235 total_memory = kMaxBuffersSize; |
| 2234 | 2236 |
| 2235 done = true; | 2237 done = true; |
| 2236 } | 2238 } |
| 2237 | 2239 |
| 2238 return static_cast<int>(total_memory); | 2240 return static_cast<int>(total_memory); |
| 2239 } | 2241 } |
| 2240 | 2242 |
| 2241 } // namespace disk_cache | 2243 } // namespace disk_cache |
| OLD | NEW |