Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: Source/bindings/v8/custom/V8CryptoCustom.cpp

Issue 222553007: [webcrypto] Expose crypto.subtle to web workers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: check if changes... Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/bindings/bindings.gypi ('k') | Source/bindings/v8/custom/V8WorkerCryptoCustom.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
28 #include "bindings/v8/ExceptionMessages.h" 28 #include "bindings/v8/ExceptionMessages.h"
29 #include "bindings/v8/ExceptionState.h" 29 #include "bindings/v8/ExceptionState.h"
30 #include "bindings/v8/V8Binding.h" 30 #include "bindings/v8/V8Binding.h"
31 #include "bindings/v8/custom/V8ArrayBufferViewCustom.h" 31 #include "bindings/v8/custom/V8ArrayBufferViewCustom.h"
32 #include "core/dom/ExceptionCode.h" 32 #include "core/dom/ExceptionCode.h"
33 #include "modules/crypto/Crypto.h" 33 #include "modules/crypto/Crypto.h"
34 #include "wtf/ArrayBufferView.h" 34 #include "wtf/ArrayBufferView.h"
35 35
36 namespace WebCore { 36 namespace WebCore {
37 37
38 // This custom binding is shared by V8WorkerCrypto. As such:
39 // * Do not call V8Crypto::toNative()
40 // * Must be threadsafe
41 void V8Crypto::getRandomValuesMethodCustom(const v8::FunctionCallbackInfo<v8::Va lue>& info) 38 void V8Crypto::getRandomValuesMethodCustom(const v8::FunctionCallbackInfo<v8::Va lue>& info)
42 { 39 {
43 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getRandomVa lues", "Crypto", info.Holder(), info.GetIsolate()); 40 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getRandomVa lues", "Crypto", info.Holder(), info.GetIsolate());
44 if (info.Length() < 1) { 41 if (info.Length() < 1) {
45 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i nfo.Length())); 42 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i nfo.Length()));
46 exceptionState.throwIfNeeded(); 43 exceptionState.throwIfNeeded();
47 return; 44 return;
48 } 45 }
49 46
50 v8::Handle<v8::Value> buffer = info[0]; 47 v8::Handle<v8::Value> buffer = info[0];
51 if (!V8ArrayBufferView::hasInstance(buffer, info.GetIsolate())) { 48 if (!V8ArrayBufferView::hasInstance(buffer, info.GetIsolate())) {
52 exceptionState.throwTypeError("First argument is not an ArrayBufferView" ); 49 exceptionState.throwTypeError("First argument is not an ArrayBufferView" );
53 } else { 50 } else {
54 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(v8::Handl e<v8::Object>::Cast(buffer)); 51 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(v8::Handl e<v8::Object>::Cast(buffer));
55 ASSERT(arrayBufferView); 52 ASSERT(arrayBufferView);
56 53
57 Crypto::getRandomValues(arrayBufferView, exceptionState); 54 Crypto* crypto = V8Crypto::toNative(info.Holder());
55 crypto->getRandomValues(arrayBufferView, exceptionState);
58 } 56 }
59 57
60 if (exceptionState.throwIfNeeded()) 58 if (exceptionState.throwIfNeeded())
61 return; 59 return;
62 60
63 v8SetReturnValue(info, buffer); 61 v8SetReturnValue(info, buffer);
64 } 62 }
65 63
66 } // namespace WebCore 64 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/bindings.gypi ('k') | Source/bindings/v8/custom/V8WorkerCryptoCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698