Chromium Code Reviews| Index: Source/bindings/v8/V8StringResource.h |
| diff --git a/Source/bindings/v8/V8StringResource.h b/Source/bindings/v8/V8StringResource.h |
| index e11002e5b0492b719f3bb4e560c5610ef63c0dce..13534f2aed8052ba8e4c5f9b77fd8ce8e3321050 100644 |
| --- a/Source/bindings/v8/V8StringResource.h |
| +++ b/Source/bindings/v8/V8StringResource.h |
| @@ -176,12 +176,28 @@ public: |
| { |
| } |
| - bool prepare(); |
| + // Returns false if calling ToString is needed. |
| + bool setStringAsPrimitive(); |
| + // This function assumes that setStringAsPrimitive is already called. |
| + // If ToString fails returns false and throws and JS exception. |
| + bool setStringWithToString() |
| + { |
| + ASSERT(!m_v8Object.IsEmpty()); |
| + ASSERT(!m_v8Object->IsString()); |
| + ASSERT(!m_v8Object->IsInt32()); |
| + ASSERT(m_mode == Externalize); |
| + m_mode = DoNotExternalize; |
| + m_v8Object = m_v8Object->ToString(); |
| + return !m_v8Object.IsEmpty(); |
| + } |
| + |
| operator String() const { return toString<String>(); } |
| operator AtomicString() const { return toString<AtomicString>(); } |
| + bool setStringUsingToString(); |
|
haraken
2014/04/21 03:57:02
What's this?
yhirano
2014/04/21 04:08:06
Thanks, I deleted it.
|
| + |
| private: |
| - bool prepareBase() |
| + bool setStringAsPrimitiveBase() |
| { |
| if (m_v8Object.IsEmpty()) |
| return true; |
| @@ -193,16 +209,7 @@ private: |
| setString(int32ToWebCoreString(m_v8Object->Int32Value())); |
| return true; |
| } |
| - |
| - 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; |
| } |
| void setString(const String& string) |
| @@ -225,27 +232,27 @@ private: |
| String m_string; |
| }; |
| -template<> inline bool V8StringResource<DefaultMode>::prepare() |
| +template<> inline bool V8StringResource<DefaultMode>::setStringAsPrimitive() |
| { |
| - return prepareBase(); |
| + return setStringAsPrimitiveBase(); |
| } |
| -template<> inline bool V8StringResource<WithNullCheck>::prepare() |
| +template<> inline bool V8StringResource<WithNullCheck>::setStringAsPrimitive() |
| { |
| if (m_v8Object.IsEmpty() || m_v8Object->IsNull()) { |
| setString(String()); |
| return true; |
| } |
| - return prepareBase(); |
| + return setStringAsPrimitiveBase(); |
| } |
| -template<> inline bool V8StringResource<WithUndefinedOrNullCheck>::prepare() |
| +template<> inline bool V8StringResource<WithUndefinedOrNullCheck>::setStringAsPrimitive() |
| { |
| if (m_v8Object.IsEmpty() || m_v8Object->IsNull() || m_v8Object->IsUndefined()) { |
| setString(String()); |
| return true; |
| } |
| - return prepareBase(); |
| + return setStringAsPrimitiveBase(); |
| } |
| } // namespace WebCore |