| 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 // A StatsTable is a table of statistics. It can be used across multiple | 5 // A StatsTable is a table of statistics. It can be used across multiple |
| 6 // processes and threads, maintaining cheap statistics counters without | 6 // processes and threads, maintaining cheap statistics counters without |
| 7 // locking. | 7 // locking. |
| 8 // | 8 // |
| 9 // The goal is to make it very cheap and easy for developers to add | 9 // The goal is to make it very cheap and easy for developers to add |
| 10 // counters to code, without having to build one-off utilities or mechanisms | 10 // counters to code, without having to build one-off utilities or mechanisms |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 // On success, returns the counter_id for the newly added counter. | 165 // On success, returns the counter_id for the newly added counter. |
| 166 // On failure, returns 0. | 166 // On failure, returns 0. |
| 167 int AddCounter(const std::string& name); | 167 int AddCounter(const std::string& name); |
| 168 | 168 |
| 169 // Get the TLS data for the calling thread. Returns NULL if none is | 169 // Get the TLS data for the calling thread. Returns NULL if none is |
| 170 // initialized. | 170 // initialized. |
| 171 StatsTableTLSData* GetTLSData() const; | 171 StatsTableTLSData* GetTLSData() const; |
| 172 | 172 |
| 173 typedef base::hash_map<std::string, int> CountersMap; | 173 typedef base::hash_map<std::string, int> CountersMap; |
| 174 | 174 |
| 175 bool opened_; | 175 StatsTablePrivate* impl_; |
| 176 StatsTablePrivate* impl_; | |
| 177 // The counters_lock_ protects the counters_ hash table. | 176 // The counters_lock_ protects the counters_ hash table. |
| 178 Lock counters_lock_; | 177 Lock counters_lock_; |
| 179 // The counters_ hash map is an in-memory hash of the counters. | 178 // The counters_ hash map is an in-memory hash of the counters. |
| 180 // It is used for quick lookup of counters, but is cannot be used | 179 // It is used for quick lookup of counters, but is cannot be used |
| 181 // as a substitute for what is in the shared memory. Even though | 180 // as a substitute for what is in the shared memory. Even though |
| 182 // we don't have a counter in our hash table, another process may | 181 // we don't have a counter in our hash table, another process may |
| 183 // have created it. | 182 // have created it. |
| 184 CountersMap counters_; | 183 CountersMap counters_; |
| 185 TLSSlot tls_index_; | 184 TLSSlot tls_index_; |
| 186 | 185 |
| 187 static StatsTable* global_table_; | 186 static StatsTable* global_table_; |
| 187 |
| 188 DISALLOW_EVIL_CONSTRUCTORS(StatsTable); | 188 DISALLOW_EVIL_CONSTRUCTORS(StatsTable); |
| 189 }; | 189 }; |
| 190 | 190 |
| 191 #endif // BASE_STATS_TABLE_H__ | 191 #endif // BASE_STATS_TABLE_H__ |
| OLD | NEW |