Chromium Code Reviews| Index: third_party/WebKit/Source/wtf/text/AtomicStringTable.h |
| diff --git a/third_party/WebKit/Source/wtf/text/AtomicStringTable.h b/third_party/WebKit/Source/wtf/text/AtomicStringTable.h |
| index e129b59d517474cd2f7093414c635704c30aee47..ca56947827e3a63f7af2e06e99438242a8736cf6 100644 |
| --- a/third_party/WebKit/Source/wtf/text/AtomicStringTable.h |
| +++ b/third_party/WebKit/Source/wtf/text/AtomicStringTable.h |
| @@ -7,6 +7,8 @@ |
| #include "wtf/Allocator.h" |
| #include "wtf/HashSet.h" |
| +#include "wtf/WTFExport.h" |
| +#include "wtf/WTFThreadData.h" |
| #include "wtf/text/StringHash.h" |
| #include "wtf/text/StringImpl.h" |
| @@ -14,21 +16,56 @@ namespace WTF { |
| // The underlying storage that keeps the map of unique AtomicStrings. This is |
| // not thread safe and each WTFThreadData has one. |
| -class AtomicStringTable { |
| +class WTF_EXPORT AtomicStringTable final { |
| USING_FAST_MALLOC(AtomicStringTable); |
| WTF_MAKE_NONCOPYABLE(AtomicStringTable); |
| public: |
| AtomicStringTable(); |
| ~AtomicStringTable(); |
| - StringImpl* addStringImpl(StringImpl*); |
| + // Gets the shared table for the current thread. |
| + static AtomicStringTable& instance() |
| + { |
| + return wtfThreadData().getAtomicStringTable(); |
| + } |
| - HashSet<StringImpl*>& table() { return m_table; } |
| + // Used by system initialization to preallocate enough storage for all of |
| + // the static strings. |
| + void reserveCapacity(unsigned); |
| + |
| + // Adding a StringImpl. |
| + StringImpl* add(StringImpl*); |
| + PassRefPtr<StringImpl> add(StringImpl*, unsigned offset, unsigned length); |
| + |
| + // Adding an LChar. |
| + PassRefPtr<StringImpl> add(const LChar*, unsigned length); |
| + |
| + // Adding a UChar. |
| + PassRefPtr<StringImpl> add(const UChar*, unsigned length); |
| + PassRefPtr<StringImpl> add(const UChar*, unsigned length, unsigned existingHash); |
| + PassRefPtr<StringImpl> add(const UChar*); |
| + |
| + // Adding UTF8. |
| + // Returns null if the characters contain invalid utf8 sequences. |
| + // Pass null for the charactersEnd to automatically detect the length. |
| + PassRefPtr<StringImpl> addUTF8(const char* charactersStart, const char* charactersEnd); |
| + |
| + // Froming a StringImpl. This is for ~StringImpl, and should not be used |
|
haraken
2016/06/29 23:50:02
Froming => Removing
|
| + // directly. |
| + void remove(StringImpl*); |
| private: |
| + template<typename T, typename HashTranslator> |
| + inline PassRefPtr<StringImpl> addToStringTable(const T& value); |
| + |
| + template<typename CharacterType> |
| + inline HashSet<StringImpl*>::iterator find(const StringImpl*); |
| + |
| HashSet<StringImpl*> m_table; |
| }; |
| } // namespace WTF |
| +using WTF::AtomicStringTable; |
| + |
| #endif |