Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: third_party/WebKit/Source/core/frame/UseCounter.h

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

Powered by Google App Engine
This is Rietveld 408576698