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 "chrome/common/chrome_counters.h" | 5 #include "chrome/common/chrome_counters.h" |
6 | 6 |
7 #include "base/stats_counters.h" | 7 #include "base/stats_counters.h" |
8 | 8 |
9 namespace chrome { | 9 namespace chrome { |
10 | 10 |
11 // Note: We use the construct-on-first-use pattern here, because we don't | 11 // Note: We use the construct-on-first-use pattern here, because we don't |
12 // want to fight with any static initializer ordering problems later. | 12 // want to fight with any static initializer ordering problems later. |
13 // The downside of this is that the objects don't ever get cleaned up. | 13 // The downside of this is that the objects don't ever get cleaned up. |
14 // But they are small and this is okay. | 14 // But they are small and this is okay. |
15 | 15 |
16 // Note: Because these are constructed on-first-use, there is a slight | 16 // Note: Because these are constructed on-first-use, there is a slight |
17 // race condition - two threads could initialize the same counter. | 17 // race condition - two threads could initialize the same counter. |
18 // If this happened, the stats table would still work just fine; | 18 // If this happened, the stats table would still work just fine; |
19 // we'd leak the extraneous StatsCounter object once, and that | 19 // we'd leak the extraneous StatsCounter object once, and that |
20 // would be it. But these are small objects, so this is ok. | 20 // would be it. But these are small objects, so this is ok. |
21 | 21 |
22 StatsCounter& Counters::ipc_send_counter() { | |
23 static StatsCounter* ctr = new StatsCounter("IPC.SendMsgCount"); | |
24 return *ctr; | |
25 } | |
26 | |
27 StatsCounterTimer& Counters::chrome_main() { | 22 StatsCounterTimer& Counters::chrome_main() { |
28 static StatsCounterTimer* ctr = new StatsCounterTimer("Chrome.Init"); | 23 static StatsCounterTimer* ctr = new StatsCounterTimer("Chrome.Init"); |
29 return *ctr; | 24 return *ctr; |
30 } | 25 } |
31 | 26 |
32 StatsCounterTimer& Counters::renderer_main() { | 27 StatsCounterTimer& Counters::renderer_main() { |
33 static StatsCounterTimer* ctr = new StatsCounterTimer("Chrome.RendererInit"); | 28 static StatsCounterTimer* ctr = new StatsCounterTimer("Chrome.RendererInit"); |
34 return *ctr; | 29 return *ctr; |
35 } | 30 } |
36 | 31 |
(...skipping 11 matching lines...) Expand all Loading... |
48 static StatsCounterTimer* ctr = new StatsCounterTimer("ChromePlugin.Load"); | 43 static StatsCounterTimer* ctr = new StatsCounterTimer("ChromePlugin.Load"); |
49 return *ctr; | 44 return *ctr; |
50 } | 45 } |
51 | 46 |
52 StatsRate& Counters::plugin_intercept() { | 47 StatsRate& Counters::plugin_intercept() { |
53 static StatsRate* ctr = new StatsRate("ChromePlugin.Intercept"); | 48 static StatsRate* ctr = new StatsRate("ChromePlugin.Intercept"); |
54 return *ctr; | 49 return *ctr; |
55 } | 50 } |
56 | 51 |
57 } // namespace chrome | 52 } // namespace chrome |
OLD | NEW |