| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/common/chrome_counters.h" | |
| 6 | |
| 7 #include "base/metrics/stats_counters.h" | |
| 8 | |
| 9 namespace chrome { | |
| 10 | |
| 11 using base::StatsCounterTimer; | |
| 12 using base::StatsRate; | |
| 13 | |
| 14 // Note: We use the construct-on-first-use pattern here, because we don't | |
| 15 // want to fight with any static initializer ordering problems later. | |
| 16 // The downside of this is that the objects don't ever get cleaned up. | |
| 17 // But they are small and this is okay. | |
| 18 | |
| 19 // Note: Because these are constructed on-first-use, there is a slight | |
| 20 // race condition - two threads could initialize the same counter. | |
| 21 // If this happened, the stats table would still work just fine; | |
| 22 // we'd leak the extraneous StatsCounter object once, and that | |
| 23 // would be it. But these are small objects, so this is ok. | |
| 24 | |
| 25 StatsCounterTimer& Counters::chrome_main() { | |
| 26 static StatsCounterTimer* ctr = new StatsCounterTimer("Chrome.Init"); | |
| 27 return *ctr; | |
| 28 } | |
| 29 | |
| 30 StatsCounterTimer& Counters::renderer_main() { | |
| 31 static StatsCounterTimer* ctr = new StatsCounterTimer("Chrome.RendererInit"); | |
| 32 return *ctr; | |
| 33 } | |
| 34 | |
| 35 StatsCounterTimer& Counters::spellcheck_init() { | |
| 36 static StatsCounterTimer* ctr = new StatsCounterTimer("SpellCheck.Init"); | |
| 37 return *ctr; | |
| 38 } | |
| 39 | |
| 40 StatsRate& Counters::spellcheck_lookup() { | |
| 41 static StatsRate* ctr = new StatsRate("SpellCheck.Lookup"); | |
| 42 return *ctr; | |
| 43 } | |
| 44 | |
| 45 } // namespace chrome | |
| OLD | NEW |