OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 void V8Crypto::getRandomValuesMethodCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) | 38 void V8Crypto::getRandomValuesMethodCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) |
39 { | 39 { |
40 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getRandomVa
lues", "Crypto", info.Holder(), info.GetIsolate()); | 40 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getRandomVa
lues", "Crypto", info.Holder(), info.GetIsolate()); |
41 if (info.Length() < 1) { | 41 if (info.Length() < 1) { |
42 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); | 42 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); |
43 exceptionState.throwIfNeeded(); | 43 exceptionState.throwIfNeeded(); |
44 return; | 44 return; |
45 } | 45 } |
46 | 46 |
47 v8::Handle<v8::Value> buffer = info[0]; | 47 v8::Local<v8::Value> buffer = info[0]; |
48 if (!V8ArrayBufferView::hasInstance(buffer, info.GetIsolate())) { | 48 if (!V8ArrayBufferView::hasInstance(buffer, info.GetIsolate())) { |
49 exceptionState.throwTypeError("First argument is not an ArrayBufferView"
); | 49 exceptionState.throwTypeError("First argument is not an ArrayBufferView"
); |
50 } else { | 50 } else { |
51 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toImpl(v8::Handle<
v8::Object>::Cast(buffer)); | 51 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toImpl(v8::Local<v
8::Object>::Cast(buffer)); |
52 ASSERT(arrayBufferView); | 52 ASSERT(arrayBufferView); |
53 | 53 |
54 Crypto* crypto = V8Crypto::toImpl(info.Holder()); | 54 Crypto* crypto = V8Crypto::toImpl(info.Holder()); |
55 crypto->getRandomValues(arrayBufferView, exceptionState); | 55 crypto->getRandomValues(arrayBufferView, exceptionState); |
56 } | 56 } |
57 | 57 |
58 if (exceptionState.throwIfNeeded()) | 58 if (exceptionState.throwIfNeeded()) |
59 return; | 59 return; |
60 | 60 |
61 v8SetReturnValue(info, buffer); | 61 v8SetReturnValue(info, buffer); |
62 } | 62 } |
63 | 63 |
64 } // namespace blink | 64 } // namespace blink |
OLD | NEW |