Index: third_party/WebKit/Source/core/frame/UseCounter.h |
diff --git a/third_party/WebKit/Source/core/frame/UseCounter.h b/third_party/WebKit/Source/core/frame/UseCounter.h |
index b78eab5f47bd63b7510a6bc5bd40ef2df1c29e66..a874950eaa1b02c8ea691e48eaa20c171ecde7fe 100644 |
--- a/third_party/WebKit/Source/core/frame/UseCounter.h |
+++ b/third_party/WebKit/Source/core/frame/UseCounter.h |
@@ -26,14 +26,16 @@ |
#ifndef UseCounter_h |
#define UseCounter_h |
+#include <v8.h> |
#include "core/CSSPropertyNames.h" |
#include "core/CoreExport.h" |
#include "core/css/parser/CSSParserMode.h" |
+#include "platform/heap/GarbageCollected.h" |
+#include "platform/heap/HeapAllocator.h" |
#include "platform/weborigin/KURL.h" |
#include "wtf/BitVector.h" |
#include "wtf/Noncopyable.h" |
#include "wtf/text/WTFString.h" |
-#include <v8.h> |
namespace blink { |
@@ -1464,6 +1466,15 @@ class CORE_EXPORT UseCounter { |
NumberOfFeatures, // This enum value must be last. |
}; |
+ // An interface to observe UseCounter changes. |
+ class Observer : public GarbageCollected<Observer> { |
+ public: |
+ // Returns true if this observer no longer needs to observe the counter. |
+ virtual bool onCountFeature(Feature) = 0; |
+ |
+ DEFINE_INLINE_VIRTUAL_TRACE() {} |
+ }; |
+ |
// "count" sets the bit for this feature to 1. Repeated calls are ignored. |
static void count(const Frame*, Feature); |
static void count(const Document&, Feature); |
@@ -1484,6 +1495,9 @@ class CORE_EXPORT UseCounter { |
static bool isCounted(Document&, const String&); |
bool isCounted(CSSPropertyID unresolvedProperty); |
+ // Adds an observer that observes UseCounter changes. |
+ static void addObserver(Document&, Observer*); |
+ |
// Invoked when a new document is loaded into the main frame of the page. |
void didCommitLoad(KURL); |
@@ -1500,6 +1514,8 @@ class CORE_EXPORT UseCounter { |
// reporting disabled. |
bool hasRecordedMeasurement(Feature) const; |
+ DECLARE_TRACE(); |
+ |
private: |
EnumerationHistogram& featuresHistogram() const; |
EnumerationHistogram& cssHistogram() const; |
@@ -1518,6 +1534,8 @@ class CORE_EXPORT UseCounter { |
BitVector m_featuresRecorded; |
BitVector m_CSSRecorded; |
+ HeapHashSet<Member<Observer>> m_observers; |
+ |
// Encapsulates the work to preserve the old "FeatureObserver" histogram with |
// original semantics |
// TODO(rbyers): remove this - http://crbug.com/676837 |