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

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

Issue 2831943002: bindings: Port bindings/core/v8 away from ToImplArray APIs. (Closed)
Patch Set: Check for exception in SerializedScriptValue Created 3 years, 8 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/SerializedScriptValue.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.cpp b/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.cpp
index 52b5662c4e83831d7f51ce317ba3dca33c88ea89..d06085684d15a634b1b040957fcdd8f16efa905e 100644
--- a/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.cpp
@@ -34,6 +34,8 @@
#include "bindings/core/v8/DOMDataStore.h"
#include "bindings/core/v8/DOMWrapperWorld.h"
#include "bindings/core/v8/ExceptionState.h"
+#include "bindings/core/v8/IDLTypes.h"
+#include "bindings/core/v8/NativeValueTraitsImpl.h"
#include "bindings/core/v8/ScriptState.h"
#include "bindings/core/v8/SerializationTag.h"
#include "bindings/core/v8/SerializedScriptValueFactory.h"
@@ -373,25 +375,15 @@ bool SerializedScriptValue::ExtractTransferables(
if (value.IsEmpty() || value->IsUndefined())
return true;
- uint32_t length = 0;
- if (value->IsArray()) {
- v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(value);
- length = array->Length();
- } else if (!ToV8Sequence(value, length, isolate, exception_state)) {
- if (!exception_state.HadException())
- exception_state.ThrowTypeError(
- ExceptionMessages::NotAnArrayTypeArgumentOrValue(argument_index + 1));
+ Vector<v8::Local<v8::Value>> transferable_array =
+ NativeValueTraits<IDLSequence<v8::Local<v8::Value>>>::NativeValue(
+ isolate, value, exception_state);
+ if (exception_state.HadException())
return false;
- }
-
- v8::Local<v8::Object> transferable_array = v8::Local<v8::Object>::Cast(value);
// Validate the passed array of transferables.
- for (unsigned i = 0; i < length; ++i) {
- v8::Local<v8::Value> transferable_object;
- if (!transferable_array->Get(isolate->GetCurrentContext(), i)
- .ToLocal(&transferable_object))
- return false;
+ uint32_t i = 0;
+ for (const auto& transferable_object : transferable_array) {
// Validation of non-null objects, per HTML5 spec 10.3.3.
if (IsUndefinedOrNull(transferable_object)) {
exception_state.ThrowTypeError(
@@ -459,6 +451,7 @@ bool SerializedScriptValue::ExtractTransferables(
" does not have a transferable type.");
return false;
}
+ i++;
}
return true;
}

Powered by Google App Engine
This is Rietveld 408576698