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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/V8ThrowException.cpp

Issue 2834463002: Move CreateDOMException out of V8ThrowException (Closed)
Patch Set: Add comments Created 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/V8ThrowException.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8ThrowException.cpp b/third_party/WebKit/Source/bindings/core/v8/V8ThrowException.cpp
index befb07846c5871a6241402a554ed3bc993aca5ad..485b3596487f21a697365de004020d0622193e26 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8ThrowException.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8ThrowException.cpp
@@ -24,84 +24,10 @@
#include "bindings/core/v8/V8ThrowException.h"
-#include "bindings/core/v8/BindingSecurity.h"
#include "bindings/core/v8/V8Binding.h"
-#include "bindings/core/v8/V8DOMException.h"
-#include "bindings/core/v8/V8PrivateProperty.h"
-#include "core/dom/DOMException.h"
-#include "core/dom/ExceptionCode.h"
namespace blink {
-namespace {
-
-void DomExceptionStackGetter(v8::Local<v8::Name> name,
- const v8::PropertyCallbackInfo<v8::Value>& info) {
- v8::Isolate* isolate = info.GetIsolate();
- v8::Local<v8::Value> value;
- if (info.Data()
- .As<v8::Object>()
- ->Get(isolate->GetCurrentContext(), V8AtomicString(isolate, "stack"))
- .ToLocal(&value))
- V8SetReturnValue(info, value);
-}
-
-void DomExceptionStackSetter(v8::Local<v8::Name> name,
- v8::Local<v8::Value> value,
- const v8::PropertyCallbackInfo<void>& info) {
- v8::Maybe<bool> unused = info.Data().As<v8::Object>()->Set(
- info.GetIsolate()->GetCurrentContext(),
- V8AtomicString(info.GetIsolate(), "stack"), value);
- ALLOW_UNUSED_LOCAL(unused);
-}
-
-} // namespace
-
-v8::Local<v8::Value> V8ThrowException::CreateDOMException(
- v8::Isolate* isolate,
- ExceptionCode exception_code,
- const String& sanitized_message,
- const String& unsanitized_message) {
- DCHECK_GT(exception_code, 0);
- DCHECK(exception_code == kSecurityError || unsanitized_message.IsNull());
-
- if (isolate->IsExecutionTerminating())
- return v8::Local<v8::Value>();
-
- switch (exception_code) {
- case kV8Error:
- return CreateError(isolate, sanitized_message);
- case kV8TypeError:
- return CreateTypeError(isolate, sanitized_message);
- case kV8RangeError:
- return CreateRangeError(isolate, sanitized_message);
- case kV8SyntaxError:
- return CreateSyntaxError(isolate, sanitized_message);
- case kV8ReferenceError:
- return CreateReferenceError(isolate, sanitized_message);
- }
-
- DOMException* dom_exception = DOMException::Create(
- exception_code, sanitized_message, unsanitized_message);
- v8::Local<v8::Object> exception_obj =
- ToV8(dom_exception, isolate->GetCurrentContext()->Global(), isolate)
- .As<v8::Object>();
- // Attach an Error object to the DOMException. This is then lazily used to
- // get the stack value.
- v8::Local<v8::Value> error =
- v8::Exception::Error(V8String(isolate, dom_exception->message()));
- exception_obj
- ->SetAccessor(isolate->GetCurrentContext(),
- V8AtomicString(isolate, "stack"), DomExceptionStackGetter,
- DomExceptionStackSetter, error)
- .ToChecked();
-
- auto private_error = V8PrivateProperty::GetDOMExceptionError(isolate);
- private_error.Set(exception_obj, error);
-
- return exception_obj;
-}
-
#define DEFINE_CREATE_AND_THROW_ERROR_FUNC(blinkErrorType, v8ErrorType, \
defaultMessage) \
v8::Local<v8::Value> V8ThrowException::Create##blinkErrorType( \

Powered by Google App Engine
This is Rietveld 408576698