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

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

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
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ExceptionState.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp b/third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp
index a446114b11798ba8f25ee03c6dd238db98817c89..f035f4cd6d6fb829959b0ee483d806223a03ad38 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/ExceptionState.cpp
@@ -37,6 +37,10 @@
namespace blink {
+bool ExceptionState::shouldThrow() const {
+ return true;
+}
+
void ExceptionState::throwDOMException(ExceptionCode ec, const char* message) {
throwDOMException(ec, String(message));
}
@@ -61,12 +65,18 @@ void ExceptionState::throwDOMException(ExceptionCode ec,
// 'sanitizedMessage'.
DCHECK(ec != SecurityError);
+ if (!shouldThrow())
+ return;
+
const String& processedMessage = addExceptionContext(message);
setException(ec, processedMessage, V8ThrowException::createDOMException(
m_isolate, ec, processedMessage));
}
void ExceptionState::throwRangeError(const String& message) {
+ if (!shouldThrow())
+ return;
+
setException(V8RangeError, message,
V8ThrowException::createRangeError(
m_isolate, addExceptionContext(message)));
@@ -74,6 +84,9 @@ void ExceptionState::throwRangeError(const String& message) {
void ExceptionState::throwSecurityError(const String& sanitizedMessage,
const String& unsanitizedMessage) {
+ if (!shouldThrow())
+ return;
+
const String& finalSanitized = addExceptionContext(sanitizedMessage);
const String& finalUnsanitized = addExceptionContext(unsanitizedMessage);
setException(SecurityError, finalSanitized,
@@ -82,12 +95,18 @@ void ExceptionState::throwSecurityError(const String& sanitizedMessage,
}
void ExceptionState::throwTypeError(const String& message) {
+ if (!shouldThrow())
+ return;
+
setException(V8TypeError, message,
V8ThrowException::createTypeError(m_isolate,
addExceptionContext(message)));
}
void ExceptionState::rethrowV8Exception(v8::Local<v8::Value> value) {
+ if (!shouldThrow())
+ return;
+
setException(kRethrownException, String(), value);
}
@@ -172,50 +191,14 @@ NonThrowableExceptionState::NonThrowableExceptionState(const char* file,
m_file(file),
m_line(line) {}
-void NonThrowableExceptionState::throwDOMException(ExceptionCode ec,
- const String& message) {
- DCHECK_AT(false, m_file, m_line) << "DOMExeption should not be thrown.";
-}
-
-void NonThrowableExceptionState::throwRangeError(const String& message) {
- DCHECK_AT(false, m_file, m_line) << "RangeError should not be thrown.";
-}
-
-void NonThrowableExceptionState::throwSecurityError(
- const String& sanitizedMessage,
- const String&) {
- DCHECK_AT(false, m_file, m_line) << "SecurityError should not be thrown.";
-}
-
-void NonThrowableExceptionState::throwTypeError(const String& message) {
- DCHECK_AT(false, m_file, m_line) << "TypeError should not be thrown.";
-}
-
-void NonThrowableExceptionState::rethrowV8Exception(v8::Local<v8::Value>) {
- DCHECK_AT(false, m_file, m_line) << "An exception should not be rethrown.";
-}
-
-void DummyExceptionStateForTesting::throwDOMException(ExceptionCode ec,
- const String& message) {
- setException(ec, message, v8::Local<v8::Value>());
-}
-
-void DummyExceptionStateForTesting::throwRangeError(const String& message) {
- setException(V8RangeError, message, v8::Local<v8::Value>());
-}
-
-void DummyExceptionStateForTesting::throwSecurityError(
- const String& sanitizedMessage,
- const String&) {
- setException(SecurityError, sanitizedMessage, v8::Local<v8::Value>());
-}
-
-void DummyExceptionStateForTesting::throwTypeError(const String& message) {
- setException(V8TypeError, message, v8::Local<v8::Value>());
+bool NonThrowableExceptionState::shouldThrow() const {
+ DCHECK_AT(false, m_file, m_line) << "An exception should not be thrown.";
+ return false;
}
-void DummyExceptionStateForTesting::rethrowV8Exception(v8::Local<v8::Value>) {
- setException(kRethrownException, String(), v8::Local<v8::Value>());
+bool DummyExceptionStateForTesting::shouldThrow() const {
+ // This class ignores all exceptions.
+ return false;
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ExceptionState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698