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

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

Issue 2755383004: Encapsulate optional SerializedScriptValue serialize/deserialize parameters. (Closed)
Patch Set: fuzzer 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #include "wtf/Vector.h" 55 #include "wtf/Vector.h"
56 #include "wtf/text/StringBuffer.h" 56 #include "wtf/text/StringBuffer.h"
57 #include "wtf/text/StringHash.h" 57 #include "wtf/text/StringHash.h"
58 #include <memory> 58 #include <memory>
59 59
60 namespace blink { 60 namespace blink {
61 61
62 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serialize( 62 PassRefPtr<SerializedScriptValue> SerializedScriptValue::serialize(
63 v8::Isolate* isolate, 63 v8::Isolate* isolate,
64 v8::Local<v8::Value> value, 64 v8::Local<v8::Value> value,
65 Transferables* transferables, 65 const SerializeOptions& options,
66 WebBlobInfoArray* blobInfo,
67 ExceptionState& exception) { 66 ExceptionState& exception) {
68 return SerializedScriptValueFactory::instance().create( 67 return SerializedScriptValueFactory::instance().create(isolate, value,
69 isolate, value, transferables, blobInfo, exception); 68 options, exception);
70 } 69 }
71 70
72 PassRefPtr<SerializedScriptValue> 71 PassRefPtr<SerializedScriptValue>
73 SerializedScriptValue::serializeAndSwallowExceptions( 72 SerializedScriptValue::serializeAndSwallowExceptions(
74 v8::Isolate* isolate, 73 v8::Isolate* isolate,
75 v8::Local<v8::Value> value) { 74 v8::Local<v8::Value> value) {
76 DummyExceptionStateForTesting exceptionState; 75 DummyExceptionStateForTesting exceptionState;
77 RefPtr<SerializedScriptValue> serialized = 76 RefPtr<SerializedScriptValue> serialized =
78 serialize(isolate, value, nullptr, nullptr, exceptionState); 77 serialize(isolate, value, SerializeOptions(), exceptionState);
79 if (exceptionState.hadException()) 78 if (exceptionState.hadException())
80 return nullValue(); 79 return nullValue();
81 return serialized.release(); 80 return serialized.release();
82 } 81 }
83 82
84 PassRefPtr<SerializedScriptValue> SerializedScriptValue::create() { 83 PassRefPtr<SerializedScriptValue> SerializedScriptValue::create() {
85 return adoptRef(new SerializedScriptValue); 84 return adoptRef(new SerializedScriptValue);
86 } 85 }
87 86
88 PassRefPtr<SerializedScriptValue> SerializedScriptValue::create( 87 PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 void SerializedScriptValue::transferArrayBuffers( 252 void SerializedScriptValue::transferArrayBuffers(
254 v8::Isolate* isolate, 253 v8::Isolate* isolate,
255 const ArrayBufferArray& arrayBuffers, 254 const ArrayBufferArray& arrayBuffers,
256 ExceptionState& exceptionState) { 255 ExceptionState& exceptionState) {
257 m_arrayBufferContentsArray = 256 m_arrayBufferContentsArray =
258 transferArrayBufferContents(isolate, arrayBuffers, exceptionState); 257 transferArrayBufferContents(isolate, arrayBuffers, exceptionState);
259 } 258 }
260 259
261 v8::Local<v8::Value> SerializedScriptValue::deserialize( 260 v8::Local<v8::Value> SerializedScriptValue::deserialize(
262 v8::Isolate* isolate, 261 v8::Isolate* isolate,
263 MessagePortArray* messagePorts, 262 const DeserializeOptions& options) {
264 const WebBlobInfoArray* blobInfo) { 263 return SerializedScriptValueFactory::instance().deserialize(this, isolate,
265 return SerializedScriptValueFactory::instance().deserialize( 264 options);
266 this, isolate, messagePorts, blobInfo);
267 } 265 }
268 266
269 bool SerializedScriptValue::extractTransferables( 267 bool SerializedScriptValue::extractTransferables(
270 v8::Isolate* isolate, 268 v8::Isolate* isolate,
271 v8::Local<v8::Value> value, 269 v8::Local<v8::Value> value,
272 int argumentIndex, 270 int argumentIndex,
273 Transferables& transferables, 271 Transferables& transferables,
274 ExceptionState& exceptionState) { 272 ExceptionState& exceptionState) {
275 if (value.IsEmpty() || value->IsUndefined()) 273 if (value.IsEmpty() || value->IsUndefined())
276 return true; 274 return true;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 // Only (re)register allocation cost for transferables if this 461 // Only (re)register allocation cost for transferables if this
464 // SerializedScriptValue has explicitly unregistered them before. 462 // SerializedScriptValue has explicitly unregistered them before.
465 if (m_arrayBufferContentsArray && 463 if (m_arrayBufferContentsArray &&
466 m_transferablesNeedExternalAllocationRegistration) { 464 m_transferablesNeedExternalAllocationRegistration) {
467 for (auto& buffer : *m_arrayBufferContentsArray) 465 for (auto& buffer : *m_arrayBufferContentsArray)
468 buffer.registerExternalAllocationWithCurrentContext(); 466 buffer.registerExternalAllocationWithCurrentContext();
469 } 467 }
470 } 468 }
471 469
472 } // namespace blink 470 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698