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

Side by Side Diff: Source/modules/crypto/Crypto.cpp

Issue 801283002: [bindings] Make Crypto.getRandomValues use generated binding rather than using custom binding. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « Source/modules/crypto/Crypto.h ('k') | Source/modules/crypto/Crypto.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 || type == DOMArrayBufferView::TypeUint8 46 || type == DOMArrayBufferView::TypeUint8
47 || type == DOMArrayBufferView::TypeUint8Clamped 47 || type == DOMArrayBufferView::TypeUint8Clamped
48 || type == DOMArrayBufferView::TypeInt16 48 || type == DOMArrayBufferView::TypeInt16
49 || type == DOMArrayBufferView::TypeUint16 49 || type == DOMArrayBufferView::TypeUint16
50 || type == DOMArrayBufferView::TypeInt32 50 || type == DOMArrayBufferView::TypeInt32
51 || type == DOMArrayBufferView::TypeUint32; 51 || type == DOMArrayBufferView::TypeUint32;
52 } 52 }
53 53
54 } // namespace 54 } // namespace
55 55
56 void Crypto::getRandomValues(DOMArrayBufferView* array, ExceptionState& exceptio nState) 56 DOMArrayBufferView* Crypto::getRandomValues(DOMArrayBufferView* array, Exception State& exceptionState)
57 { 57 {
58 if (!array) { 58 if (!array) {
59 exceptionState.throwDOMException(TypeMismatchError, "The provided ArrayB ufferView is null."); 59 exceptionState.throwDOMException(TypeMismatchError, "The provided ArrayB ufferView is null.");
60 return; 60 return nullptr;
61 } 61 }
62 if (!isIntegerArray(array)) { 62 if (!isIntegerArray(array)) {
63 exceptionState.throwDOMException(TypeMismatchError, String::format("The provided ArrayBufferView is of type '%s', which is not an integer array type.", array->typeName())); 63 exceptionState.throwDOMException(TypeMismatchError, String::format("The provided ArrayBufferView is of type '%s', which is not an integer array type.", array->typeName()));
64 return; 64 return nullptr;
65 } 65 }
66 if (array->byteLength() > 65536) { 66 if (array->byteLength() > 65536) {
67 exceptionState.throwDOMException(QuotaExceededError, String::format("The ArrayBufferView's byte length (%u) exceeds the number of bytes of entropy avail able via this API (65536).", array->byteLength())); 67 exceptionState.throwDOMException(QuotaExceededError, String::format("The ArrayBufferView's byte length (%u) exceeds the number of bytes of entropy avail able via this API (65536).", array->byteLength()));
68 return; 68 return nullptr;
69 } 69 }
70 cryptographicallyRandomValues(array->baseAddress(), array->byteLength()); 70 cryptographicallyRandomValues(array->baseAddress(), array->byteLength());
71 return array;
71 } 72 }
72 73
73 SubtleCrypto* Crypto::subtle() 74 SubtleCrypto* Crypto::subtle()
74 { 75 {
75 if (!m_subtleCrypto) 76 if (!m_subtleCrypto)
76 m_subtleCrypto = SubtleCrypto::create(); 77 m_subtleCrypto = SubtleCrypto::create();
77 return m_subtleCrypto.get(); 78 return m_subtleCrypto.get();
78 } 79 }
79 80
80 void Crypto::trace(Visitor* visitor) 81 void Crypto::trace(Visitor* visitor)
81 { 82 {
82 visitor->trace(m_subtleCrypto); 83 visitor->trace(m_subtleCrypto);
83 } 84 }
84 85
85 } // namespace blink 86 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/crypto/Crypto.h ('k') | Source/modules/crypto/Crypto.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698