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::TypeUint8 || | 43 type == DOMArrayBufferView::TypeUint8 || |
44 type == DOMArrayBufferView::TypeUint8Clamped || | 44 type == DOMArrayBufferView::TypeUint8Clamped || |
45 type == DOMArrayBufferView::TypeInt16 || | 45 type == DOMArrayBufferView::TypeInt16 || |
46 type == DOMArrayBufferView::TypeUint16 || | 46 type == DOMArrayBufferView::TypeUint16 || |
47 type == DOMArrayBufferView::TypeInt32 || | 47 type == DOMArrayBufferView::TypeInt32 || |
48 type == DOMArrayBufferView::TypeUint32; | 48 type == DOMArrayBufferView::TypeUint32; |
49 } | 49 } |
50 | 50 |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 DOMArrayBufferView* Crypto::getRandomValues(DOMArrayBufferView* array, | 53 DOMArrayBufferView* Crypto::getRandomValues( |
54 ExceptionState& exceptionState) { | 54 const NotShared<DOMArrayBufferView>& array, |
55 ASSERT(array); | 55 ExceptionState& exceptionState) { |
56 if (!isIntegerArray(array)) { | 56 DCHECK(array.view()); |
| 57 if (!isIntegerArray(array.view())) { |
57 exceptionState.throwDOMException( | 58 exceptionState.throwDOMException( |
58 TypeMismatchError, | 59 TypeMismatchError, |
59 String::format("The provided ArrayBufferView is of type '%s', which is " | 60 String::format("The provided ArrayBufferView is of type '%s', which is " |
60 "not an integer array type.", | 61 "not an integer array type.", |
61 array->typeName())); | 62 array.view()->typeName())); |
62 return nullptr; | 63 return nullptr; |
63 } | 64 } |
64 if (array->byteLength() > 65536) { | 65 if (array.view()->byteLength() > 65536) { |
65 exceptionState.throwDOMException( | 66 exceptionState.throwDOMException( |
66 QuotaExceededError, | 67 QuotaExceededError, |
67 String::format("The ArrayBufferView's byte length (%u) exceeds the " | 68 String::format("The ArrayBufferView's byte length (%u) exceeds the " |
68 "number of bytes of entropy available via this API " | 69 "number of bytes of entropy available via this API " |
69 "(65536).", | 70 "(65536).", |
70 array->byteLength())); | 71 array.view()->byteLength())); |
71 return nullptr; | 72 return nullptr; |
72 } | 73 } |
73 cryptographicallyRandomValues(array->baseAddress(), array->byteLength()); | 74 cryptographicallyRandomValues(array.view()->baseAddress(), |
74 return array; | 75 array.view()->byteLength()); |
| 76 return array.view(); |
75 } | 77 } |
76 | 78 |
77 SubtleCrypto* Crypto::subtle() { | 79 SubtleCrypto* Crypto::subtle() { |
78 if (!m_subtleCrypto) | 80 if (!m_subtleCrypto) |
79 m_subtleCrypto = SubtleCrypto::create(); | 81 m_subtleCrypto = SubtleCrypto::create(); |
80 return m_subtleCrypto.get(); | 82 return m_subtleCrypto.get(); |
81 } | 83 } |
82 | 84 |
83 DEFINE_TRACE(Crypto) { | 85 DEFINE_TRACE(Crypto) { |
84 visitor->trace(m_subtleCrypto); | 86 visitor->trace(m_subtleCrypto); |
85 } | 87 } |
86 | 88 |
87 } // namespace blink | 89 } // namespace blink |
OLD | NEW |