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 #ifndef NET_DISK_CACHE_BLOCKFILE_STATS_H_ | 5 #ifndef NET_DISK_CACHE_BLOCKFILE_STATS_H_ |
6 #define NET_DISK_CACHE_BLOCKFILE_STATS_H_ | 6 #define NET_DISK_CACHE_BLOCKFILE_STATS_H_ |
7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include <string> | 11 #include <string> |
9 | 12 |
10 #include "base/basictypes.h" | 13 #include "base/macros.h" |
11 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
12 #include "net/base/net_export.h" | 15 #include "net/base/net_export.h" |
13 #include "net/disk_cache/blockfile/addr.h" | 16 #include "net/disk_cache/blockfile/addr.h" |
14 | 17 |
15 namespace base { | 18 namespace base { |
16 class HistogramSamples; | 19 class HistogramSamples; |
17 } // namespace base | 20 } // namespace base |
18 | 21 |
19 namespace disk_cache { | 22 namespace disk_cache { |
20 | 23 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // Initializes this object with |data| from disk. | 60 // Initializes this object with |data| from disk. |
58 bool Init(void* data, int num_bytes, Addr address); | 61 bool Init(void* data, int num_bytes, Addr address); |
59 | 62 |
60 // Generates a size distribution histogram. | 63 // Generates a size distribution histogram. |
61 void InitSizeHistogram(); | 64 void InitSizeHistogram(); |
62 | 65 |
63 // Returns the number of bytes needed to store the stats on disk. | 66 // Returns the number of bytes needed to store the stats on disk. |
64 int StorageSize(); | 67 int StorageSize(); |
65 | 68 |
66 // Tracks changes to the stoage space used by an entry. | 69 // Tracks changes to the stoage space used by an entry. |
67 void ModifyStorageStats(int32 old_size, int32 new_size); | 70 void ModifyStorageStats(int32_t old_size, int32_t new_size); |
68 | 71 |
69 // Tracks general events. | 72 // Tracks general events. |
70 void OnEvent(Counters an_event); | 73 void OnEvent(Counters an_event); |
71 void SetCounter(Counters counter, int64 value); | 74 void SetCounter(Counters counter, int64_t value); |
72 int64 GetCounter(Counters counter) const; | 75 int64_t GetCounter(Counters counter) const; |
73 | 76 |
74 void GetItems(StatsItems* items); | 77 void GetItems(StatsItems* items); |
75 int GetHitRatio() const; | 78 int GetHitRatio() const; |
76 int GetResurrectRatio() const; | 79 int GetResurrectRatio() const; |
77 void ResetRatios(); | 80 void ResetRatios(); |
78 | 81 |
79 // Returns the lower bound of the space used by entries bigger than 512 KB. | 82 // Returns the lower bound of the space used by entries bigger than 512 KB. |
80 int GetLargeEntriesSize(); | 83 int GetLargeEntriesSize(); |
81 | 84 |
82 // Writes the stats into |data|, to be stored at the given cache address. | 85 // Writes the stats into |data|, to be stored at the given cache address. |
83 // Returns the number of bytes copied. | 86 // Returns the number of bytes copied. |
84 int SerializeStats(void* data, int num_bytes, Addr* address); | 87 int SerializeStats(void* data, int num_bytes, Addr* address); |
85 | 88 |
86 private: | 89 private: |
87 // Supports generation of SizeStats histogram data. | 90 // Supports generation of SizeStats histogram data. |
88 int GetBucketRange(size_t i) const; | 91 int GetBucketRange(size_t i) const; |
89 int GetStatsBucket(int32 size); | 92 int GetStatsBucket(int32_t size); |
90 int GetRatio(Counters hit, Counters miss) const; | 93 int GetRatio(Counters hit, Counters miss) const; |
91 | 94 |
92 Addr storage_addr_; | 95 Addr storage_addr_; |
93 int data_sizes_[kDataSizesLength]; | 96 int data_sizes_[kDataSizesLength]; |
94 int64 counters_[MAX_COUNTER]; | 97 int64_t counters_[MAX_COUNTER]; |
95 | 98 |
96 DISALLOW_COPY_AND_ASSIGN(Stats); | 99 DISALLOW_COPY_AND_ASSIGN(Stats); |
97 }; | 100 }; |
98 | 101 |
99 } // namespace disk_cache | 102 } // namespace disk_cache |
100 | 103 |
101 #endif // NET_DISK_CACHE_BLOCKFILE_STATS_H_ | 104 #endif // NET_DISK_CACHE_BLOCKFILE_STATS_H_ |
OLD | NEW |