Title: [115339] trunk/Source/WebKit/chromium
Revision
115339
Author
[email protected]
Date
2012-04-26 12:19:58 -0700 (Thu, 26 Apr 2012)

Log Message

[Chromium] IndexedDB: Use WebIDBKeyPath type for key paths in WebKit API
https://bugs.webkit.org/show_bug.cgi?id=84631

Reviewed by James Robinson.

WebIDBKeyPath was previously a utility class for parsing key paths into components,
but the API exposed key paths only as nullable strings. To support array-type keypaths,
WebIDBKeyPath becomes a value class with type flags. For landing, several legacy methods
are retained but will be cleaned up after all callers have been updated, tracked as
the bug: http://webkit.org/b/84207

* public/WebIDBDatabase.h:
(WebKit::WebIDBDatabase::createObjectStore): Add WebIDBKeyPath overload; WebString overload delegates so implementers can switch.
* public/WebIDBIndex.h:
(WebKit::WebIDBIndex::keyPath): Calls keyPathString if not overridden.
(WebKit::WebIDBIndex::keyPathString): Comment change.
* public/WebIDBKeyPath.h:
(WebKit::WebIDBKeyPath::create): Overload added for creating array-type key paths.
(WebKit::WebIDBKeyPath::array): Accessor for array-type key paths.
(WebKit::WebIDBKeyPath::operator const WebString ): Temporary, for compatibility.
* public/WebIDBObjectStore.h:
(WebKit::WebIDBObjectStore::keyPath): Calls keyPathString if not overridden.
(WebKit::WebIDBObjectStore::keyPathString): Comment change.
(WebKit::WebIDBObjectStore::createIndex): Add WebIDBKeyPath overload; WebString overload delegates so implementers can switch.
* public/platform/WebKitPlatformSupport.h:
(WebKitPlatformSupport): WebIDBKeyPath overloads for these methods added, delegate to WebString version until implementers are updated.
(WebKit::WebKitPlatformSupport::createIDBKeysFromSerializedValuesAndKeyPath):
(WebKit::WebKitPlatformSupport::injectIDBKeyIntoSerializedValue):
* src/IDBIndexBackendProxy.cpp:
(WebKit::IDBIndexBackendProxy::keyPath): Returns the string version until WebCore is updated.
* src/IDBObjectStoreBackendProxy.cpp:
(WebKit::IDBObjectStoreBackendProxy::keyPath): Returns the string version until WebCore is updated.
* src/WebIDBDatabaseImpl.h:
(WebIDBDatabaseImpl): Add createObjectStore overload for WebIDBKeyPath type, delegates to WebString version until callers are updated.
* src/WebIDBIndexImpl.cpp:
(WebKit::WebIDBIndexImpl::keyPath): Implements the new WebIDBKeyPath return type.
(WebKit):
* src/WebIDBIndexImpl.h:
(WebIDBIndexImpl): Implements the new WebIDBKeyPath return type.
* src/WebIDBKeyPath.cpp:
(WebKit::WebIDBKeyPath::create): Support null key path types.
(WebKit::WebIDBKeyPath::createNull): New API.
(WebKit):
(WebKit::WebIDBKeyPath::isValid): New API.
(WebKit::WebIDBKeyPath::type): New API.
(WebKit::WebIDBKeyPath::string): New API (value accessor).
(WebKit::WebIDBKeyPath::WebIDBKeyPath):
(WebKit::WebIDBKeyPath::assign): This API will be removed.
(WebKit::WebIDBKeyPath::operator const WTF::Vector<WTF::String, 0>&): Ensure it is non-null - only used in copy constructor which guards against this.
* src/WebIDBObjectStoreImpl.cpp:
(WebKit::WebIDBObjectStoreImpl::keyPath): Implement the new WebIDBKeyPath return type.
(WebKit):
* src/WebIDBObjectStoreImpl.h:
(WebIDBObjectStoreImpl): Add createIndex overload for WebIDBKeyPath type, delegates to WebString version until callers are updated.

Modified Paths

Diff

Modified: trunk/Source/WebKit/chromium/ChangeLog (115338 => 115339)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-04-26 19:01:49 UTC (rev 115338)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-04-26 19:19:58 UTC (rev 115339)
@@ -1,3 +1,60 @@
+2012-04-26  Joshua Bell  <[email protected]>
+
+        [Chromium] IndexedDB: Use WebIDBKeyPath type for key paths in WebKit API
+        https://bugs.webkit.org/show_bug.cgi?id=84631
+
+        Reviewed by James Robinson.
+
+        WebIDBKeyPath was previously a utility class for parsing key paths into components,
+        but the API exposed key paths only as nullable strings. To support array-type keypaths,
+        WebIDBKeyPath becomes a value class with type flags. For landing, several legacy methods
+        are retained but will be cleaned up after all callers have been updated, tracked as
+        the bug: http://webkit.org/b/84207
+
+        * public/WebIDBDatabase.h:
+        (WebKit::WebIDBDatabase::createObjectStore): Add WebIDBKeyPath overload; WebString overload delegates so implementers can switch.
+        * public/WebIDBIndex.h:
+        (WebKit::WebIDBIndex::keyPath): Calls keyPathString if not overridden.
+        (WebKit::WebIDBIndex::keyPathString): Comment change.
+        * public/WebIDBKeyPath.h:
+        (WebKit::WebIDBKeyPath::create): Overload added for creating array-type key paths.
+        (WebKit::WebIDBKeyPath::array): Accessor for array-type key paths.
+        (WebKit::WebIDBKeyPath::operator const WebString ): Temporary, for compatibility.
+        * public/WebIDBObjectStore.h:
+        (WebKit::WebIDBObjectStore::keyPath): Calls keyPathString if not overridden.
+        (WebKit::WebIDBObjectStore::keyPathString): Comment change.
+        (WebKit::WebIDBObjectStore::createIndex): Add WebIDBKeyPath overload; WebString overload delegates so implementers can switch.
+        * public/platform/WebKitPlatformSupport.h:
+        (WebKitPlatformSupport): WebIDBKeyPath overloads for these methods added, delegate to WebString version until implementers are updated.
+        (WebKit::WebKitPlatformSupport::createIDBKeysFromSerializedValuesAndKeyPath):
+        (WebKit::WebKitPlatformSupport::injectIDBKeyIntoSerializedValue):
+        * src/IDBIndexBackendProxy.cpp:
+        (WebKit::IDBIndexBackendProxy::keyPath): Returns the string version until WebCore is updated.
+        * src/IDBObjectStoreBackendProxy.cpp:
+        (WebKit::IDBObjectStoreBackendProxy::keyPath): Returns the string version until WebCore is updated.
+        * src/WebIDBDatabaseImpl.h:
+        (WebIDBDatabaseImpl): Add createObjectStore overload for WebIDBKeyPath type, delegates to WebString version until callers are updated.
+        * src/WebIDBIndexImpl.cpp:
+        (WebKit::WebIDBIndexImpl::keyPath): Implements the new WebIDBKeyPath return type.
+        (WebKit):
+        * src/WebIDBIndexImpl.h:
+        (WebIDBIndexImpl): Implements the new WebIDBKeyPath return type.
+        * src/WebIDBKeyPath.cpp:
+        (WebKit::WebIDBKeyPath::create): Support null key path types.
+        (WebKit::WebIDBKeyPath::createNull): New API.
+        (WebKit):
+        (WebKit::WebIDBKeyPath::isValid): New API.
+        (WebKit::WebIDBKeyPath::type): New API.
+        (WebKit::WebIDBKeyPath::string): New API (value accessor).
+        (WebKit::WebIDBKeyPath::WebIDBKeyPath):
+        (WebKit::WebIDBKeyPath::assign): This API will be removed.
+        (WebKit::WebIDBKeyPath::operator const WTF::Vector<WTF::String, 0>&): Ensure it is non-null - only used in copy constructor which guards against this.
+        * src/WebIDBObjectStoreImpl.cpp:
+        (WebKit::WebIDBObjectStoreImpl::keyPath): Implement the new WebIDBKeyPath return type.
+        (WebKit):
+        * src/WebIDBObjectStoreImpl.h:
+        (WebIDBObjectStoreImpl): Add createIndex overload for WebIDBKeyPath type, delegates to WebString version until callers are updated.
+
 2012-04-26  Alexander Pavlov  <[email protected]>
 
         Web Inspector: [CRASH] WebViewImpl::setZoomLevel when emulating device metrics

Modified: trunk/Source/WebKit/chromium/public/WebIDBDatabase.h (115338 => 115339)


--- trunk/Source/WebKit/chromium/public/WebIDBDatabase.h	2012-04-26 19:01:49 UTC (rev 115338)
+++ trunk/Source/WebKit/chromium/public/WebIDBDatabase.h	2012-04-26 19:19:58 UTC (rev 115339)
@@ -28,6 +28,7 @@
 
 #include "WebDOMStringList.h"
 #include "WebExceptionCode.h"
+#include "WebIDBKeyPath.h"
 #include "platform/WebCommon.h"
 
 namespace WebKit {
@@ -58,8 +59,14 @@
         WEBKIT_ASSERT_NOT_REACHED();
         return WebDOMStringList();
     }
-    virtual WebIDBObjectStore* createObjectStore(const WebString& name, const WebString& keyPath, bool autoIncrement, const WebIDBTransaction&, WebExceptionCode&)
+    // FIXME: Remove WebString keyPath overload once callers are updated.
+    // http://webkit.org/b/84207
+    virtual WebIDBObjectStore* createObjectStore(const WebString& name, const WebString& keyPath, bool autoIncrement, const WebIDBTransaction& transaction, WebExceptionCode& ec)
     {
+        return createObjectStore(name, WebIDBKeyPath(keyPath), autoIncrement, transaction, ec);
+    }
+    virtual WebIDBObjectStore* createObjectStore(const WebString&, const WebIDBKeyPath&, bool, const WebIDBTransaction&, WebExceptionCode&)
+    {
         WEBKIT_ASSERT_NOT_REACHED();
         return 0;
     }

Modified: trunk/Source/WebKit/chromium/public/WebIDBIndex.h (115338 => 115339)


--- trunk/Source/WebKit/chromium/public/WebIDBIndex.h	2012-04-26 19:01:49 UTC (rev 115338)
+++ trunk/Source/WebKit/chromium/public/WebIDBIndex.h	2012-04-26 19:19:58 UTC (rev 115339)
@@ -27,6 +27,7 @@
 #define WebIDBIndex_h
 
 #include "WebExceptionCode.h"
+#include "WebIDBKeyPath.h"
 #include "WebIDBTransaction.h"
 #include "platform/WebString.h"
 
@@ -51,14 +52,14 @@
         WEBKIT_ASSERT_NOT_REACHED();
         return WebString();
     }
-    virtual WebString keyPath() const
+    virtual WebIDBKeyPath keyPath() const
     {
-        return keyPathString();
+        return WebIDBKeyPath(keyPathString());
     }
+    // FIXME: Remove method once callers are updated.
+    // http://webkit.org/b/84207
     virtual WebString keyPathString() const
     {
-        // FIXME: Temporary to allow keyPath()'s return type to change.
-        // http://webkit.org/b/84207
         WEBKIT_ASSERT_NOT_REACHED();
         return WebString();
     }

Modified: trunk/Source/WebKit/chromium/public/WebIDBKeyPath.h (115338 => 115339)


--- trunk/Source/WebKit/chromium/public/WebIDBKeyPath.h	2012-04-26 19:01:49 UTC (rev 115338)
+++ trunk/Source/WebKit/chromium/public/WebIDBKeyPath.h	2012-04-26 19:19:58 UTC (rev 115339)
@@ -28,6 +28,7 @@
 
 #include "platform/WebCommon.h"
 #include "platform/WebPrivateOwnPtr.h"
+#include "platform/WebString.h"
 #include "platform/WebVector.h"
 
 namespace WTF {
@@ -37,14 +38,29 @@
 
 namespace WebKit {
 
-class WebString;
-
 class WebIDBKeyPath {
 public:
     WEBKIT_EXPORT static WebIDBKeyPath create(const WebString&);
-    WebIDBKeyPath(const WebIDBKeyPath& keyPath) { assign(keyPath); }
+    WEBKIT_EXPORT static WebIDBKeyPath create(const WebVector<WebString>&);
+    WEBKIT_EXPORT static WebIDBKeyPath createNull();
+    WEBKIT_EXPORT WebIDBKeyPath(const WebIDBKeyPath&);
     ~WebIDBKeyPath() { reset(); }
 
+    enum Type {
+        NullType = 0,
+        StringType,
+        ArrayType,
+    };
+
+    WEBKIT_EXPORT bool isValid() const;
+    WEBKIT_EXPORT Type type() const;
+    // FIXME: Array-type key paths not yet supported. http://webkit.org/b/84207
+    WebVector<WebString> array() const { WEBKIT_ASSERT_NOT_REACHED(); return WebVector<WebString>(); }
+    WEBKIT_EXPORT WebString string() const;
+
+    // FIXME: Remove these once callers are updated. http://webkit.org/b/84207
+    WEBKIT_EXPORT WebIDBKeyPath(const WebString&);
+    operator const WebString () const { return string(); }
     WEBKIT_EXPORT int parseError() const;
     WEBKIT_EXPORT void assign(const WebIDBKeyPath&);
     WEBKIT_EXPORT void reset();

Modified: trunk/Source/WebKit/chromium/public/WebIDBObjectStore.h (115338 => 115339)


--- trunk/Source/WebKit/chromium/public/WebIDBObjectStore.h	2012-04-26 19:01:49 UTC (rev 115338)
+++ trunk/Source/WebKit/chromium/public/WebIDBObjectStore.h	2012-04-26 19:19:58 UTC (rev 115339)
@@ -29,6 +29,7 @@
 #include "WebExceptionCode.h"
 #include "WebDOMStringList.h"
 #include "WebIDBCallbacks.h"
+#include "WebIDBKeyPath.h"
 #include "WebIDBTransaction.h"
 #include "platform/WebCommon.h"
 #include "platform/WebString.h"
@@ -48,14 +49,12 @@
         WEBKIT_ASSERT_NOT_REACHED();
         return WebString();
     }
-    virtual WebString keyPath() const
+    virtual WebIDBKeyPath keyPath() const
     {
-        return keyPathString();
+        return WebIDBKeyPath(keyPathString());
     }
     virtual WebString keyPathString() const
     {
-        // FIXME: Temporary to allow keyPath()'s return type to change.
-        // http://webkit.org/b/84207
         WEBKIT_ASSERT_NOT_REACHED();
         return WebString();
     }
@@ -77,8 +76,15 @@
     virtual void deleteFunction(const WebIDBKey&, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&) { WEBKIT_ASSERT_NOT_REACHED(); }
     virtual void deleteFunction(const WebIDBKeyRange&, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&) { WEBKIT_ASSERT_NOT_REACHED(); }
     virtual void clear(WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&) { WEBKIT_ASSERT_NOT_REACHED(); }
+
+    // FIXME: Remove WebString keyPath overload once callers are updated.
+    // http://webkit.org/b/84207
     virtual WebIDBIndex* createIndex(const WebString& name, const WebString& keyPath, bool unique, bool multiEntry, const WebIDBTransaction& transaction, WebExceptionCode& ec)
     {
+        return createIndex(name, WebIDBKeyPath(keyPath), unique, multiEntry, transaction, ec);
+    }
+    virtual WebIDBIndex* createIndex(const WebString&, const WebIDBKeyPath&, bool, bool, const WebIDBTransaction&, WebExceptionCode&)
+    {
         WEBKIT_ASSERT_NOT_REACHED();
         return 0;
     }

Modified: trunk/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h (115338 => 115339)


--- trunk/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h	2012-04-26 19:01:49 UTC (rev 115338)
+++ trunk/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h	2012-04-26 19:19:58 UTC (rev 115339)
@@ -31,6 +31,7 @@
 #ifndef WebKitPlatformSupport_h
 #define WebKitPlatformSupport_h
 
+#include "../WebIDBKeyPath.h" // FIXME: Remove with: http://webkit.org/b/84207
 #include "WebCommon.h"
 #include "WebGraphicsContext3D.h"
 #include "WebLocalizedString.h"
@@ -126,8 +127,14 @@
     // Indexed Database ----------------------------------------------------
 
     virtual WebIDBFactory* idbFactory() { return 0; }
-    virtual void createIDBKeysFromSerializedValuesAndKeyPath(const WebVector<WebSerializedScriptValue>& values,  const WebString& keyPath, WebVector<WebIDBKey>& keys) { }
-    virtual WebSerializedScriptValue injectIDBKeyIntoSerializedValue(const WebIDBKey& key, const WebSerializedScriptValue& value, const WebString& keyPath) { return WebSerializedScriptValue(); }
+    // FIXME: Remove WebString keyPath overload once callers are updated.
+    // http://webkit.org/b/84207
+    virtual void createIDBKeysFromSerializedValuesAndKeyPath(const WebVector<WebSerializedScriptValue>& values,  const WebString& keyPath, WebVector<WebIDBKey>& keys) { createIDBKeysFromSerializedValuesAndKeyPath(values, WebIDBKeyPath(keyPath), keys); }
+    virtual void createIDBKeysFromSerializedValuesAndKeyPath(const WebVector<WebSerializedScriptValue>& values,  const WebIDBKeyPath& keyPath, WebVector<WebIDBKey>& keys) { }
+    // FIXME: Remove WebString keyPath overload once callers are updated.
+    // http://webkit.org/b/84207
+    virtual WebSerializedScriptValue injectIDBKeyIntoSerializedValue(const WebIDBKey& key, const WebSerializedScriptValue& value, const WebString& keyPath) { return injectIDBKeyIntoSerializedValue(key, value, WebIDBKeyPath(keyPath)); }
+    virtual WebSerializedScriptValue injectIDBKeyIntoSerializedValue(const WebIDBKey& key, const WebSerializedScriptValue& value, const WebIDBKeyPath& keyPath) { return WebSerializedScriptValue(); }
 
 
     // Message Ports -------------------------------------------------------

Modified: trunk/Source/WebKit/chromium/src/IDBIndexBackendProxy.cpp (115338 => 115339)


--- trunk/Source/WebKit/chromium/src/IDBIndexBackendProxy.cpp	2012-04-26 19:01:49 UTC (rev 115338)
+++ trunk/Source/WebKit/chromium/src/IDBIndexBackendProxy.cpp	2012-04-26 19:19:58 UTC (rev 115339)
@@ -67,7 +67,7 @@
 
 String IDBIndexBackendProxy::keyPath()
 {
-    return m_webIDBIndex->keyPath();
+    return m_webIDBIndex->keyPath().string();
 }
 
 bool IDBIndexBackendProxy::unique()

Modified: trunk/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.cpp (115338 => 115339)


--- trunk/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.cpp	2012-04-26 19:01:49 UTC (rev 115338)
+++ trunk/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.cpp	2012-04-26 19:19:58 UTC (rev 115339)
@@ -66,7 +66,7 @@
 
 String IDBObjectStoreBackendProxy::keyPath() const
 {
-    return m_webIDBObjectStore->keyPath();
+    return m_webIDBObjectStore->keyPath().string();
 }
 
 PassRefPtr<DOMStringList> IDBObjectStoreBackendProxy::indexNames() const

Modified: trunk/Source/WebKit/chromium/src/WebIDBDatabaseImpl.h (115338 => 115339)


--- trunk/Source/WebKit/chromium/src/WebIDBDatabaseImpl.h	2012-04-26 19:01:49 UTC (rev 115338)
+++ trunk/Source/WebKit/chromium/src/WebIDBDatabaseImpl.h	2012-04-26 19:19:58 UTC (rev 115339)
@@ -53,7 +53,10 @@
     virtual WebString version() const;
     virtual WebDOMStringList objectStoreNames() const;
 
-    virtual WebIDBObjectStore* createObjectStore(const WebString& name, const WebString& keyPath, bool autoIncrement, const WebIDBTransaction&, WebExceptionCode&);
+    // FIXME: Remove WebString keyPath overload once callers are updated.
+    // http://webkit.org/b/84207
+    virtual WebIDBObjectStore* createObjectStore(const WebString&, const WebString&, bool, const WebIDBTransaction&, WebExceptionCode&);
+    virtual WebIDBObjectStore* createObjectStore(const WebString& name, const WebIDBKeyPath& keyPath, bool autoIncrement, const WebIDBTransaction& transaction, WebExceptionCode& ec) { return createObjectStore(name, keyPath.string(), autoIncrement, transaction, ec); }
     virtual void deleteObjectStore(const WebString& name, const WebIDBTransaction&, WebExceptionCode&);
     virtual void setVersion(const WebString& version, WebIDBCallbacks*, WebExceptionCode&);
     virtual WebIDBTransaction* transaction(const WebDOMStringList& names, unsigned short mode, WebExceptionCode&);

Modified: trunk/Source/WebKit/chromium/src/WebIDBIndexImpl.cpp (115338 => 115339)


--- trunk/Source/WebKit/chromium/src/WebIDBIndexImpl.cpp	2012-04-26 19:01:49 UTC (rev 115338)
+++ trunk/Source/WebKit/chromium/src/WebIDBIndexImpl.cpp	2012-04-26 19:19:58 UTC (rev 115339)
@@ -58,6 +58,13 @@
     return m_backend->storeName();
 }
 
+WebIDBKeyPath WebIDBIndexImpl::keyPath() const
+{
+    return WebIDBKeyPath(m_backend->keyPath());
+}
+
+// FIXME: Remove this method once callers are updated.
+// http://webkit.org/b/84207
 WebString WebIDBIndexImpl::keyPathString() const
 {
     return m_backend->keyPath();

Modified: trunk/Source/WebKit/chromium/src/WebIDBIndexImpl.h (115338 => 115339)


--- trunk/Source/WebKit/chromium/src/WebIDBIndexImpl.h	2012-04-26 19:01:49 UTC (rev 115338)
+++ trunk/Source/WebKit/chromium/src/WebIDBIndexImpl.h	2012-04-26 19:19:58 UTC (rev 115339)
@@ -45,6 +45,9 @@
 
     virtual WebString name() const;
     virtual WebString storeName() const;
+    virtual WebIDBKeyPath keyPath() const;
+    // FIXME: Remove this method once callers are updated.
+    // http://webkit.org/b/84207
     virtual WebString keyPathString() const;
     virtual bool unique() const;
     virtual bool multiEntry() const;

Modified: trunk/Source/WebKit/chromium/src/WebIDBKeyPath.cpp (115338 => 115339)


--- trunk/Source/WebKit/chromium/src/WebIDBKeyPath.cpp	2012-04-26 19:01:49 UTC (rev 115338)
+++ trunk/Source/WebKit/chromium/src/WebIDBKeyPath.cpp	2012-04-26 19:19:58 UTC (rev 115339)
@@ -37,20 +37,78 @@
 
 namespace WebKit {
 
+WebIDBKeyPath WebIDBKeyPath::create(const WebVector<WebString>&)
+{
+    // FIXME: Array-type key paths not yet supported. http://webkit.org/b/84207
+    WEBKIT_ASSERT_NOT_REACHED();
+    return createNull();
+}
+
 WebIDBKeyPath WebIDBKeyPath::create(const WebString& keyPath)
 {
+    if (keyPath.isNull())
+        return createNull();
+
     WTF::Vector<WTF::String> idbElements;
     IDBKeyPathParseError idbError;
     IDBParseKeyPath(keyPath, idbElements, idbError);
     return WebIDBKeyPath(idbElements, static_cast<int>(idbError));
 }
 
+WebIDBKeyPath WebIDBKeyPath::createNull()
+{
+    return WebIDBKeyPath(WebString());
+}
+
+WebIDBKeyPath::WebIDBKeyPath(const WebIDBKeyPath& keyPath)
+{
+    assign(keyPath);
+}
+
 WebIDBKeyPath::WebIDBKeyPath(const WTF::Vector<WTF::String>& elements, int parseError)
     : m_private(new WTF::Vector<WTF::String>(elements))
     , m_parseError(parseError)
 {
 }
 
+bool WebIDBKeyPath::isValid() const
+{
+    return m_parseError == IDBKeyPathParseErrorNone;
+}
+
+WebIDBKeyPath::Type WebIDBKeyPath::type() const
+{
+    return m_private.get() ? StringType : NullType;
+}
+
+WebString WebIDBKeyPath::string() const
+{
+    if (!m_private.get())
+        return WebString();
+
+    // FIXME: Store the complete string instead of rebuilding it.
+    // http://webkit.org/b/84207
+    WTF::String string("");
+    WTF::Vector<WTF::String>& array = *m_private.get();
+    for (size_t i = 0; i < array.size(); ++i) {
+        if (i)
+            string.append(".");
+        string.append(array[i]);
+    }
+    return WebString(string);
+}
+
+WebIDBKeyPath::WebIDBKeyPath(const WebString& keyPath)
+    : m_parseError(IDBKeyPathParseErrorNone)
+{
+    if (!keyPath.isNull()) {
+        m_private.reset(new WTF::Vector<WTF::String>());
+        IDBKeyPathParseError idbParseError;
+        IDBParseKeyPath(keyPath, *m_private.get(), idbParseError);
+        m_parseError = idbParseError;
+    }
+}
+
 int WebIDBKeyPath::parseError() const
 {
     return m_parseError;
@@ -59,7 +117,10 @@
 void WebIDBKeyPath::assign(const WebIDBKeyPath& keyPath)
 {
     m_parseError = keyPath.m_parseError;
-    m_private.reset(new WTF::Vector<WTF::String>(keyPath));
+    if (keyPath.m_private.get())
+        m_private.reset(new WTF::Vector<WTF::String>(keyPath));
+    else
+        m_private.reset(0);
 }
 
 void WebIDBKeyPath::reset()
@@ -69,6 +130,7 @@
 
 WebIDBKeyPath::operator const WTF::Vector<WTF::String, 0>&() const
 {
+    ASSERT(m_private.get());
     return *m_private.get();
 }
 

Modified: trunk/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.cpp (115338 => 115339)


--- trunk/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.cpp	2012-04-26 19:01:49 UTC (rev 115338)
+++ trunk/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.cpp	2012-04-26 19:19:58 UTC (rev 115339)
@@ -57,6 +57,13 @@
     return m_objectStore->name();
 }
 
+WebIDBKeyPath WebIDBObjectStoreImpl::keyPath() const
+{
+    return WebIDBKeyPath(m_objectStore->keyPath());
+}
+
+// FIXME: Remove this method once callers are updated.
+// http://webkit.org/b/84207
 WebString WebIDBObjectStoreImpl::keyPathString() const
 {
     return m_objectStore->keyPath();

Modified: trunk/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.h (115338 => 115339)


--- trunk/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.h	2012-04-26 19:01:49 UTC (rev 115338)
+++ trunk/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.h	2012-04-26 19:19:58 UTC (rev 115339)
@@ -46,6 +46,9 @@
     ~WebIDBObjectStoreImpl();
 
     WebString name() const;
+    WebIDBKeyPath keyPath() const;
+    // FIXME: Remove this method once callers are updated.
+    // http://webkit.org/b/84207
     WebString keyPathString() const;
     WebDOMStringList indexNames() const;
 
@@ -55,9 +58,10 @@
     void deleteFunction(const WebIDBKeyRange&, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&);
     void clear(WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&);
 
-    // FIXME: Remove once callers are updated.
-    WebIDBIndex* createIndex(const WebString& name, const WebString& keyPath, bool unique, const WebIDBTransaction& transaction, WebExceptionCode& ec) { return createIndex(name, keyPath, unique, false, transaction, ec); }
-    WebIDBIndex* createIndex(const WebString& name, const WebString& keyPath, bool unique, bool multiEntry, const WebIDBTransaction&, WebExceptionCode&);
+    // FIXME: Remove WebString keyPath overload once callers are updated.
+    // http://webkit.org/b/84207
+    WebIDBIndex* createIndex(const WebString&, const WebString&, bool, bool, const WebIDBTransaction&, WebExceptionCode&);
+    WebIDBIndex* createIndex(const WebString& name, const WebIDBKeyPath& keyPath, bool unique, bool multiEntry, const WebIDBTransaction& transaction, WebExceptionCode& ec) { return createIndex(name, keyPath.string(), unique, multiEntry, transaction, ec); }
     WebIDBIndex* index(const WebString& name, WebExceptionCode&);
     void deleteIndex(const WebString& name, const WebIDBTransaction&, WebExceptionCode&);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to