Chromium Code Reviews| Index: Source/core/frame/UseByOriginCounter.h |
| diff --git a/Source/core/frame/UseByOriginCounter.h b/Source/core/frame/UseByOriginCounter.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b552d611f2a1488307e577bb86087bfb9ff99d97 |
| --- /dev/null |
| +++ b/Source/core/frame/UseByOriginCounter.h |
| @@ -0,0 +1,59 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef UseByOriginCounter_h |
| +#define UseByOriginCounter_h |
| + |
| +#include "platform/heap/Handle.h" |
| +#include "wtf/Vector.h" |
| +#include "wtf/text/WTFString.h" |
| + |
| +namespace blink { |
| + |
| +class Document; |
| +class ScriptState; |
| + |
| +class UseByOriginCounter { |
|
tkent
2015/03/16 00:30:19
I feel this is not a counter. Is this origin-usin
kojii
2015/03/16 03:52:51
Done.
|
| + DISALLOW_ALLOCATION(); |
| +public: |
| + ~UseByOriginCounter(); |
| + |
| + enum class Feature { |
| + ElementCreateShadowRoot, |
| + DocumentRegisterElement, |
| + |
| + NumberOfFeatures // This must be the last item. |
| + }; |
| + |
| + static void count(const ScriptState*, Document&, Feature); |
| + |
| + void documentDetached(Document&); |
| + void updateMeasurementsAndClear(); |
| + |
| + class Value { |
| + public: |
| + Value(); |
| + |
| + bool isEmpty() const { return !m_countBits; } |
| + void clear() { m_countBits = 0; } |
| + |
| + void count(Feature); |
| + bool get(Feature feature) const { return m_countBits & (1 << (unsigned)feature); } |
|
tkent
2015/03/16 00:30:19
We don't use C-style cast. (unsigned) -> static_c
kojii
2015/03/16 03:52:51
Done.
|
| + |
| + void aggregate(Value); |
| + void updateMeasurements(const String& origin); |
| + |
| + private: |
| + unsigned m_countBits : (unsigned)Feature::NumberOfFeatures; |
|
tkent
2015/03/16 00:30:19
Ditto.
Also, do you think the number of features
kojii
2015/03/16 03:52:51
Done.
|
| + }; |
| + |
| + DEFINE_INLINE_TRACE() { visitor->trace(m_originAndValues); } |
|
tkent
2015/03/16 00:30:19
Oilpan tracing is not necessary because this class
kojii
2015/03/16 03:52:51
Done, I thought we need because it has String, sor
|
| + |
| +private: |
| + WillBeHeapVector<std::pair<String, UseByOriginCounter::Value>, 1> m_originAndValues; |
|
tkent
2015/03/16 00:30:19
Ditto.
should be Vector<std::pair<String, UseByOri
kojii
2015/03/16 03:52:51
Done.
|
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // UseByOriginCounter_h |