diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/platform/bindings/exception_state.h')
-rw-r--r-- | chromium/third_party/blink/renderer/platform/bindings/exception_state.h | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/chromium/third_party/blink/renderer/platform/bindings/exception_state.h b/chromium/third_party/blink/renderer/platform/bindings/exception_state.h index 3f31d439537..9ba5753c7f1 100644 --- a/chromium/third_party/blink/renderer/platform/bindings/exception_state.h +++ b/chromium/third_party/blink/renderer/platform/bindings/exception_state.h @@ -32,7 +32,6 @@ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_BINDINGS_EXCEPTION_STATE_H_ #include "base/dcheck_is_on.h" -#include "base/macros.h" #include "base/notreached.h" #include "third_party/blink/renderer/platform/bindings/exception_code.h" #include "third_party/blink/renderer/platform/bindings/exception_context.h" @@ -99,6 +98,13 @@ class PLATFORM_EXPORT ExceptionState { ~ContextScope() { exception_state_.PopContextScope(); } + // This is used for a performance hack to reduce the number of construction + // and destruction times of ContextScope when iterating over properties. + // Only the generated bindings code is allowed to use this hack. + void ChangePropertyNameAsOptimizationHack(const char* property_name) { + context_.ChangePropertyNameAsOptimizationHack(property_name); + } + private: void SetParent(const ContextScope* parent) { parent_ = parent; } const ContextScope* GetParent() const { return parent_; } @@ -106,7 +112,7 @@ class PLATFORM_EXPORT ExceptionState { ExceptionState& exception_state_; const ContextScope* parent_ = nullptr; - const ExceptionContext context_; + ExceptionContext context_; friend class ExceptionState; }; @@ -141,9 +147,12 @@ class PLATFORM_EXPORT ExceptionState { : ExceptionState(isolate, ExceptionContext(context_type, interface_name)) {} + ExceptionState(const ExceptionState&) = delete; + ExceptionState& operator=(const ExceptionState&) = delete; + ~ExceptionState() { - if (!exception_.IsEmpty()) { - V8ThrowException::ThrowException(isolate_, exception_.NewLocal(isolate_)); + if (UNLIKELY(!exception_.IsEmpty())) { + PropagateException(); } } @@ -197,7 +206,7 @@ class PLATFORM_EXPORT ExceptionState { const String& Message() const { return message_; } - v8::Local<v8::Value> GetException() { + virtual v8::Local<v8::Value> GetException() { DCHECK(!exception_.IsEmpty()); return exception_.NewLocal(isolate_); } @@ -208,11 +217,12 @@ class PLATFORM_EXPORT ExceptionState { return main_context_; } - // Deprecated APIs to get information about where this ExceptionState has - // been created. - ContextType Context() const { return GetContext().GetContext(); } - const char* PropertyName() const { return GetContext().GetPropertyName(); } - const char* InterfaceName() const { return GetContext().GetClassName(); } + // Returns the innermost context of the nested exception contexts. + const ExceptionContext& GetInnerMostContext() const { + if (context_stack_top_) + return context_stack_top_->GetContext(); + return main_context_; + } protected: void SetException(ExceptionCode, const String&, v8::Local<v8::Value>); @@ -222,6 +232,7 @@ class PLATFORM_EXPORT ExceptionState { private: void PushContextScope(ContextScope* scope); void PopContextScope(); + void PropagateException(); String AddExceptionContext(const String&) const; @@ -247,7 +258,6 @@ class PLATFORM_EXPORT ExceptionState { TraceWrapperV8Reference<v8::Value> exception_; friend class ContextScope; - DISALLOW_COPY_AND_ASSIGN(ExceptionState); }; // NonThrowableExceptionState never allow call sites to throw an exception. @@ -309,6 +319,9 @@ class PLATFORM_EXPORT DummyExceptionStateForTesting final void ThrowWasmCompileError(const String& message) override; void RethrowV8Exception(v8::Local<v8::Value>) override; ExceptionState& ReturnThis() { return *this; } + v8::Local<v8::Value> GetException() override { + return v8::Local<v8::Value>(); + } }; // Syntax sugar for DummyExceptionStateForTesting. |