| 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 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef UseCounter_h | 26 #ifndef UseCounter_h |
| 27 #define UseCounter_h | 27 #define UseCounter_h |
| 28 | 28 |
| 29 #include "core/CSSPropertyNames.h" | 29 #include "core/CSSPropertyNames.h" |
| 30 #include "core/CoreExport.h" | 30 #include "core/CoreExport.h" |
| 31 #include "core/css/parser/CSSParserMode.h" | 31 #include "core/css/parser/CSSParserMode.h" |
| 32 #include "platform/weborigin/KURL.h" |
| 32 #include "wtf/BitVector.h" | 33 #include "wtf/BitVector.h" |
| 33 #include "wtf/Noncopyable.h" | 34 #include "wtf/Noncopyable.h" |
| 34 #include "wtf/text/WTFString.h" | 35 #include "wtf/text/WTFString.h" |
| 35 #include <v8.h> | 36 #include <v8.h> |
| 36 | 37 |
| 37 namespace blink { | 38 namespace blink { |
| 38 | 39 |
| 39 class CSSStyleSheet; | 40 class CSSStyleSheet; |
| 40 class Document; | 41 class Document; |
| 41 class EnumerationHistogram; | 42 class EnumerationHistogram; |
| (...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1421 static void countCrossOriginIframe(const Document&, Feature); | 1422 static void countCrossOriginIframe(const Document&, Feature); |
| 1422 | 1423 |
| 1423 // Return whether the Feature was previously counted for this document. | 1424 // Return whether the Feature was previously counted for this document. |
| 1424 // NOTE: only for use in testing. | 1425 // NOTE: only for use in testing. |
| 1425 static bool isCounted(Document&, Feature); | 1426 static bool isCounted(Document&, Feature); |
| 1426 // Return whether the CSSPropertyID was previously counted for this document. | 1427 // Return whether the CSSPropertyID was previously counted for this document. |
| 1427 // NOTE: only for use in testing. | 1428 // NOTE: only for use in testing. |
| 1428 static bool isCounted(Document&, const String&); | 1429 static bool isCounted(Document&, const String&); |
| 1429 bool isCounted(CSSPropertyID unresolvedProperty); | 1430 bool isCounted(CSSPropertyID unresolvedProperty); |
| 1430 | 1431 |
| 1431 void didCommitLoad(); | 1432 // Invoked when a new document is loaded into the main frame of the page. |
| 1433 void didCommitLoad(KURL); |
| 1432 | 1434 |
| 1433 static UseCounter* getFrom(const Document*); | 1435 static UseCounter* getFrom(const Document*); |
| 1434 static UseCounter* getFrom(const CSSStyleSheet*); | 1436 static UseCounter* getFrom(const CSSStyleSheet*); |
| 1435 static UseCounter* getFrom(const StyleSheetContents*); | 1437 static UseCounter* getFrom(const StyleSheetContents*); |
| 1436 | 1438 |
| 1437 static int mapCSSPropertyIdToCSSSampleIdForHistogram(CSSPropertyID); | 1439 static int mapCSSPropertyIdToCSSSampleIdForHistogram(CSSPropertyID); |
| 1438 | 1440 |
| 1441 // When muted, all calls to "count" functions are ignoed. May be nested. |
| 1439 void muteForInspector(); | 1442 void muteForInspector(); |
| 1440 void unmuteForInspector(); | 1443 void unmuteForInspector(); |
| 1441 | 1444 |
| 1442 void recordMeasurement(Feature); | 1445 void recordMeasurement(Feature); |
| 1443 void updateMeasurements(); | |
| 1444 | 1446 |
| 1447 // Return whether the feature has been seen since the last page load |
| 1448 // (except when muted). Does include features seen in documents which have |
| 1449 // reporting disabled. |
| 1445 bool hasRecordedMeasurement(Feature) const; | 1450 bool hasRecordedMeasurement(Feature) const; |
| 1446 | 1451 |
| 1447 private: | 1452 private: |
| 1448 EnumerationHistogram& featuresHistogram() const; | 1453 EnumerationHistogram& featuresHistogram() const; |
| 1449 EnumerationHistogram& cssHistogram() const; | 1454 EnumerationHistogram& cssHistogram() const; |
| 1450 | 1455 |
| 1456 // If non-zero, ignore all 'count' calls completely. |
| 1451 unsigned m_muteCount; | 1457 unsigned m_muteCount; |
| 1458 |
| 1459 // If true, disable reporting all histogram entries. |
| 1460 bool m_disableReporting; |
| 1461 |
| 1462 // The scope represented by this UseCounter instance. |
| 1452 Context m_context; | 1463 Context m_context; |
| 1453 | 1464 |
| 1454 // Track what features/properties have been reported to the (non-legacy) | 1465 // Track what features/properties have been reported to the (non-legacy) |
| 1455 // histograms. | 1466 // histograms. |
| 1456 BitVector m_featuresRecorded; | 1467 BitVector m_featuresRecorded; |
| 1457 BitVector m_CSSRecorded; | 1468 BitVector m_CSSRecorded; |
| 1458 | 1469 |
| 1459 // Encapsulates the work to preserve the old "FeatureObserver" histogram with | 1470 // Encapsulates the work to preserve the old "FeatureObserver" histogram with |
| 1460 // original semantics | 1471 // original semantics |
| 1461 // TODO(rbyers): remove this - http://crbug.com/597963 | 1472 // TODO(rbyers): remove this - http://crbug.com/676837 |
| 1462 class CORE_EXPORT LegacyCounter { | 1473 class CORE_EXPORT LegacyCounter { |
| 1463 public: | 1474 public: |
| 1464 LegacyCounter(); | 1475 LegacyCounter(); |
| 1465 ~LegacyCounter(); | 1476 ~LegacyCounter(); |
| 1466 void countFeature(Feature); | 1477 void countFeature(Feature); |
| 1467 void countCSS(CSSPropertyID); | 1478 void countCSS(CSSPropertyID); |
| 1468 void updateMeasurements(); | 1479 void updateMeasurements(); |
| 1469 | 1480 |
| 1470 private: | 1481 private: |
| 1471 // Tracks what features/properties need to be reported to the legacy | 1482 // Tracks what features/properties need to be reported to the legacy |
| 1472 // histograms. | 1483 // histograms. |
| 1473 BitVector m_featureBits; | 1484 BitVector m_featureBits; |
| 1474 BitVector m_CSSBits; | 1485 BitVector m_CSSBits; |
| 1475 } m_legacyCounter; | 1486 } m_legacyCounter; |
| 1476 }; | 1487 }; |
| 1477 | 1488 |
| 1478 } // namespace blink | 1489 } // namespace blink |
| 1479 | 1490 |
| 1480 #endif // UseCounter_h | 1491 #endif // UseCounter_h |
| OLD | NEW |