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

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

Issue 2712783002: V8ScriptValueSerializer: Add a separate version 'envelope' for Blink format version. (Closed)
Patch Set: Merge branch 'master' into ssv-separate-version Created 3 years, 10 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.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp b/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp
index 377090f2126a81bf6263e72111cff6873a89157f..e652f770e74231b7ed61663400e5de23c38beb9d 100644
--- a/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp
@@ -25,6 +25,23 @@
namespace blink {
+// The "Blink-side" serialization version, which defines how Blink will behave
+// during the serialization process. The serialization format has two
+// "envelopes": an outer one controlled by Blink and an inner one by V8.
+//
+// They are formatted as follows:
+// [version tag] [Blink version] [version tag] [v8 version] ...
+//
+// Before version 16, there was only a single envelope and the version number
+// for both parts was always equal.
+//
+// See also V8ScriptValueDeserializer.cpp.
+//
+// This version number must be incremented whenever any incompatible changes are
+// made to how Blink writes data. Purely V8-side changes do not require an
+// adjustment to this value.
+static const uint32_t kLatestVersion = 16;
+
V8ScriptValueSerializer::V8ScriptValueSerializer(
RefPtr<ScriptState> scriptState)
: m_scriptState(std::move(scriptState)),
@@ -48,9 +65,13 @@ RefPtr<SerializedScriptValue> V8ScriptValueSerializer::serialize(
if (exceptionState.hadException())
return nullptr;
+ // Write out the file header.
+ writeTag(VersionTag);
+ writeUint32(kLatestVersion);
+ m_serializer.WriteHeader();
Sami 2017/02/27 17:35:04 Should this still be inside the try-catch?
jbroman 2017/02/27 18:59:46 It can't throw, so it doesn't matter.
+
// Serialize the value and handle errors.
v8::TryCatch tryCatch(m_scriptState->isolate());
- m_serializer.WriteHeader();
bool wroteValue;
if (!m_serializer.WriteValue(m_scriptState->context(), value)
.To(&wroteValue)) {

Powered by Google App Engine
This is Rietveld 408576698