| 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" |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/hash.h" | 12 #include "base/hash.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/metrics/stats_counters.h" | |
| 17 #include "base/rand_util.h" | 16 #include "base/rand_util.h" |
| 18 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 19 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 20 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
| 21 #include "base/sys_info.h" | 20 #include "base/sys_info.h" |
| 22 #include "base/threading/thread_restrictions.h" | 21 #include "base/threading/thread_restrictions.h" |
| 23 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 24 #include "base/timer/timer.h" | 23 #include "base/timer/timer.h" |
| 25 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
| 26 #include "net/disk_cache/blockfile/disk_format.h" | 25 #include "net/disk_cache/blockfile/disk_format.h" |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 Trace("Open hash 0x%x end: 0x%x", hash, | 497 Trace("Open hash 0x%x end: 0x%x", hash, |
| 499 cache_entry->entry()->address().value()); | 498 cache_entry->entry()->address().value()); |
| 500 CACHE_UMA(AGE_MS, "OpenTime", 0, start); | 499 CACHE_UMA(AGE_MS, "OpenTime", 0, start); |
| 501 CACHE_UMA(COUNTS_10000, "AllOpenBySize.Hit", 0, current_size); | 500 CACHE_UMA(COUNTS_10000, "AllOpenBySize.Hit", 0, current_size); |
| 502 CACHE_UMA(HOURS, "AllOpenByTotalHours.Hit", 0, | 501 CACHE_UMA(HOURS, "AllOpenByTotalHours.Hit", 0, |
| 503 static_cast<base::HistogramBase::Sample>(total_hours)); | 502 static_cast<base::HistogramBase::Sample>(total_hours)); |
| 504 CACHE_UMA(HOURS, "AllOpenByUseHours.Hit", 0, | 503 CACHE_UMA(HOURS, "AllOpenByUseHours.Hit", 0, |
| 505 static_cast<base::HistogramBase::Sample>(use_hours)); | 504 static_cast<base::HistogramBase::Sample>(use_hours)); |
| 506 stats_.OnEvent(Stats::OPEN_HIT); | 505 stats_.OnEvent(Stats::OPEN_HIT); |
| 507 web_fonts_histogram::RecordCacheHit(cache_entry); | 506 web_fonts_histogram::RecordCacheHit(cache_entry); |
| 508 SIMPLE_STATS_COUNTER("disk_cache.hit"); | |
| 509 return cache_entry; | 507 return cache_entry; |
| 510 } | 508 } |
| 511 | 509 |
| 512 EntryImpl* BackendImpl::CreateEntryImpl(const std::string& key) { | 510 EntryImpl* BackendImpl::CreateEntryImpl(const std::string& key) { |
| 513 if (disabled_ || key.empty()) | 511 if (disabled_ || key.empty()) |
| 514 return NULL; | 512 return NULL; |
| 515 | 513 |
| 516 TimeTicks start = TimeTicks::Now(); | 514 TimeTicks start = TimeTicks::Now(); |
| 517 uint32 hash = base::Hash(key); | 515 uint32 hash = base::Hash(key); |
| 518 Trace("Create hash 0x%x", hash); | 516 Trace("Create hash 0x%x", hash); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 parent->SetNextAddress(entry_address); | 592 parent->SetNextAddress(entry_address); |
| 595 } else { | 593 } else { |
| 596 data_->table[hash & mask_] = entry_address.value(); | 594 data_->table[hash & mask_] = entry_address.value(); |
| 597 } | 595 } |
| 598 | 596 |
| 599 // Link this entry through the lists. | 597 // Link this entry through the lists. |
| 600 eviction_.OnCreateEntry(cache_entry.get()); | 598 eviction_.OnCreateEntry(cache_entry.get()); |
| 601 | 599 |
| 602 CACHE_UMA(AGE_MS, "CreateTime", 0, start); | 600 CACHE_UMA(AGE_MS, "CreateTime", 0, start); |
| 603 stats_.OnEvent(Stats::CREATE_HIT); | 601 stats_.OnEvent(Stats::CREATE_HIT); |
| 604 SIMPLE_STATS_COUNTER("disk_cache.miss"); | |
| 605 Trace("create entry hit "); | 602 Trace("create entry hit "); |
| 606 FlushIndex(); | 603 FlushIndex(); |
| 607 cache_entry->AddRef(); | 604 cache_entry->AddRef(); |
| 608 return cache_entry.get(); | 605 return cache_entry.get(); |
| 609 } | 606 } |
| 610 | 607 |
| 611 EntryImpl* BackendImpl::OpenNextEntryImpl(Rankings::Iterator* iterator) { | 608 EntryImpl* BackendImpl::OpenNextEntryImpl(Rankings::Iterator* iterator) { |
| 612 if (disabled_) | 609 if (disabled_) |
| 613 return NULL; | 610 return NULL; |
| 614 | 611 |
| (...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2085 if (total_memory > kMaxBuffersSize || total_memory <= 0) | 2082 if (total_memory > kMaxBuffersSize || total_memory <= 0) |
| 2086 total_memory = kMaxBuffersSize; | 2083 total_memory = kMaxBuffersSize; |
| 2087 | 2084 |
| 2088 done = true; | 2085 done = true; |
| 2089 } | 2086 } |
| 2090 | 2087 |
| 2091 return static_cast<int>(total_memory); | 2088 return static_cast<int>(total_memory); |
| 2092 } | 2089 } |
| 2093 | 2090 |
| 2094 } // namespace disk_cache | 2091 } // namespace disk_cache |
| OLD | NEW |