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 DOMArrayBufferView* Crypto::getRandomValues(DOMArrayBufferView* array, | 53 NotShared<DOMArrayBufferView> Crypto::getRandomValues( |
54 ExceptionState& exception_state) { | 54 NotShared<DOMArrayBufferView> array, |
55 ASSERT(array); | 55 ExceptionState& exception_state) { |
56 if (!IsIntegerArray(array)) { | 56 DCHECK(array); |
| 57 if (!IsIntegerArray(array.View())) { |
57 exception_state.ThrowDOMException( | 58 exception_state.ThrowDOMException( |
58 kTypeMismatchError, | 59 kTypeMismatchError, |
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 NotShared<DOMArrayBufferView>(nullptr); |
63 } | 64 } |
64 if (array->byteLength() > 65536) { | 65 if (array.View()->byteLength() > 65536) { |
65 exception_state.ThrowDOMException( | 66 exception_state.ThrowDOMException( |
66 kQuotaExceededError, | 67 kQuotaExceededError, |
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 NotShared<DOMArrayBufferView>(nullptr); |
72 } | 73 } |
73 CryptographicallyRandomValues(array->BaseAddress(), array->byteLength()); | 74 CryptographicallyRandomValues(array.View()->BaseAddress(), |
| 75 array.View()->byteLength()); |
74 return array; | 76 return array; |
75 } | 77 } |
76 | 78 |
77 SubtleCrypto* Crypto::subtle() { | 79 SubtleCrypto* Crypto::subtle() { |
78 if (!subtle_crypto_) | 80 if (!subtle_crypto_) |
79 subtle_crypto_ = SubtleCrypto::Create(); | 81 subtle_crypto_ = SubtleCrypto::Create(); |
80 return subtle_crypto_.Get(); | 82 return subtle_crypto_.Get(); |
81 } | 83 } |
82 | 84 |
83 DEFINE_TRACE(Crypto) { | 85 DEFINE_TRACE(Crypto) { |
84 visitor->Trace(subtle_crypto_); | 86 visitor->Trace(subtle_crypto_); |
85 } | 87 } |
86 | 88 |
87 } // namespace blink | 89 } // namespace blink |
OLD | NEW |