Chromium Code Reviews| Index: Source/core/page/DeprecationAgent.cpp |
| diff --git a/Source/core/page/UseCounter.cpp b/Source/core/page/DeprecationAgent.cpp |
| similarity index 53% |
| copy from Source/core/page/UseCounter.cpp |
| copy to Source/core/page/DeprecationAgent.cpp |
| index 35eb07474e73b3f1423f8c9d1d0aa63a1d90138c..30768186b2a378c8fc21ff1d5f2c0192f09abc64 100644 |
| --- a/Source/core/page/UseCounter.cpp |
| +++ b/Source/core/page/DeprecationAgent.cpp |
| @@ -1,5 +1,5 @@ |
| /* |
| - * Copyright (C) 2012 Google, Inc. All rights reserved. |
| + * Copyright (C) 2013 Google, Inc. All rights reserved. |
| * |
| * Redistribution and use in source and binary forms, with or without |
| * modification, are permitted provided that the following conditions |
| @@ -24,49 +24,39 @@ |
| */ |
| #include "config.h" |
| -#include "UseCounter.h" |
| +#include "DeprecationAgent.h" |
| -#include "DOMWindow.h" |
| #include "Document.h" |
| -#include "HistogramSupport.h" |
| #include "Page.h" |
| +#include "PageConsole.h" |
| +#include <wtf/BitVector.h> |
| +#include <wtf/Noncopyable.h> |
| +#include <wtf/OwnPtr.h> |
| +#include <wtf/PassOwnPtr.h> |
| +#include <wtf/text/WTFString.h> |
| namespace WebCore { |
| -UseCounter::UseCounter() |
| -{ |
| -} |
| +namespace { |
| -UseCounter::~UseCounter() |
| -{ |
| - // We always log PageDestruction so that we have a scale for the rest of the features. |
| - HistogramSupport::histogramEnumeration("WebCore.FeatureObserver", PageDestruction, NumberOfFeatures); |
| +// Ensure that this stays in sync with the Feature enum. |
| +static const char* const deprecationMessages[] = { |
| + "The 'X-WebKit-CSP' headers are deprecated; please consider using the canonical 'Content-Security-Policy' header instead." |
| +}; |
| + |
| +// COMPILE_ASSERT(WTF_ARRAY_LENGTH(deprecationMessages) == static_cast<int>(WebCore::DeprecationAgent::NumberOfFeatures), DeprecationMessages_matches_Feature_enum); |
|
pfeldman
2013/04/19 13:04:22
It should work, right?
|
| - updateMeasurements(); |
| } |
| -void UseCounter::updateMeasurements() |
| +DeprecationAgent::DeprecationAgent() |
| { |
| - HistogramSupport::histogramEnumeration("WebCore.FeatureObserver", PageVisits, NumberOfFeatures); |
| - |
| - if (!m_countBits) |
| - return; |
| - |
| - for (unsigned i = 0; i < NumberOfFeatures; ++i) { |
| - if (m_countBits->quickGet(i)) |
| - HistogramSupport::histogramEnumeration("WebCore.FeatureObserver", i, NumberOfFeatures); |
| - } |
| - |
| - // Clearing count bits is timing sensitive. |
| - m_countBits->clearAll(); |
| } |
| -void UseCounter::didCommitLoad() |
| +DeprecationAgent::~DeprecationAgent() |
| { |
| - updateMeasurements(); |
| } |
| -void UseCounter::observe(Document* document, Feature feature) |
| +void DeprecationAgent::notify(Document* document, Feature feature) |
| { |
| if (!document) |
| return; |
| @@ -75,13 +65,24 @@ void UseCounter::observe(Document* document, Feature feature) |
| if (!page) |
| return; |
| - page->useCounter()->didObserve(feature); |
| + page->deprecationAgent()->sendNotification(page->console(), feature); |
| } |
| -void UseCounter::observe(DOMWindow* domWindow, Feature feature) |
| +void DeprecationAgent::sendNotification(PageConsole* console, Feature feature) |
| { |
| - ASSERT(domWindow); |
| - observe(domWindow->document(), feature); |
| + ASSERT(feature < NumberOfFeatures); |
| + ASSERT(console); |
| + |
| + if (!m_countBits) { |
| + m_countBits = adoptPtr(new BitVector(NumberOfFeatures)); |
| + m_countBits->clearAll(); |
| + } |
| + |
| + if (m_countBits->quickGet(feature)) |
|
pfeldman
2013/04/19 13:04:22
Is this covered with the tests? I.e. are you gener
|
| + return; |
| + |
| + m_countBits->quickSet(feature); |
| + console->addMessage(DeprecationMessageSource, WarningMessageLevel, ASCIILiteral(deprecationMessages[feature])); |
| } |
| } // namespace WebCore |