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

Side by Side Diff: third_party/WebKit/Source/platform/text/CompressibleString.h

Issue 1583263002: Experimental CompressibleString UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add DecompressingInForegroundTab Created 4 years, 11 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 unified diff | Download patch
OLDNEW
(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/text/Unicode.h"
10 #include "wtf/text/WTFString.h"
11
12 namespace blink {
13
14 // TODO(hajimehoshi): Now these classes are in platform/text to use UMA. Move
15 // them to wtf/text.
16
17 // This method must be called only by Platform::initialize.
18 void initializeCompressibleStringTable();
19
20 class PLATFORM_EXPORT CompressibleStringImpl final : public RefCounted<Compressi bleStringImpl> {
21 WTF_MAKE_NONCOPYABLE(CompressibleStringImpl);
22 public:
23 static void compressAll();
24 static void setPageBackground(bool);
25
26 CompressibleStringImpl();
27 CompressibleStringImpl(PassRefPtr<StringImpl>);
haraken 2016/01/19 07:43:36 Add explicit.
hajimehoshi 2016/01/19 10:19:21 Done.
28 ~CompressibleStringImpl();
29
30 bool isEmpty() const { return originalLength() == 0; }
31
32 bool isCompressed() const { return m_isCompressed; }
33 unsigned originalLength() const { return m_string.length(); }
34 bool is8Bit() const { return m_string.is8Bit(); }
35
36 unsigned originalContentSizeInBytes() const;
37 unsigned currentSizeInBytes() const;
38
39 const String& toString();
40 const LChar* characters8();
41 const UChar* characters16();
42
43 void compressString();
44 void decompressString();
45
46 private:
47 static bool s_isPageBackground;
48
49 String m_string;
50 bool m_isCompressed;
51 };
52
53 class PLATFORM_EXPORT CompressibleString final {
54 public:
55 CompressibleString();
56 CompressibleString(const CompressibleString&);
57 explicit CompressibleString(PassRefPtr<StringImpl>);
58
59 bool isNull() const { return !m_impl; }
60 bool isEmpty() const { return isNull() || m_impl->isEmpty(); }
61 unsigned length() const { return m_impl ? m_impl->originalLength() : 0; }
62
63 unsigned currentSizeInBytes() const { return m_impl ? m_impl->currentSizeInB ytes() : 0; }
64
65 bool isCompressed() const { return m_impl ? m_impl->isCompressed() : false; }
66 bool is8Bit() const { return m_impl ? m_impl->is8Bit() : false; }
67
68 const String& toString() const { return m_impl ? m_impl->toString() : emptyS tring(); }
69 const LChar* characters8() const { return m_impl ? m_impl->characters8() : n ullptr; }
70 const UChar* characters16() const { return m_impl ? m_impl->characters16() : nullptr; }
71
72 PassRefPtr<CompressibleStringImpl> impl() const { return m_impl; }
haraken 2016/01/19 07:43:35 This is a getter for impl, so it should return Com
hajimehoshi 2016/01/19 10:19:21 Done.
73
74 private:
75 void compressString() const;
76 void decompressString() const;
77
78 mutable RefPtr<CompressibleStringImpl> m_impl;
79 };
80
81 } // namespace blink
82
83 using blink::CompressibleString;
84 using blink::CompressibleStringImpl;
85
86 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698