| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/stats.h" | 5 #include "net/disk_cache/stats.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "net/disk_cache/backend_impl.h" | 10 #include "net/disk_cache/backend_impl.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // It seems impossible to support this histogram for more than one | 131 // It seems impossible to support this histogram for more than one |
| 132 // simultaneous objects with the current infrastructure. | 132 // simultaneous objects with the current infrastructure. |
| 133 static bool first_time = true; | 133 static bool first_time = true; |
| 134 if (first_time) { | 134 if (first_time) { |
| 135 first_time = false; | 135 first_time = false; |
| 136 // ShouldReportAgain() will re-enter this object. | 136 // ShouldReportAgain() will re-enter this object. |
| 137 if (!size_histogram_.get() && backend->cache_type() == net::DISK_CACHE && | 137 if (!size_histogram_.get() && backend->cache_type() == net::DISK_CACHE && |
| 138 backend->ShouldReportAgain()) { | 138 backend->ShouldReportAgain()) { |
| 139 // Stats may be reused when the cache is re-created, but we want only one | 139 // Stats may be reused when the cache is re-created, but we want only one |
| 140 // histogram at any given time. | 140 // histogram at any given time. |
| 141 size_histogram_.reset(new StatsHistogram("DiskCache.SizeStats")); | 141 size_histogram_ = |
| 142 StatsHistogram::StatsHistogramFactoryGet("DiskCache.SizeStats"); |
| 142 size_histogram_->Init(this); | 143 size_histogram_->Init(this); |
| 143 } | 144 } |
| 144 } | 145 } |
| 145 | 146 |
| 146 return true; | 147 return true; |
| 147 } | 148 } |
| 148 | 149 |
| 149 Stats::~Stats() { | 150 Stats::~Stats() { |
| 150 Store(); | 151 Store(); |
| 151 } | 152 } |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 stats.signature = kDiskSignature; | 312 stats.signature = kDiskSignature; |
| 312 stats.size = sizeof(stats); | 313 stats.size = sizeof(stats); |
| 313 memcpy(stats.data_sizes, data_sizes_, sizeof(data_sizes_)); | 314 memcpy(stats.data_sizes, data_sizes_, sizeof(data_sizes_)); |
| 314 memcpy(stats.counters, counters_, sizeof(counters_)); | 315 memcpy(stats.counters, counters_, sizeof(counters_)); |
| 315 | 316 |
| 316 Addr address(storage_addr_); | 317 Addr address(storage_addr_); |
| 317 StoreStats(backend_, address, &stats); | 318 StoreStats(backend_, address, &stats); |
| 318 } | 319 } |
| 319 | 320 |
| 320 } // namespace disk_cache | 321 } // namespace disk_cache |
| OLD | NEW |