Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UseByOriginCounter_h | |
| 6 #define UseByOriginCounter_h | |
| 7 | |
| 8 #include "platform/heap/Handle.h" | |
| 9 #include "wtf/Vector.h" | |
| 10 #include "wtf/text/WTFString.h" | |
| 11 | |
| 12 namespace blink { | |
| 13 | |
| 14 class Document; | |
| 15 class ScriptState; | |
| 16 | |
| 17 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.
| |
| 18 DISALLOW_ALLOCATION(); | |
| 19 public: | |
| 20 ~UseByOriginCounter(); | |
| 21 | |
| 22 enum class Feature { | |
| 23 ElementCreateShadowRoot, | |
| 24 DocumentRegisterElement, | |
| 25 | |
| 26 NumberOfFeatures // This must be the last item. | |
| 27 }; | |
| 28 | |
| 29 static void count(const ScriptState*, Document&, Feature); | |
| 30 | |
| 31 void documentDetached(Document&); | |
| 32 void updateMeasurementsAndClear(); | |
| 33 | |
| 34 class Value { | |
| 35 public: | |
| 36 Value(); | |
| 37 | |
| 38 bool isEmpty() const { return !m_countBits; } | |
| 39 void clear() { m_countBits = 0; } | |
| 40 | |
| 41 void count(Feature); | |
| 42 bool get(Feature feature) const { return m_countBits & (1 << (unsigned)f eature); } | |
|
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.
| |
| 43 | |
| 44 void aggregate(Value); | |
| 45 void updateMeasurements(const String& origin); | |
| 46 | |
| 47 private: | |
| 48 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.
| |
| 49 }; | |
| 50 | |
| 51 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
| |
| 52 | |
| 53 private: | |
| 54 WillBeHeapVector<std::pair<String, UseByOriginCounter::Value>, 1> m_originAn dValues; | |
|
tkent
2015/03/16 00:30:19
Ditto.
should be Vector<std::pair<String, UseByOri
kojii
2015/03/16 03:52:51
Done.
| |
| 55 }; | |
| 56 | |
| 57 } // namespace blink | |
| 58 | |
| 59 #endif // UseByOriginCounter_h | |
| OLD | NEW |