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

Side by Side Diff: Source/bindings/modules/v8/ScriptValueSerializerForModules.cpp

Issue 1100223003: bindings: Add empty checks for toV8() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 7 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "bindings/modules/v8/ScriptValueSerializerForModules.h" 6 #include "bindings/modules/v8/ScriptValueSerializerForModules.h"
7 7
8 #include "bindings/core/v8/SerializationTag.h" 8 #include "bindings/core/v8/SerializationTag.h"
9 #include "bindings/core/v8/V8Binding.h" 9 #include "bindings/core/v8/V8Binding.h"
10 #include "bindings/modules/v8/V8CryptoKey.h" 10 #include "bindings/modules/v8/V8CryptoKey.h"
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 String name; 338 String name;
339 String url; 339 String url;
340 if (!doReadUint32(&type)) 340 if (!doReadUint32(&type))
341 return false; 341 return false;
342 if (!readWebCoreString(&name)) 342 if (!readWebCoreString(&name))
343 return false; 343 return false;
344 if (!readWebCoreString(&url)) 344 if (!readWebCoreString(&url))
345 return false; 345 return false;
346 DOMFileSystem* fs = DOMFileSystem::create(scriptState()->executionContext(), name, static_cast<FileSystemType>(type), KURL(ParsedURLString, url)); 346 DOMFileSystem* fs = DOMFileSystem::create(scriptState()->executionContext(), name, static_cast<FileSystemType>(type), KURL(ParsedURLString, url));
347 *value = toV8(fs, scriptState()->context()->Global(), isolate()); 347 *value = toV8(fs, scriptState()->context()->Global(), isolate());
348 return true; 348 return !value->IsEmpty();
349 } 349 }
350 350
351 bool SerializedScriptValueReaderForModules::readCryptoKey(v8::Local<v8::Value>* value) 351 bool SerializedScriptValueReaderForModules::readCryptoKey(v8::Local<v8::Value>* value)
352 { 352 {
353 uint32_t rawKeyType; 353 uint32_t rawKeyType;
354 if (!doReadUint32(&rawKeyType)) 354 if (!doReadUint32(&rawKeyType))
355 return false; 355 return false;
356 356
357 WebCryptoKeyAlgorithm algorithm; 357 WebCryptoKeyAlgorithm algorithm;
358 WebCryptoKeyType type = WebCryptoKeyTypeSecret; 358 WebCryptoKeyType type = WebCryptoKeyTypeSecret;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 return false; 395 return false;
396 396
397 const uint8_t* keyData = allocate(keyDataLength); 397 const uint8_t* keyData = allocate(keyDataLength);
398 WebCryptoKey key = WebCryptoKey::createNull(); 398 WebCryptoKey key = WebCryptoKey::createNull();
399 if (!Platform::current()->crypto()->deserializeKeyForClone( 399 if (!Platform::current()->crypto()->deserializeKeyForClone(
400 algorithm, type, extractable, usages, keyData, keyDataLength, key)) { 400 algorithm, type, extractable, usages, keyData, keyDataLength, key)) {
401 return false; 401 return false;
402 } 402 }
403 403
404 *value = toV8(CryptoKey::create(key), scriptState()->context()->Global(), is olate()); 404 *value = toV8(CryptoKey::create(key), scriptState()->context()->Global(), is olate());
405 return true; 405 return !value->IsEmpty();
406 } 406 }
407 407
408 bool SerializedScriptValueReaderForModules::doReadHmacKey(WebCryptoKeyAlgorithm& algorithm, WebCryptoKeyType& type) 408 bool SerializedScriptValueReaderForModules::doReadHmacKey(WebCryptoKeyAlgorithm& algorithm, WebCryptoKeyType& type)
409 { 409 {
410 uint32_t lengthBytes; 410 uint32_t lengthBytes;
411 if (!doReadUint32(&lengthBytes)) 411 if (!doReadUint32(&lengthBytes))
412 return false; 412 return false;
413 WebCryptoAlgorithmId hash; 413 WebCryptoAlgorithmId hash;
414 if (!doReadAlgorithmId(hash)) 414 if (!doReadAlgorithmId(hash))
415 return false; 415 return false;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 : ScriptValueDeserializer(reader, messagePorts, arrayBufferContents) 628 : ScriptValueDeserializer(reader, messagePorts, arrayBufferContents)
629 { 629 {
630 } 630 }
631 631
632 bool ScriptValueDeserializerForModules::read(v8::Local<v8::Value>* value) 632 bool ScriptValueDeserializerForModules::read(v8::Local<v8::Value>* value)
633 { 633 {
634 return toSerializedScriptValueReaderForModules(reader()).read(value, *this); 634 return toSerializedScriptValueReaderForModules(reader()).read(value, *this);
635 } 635 }
636 636
637 } // namespace blink 637 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/custom/V8PopStateEventCustom.cpp ('k') | Source/bindings/templates/attributes.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698