OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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/PlatformExport.h" | |
9 #include "wtf/HashTableDeletedValueType.h" | |
haraken
2016/01/15 12:46:21
This wouldn't be needed.
hajimehoshi
2016/01/18 09:42:27
Done.
| |
10 #include "wtf/text/Unicode.h" | |
11 #include "wtf/text/WTFString.h" | |
12 | |
13 namespace blink { | |
14 | |
15 // TODO(hajimehoshi): Now these classes are in platform/text to use UMA. Move | |
16 // them to wtf/text. | |
17 | |
18 class PLATFORM_EXPORT CompressibleStringImpl : public RefCounted<CompressibleStr ingImpl> { | |
haraken
2016/01/15 12:46:21
Add final.
hajimehoshi
2016/01/18 09:42:27
Done.
| |
19 WTF_MAKE_NONCOPYABLE(CompressibleStringImpl); | |
20 public: | |
21 static void compressAll(); | |
22 static void setPageBackground(bool); | |
23 | |
24 CompressibleStringImpl(PassRefPtr<StringImpl>); | |
25 ~CompressibleStringImpl(); | |
26 | |
27 bool isEmpty() const { return originalLength() == 0; } | |
28 | |
29 PassRefPtr<StringImpl> impl() { return m_impl; } | |
haraken
2016/01/15 12:46:21
Add const.
hajimehoshi
2016/01/18 09:42:27
This was removed.
| |
30 bool isCompressed() const { return m_isCompressed; } | |
haraken
2016/01/15 12:46:21
Add const.
hajimehoshi
2016/01/18 09:42:27
Where do I have to add const?
| |
31 unsigned originalLength() const { return m_impl->length(); } | |
32 bool is8Bit() const { return m_impl->is8Bit(); } | |
33 | |
34 unsigned originalContentSizeInBytes() const; | |
haraken
2016/01/15 12:46:21
originalContentSizeInBytes => originalSizeInBytes
hajimehoshi
2016/01/18 09:42:27
StringImpl's sizeInBytes contains the size of Stri
| |
35 unsigned currentSizeInBytes() const; | |
36 | |
37 String toString(); | |
38 const LChar* characters8(); | |
39 const UChar* characters16(); | |
40 | |
41 void compressString(); | |
42 void decompressString(); | |
43 | |
44 private: | |
45 static bool s_isPageBackground; | |
46 | |
47 RefPtr<StringImpl> m_impl; | |
48 bool m_isCompressed; | |
49 }; | |
50 | |
51 class PLATFORM_EXPORT CompressibleString { | |
haraken
2016/01/15 12:46:21
Add final.
hajimehoshi
2016/01/18 09:42:27
Done.
| |
52 public: | |
53 CompressibleString(); | |
54 CompressibleString(const CompressibleString&); | |
55 explicit CompressibleString(PassRefPtr<StringImpl>); | |
56 | |
57 bool isNull() const { return !m_impl; } | |
58 bool isEmpty() const { return isNull() || m_impl->isEmpty(); } | |
59 unsigned length() const { return m_impl ? m_impl->originalLength() : 0; } | |
60 | |
61 unsigned currentSizeInBytes() const { return m_impl ? m_impl->currentSizeInB ytes() : 0; } | |
62 | |
63 bool isCompressed() const { return m_impl ? m_impl->isCompressed() : false; } | |
64 bool is8Bit() const { return m_impl->is8Bit(); } | |
haraken
2016/01/15 12:46:21
m_impl ? m_impl->is8Bit() : false;
hajimehoshi
2016/01/18 09:42:27
Done.
| |
65 | |
66 String toString() const { return m_impl ? m_impl->toString() : String(); } | |
67 const LChar* characters8() const { return m_impl ? m_impl->characters8() : n ullptr; } | |
68 const UChar* characters16() const { return m_impl ? m_impl->characters16() : nullptr; } | |
69 | |
70 PassRefPtr<CompressibleStringImpl> impl() const { return m_impl; } | |
71 | |
72 private: | |
73 void compressString() const; | |
74 void decompressString() const; | |
75 | |
76 mutable RefPtr<CompressibleStringImpl> m_impl; | |
77 }; | |
78 | |
79 } // namespace blink | |
80 | |
81 using blink::CompressibleString; | |
82 using blink::CompressibleStringImpl; | |
83 | |
84 #endif | |
OLD | NEW |