| Index: third_party/WebKit/Source/wtf/text/CompressibleString.h
|
| diff --git a/third_party/WebKit/Source/wtf/text/CompressibleString.h b/third_party/WebKit/Source/wtf/text/CompressibleString.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8942beb18fa4c91a5299d08f66a736a1724899ee
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/wtf/text/CompressibleString.h
|
| @@ -0,0 +1,80 @@
|
| +// Copyright 2016 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 CompressibleString_h
|
| +#define CompressibleString_h
|
| +
|
| +#include "wtf/HashTableDeletedValueType.h"
|
| +#include "wtf/text/Unicode.h"
|
| +#include "wtf/text/WTFString.h"
|
| +
|
| +namespace WTF {
|
| +
|
| +class WTF_EXPORT CompressibleStringImpl : public RefCounted<CompressibleStringImpl> {
|
| + WTF_MAKE_NONCOPYABLE(CompressibleStringImpl);
|
| +public:
|
| + static void purgeMemory();
|
| +
|
| + CompressibleStringImpl(PassRefPtr<StringImpl>);
|
| + ~CompressibleStringImpl();
|
| +
|
| + bool isEmpty() const { return m_originalLength == 0; }
|
| +
|
| + PassRefPtr<StringImpl> impl() { return m_impl; }
|
| + bool isCompressed() const { return !!m_compressedData; }
|
| + unsigned originalLength() const { return m_originalLength; }
|
| + bool is8Bit() const { return m_is8Bit; }
|
| +
|
| + unsigned originalContentSizeInBytes() const;
|
| + unsigned currentSizeInBytes() const;
|
| +
|
| + String toString();
|
| + const LChar* characters8();
|
| + const UChar* characters16();
|
| +
|
| + void compressString();
|
| + void uncompressString();
|
| +
|
| +private:
|
| + RefPtr<StringImpl> m_impl;
|
| + const unsigned m_originalLength;
|
| + void* m_compressedData;
|
| + unsigned m_compressedDataSize;
|
| + const bool m_is8Bit;
|
| +};
|
| +
|
| +class WTF_EXPORT CompressibleString {
|
| +public:
|
| + CompressibleString();
|
| + CompressibleString(const CompressibleString&);
|
| + explicit CompressibleString(PassRefPtr<StringImpl>);
|
| +
|
| + bool isNull() const { return !m_impl; }
|
| + bool isEmpty() const { return isNull() || m_impl->isEmpty(); }
|
| + unsigned length() const { return m_impl ? m_impl->originalLength() : 0; }
|
| +
|
| + unsigned currentSizeInBytes() const { return m_impl ? m_impl->currentSizeInBytes() : 0; }
|
| +
|
| + bool isCompressed() const { return m_impl ? m_impl->isCompressed() : false; }
|
| + bool is8Bit() const { return m_impl->is8Bit(); }
|
| +
|
| + String toString() const { return m_impl ? m_impl->toString() : String(); }
|
| + const LChar* characters8() const { return m_impl ? m_impl->characters8() : nullptr; }
|
| + const UChar* characters16() const { return m_impl ? m_impl->characters16() : nullptr; }
|
| +
|
| + PassRefPtr<CompressibleStringImpl> impl() const { return m_impl; }
|
| +
|
| +private:
|
| + void compressString() const;
|
| + void uncompressString() const;
|
| +
|
| + mutable RefPtr<CompressibleStringImpl> m_impl;
|
| +};
|
| +
|
| +} // namespace WTF
|
| +
|
| +using WTF::CompressibleString;
|
| +using WTF::CompressibleStringImpl;
|
| +
|
| +#endif
|
|
|