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/logging.h" | 8 #include "base/logging.h" |
8 #include "base/string_util.h" | 9 #include "base/string_util.h" |
9 #include "net/disk_cache/backend_impl.h" | 10 #include "net/disk_cache/backend_impl.h" |
10 | 11 |
11 namespace { | 12 namespace { |
12 | 13 |
13 const int32 kDiskSignature = 0xF01427E0; | 14 const int32 kDiskSignature = 0xF01427E0; |
14 | 15 |
15 struct OnDiskStats { | 16 struct OnDiskStats { |
16 int32 signature; | 17 int32 signature; |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 void Stats::GetItems(StatsItems* items) { | 257 void Stats::GetItems(StatsItems* items) { |
257 std::pair<std::string, std::string> item; | 258 std::pair<std::string, std::string> item; |
258 for (int i = 0; i < kDataSizesLength; i++) { | 259 for (int i = 0; i < kDataSizesLength; i++) { |
259 item.first = StringPrintf("Size%02d", i); | 260 item.first = StringPrintf("Size%02d", i); |
260 item.second = StringPrintf("0x%08x", data_sizes_[i]); | 261 item.second = StringPrintf("0x%08x", data_sizes_[i]); |
261 items->push_back(item); | 262 items->push_back(item); |
262 } | 263 } |
263 | 264 |
264 for (int i = MIN_COUNTER + 1; i < MAX_COUNTER; i++) { | 265 for (int i = MIN_COUNTER + 1; i < MAX_COUNTER; i++) { |
265 item.first = kCounterNames[i]; | 266 item.first = kCounterNames[i]; |
266 item.second = StringPrintf("0x%I64x", counters_[i]); | 267 item.second = StringPrintf("0x%" PRIx64, counters_[i]); |
267 items->push_back(item); | 268 items->push_back(item); |
268 } | 269 } |
269 } | 270 } |
270 | 271 |
271 int Stats::GetHitRatio() const { | 272 int Stats::GetHitRatio() const { |
272 return GetRatio(OPEN_HIT, OPEN_MISS); | 273 return GetRatio(OPEN_HIT, OPEN_MISS); |
273 } | 274 } |
274 | 275 |
275 int Stats::GetResurrectRatio() const { | 276 int Stats::GetResurrectRatio() const { |
276 return GetRatio(RESURRECT_HIT, CREATE_HIT); | 277 return GetRatio(RESURRECT_HIT, CREATE_HIT); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 stats.signature = kDiskSignature; | 311 stats.signature = kDiskSignature; |
311 stats.size = sizeof(stats); | 312 stats.size = sizeof(stats); |
312 memcpy(stats.data_sizes, data_sizes_, sizeof(data_sizes_)); | 313 memcpy(stats.data_sizes, data_sizes_, sizeof(data_sizes_)); |
313 memcpy(stats.counters, counters_, sizeof(counters_)); | 314 memcpy(stats.counters, counters_, sizeof(counters_)); |
314 | 315 |
315 Addr address(storage_addr_); | 316 Addr address(storage_addr_); |
316 StoreStats(backend_, address, &stats); | 317 StoreStats(backend_, address, &stats); |
317 } | 318 } |
318 | 319 |
319 } // namespace disk_cache | 320 } // namespace disk_cache |
OLD | NEW |