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 CompressibleString_h | |
| 6 #define CompressibleString_h | |
| 7 | |
| 8 #include "platform/MemoryPurgeController.h" | |
| 9 #include "platform/SharedBuffer.h" | |
| 10 #include "wtf/HashTableDeletedValueType.h" | |
| 11 #include "wtf/text/Unicode.h" | |
| 12 #include "wtf/text/WTFString.h" | |
| 13 | |
| 14 namespace blink { | |
| 15 | |
| 16 class WTF_EXPORT CompressibleStringImpl : public RefCounted<CompressibleStringIm pl> { | |
| 17 WTF_MAKE_NONCOPYABLE(CompressibleStringImpl); | |
| 18 public: | |
| 19 static void purgeMemory(); | |
| 20 | |
| 21 CompressibleStringImpl(PassRefPtr<StringImpl>); | |
| 22 | |
| 23 bool isEmpty() const { return m_originalLength == 0; } | |
| 24 | |
| 25 PassRefPtr<StringImpl> impl() { return m_impl; } | |
| 26 PassRefPtr<SharedBuffer> compressedData() { return m_compressedData; } | |
| 27 bool isCompressed() const { return !!m_compressedData; } | |
| 28 unsigned originalLength() const { return m_originalLength; } | |
| 29 bool is8Bit() const { return m_is8Bit; } | |
| 30 | |
| 31 unsigned contentSizeInBytes() const; | |
| 32 | |
| 33 String toString(); | |
| 34 const LChar* characters8(); | |
| 35 const UChar* characters16(); | |
| 36 | |
| 37 void compress(); | |
| 38 void uncompress(); | |
| 39 | |
| 40 private: | |
| 41 RefPtr<StringImpl> m_impl; | |
| 42 RefPtr<SharedBuffer> m_compressedData; | |
| 43 const unsigned m_originalLength; | |
| 44 const bool m_is8Bit; | |
| 45 }; | |
| 46 | |
| 47 class WTF_EXPORT CompressibleString { | |
| 48 public: | |
| 49 CompressibleString(); | |
| 50 CompressibleString(const CompressibleString&); | |
| 51 explicit CompressibleString(PassRefPtr<StringImpl>); | |
| 52 | |
| 53 bool isNull() const { return !m_impl; } | |
| 54 bool isEmpty() const { return m_impl->isEmpty(); } | |
|
haraken
2015/11/26 11:50:03
Don't we need to check !m_impl before accessing m_
hajimehoshi
2015/11/27 11:03:58
Done.
| |
| 55 unsigned length() const { return !m_impl ? 0 : m_impl->originalLength(); } | |
| 56 | |
| 57 unsigned contentSizeInBytes() const { return !m_impl ? 0 : m_impl->contentSi zeInBytes(); } | |
| 58 | |
| 59 bool isCompressed() const { return m_impl->isCompressed(); } | |
| 60 bool is8Bit() const { return m_impl->is8Bit(); } | |
|
haraken
2015/11/26 11:50:03
Ditto.
hajimehoshi
2015/11/27 11:03:58
Done.
| |
| 61 | |
| 62 String toString() const { return m_impl->toString(); } | |
| 63 const LChar* characters8() const { return m_impl->characters8(); } | |
| 64 const UChar* characters16() const { return m_impl->characters16(); } | |
|
haraken
2015/11/26 11:50:03
Ditto.
hajimehoshi
2015/11/27 11:03:58
Done.
| |
| 65 | |
| 66 PassRefPtr<CompressibleStringImpl> impl() const { return m_impl; } | |
| 67 | |
| 68 private: | |
| 69 void compress() const; | |
| 70 void uncompress() const; | |
| 71 | |
| 72 mutable RefPtr<CompressibleStringImpl> m_impl; | |
| 73 }; | |
| 74 | |
| 75 } // namespace blink | |
| 76 | |
| 77 #endif | |
| OLD | NEW |