summaryrefslogtreecommitdiff
path: root/Source/WebCore/bindings/js/JSCryptoCustom.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/bindings/js/JSCryptoCustom.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/bindings/js/JSCryptoCustom.cpp')
-rw-r--r--Source/WebCore/bindings/js/JSCryptoCustom.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/Source/WebCore/bindings/js/JSCryptoCustom.cpp b/Source/WebCore/bindings/js/JSCryptoCustom.cpp
index 9d1177146..a71b71aeb 100644
--- a/Source/WebCore/bindings/js/JSCryptoCustom.cpp
+++ b/Source/WebCore/bindings/js/JSCryptoCustom.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -25,8 +26,9 @@
#include "config.h"
#include "JSCrypto.h"
-#include "ExceptionCode.h"
-
+#include "JSDOMConvertBufferSource.h"
+#include "JSDOMExceptionHandling.h"
+#include <heap/HeapInlines.h>
#include <runtime/ArrayBufferView.h>
#include <runtime/Error.h>
#include <runtime/JSArrayBufferView.h>
@@ -35,23 +37,20 @@ using namespace JSC;
namespace WebCore {
-JSValue JSCrypto::getRandomValues(ExecState* exec)
+JSValue JSCrypto::getRandomValues(ExecState& state)
{
- if (exec->argumentCount() < 1)
- return exec->vm().throwException(exec, createNotEnoughArgumentsError(exec));
+ VM& vm = state.vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
- JSValue buffer = exec->argument(0);
- RefPtr<ArrayBufferView> arrayBufferView = toArrayBufferView(buffer);
- if (!arrayBufferView)
- return throwTypeError(exec);
+ if (state.argumentCount() < 1)
+ return throwException(&state, scope, createNotEnoughArgumentsError(&state));
- ExceptionCode ec = 0;
- impl().getRandomValues(arrayBufferView.get(), ec);
+ JSValue buffer = state.argument(0);
+ auto arrayBufferView = toUnsharedArrayBufferView(vm, buffer);
+ if (!arrayBufferView)
+ return throwTypeError(&state, scope);
- if (ec) {
- setDOMException(exec, ec);
- return jsUndefined();
- }
+ propagateException(state, scope, wrapped().getRandomValues(*arrayBufferView));
return buffer;
}