OLD | NEW |
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 DOMArrayBufferView* Crypto::getRandomValues(DOMArrayBufferView* array, Exception
State& exceptionState) | 56 DOMArrayBufferView* Crypto::getRandomValues(DOMArrayBufferView* array, Exception
State& exceptionState) |
57 { | 57 { |
58 if (!array) { | 58 ASSERT(array); |
59 exceptionState.throwDOMException(TypeMismatchError, "The provided ArrayB
ufferView is null."); | |
60 return nullptr; | |
61 } | |
62 if (!isIntegerArray(array)) { | 59 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())); | 60 exceptionState.throwDOMException(TypeMismatchError, String::format("The
provided ArrayBufferView is of type '%s', which is not an integer array type.",
array->typeName())); |
64 return nullptr; | 61 return nullptr; |
65 } | 62 } |
66 if (array->byteLength() > 65536) { | 63 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())); | 64 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 nullptr; | 65 return nullptr; |
69 } | 66 } |
70 cryptographicallyRandomValues(array->baseAddress(), array->byteLength()); | 67 cryptographicallyRandomValues(array->baseAddress(), array->byteLength()); |
71 return array; | 68 return array; |
72 } | 69 } |
73 | 70 |
74 SubtleCrypto* Crypto::subtle() | 71 SubtleCrypto* Crypto::subtle() |
75 { | 72 { |
76 if (!m_subtleCrypto) | 73 if (!m_subtleCrypto) |
77 m_subtleCrypto = SubtleCrypto::create(); | 74 m_subtleCrypto = SubtleCrypto::create(); |
78 return m_subtleCrypto.get(); | 75 return m_subtleCrypto.get(); |
79 } | 76 } |
80 | 77 |
81 DEFINE_TRACE(Crypto) | 78 DEFINE_TRACE(Crypto) |
82 { | 79 { |
83 visitor->trace(m_subtleCrypto); | 80 visitor->trace(m_subtleCrypto); |
84 } | 81 } |
85 | 82 |
86 } // namespace blink | 83 } // namespace blink |
OLD | NEW |