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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 type == DOMArrayBufferView::kTypeUint8 || | 43 type == DOMArrayBufferView::kTypeUint8 || |
44 type == DOMArrayBufferView::kTypeUint8Clamped || | 44 type == DOMArrayBufferView::kTypeUint8Clamped || |
45 type == DOMArrayBufferView::kTypeInt16 || | 45 type == DOMArrayBufferView::kTypeInt16 || |
46 type == DOMArrayBufferView::kTypeUint16 || | 46 type == DOMArrayBufferView::kTypeUint16 || |
47 type == DOMArrayBufferView::kTypeInt32 || | 47 type == DOMArrayBufferView::kTypeInt32 || |
48 type == DOMArrayBufferView::kTypeUint32; | 48 type == DOMArrayBufferView::kTypeUint32; |
49 } | 49 } |
50 | 50 |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 NotShared<DOMArrayBufferView> Crypto::getRandomValues( | 53 DOMArrayBufferView* Crypto::getRandomValues(DOMArrayBufferView* array, |
54 NotShared<DOMArrayBufferView> array, | 54 ExceptionState& exception_state) { |
55 ExceptionState& exception_state) { | 55 ASSERT(array); |
56 DCHECK(array); | 56 if (!IsIntegerArray(array)) { |
57 if (!IsIntegerArray(array.View())) { | |
58 exception_state.ThrowDOMException( | 57 exception_state.ThrowDOMException( |
59 kTypeMismatchError, | 58 kTypeMismatchError, |
60 String::Format("The provided ArrayBufferView is of type '%s', which is " | 59 String::Format("The provided ArrayBufferView is of type '%s', which is " |
61 "not an integer array type.", | 60 "not an integer array type.", |
62 array.View()->TypeName())); | 61 array->TypeName())); |
63 return NotShared<DOMArrayBufferView>(nullptr); | 62 return nullptr; |
64 } | 63 } |
65 if (array.View()->byteLength() > 65536) { | 64 if (array->byteLength() > 65536) { |
66 exception_state.ThrowDOMException( | 65 exception_state.ThrowDOMException( |
67 kQuotaExceededError, | 66 kQuotaExceededError, |
68 String::Format("The ArrayBufferView's byte length (%u) exceeds the " | 67 String::Format("The ArrayBufferView's byte length (%u) exceeds the " |
69 "number of bytes of entropy available via this API " | 68 "number of bytes of entropy available via this API " |
70 "(65536).", | 69 "(65536).", |
71 array.View()->byteLength())); | 70 array->byteLength())); |
72 return NotShared<DOMArrayBufferView>(nullptr); | 71 return nullptr; |
73 } | 72 } |
74 CryptographicallyRandomValues(array.View()->BaseAddress(), | 73 CryptographicallyRandomValues(array->BaseAddress(), array->byteLength()); |
75 array.View()->byteLength()); | |
76 return array; | 74 return array; |
77 } | 75 } |
78 | 76 |
79 SubtleCrypto* Crypto::subtle() { | 77 SubtleCrypto* Crypto::subtle() { |
80 if (!subtle_crypto_) | 78 if (!subtle_crypto_) |
81 subtle_crypto_ = SubtleCrypto::Create(); | 79 subtle_crypto_ = SubtleCrypto::Create(); |
82 return subtle_crypto_.Get(); | 80 return subtle_crypto_.Get(); |
83 } | 81 } |
84 | 82 |
85 DEFINE_TRACE(Crypto) { | 83 DEFINE_TRACE(Crypto) { |
86 visitor->Trace(subtle_crypto_); | 84 visitor->Trace(subtle_crypto_); |
87 } | 85 } |
88 | 86 |
89 } // namespace blink | 87 } // namespace blink |
OLD | NEW |