OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 ResourceCounter, | 55 ResourceCounter, |
56 ScriptPromiseCounter, | 56 ScriptPromiseCounter, |
57 V8PerContextDataCounter, | 57 V8PerContextDataCounter, |
58 WorkerGlobalScopeCounter, | 58 WorkerGlobalScopeCounter, |
59 | 59 |
60 // This value must be the last. | 60 // This value must be the last. |
61 CounterTypeLength, | 61 CounterTypeLength, |
62 }; | 62 }; |
63 | 63 |
64 static inline void incrementCounter(CounterType type) { | 64 static inline void incrementCounter(CounterType type) { |
| 65 DCHECK_NE(type, NodeCounter); |
65 atomicIncrement(&s_counters[type]); | 66 atomicIncrement(&s_counters[type]); |
66 } | 67 } |
67 | 68 |
68 static inline void decrementCounter(CounterType type) { | 69 static inline void decrementCounter(CounterType type) { |
| 70 DCHECK_NE(type, NodeCounter); |
69 atomicDecrement(&s_counters[type]); | 71 atomicDecrement(&s_counters[type]); |
70 } | 72 } |
71 | 73 |
| 74 static inline void incrementNodeCounter() { |
| 75 DCHECK(isMainThread()); |
| 76 s_nodeCounter++; |
| 77 } |
| 78 |
| 79 static inline void decrementNodeCounter() { |
| 80 DCHECK(isMainThread()); |
| 81 s_nodeCounter--; |
| 82 } |
| 83 |
72 CORE_EXPORT static int counterValue(CounterType); | 84 CORE_EXPORT static int counterValue(CounterType); |
73 | 85 |
74 private: | 86 private: |
75 CORE_EXPORT static int s_counters[CounterTypeLength]; | 87 CORE_EXPORT static int s_counters[CounterTypeLength]; |
| 88 CORE_EXPORT static int s_nodeCounter; |
76 }; | 89 }; |
77 | 90 |
78 } // namespace blink | 91 } // namespace blink |
79 | 92 |
80 #endif // !defined(InstanceCounters_h) | 93 #endif // !defined(InstanceCounters_h) |
OLD | NEW |