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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/ExceptionState.h

Issue 2715073002: Devirtualize ExceptionState's helper throwing methods.
Patch Set: Created 3 years, 10 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/ExceptionState.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/ExceptionState.h b/third_party/WebKit/Source/bindings/core/v8/ExceptionState.h
index c1628c187509d3eb8bfa7b874dca565552f371bb..927ae0ceb974ce7b5e957c124ede730eb9190bd5 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ExceptionState.h
+++ b/third_party/WebKit/Source/bindings/core/v8/ExceptionState.h
@@ -104,18 +104,20 @@ class CORE_EXPORT ExceptionState {
}
}
+ // const char* versions to avoid code bloat from inlined temporary Strings.
void throwDOMException(ExceptionCode, const char* message);
void throwRangeError(const char* message);
void throwSecurityError(const char* sanitizedMessage,
const char* unsanitizedMessage = nullptr);
void throwTypeError(const char* message);
- virtual void throwDOMException(ExceptionCode, const String& message);
- virtual void throwRangeError(const String& message);
- virtual void throwSecurityError(const String& sanitizedMessage,
- const String& unsanitizedMessage = String());
- virtual void throwTypeError(const String& message);
- virtual void rethrowV8Exception(v8::Local<v8::Value>);
+ void throwDOMException(ExceptionCode, const String& message);
+ void throwRangeError(const String& message);
+ void throwSecurityError(const String& sanitizedMessage,
+ const String& unsanitizedMessage = String());
+ void throwTypeError(const String& message);
+
+ void rethrowV8Exception(v8::Local<v8::Value>);
bool hadException() const { return m_code; }
void clearException();
@@ -144,7 +146,7 @@ class CORE_EXPORT ExceptionState {
// case, we cannot determine an exception code.
static const int kRethrownException = UnknownError;
- void setException(ExceptionCode, const String&, v8::Local<v8::Value>);
+ virtual void setException(ExceptionCode, const String&, v8::Local<v8::Value>);
private:
ExceptionCode m_code;
@@ -165,14 +167,13 @@ class CORE_EXPORT NonThrowableExceptionState final : public ExceptionState {
NonThrowableExceptionState();
NonThrowableExceptionState(const char*, int);
- void throwDOMException(ExceptionCode, const String& message) override;
- void throwTypeError(const String& message) override;
- void throwSecurityError(const String& sanitizedMessage,
- const String& unsanitizedMessage) override;
- void throwRangeError(const String& message) override;
- void rethrowV8Exception(v8::Local<v8::Value>) override;
ExceptionState& returnThis() { return *this; }
+ protected:
+ void setException(ExceptionCode,
+ const String&,
+ v8::Local<v8::Value>) override;
+
private:
const char* m_file;
const int m_line;
@@ -201,19 +202,14 @@ class CORE_EXPORT DummyExceptionStateForTesting final : public ExceptionState {
ExceptionState::UnknownContext,
nullptr,
nullptr) {}
- ~DummyExceptionStateForTesting() {
- // Prevent the base class throw an exception.
- if (hadException()) {
- clearException();
- }
- }
- void throwDOMException(ExceptionCode, const String& message) override;
- void throwTypeError(const String& message) override;
- void throwSecurityError(const String& sanitizedMessage,
- const String& unsanitizedMessage) override;
- void throwRangeError(const String& message) override;
- void rethrowV8Exception(v8::Local<v8::Value>) override;
+ ~DummyExceptionStateForTesting() {}
+
ExceptionState& returnThis() { return *this; }
+
+ protected:
+ void setException(ExceptionCode,
+ const String&,
+ v8::Local<v8::Value>) override;
};
// Syntax sugar for DummyExceptionStateForTesting.

Powered by Google App Engine
This is Rietveld 408576698