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

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

Issue 2519403002: binding: Lets Dictionary::getPropertyNames, etc. rethrow an exception. (Closed)
Patch Set: Addressed review comments. Created 4 years, 1 month 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/V8StringResource.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8StringResource.h b/third_party/WebKit/Source/bindings/core/v8/V8StringResource.h
index 9661f9c34ec7729322121ff589f585dd1fd49623..c01715d4bfc46943297510069dd6b88dbb98bf0b 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8StringResource.h
+++ b/third_party/WebKit/Source/bindings/core/v8/V8StringResource.h
@@ -187,32 +187,21 @@ class V8StringResource {
void operator=(std::nullptr_t) { setString(String()); }
- bool prepare() {
+ bool prepare() { // DEPRECATED
if (prepareFast())
return true;
- // TODO(bashi): Pass an isolate to this function and remove
- // v8::Isolate::GetCurrent().
return m_v8Object->ToString(v8::Isolate::GetCurrent()->GetCurrentContext())
.ToLocal(&m_v8Object);
}
- bool prepare(ExceptionState& exceptionState) {
- if (prepareFast())
- return true;
+ bool prepare(v8::Isolate* isolate, ExceptionState& exceptionState) {
+ return prepareFast() || prepareSlow(isolate, exceptionState);
+ }
- // TODO(bashi): Pass an isolate to this function and remove
- // v8::Isolate::GetCurrent().
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::TryCatch block(isolate);
- // Handle the case where an exception is thrown as part of invoking toString
- // on the object.
- if (!m_v8Object->ToString(isolate->GetCurrentContext())
- .ToLocal(&m_v8Object)) {
- exceptionState.rethrowV8Exception(block.Exception());
- return false;
- }
- return true;
+ bool prepare(ExceptionState& exceptionState) { // DEPRECATED
+ return prepareFast() ||
+ prepareSlow(v8::Isolate::GetCurrent(), exceptionState);
}
operator String() const { return toString<String>(); }
@@ -240,6 +229,16 @@ class V8StringResource {
return false;
}
+ bool prepareSlow(v8::Isolate* isolate, ExceptionState& exceptionState) {
+ v8::TryCatch tryCatch(isolate);
+ if (!m_v8Object->ToString(isolate->GetCurrentContext())
+ .ToLocal(&m_v8Object)) {
+ exceptionState.rethrowV8Exception(tryCatch.Exception());
+ return false;
+ }
+ return true;
+ }
+
bool isValid() const;
String fallbackString() const;
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/Dictionary.cpp ('k') | third_party/WebKit/Source/core/animation/EffectInput.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698