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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 PrefixedUserTiming, | 127 PrefixedUserTiming, |
128 WindowEvent, | 128 WindowEvent, |
129 ContentSecurityPolicyWithBaseElement, | 129 ContentSecurityPolicyWithBaseElement, |
130 PrefixedMediaAddKey, | 130 PrefixedMediaAddKey, |
131 PrefixedMediaGenerateKeyRequest, | 131 PrefixedMediaGenerateKeyRequest, |
132 WebAudioLooping, | 132 WebAudioLooping, |
133 // Add new features above this line. Don't change assigned numbers of ea
ch items. | 133 // Add new features above this line. Don't change assigned numbers of ea
ch items. |
134 NumberOfFeatures, // This enum value must be last. | 134 NumberOfFeatures, // This enum value must be last. |
135 }; | 135 }; |
136 | 136 |
137 // "observe" sets the bit for this feature to 1. Repeated calls are ignored. | 137 // "count" sets the bit for this feature to 1. Repeated calls are ignored. |
138 static void observe(Document*, Feature); | 138 static void count(Document*, Feature); |
139 static void observe(DOMWindow*, Feature); | 139 static void count(DOMWindow*, Feature); |
140 | 140 |
141 // "measureDeprecatedFeature" sets the bit for this feature to 1, and sends
a deprecation | 141 // "countDeprecation" sets the bit for this feature to 1, and sends a deprec
ation |
142 // warning to the console. Repeated calls are ignored. | 142 // warning to the console. Repeated calls are ignored. |
143 // | 143 // |
144 // Be considerate to developers' consoles: features should only send depreca
tion warnings | 144 // Be considerate to developers' consoles: features should only send depreca
tion warnings |
145 // when we're actively interested in removing them from the platform. | 145 // when we're actively interested in removing them from the platform. |
146 static void measureDeprecatedFeature(DOMWindow*, Feature); | 146 static void countDeprecation(DOMWindow*, Feature); |
147 static void measureDeprecatedFeature(ScriptExecutionContext*, Feature); | 147 static void countDeprecation(ScriptExecutionContext*, Feature); |
148 static void measureDeprecatedFeature(Document*, Feature); | 148 static void countDeprecation(Document*, Feature); |
149 String deprecationMessage(Feature); | 149 String deprecationMessage(Feature); |
150 | 150 |
151 void didCommitLoad(); | 151 void didCommitLoad(); |
152 | 152 |
153 private: | 153 private: |
154 bool recordObservation(Feature feature) | 154 bool recordMeasurement(Feature feature) |
155 { | 155 { |
156 ASSERT(feature != PageDestruction); // PageDestruction is reserved as a
scaling factor. | 156 ASSERT(feature != PageDestruction); // PageDestruction is reserved as a
scaling factor. |
157 ASSERT(feature < NumberOfFeatures); | 157 ASSERT(feature < NumberOfFeatures); |
158 if (!m_countBits) { | 158 if (!m_countBits) { |
159 m_countBits = adoptPtr(new BitVector(NumberOfFeatures)); | 159 m_countBits = adoptPtr(new BitVector(NumberOfFeatures)); |
160 m_countBits->clearAll(); | 160 m_countBits->clearAll(); |
161 } | 161 } |
162 | 162 |
163 if (m_countBits->quickGet(feature)) | 163 if (m_countBits->quickGet(feature)) |
164 return false; | 164 return false; |
165 | 165 |
166 m_countBits->quickSet(feature); | 166 m_countBits->quickSet(feature); |
167 return true; | 167 return true; |
168 } | 168 } |
169 | 169 |
170 void updateMeasurements(); | 170 void updateMeasurements(); |
171 | 171 |
172 OwnPtr<BitVector> m_countBits; | 172 OwnPtr<BitVector> m_countBits; |
173 }; | 173 }; |
174 | 174 |
175 } // namespace WebCore | 175 } // namespace WebCore |
176 | 176 |
177 #endif // UseCounter_h | 177 #endif // UseCounter_h |
OLD | NEW |