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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/V8StringResource.h

Issue 1389383003: WIP: Introduce CompressibleString Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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/bindings/core/v8/V8StringResource.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8StringResource.h b/third_party/WebKit/Source/bindings/core/v8/V8StringResource.h
index 65b12efe12a28b11cce0376f64cda85c6c0288ba..d13e29ef81de9e9b401b7831b5b1094abf5926b7 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8StringResource.h
+++ b/third_party/WebKit/Source/bindings/core/v8/V8StringResource.h
@@ -31,6 +31,7 @@
#include "wtf/Allocator.h"
#include "wtf/Threading.h"
#include "wtf/text/AtomicString.h"
+#include "wtf/text/CompressableString.h"
#include <v8.h>
namespace blink {
@@ -153,6 +154,54 @@ public:
}
};
+class WebCoreCompressableStringResource16 final : public v8::String::ExternalStringResource {
+ WTF_MAKE_NONCOPYABLE(WebCoreCompressableStringResource16);
+public:
+ explicit WebCoreCompressableStringResource16(RefPtrWillBeRawPtr<CompressableString> string)
+ : m_string(string)
+ {
+ ASSERT(m_string);
+ ASSERT(!m_string->is8Bit());
+ }
+
+ size_t length() const override
+ {
+ return m_string->length();
+ }
+
+ const uint16_t* data() const override
+ {
+ return reinterpret_cast<const uint16_t*>(m_string->toString().characters16());
+ }
+
+private:
+ RefPtrWillBeMember<CompressableString> m_string;
+};
+
+class WebCoreCompressableStringResource8 final : public v8::String::ExternalOneByteStringResource {
+ WTF_MAKE_NONCOPYABLE(WebCoreCompressableStringResource8);
+public:
+ explicit WebCoreCompressableStringResource8(RefPtrWillBeRawPtr<CompressableString> string)
+ : m_string(string)
+ {
+ ASSERT(m_string);
+ ASSERT(m_string->is8Bit());
+ }
+
+ size_t length() const override
+ {
+ return m_string->length();
+ }
+
+ const char* data() const override
+ {
+ return reinterpret_cast<const char*>(m_string->toString().characters8());
+ }
+
+private:
+ RefPtrWillBeMember<CompressableString> m_string;
+};
+
enum ExternalMode {
Externalize,
DoNotExternalize

Powered by Google App Engine
This is Rietveld 408576698