| 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 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1495 }; | 1495 }; |
| 1496 | 1496 |
| 1497 // "count" sets the bit for this feature to 1. Repeated calls are ignored. | 1497 // "count" sets the bit for this feature to 1. Repeated calls are ignored. |
| 1498 static void count(const Frame*, Feature); | 1498 static void count(const Frame*, Feature); |
| 1499 static void count(const Document&, Feature); | 1499 static void count(const Document&, Feature); |
| 1500 static void count(ExecutionContext*, Feature); | 1500 static void count(ExecutionContext*, Feature); |
| 1501 | 1501 |
| 1502 void count(CSSParserMode, CSSPropertyID); | 1502 void count(CSSParserMode, CSSPropertyID); |
| 1503 void count(Feature); | 1503 void count(Feature); |
| 1504 | 1504 |
| 1505 static void countAnimatedCSS(const Document&, CSSPropertyID); |
| 1506 void countAnimatedCSS(CSSPropertyID); |
| 1507 |
| 1505 // Count only features if they're being used in an iframe which does not | 1508 // Count only features if they're being used in an iframe which does not |
| 1506 // have script access into the top level document. | 1509 // have script access into the top level document. |
| 1507 static void countCrossOriginIframe(const Document&, Feature); | 1510 static void countCrossOriginIframe(const Document&, Feature); |
| 1508 | 1511 |
| 1509 // Return whether the Feature was previously counted for this document. | 1512 // Return whether the Feature was previously counted for this document. |
| 1510 // NOTE: only for use in testing. | 1513 // NOTE: only for use in testing. |
| 1511 static bool isCounted(Document&, Feature); | 1514 static bool isCounted(Document&, Feature); |
| 1512 // Return whether the CSSPropertyID was previously counted for this document. | 1515 // Return whether the CSSPropertyID was previously counted for this document. |
| 1513 // NOTE: only for use in testing. | 1516 // NOTE: only for use in testing. |
| 1514 static bool isCounted(Document&, const String&); | 1517 static bool isCounted(Document&, const String&); |
| 1515 bool isCounted(CSSPropertyID unresolvedProperty); | 1518 bool isCounted(CSSPropertyID unresolvedProperty); |
| 1516 | 1519 |
| 1520 // Return whether the CSSPropertyID was previously counted for this document. |
| 1521 // NOTE: only for use in testing. |
| 1522 static bool isCountedAnimatedCSS(Document&, const String&); |
| 1523 bool isCountedAnimatedCSS(CSSPropertyID unresolvedProperty); |
| 1524 |
| 1517 // Retains a reference to the observer to notify of UseCounter changes. | 1525 // Retains a reference to the observer to notify of UseCounter changes. |
| 1518 void addObserver(Observer*); | 1526 void addObserver(Observer*); |
| 1519 | 1527 |
| 1520 // Invoked when a new document is loaded into the main frame of the page. | 1528 // Invoked when a new document is loaded into the main frame of the page. |
| 1521 void didCommitLoad(KURL); | 1529 void didCommitLoad(KURL); |
| 1522 | 1530 |
| 1523 static int mapCSSPropertyIdToCSSSampleIdForHistogram(CSSPropertyID); | 1531 static int mapCSSPropertyIdToCSSSampleIdForHistogram(CSSPropertyID); |
| 1524 | 1532 |
| 1525 // When muted, all calls to "count" functions are ignoed. May be nested. | 1533 // When muted, all calls to "count" functions are ignoed. May be nested. |
| 1526 void muteForInspector(); | 1534 void muteForInspector(); |
| 1527 void unmuteForInspector(); | 1535 void unmuteForInspector(); |
| 1528 | 1536 |
| 1529 void recordMeasurement(Feature); | 1537 void recordMeasurement(Feature); |
| 1530 | 1538 |
| 1531 // Return whether the feature has been seen since the last page load | 1539 // Return whether the feature has been seen since the last page load |
| 1532 // (except when muted). Does include features seen in documents which have | 1540 // (except when muted). Does include features seen in documents which have |
| 1533 // reporting disabled. | 1541 // reporting disabled. |
| 1534 bool hasRecordedMeasurement(Feature) const; | 1542 bool hasRecordedMeasurement(Feature) const; |
| 1535 | 1543 |
| 1536 DECLARE_TRACE(); | 1544 DECLARE_TRACE(); |
| 1537 | 1545 |
| 1538 private: | 1546 private: |
| 1539 // Notifies that a feature is newly counted to |m_observers|. This shouldn't | 1547 // Notifies that a feature is newly counted to |m_observers|. This shouldn't |
| 1540 // be called when the counter is disabled by |m_muteCount| or | 1548 // be called when the counter is disabled by |m_muteCount| or |
| 1541 // |m_disableReporting|. | 1549 // |m_disableReporting|. |
| 1542 void notifyFeatureCounted(Feature); | 1550 void notifyFeatureCounted(Feature); |
| 1543 | 1551 |
| 1544 EnumerationHistogram& featuresHistogram() const; | 1552 EnumerationHistogram& featuresHistogram() const; |
| 1545 EnumerationHistogram& cssHistogram() const; | 1553 EnumerationHistogram& cssHistogram() const; |
| 1554 EnumerationHistogram& animatedCSSHistogram() const; |
| 1546 | 1555 |
| 1547 // If non-zero, ignore all 'count' calls completely. | 1556 // If non-zero, ignore all 'count' calls completely. |
| 1548 unsigned m_muteCount; | 1557 unsigned m_muteCount; |
| 1549 | 1558 |
| 1550 // If true, disable reporting all histogram entries. | 1559 // If true, disable reporting all histogram entries. |
| 1551 bool m_disableReporting; | 1560 bool m_disableReporting; |
| 1552 | 1561 |
| 1553 // The scope represented by this UseCounter instance. | 1562 // The scope represented by this UseCounter instance. |
| 1554 Context m_context; | 1563 Context m_context; |
| 1555 | 1564 |
| 1556 // Track what features/properties have been reported to the (non-legacy) | 1565 // Track what features/properties have been reported to the (non-legacy) |
| 1557 // histograms. | 1566 // histograms. |
| 1558 BitVector m_featuresRecorded; | 1567 BitVector m_featuresRecorded; |
| 1559 BitVector m_CSSRecorded; | 1568 BitVector m_CSSRecorded; |
| 1569 BitVector m_animatedCSSRecorded; |
| 1560 | 1570 |
| 1561 HeapHashSet<Member<Observer>> m_observers; | 1571 HeapHashSet<Member<Observer>> m_observers; |
| 1562 | 1572 |
| 1563 // Encapsulates the work to preserve the old "FeatureObserver" histogram with | 1573 // Encapsulates the work to preserve the old "FeatureObserver" histogram with |
| 1564 // original semantics | 1574 // original semantics |
| 1565 // TODO(rbyers): remove this - http://crbug.com/676837 | 1575 // TODO(rbyers): remove this - http://crbug.com/676837 |
| 1566 class CORE_EXPORT LegacyCounter { | 1576 class CORE_EXPORT LegacyCounter { |
| 1567 public: | 1577 public: |
| 1568 LegacyCounter(); | 1578 LegacyCounter(); |
| 1569 ~LegacyCounter(); | 1579 ~LegacyCounter(); |
| 1570 void countFeature(Feature); | 1580 void countFeature(Feature); |
| 1571 void countCSS(CSSPropertyID); | 1581 void countCSS(CSSPropertyID); |
| 1572 void updateMeasurements(); | 1582 void updateMeasurements(); |
| 1573 | 1583 |
| 1574 private: | 1584 private: |
| 1575 // Tracks what features/properties need to be reported to the legacy | 1585 // Tracks what features/properties need to be reported to the legacy |
| 1576 // histograms. | 1586 // histograms. |
| 1577 BitVector m_featureBits; | 1587 BitVector m_featureBits; |
| 1578 BitVector m_CSSBits; | 1588 BitVector m_CSSBits; |
| 1579 } m_legacyCounter; | 1589 } m_legacyCounter; |
| 1580 }; | 1590 }; |
| 1581 | 1591 |
| 1582 } // namespace blink | 1592 } // namespace blink |
| 1583 | 1593 |
| 1584 #endif // UseCounter_h | 1594 #endif // UseCounter_h |
| OLD | NEW |