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

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

Issue 2305703002: Move V8-based serialization into dedicated classes and add support for ArrayBuffer transfer. (Closed)
Patch Set: reviewer comments Created 4 years, 3 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/V8ScriptValueSerializer.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.h b/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.h
new file mode 100644
index 0000000000000000000000000000000000000000..d678ef67356b144a41ef66437aef80660e9bc38e
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.h
@@ -0,0 +1,48 @@
+// 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 V8ScriptValueSerializer_h
+#define V8ScriptValueSerializer_h
+
+#include "bindings/core/v8/ExceptionState.h"
+#include "bindings/core/v8/ScriptState.h"
+#include "bindings/core/v8/SerializedScriptValue.h"
+#include "wtf/Allocator.h"
+#include "wtf/Noncopyable.h"
+#include "wtf/RefPtr.h"
+#include <v8.h>
+
+namespace blink {
+
+class Transferables;
+
+// Serializes V8 values according to the HTML structured clone algorithm:
+// https://html.spec.whatwg.org/multipage/infrastructure.html#structured-clone
+//
+// Supports only basic JavaScript objects and core DOM types. Support for
+// modules types is implemented in a subclass.
+//
+// A serializer cannot be used multiple times; it is expected that its serialize
+// method will be invoked exactly once.
+class V8ScriptValueSerializer {
+ STACK_ALLOCATED();
+ WTF_MAKE_NONCOPYABLE(V8ScriptValueSerializer);
+public:
+ explicit V8ScriptValueSerializer(RefPtr<ScriptState>);
+ RefPtr<SerializedScriptValue> serialize(v8::Local<v8::Value>, Transferables*, ExceptionState&);
+
+private:
+ void transfer(Transferables*, ExceptionState&);
+
+ RefPtr<ScriptState> m_scriptState;
+ RefPtr<SerializedScriptValue> m_serializedScriptValue;
+ v8::ValueSerializer m_serializer;
+#if DCHECK_IS_ON()
+ bool m_serializeInvoked = false;
+#endif
+};
+
+} // namespace blink
+
+#endif // V8ScriptValueSerializer_h

Powered by Google App Engine
This is Rietveld 408576698