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

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

Issue 555133003: Use ExceptionState to throw exceptions when converting arrays (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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: Source/bindings/core/v8/V8StringResource.h
diff --git a/Source/bindings/core/v8/V8StringResource.h b/Source/bindings/core/v8/V8StringResource.h
index a061f6146072bdf338e5262cdf035425bdc7c7dd..bb1f04b50a7987d9de4bf9141da4fcebdbb21de6 100644
--- a/Source/bindings/core/v8/V8StringResource.h
+++ b/Source/bindings/core/v8/V8StringResource.h
@@ -198,6 +198,40 @@ public:
bool prepare()
{
+ if (prepareSimple())
+ return true;
+
+ v8::TryCatch block;
+ m_v8Object = m_v8Object->ToString();
+ // Handle the case where an exception is thrown as part of invoking toString on the object.
+ if (block.HasCaught()) {
+ block.ReThrow();
+ return false;
+ }
+ return true;
+ }
+
+ bool prepare(ExceptionState& exceptionState)
+ {
+ if (prepareSimple())
+ return true;
+
+ v8::TryCatch block;
+ m_v8Object = m_v8Object->ToString();
+ // Handle the case where an exception is thrown as part of invoking toString on the object.
+ if (block.HasCaught()) {
+ exceptionState.rethrowV8Exception(block.Exception());
+ return false;
+ }
+ return true;
+ }
+
+ operator String() const { return toString<String>(); }
+ operator AtomicString() const { return toString<AtomicString>(); }
+
+private:
+ bool prepareSimple()
+ {
if (m_v8Object.IsEmpty())
return true;
@@ -215,19 +249,9 @@ public:
}
m_mode = DoNotExternalize;
- v8::TryCatch block;
- m_v8Object = m_v8Object->ToString();
- // Handle the case where an exception is thrown as part of invoking toString on the object.
- if (block.HasCaught()) {
- block.ReThrow();
- return false;
- }
- return true;
+ return false;
}
- operator String() const { return toString<String>(); }
- operator AtomicString() const { return toString<AtomicString>(); }
-private:
bool isValid() const;
String fallbackString() const;

Powered by Google App Engine
This is Rietveld 408576698