OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/common/chrome_counters.h" | 5 #include "content/common/content_counters.h" |
6 | 6 |
7 #include "base/metrics/stats_counters.h" | 7 #include "base/metrics/stats_counters.h" |
8 | 8 |
9 namespace chrome { | 9 namespace content { |
10 | 10 |
11 using base::StatsCounterTimer; | 11 using base::StatsCounterTimer; |
12 using base::StatsRate; | 12 using base::StatsRate; |
13 | 13 |
14 // Note: We use the construct-on-first-use pattern here, because we don't | 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. | 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. | 16 // The downside of this is that the objects don't ever get cleaned up. |
17 // But they are small and this is okay. | 17 // But they are small and this is okay. |
18 | 18 |
19 // Note: Because these are constructed on-first-use, there is a slight | 19 // Note: Because these are constructed on-first-use, there is a slight |
20 // race condition - two threads could initialize the same counter. | 20 // race condition - two threads could initialize the same counter. |
21 // If this happened, the stats table would still work just fine; | 21 // If this happened, the stats table would still work just fine; |
22 // we'd leak the extraneous StatsCounter object once, and that | 22 // we'd leak the extraneous StatsCounter object once, and that |
23 // would be it. But these are small objects, so this is ok. | 23 // would be it. But these are small objects, so this is ok. |
24 | 24 |
25 StatsCounterTimer& Counters::chrome_main() { | 25 StatsCounterTimer& Counters::chrome_main() { |
26 static StatsCounterTimer* ctr = new StatsCounterTimer("Chrome.Init"); | 26 static StatsCounterTimer* ctr = new StatsCounterTimer("Chrome.Init"); |
27 return *ctr; | 27 return *ctr; |
28 } | 28 } |
29 | 29 |
30 StatsCounterTimer& Counters::renderer_main() { | 30 StatsCounterTimer& Counters::renderer_main() { |
31 static StatsCounterTimer* ctr = new StatsCounterTimer("Chrome.RendererInit"); | 31 static StatsCounterTimer* ctr = new StatsCounterTimer("Chrome.RendererInit"); |
32 return *ctr; | 32 return *ctr; |
33 } | 33 } |
34 | 34 |
35 StatsCounterTimer& Counters::spellcheck_init() { | 35 } // namespace content |
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 |