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 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1323 // NOTE: only for use in testing. | 1323 // NOTE: only for use in testing. |
1324 static bool isCounted(Document&, const String&); | 1324 static bool isCounted(Document&, const String&); |
1325 bool isCounted(CSSPropertyID unresolvedProperty); | 1325 bool isCounted(CSSPropertyID unresolvedProperty); |
1326 | 1326 |
1327 void didCommitLoad(); | 1327 void didCommitLoad(); |
1328 | 1328 |
1329 static UseCounter* getFrom(const Document*); | 1329 static UseCounter* getFrom(const Document*); |
1330 static UseCounter* getFrom(const CSSStyleSheet*); | 1330 static UseCounter* getFrom(const CSSStyleSheet*); |
1331 static UseCounter* getFrom(const StyleSheetContents*); | 1331 static UseCounter* getFrom(const StyleSheetContents*); |
1332 | 1332 |
1333 static int mapCSSPropertyIdToCSSSampleIdForHistogram(int id); | 1333 static int mapCSSPropertyIdToCSSSampleIdForHistogram(CSSPropertyID); |
1334 | 1334 |
1335 void muteForInspector(); | 1335 void muteForInspector(); |
1336 void unmuteForInspector(); | 1336 void unmuteForInspector(); |
1337 | 1337 |
1338 void recordMeasurement(Feature); | 1338 void recordMeasurement(Feature); |
1339 void updateMeasurements(); | 1339 void updateMeasurements(); |
1340 | 1340 |
1341 bool hasRecordedMeasurement(Feature feature) const { return m_countBits.hasR
ecordedMeasurement(feature); } | 1341 bool hasRecordedMeasurement(Feature) const; |
1342 | |
1343 class CountBits { | |
1344 DISALLOW_NEW(); | |
1345 public: | |
1346 CountBits() : m_bits(NumberOfFeatures) { } | |
1347 | |
1348 bool hasRecordedMeasurement(Feature feature) const | |
1349 { | |
1350 ASSERT(feature != PageDestruction); // PageDestruction is reserved a
s a scaling factor. | |
1351 ASSERT(feature < NumberOfFeatures); | |
1352 | |
1353 return m_bits.quickGet(feature); | |
1354 } | |
1355 | |
1356 void recordMeasurement(Feature feature) | |
1357 { | |
1358 ASSERT(feature != PageDestruction); // PageDestruction is reserved a
s a scaling factor. | |
1359 ASSERT(feature < NumberOfFeatures); | |
1360 | |
1361 m_bits.quickSet(feature); | |
1362 } | |
1363 | |
1364 void updateMeasurements(); | |
1365 | |
1366 private: | |
1367 BitVector m_bits; | |
1368 }; | |
1369 | 1342 |
1370 protected: | 1343 protected: |
1371 friend class UseCounterTest; | 1344 friend class UseCounterTest; |
1372 unsigned m_muteCount; | 1345 unsigned m_muteCount; |
1373 | 1346 |
1374 CountBits m_countBits; | 1347 BitVector m_featureBits; |
1375 BitVector m_CSSFeatureBits; | 1348 BitVector m_CSSFeatureBits; |
1376 }; | 1349 }; |
1377 | 1350 |
1378 } // namespace blink | 1351 } // namespace blink |
1379 | 1352 |
1380 #endif // UseCounter_h | 1353 #endif // UseCounter_h |
OLD | NEW |