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

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

Issue 2768113002: WIP: Create a LongStringCollection that transfers long strings with fewer copies.
Patch Set: Created 3 years, 9 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/serialization/LongStringCollection.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/serialization/LongStringCollection.h b/third_party/WebKit/Source/bindings/core/v8/serialization/LongStringCollection.h
new file mode 100644
index 0000000000000000000000000000000000000000..08518bfb27381fb8ca8c24aad395a94c254d6348
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/core/v8/serialization/LongStringCollection.h
@@ -0,0 +1,57 @@
+// Copyright 2017 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 LongStringCollection_h
+#define LongStringCollection_h
+
+#include <cstdint>
+#include "v8/include/v8.h"
+#include "wtf/Allocator.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/Vector.h"
+#include "wtf/text/WTFString.h"
+
+namespace blink {
+
+class LongStringPolicy {
+ public:
+ enum PolicyType { kNone, kSameIsolate, kSameProcess };
+
+ LongStringPolicy() : LongStringPolicy(kNone, -1) {}
+ LongStringPolicy(PolicyType type, int minimumLength)
+ : m_type(type), m_minimumLength(minimumLength) {}
+
+ PolicyType type() const { return m_type; }
+ int minimumLength() const { return m_minimumLength; }
+
+ private:
+ PolicyType m_type;
+ int m_minimumLength;
+};
+
+class LongStringCollection {
+ WTF_MAKE_NONCOPYABLE(LongStringCollection);
+
+ public:
+ LongStringCollection() {}
+ explicit LongStringCollection(const LongStringPolicy& policy)
+ : m_policy(policy) {}
+ ~LongStringCollection();
+
+ const LongStringPolicy& policy() const { return m_policy; }
+ Vector<v8::Local<v8::String>> getAll(v8::Isolate*) const;
+ uint32_t put(v8::Isolate*, v8::Local<v8::String>);
+
+ private:
+ LongStringPolicy m_policy;
+ Vector<v8::Global<v8::String>> m_v8Strings;
+ Vector<String> m_wtfStrings;
+#if DCHECK_IS_ON()
+ v8::Isolate* m_isolate = nullptr;
+#endif
+};
+
+} // namespace blink
+
+#endif // LongStringCollection_h

Powered by Google App Engine
This is Rietveld 408576698