Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / v8 / V8StringResource.h
index feb63a9..c7fbdf8 100644 (file)
@@ -39,8 +39,6 @@ class ExternalStringVisitor;
 // to manage the life-cycle of the underlying buffer of the external string.
 class WebCoreStringResourceBase {
 public:
-    static WebCoreStringResourceBase* toWebCoreStringResourceBase(v8::Handle<v8::String>);
-
     explicit WebCoreStringResourceBase(const String& string)
         : m_plainString(string)
     {
@@ -89,8 +87,6 @@ public:
         return m_atomicString;
     }
 
-    void visitStrings(ExternalStringVisitor*);
-
 protected:
     // A shallow copy of the string. Keeps the string buffer alive until the V8 engine garbage collects it.
     String m_plainString;
@@ -180,16 +176,16 @@ public:
     {
     }
 
-    bool prepare();
-    operator String() const { return toString<String>(); }
-    operator AtomicString() const { return toString<AtomicString>(); }
-
-private:
-    bool prepareBase()
+    bool prepare()
     {
         if (m_v8Object.IsEmpty())
             return true;
 
+        if (!isValid()) {
+            setString(String());
+            return true;
+        }
+
         if (LIKELY(m_v8Object->IsString()))
             return true;
 
@@ -208,6 +204,11 @@ private:
         }
         return true;
     }
+    operator String() const { return toString<String>(); }
+    operator AtomicString() const { return toString<AtomicString>(); }
+
+private:
+    bool isValid() const;
 
     void setString(const String& string)
     {
@@ -229,27 +230,19 @@ private:
     String m_string;
 };
 
-template<> inline bool V8StringResource<DefaultMode>::prepare()
+template<> inline bool V8StringResource<DefaultMode>::isValid() const
 {
-    return prepareBase();
+    return true;
 }
 
-template<> inline bool V8StringResource<WithNullCheck>::prepare()
+template<> inline bool V8StringResource<WithNullCheck>::isValid() const
 {
-    if (m_v8Object.IsEmpty() || m_v8Object->IsNull()) {
-        setString(String());
-        return true;
-    }
-    return prepareBase();
+    return !m_v8Object->IsNull();
 }
 
-template<> inline bool V8StringResource<WithUndefinedOrNullCheck>::prepare()
+template<> inline bool V8StringResource<WithUndefinedOrNullCheck>::isValid() const
 {
-    if (m_v8Object.IsEmpty() || m_v8Object->IsNull() || m_v8Object->IsUndefined()) {
-        setString(String());
-        return true;
-    }
-    return prepareBase();
+    return !m_v8Object->IsNull() && !m_v8Object->IsUndefined();
 }
 
 } // namespace WebCore