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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/text/CompressibleString.h
diff --git a/third_party/WebKit/Source/platform/text/CompressibleString.h b/third_party/WebKit/Source/platform/text/CompressibleString.h
new file mode 100644
index 0000000000000000000000000000000000000000..9badef3444268a61765ddecfa7859daeafe783d2
--- /dev/null
+++ b/third_party/WebKit/Source/platform/text/CompressibleString.h
@@ -0,0 +1,84 @@
+// 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 "platform/PlatformExport.h"
+#include "wtf/HashTableDeletedValueType.h"
haraken 2016/01/15 12:46:21 This wouldn't be needed.
hajimehoshi 2016/01/18 09:42:27 Done.
+#include "wtf/text/Unicode.h"
+#include "wtf/text/WTFString.h"
+
+namespace blink {
+
+// TODO(hajimehoshi): Now these classes are in platform/text to use UMA. Move
+// them to wtf/text.
+
+class PLATFORM_EXPORT CompressibleStringImpl : public RefCounted<CompressibleStringImpl> {
haraken 2016/01/15 12:46:21 Add final.
hajimehoshi 2016/01/18 09:42:27 Done.
+ WTF_MAKE_NONCOPYABLE(CompressibleStringImpl);
+public:
+ static void compressAll();
+ static void setPageBackground(bool);
+
+ CompressibleStringImpl(PassRefPtr<StringImpl>);
+ ~CompressibleStringImpl();
+
+ bool isEmpty() const { return originalLength() == 0; }
+
+ 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.
+ 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?
+ unsigned originalLength() const { return m_impl->length(); }
+ bool is8Bit() const { return m_impl->is8Bit(); }
+
+ 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
+ unsigned currentSizeInBytes() const;
+
+ String toString();
+ const LChar* characters8();
+ const UChar* characters16();
+
+ void compressString();
+ void decompressString();
+
+private:
+ static bool s_isPageBackground;
+
+ RefPtr<StringImpl> m_impl;
+ bool m_isCompressed;
+};
+
+class PLATFORM_EXPORT CompressibleString {
haraken 2016/01/15 12:46:21 Add final.
hajimehoshi 2016/01/18 09:42:27 Done.
+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(); }
haraken 2016/01/15 12:46:21 m_impl ? m_impl->is8Bit() : false;
hajimehoshi 2016/01/18 09:42:27 Done.
+
+ 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 decompressString() const;
+
+ mutable RefPtr<CompressibleStringImpl> m_impl;
+};
+
+} // namespace blink
+
+using blink::CompressibleString;
+using blink::CompressibleStringImpl;
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698