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

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

Issue 2316763002: Implement v8::ValueSerializer::Delegate to throw DOMException for DataCloneError. (Closed)
Patch Set: V8ThrowException::createDOMException 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
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e9cc6004379947a93fbd686d9120d4e16139dae5..2e03c090e611b9e57232bb40b00babf95f65f639 100644
--- a/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp
@@ -7,13 +7,14 @@
#include "bindings/core/v8/ToV8.h"
#include "core/dom/DOMArrayBufferBase.h"
#include "platform/RuntimeEnabledFeatures.h"
+#include "wtf/AutoReset.h"
namespace blink {
V8ScriptValueSerializer::V8ScriptValueSerializer(RefPtr<ScriptState> scriptState)
: m_scriptState(std::move(scriptState))
, m_serializedScriptValue(SerializedScriptValue::create())
- , m_serializer(m_scriptState->isolate())
+ , m_serializer(m_scriptState->isolate(), this)
{
DCHECK(RuntimeEnabledFeatures::v8BasedStructuredCloneEnabled());
}
@@ -25,6 +26,7 @@ RefPtr<SerializedScriptValue> V8ScriptValueSerializer::serialize(v8::Local<v8::V
m_serializeInvoked = true;
#endif
DCHECK(m_serializedScriptValue);
+ AutoReset<const ExceptionState*> reset(&m_exceptionState, &exceptionState);
ScriptState::Scope scope(m_scriptState.get());
// Prepare to transfer the provided transferables.
@@ -42,11 +44,7 @@ RefPtr<SerializedScriptValue> V8ScriptValueSerializer::serialize(v8::Local<v8::V
exceptionState.rethrowV8Exception(tryCatch.Exception());
return nullptr;
}
- if (!wroteValue) {
- DCHECK(!tryCatch.HasCaught());
- exceptionState.throwDOMException(DataCloneError, "An object could not be cloned.");
- return nullptr;
- }
+ DCHECK(wroteValue);
// Finalize the results.
std::vector<uint8_t> buffer = m_serializer.ReleaseBuffer();
@@ -85,4 +83,14 @@ void V8ScriptValueSerializer::transfer(Transferables* transferables, ExceptionSt
}
}
+void V8ScriptValueSerializer::ThrowDataCloneError(v8::Local<v8::String> v8Message)
+{
+ DCHECK(m_exceptionState);
+ String message = m_exceptionState->addExceptionContext(
+ v8StringToWebCoreString<String>(v8Message, DoNotExternalize));
+ v8::Local<v8::Value> exception = V8ThrowException::createDOMException(
+ m_scriptState->isolate(), DataCloneError, message);
+ V8ThrowException::throwException(m_scriptState->isolate(), exception);
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698