Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Unified Diff: third_party/WebKit/Source/wtf/text/AtomicStringTable.h

Issue 2110813003: Move all the AtomicString table into AtomicStringTable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comments. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..fe56573a154404f9657b21312d104c2fd7b4ac1a 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);
+
+ // This is for ~StringImpl to unregister a string before destruction since
+ // the table is holding weak pointers. It should not be used 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
« no previous file with comments | « third_party/WebKit/Source/wtf/text/AtomicStringCF.cpp ('k') | third_party/WebKit/Source/wtf/text/AtomicStringTable.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698