Changeset 117817 in webkit


Ignore:
Timestamp:
May 21, 2012 2:34:39 PM (12 years ago)
Author:
jsbell@chromium.org
Message:

IndexedDB: Store key paths in IDBKeyPath type instead of String
https://bugs.webkit.org/show_bug.cgi?id=85298

Reviewed by Tony Chang, Kentaro Hara and James Robinson.

Source/WebCore:

Migrate from storing key paths as (nullable) Strings to a dedicated IDBKeyPath
type. Prep work for supporting array-type key paths: http://webkit.org/b/84207

Only functional change is handling of null/undefined parameters for key paths,
to align with IDB spec, covered by layout test.

Test: storage/indexeddb/keypath-basics.html
Test: WebKit/chromium/IDBLevelDBCodingTest.cpp

  • Modules/indexeddb/IDBAny.cpp: Allow IDBAny to yield DOMStrings.

(WebCore::IDBAny::createString):
(WebCore):
(WebCore::IDBAny::string):
(WebCore::IDBAny::set):

  • Modules/indexeddb/IDBAny.h:

(IDBAny):

  • Modules/indexeddb/IDBBackingStore.h: Switch from String to IDBKeyPath.

(IDBBackingStore):

  • Modules/indexeddb/IDBDatabase.cpp: Switch from String to IDBKeyPath.

(WebCore::IDBDatabase::createObjectStore):

  • Modules/indexeddb/IDBDatabaseBackendImpl.cpp: Switch from String to IDBKeyPath.

(WebCore::IDBDatabaseBackendImpl::createObjectStore):
(WebCore::IDBDatabaseBackendImpl::loadObjectStores):

  • Modules/indexeddb/IDBDatabaseBackendImpl.h: Switch from String to IDBKeyPath.

(IDBDatabaseBackendImpl):

  • Modules/indexeddb/IDBDatabaseBackendInterface.h: Switch from String to IDBKeyPath.

(WebCore):
(IDBDatabaseBackendInterface):

  • Modules/indexeddb/IDBIndex.h: Switch from String to IDBAny (via IDBKeyPath).

(WebCore::IDBIndex::keyPath):

  • Modules/indexeddb/IDBIndex.idl: Switch from DOMString? to IDBAny.
  • Modules/indexeddb/IDBIndexBackendImpl.cpp: Switch from String to IDBKeyPath.

(WebCore::IDBIndexBackendImpl::IDBIndexBackendImpl):

  • Modules/indexeddb/IDBIndexBackendImpl.h: Switch from String to IDBKeyPath.

(WebCore::IDBIndexBackendImpl::create):
(WebCore::IDBIndexBackendImpl::keyPath):
(IDBIndexBackendImpl):

  • Modules/indexeddb/IDBIndexBackendInterface.h: Switch from String to IDBKeyPath.

(WebCore):
(IDBIndexBackendInterface):

  • Modules/indexeddb/IDBKeyPath.cpp: Non-trivial method implementations.

(WebCore::IDBKeyPath::isValid):
(WebCore):
(WebCore::IDBKeyPath::operator PassRefPtr<IDBAny>):

  • Modules/indexeddb/IDBKeyPath.h: Introduce IDBKeyPath type.

(IDBKeyPath):
(WebCore::IDBKeyPath::IDBKeyPath):
(WebCore::IDBKeyPath::type):
(WebCore::IDBKeyPath::array):
(WebCore::IDBKeyPath::string):
(WebCore::IDBKeyPath::isNull):
(WebCore):

  • Modules/indexeddb/IDBKeyPathBackendImpl.cpp: Switch from String to IDBKeyPath.

(WebCore::IDBKeyPathBackendImpl::createIDBKeysFromSerializedValuesAndKeyPath):
(WebCore::IDBKeyPathBackendImpl::injectIDBKeyIntoSerializedValue):

  • Modules/indexeddb/IDBKeyPathBackendImpl.h: Switch from String to IDBKeyPath.

(WebCore):
(IDBKeyPathBackendImpl):

  • Modules/indexeddb/IDBLevelDBBackingStore.cpp: Switch from String to IDBKeyPath, with back-compat.

(WebCore):
(WebCore::putIDBKeyPath):
(WebCore::IDBLevelDBBackingStore::getObjectStores):
(WebCore::IDBLevelDBBackingStore::createObjectStore):
(WebCore::IDBLevelDBBackingStore::getIndexes):
(WebCore::IDBLevelDBBackingStore::createIndex):

  • Modules/indexeddb/IDBLevelDBBackingStore.h:

(IDBLevelDBBackingStore):

  • Modules/indexeddb/IDBLevelDBCoding.cpp: New coding scheme for key paths (with back-compat).

(IDBLevelDBCoding):
(WebCore::IDBLevelDBCoding::encodeIDBKeyPath):
(WebCore::IDBLevelDBCoding::decodeIDBKeyPath):

  • Modules/indexeddb/IDBLevelDBCoding.h: Add key-path-specific methods.

(WebCore):
(IDBLevelDBCoding):

  • Modules/indexeddb/IDBObjectStore.cpp: Switch from String to IDBKeyPath.

(WebCore::IDBObjectStore::keyPath):
(WebCore::IDBObjectStore::createIndex):
(WebCore):

  • Modules/indexeddb/IDBObjectStore.h: Switch from String to IDBAny (via IDBKeyPath).

(IDBObjectStore):

  • Modules/indexeddb/IDBObjectStore.idl: Switch from DOMString? to IDBAny.
  • Modules/indexeddb/IDBObjectStoreBackendImpl.cpp: Switch from String to IDBKeyPath.

(WebCore::IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl):
(WebCore::fetchKeyFromKeyPath):
(WebCore::injectKeyIntoKeyPath):
(WebCore::IDBObjectStoreBackendImpl::createIndex):
(WebCore::IDBObjectStoreBackendImpl::loadIndexes):

  • Modules/indexeddb/IDBObjectStoreBackendImpl.h: Switch from String to IDBKeyPath.

(WebCore::IDBObjectStoreBackendImpl::create):
(WebCore::IDBObjectStoreBackendImpl::keyPath):
(IDBObjectStoreBackendImpl):

  • Modules/indexeddb/IDBObjectStoreBackendInterface.h: Switch from String to IDBKeyPath.

(WebCore):
(IDBObjectStoreBackendInterface):

  • bindings/v8/Dictionary.cpp: Add getter for DOMString[] (i.e. Vector<String>)

(WebCore):
(WebCore::Dictionary::get):

  • bindings/v8/Dictionary.h:

(Dictionary):

  • bindings/v8/IDBBindingUtilities.cpp: Switch from String to IDBKeyPath.

(WebCore::createIDBKeyFromSerializedValueAndKeyPath):
(WebCore::injectIDBKeyIntoSerializedValue):

  • bindings/v8/IDBBindingUtilities.h: Switch from String to IDBKeyPath.

(WebCore):

  • bindings/v8/custom/V8IDBAnyCustom.cpp: Support String/DOMString.

(WebCore::toV8):

  • dom/DOMStringList.h: Allow easy (const) access to strings.

(WebCore::DOMStringList::operator const Vector<String>&):
(DOMStringList):

(WebCore):

  • platform/chromium/PlatformSupport.h: Switch from String to IDBKeyPath.

(WebCore):
(PlatformSupport):

  • storage/chromium/IDBKeyPathBackendImpl.cpp: Switch from String to IDBKeyPath.

(WebCore::IDBKeyPathBackendImpl::createIDBKeysFromSerializedValuesAndKeyPath):
(WebCore::IDBKeyPathBackendImpl::injectIDBKeyIntoSerializedValue):

Source/WebKit/chromium:

No functional changes, just finish migration from String to IDBKeyPath
for storing key paths, for eventual array support http://webkit.org/b/84207

  • public/WebIDBDatabase.h: Remove temporary overload.

(WebKit):
(WebKit::WebIDBDatabase::objectStoreNames):

  • public/WebIDBIndex.h: Remove temporary method.

(WebKit::WebIDBIndex::keyPath):

  • public/WebIDBKeyPath.h: Remove obsolete methods, wrap WebCore::IDBKeyPath

(WebIDBKeyPath):
(WebKit::WebIDBKeyPath::WebIDBKeyPath):

  • public/WebIDBObjectStore.h: Remove temporary method and overload.

(WebKit::WebIDBObjectStore::keyPath):

  • public/platform/WebKitPlatformSupport.h: Remove temporary overloads.

(WebKit):

  • src/AssertMatchingEnums.cpp: WebIDBKeyPath vs. IDBKeyPath enums.
  • src/IDBDatabaseBackendProxy.cpp: Switch from String to IDBKeyPath.

(WebKit::IDBDatabaseBackendProxy::createObjectStore):

  • src/IDBDatabaseBackendProxy.h: Switch from String to IDBKeyPath.

(IDBDatabaseBackendProxy):

  • src/IDBIndexBackendProxy.cpp: Switch from String to IDBKeyPath.

(WebKit::IDBIndexBackendProxy::keyPath):

  • src/IDBIndexBackendProxy.h: Switch from String to IDBKeyPath.

(IDBIndexBackendProxy):

  • src/IDBObjectStoreBackendProxy.cpp: Switch from String to IDBKeyPath.

(WebKit::IDBObjectStoreBackendProxy::keyPath):
(WebKit::IDBObjectStoreBackendProxy::createIndex):

  • src/IDBObjectStoreBackendProxy.h: Switch from String to IDBKeyPath.

(IDBObjectStoreBackendProxy):

  • src/PlatformSupport.cpp: Switch from String to IDBKeyPath.

(WebCore::PlatformSupport::createIDBKeysFromSerializedValuesAndKeyPath):
(WebCore::PlatformSupport::injectIDBKeyIntoSerializedValue):

  • src/WebIDBDatabaseImpl.cpp: Switch from String to IDBKeyPath.

(WebKit::WebIDBDatabaseImpl::createObjectStore):

  • src/WebIDBDatabaseImpl.h: Remove temporary overload.

(WebIDBDatabaseImpl):

  • src/WebIDBIndexImpl.cpp: Remove temporary method.
  • src/WebIDBIndexImpl.h: Remove temporary method.

(WebIDBIndexImpl):

  • src/WebIDBKeyPath.cpp: Remove most logic; just a wrapper for WebCore::IDBKeyPath.

(WebKit::WebIDBKeyPath::~WebIDBKeyPath):
(WebKit::WebIDBKeyPath::create):
(WebKit::WebIDBKeyPath::createNull):
(WebKit::WebIDBKeyPath::isValid):
(WebKit::WebIDBKeyPath::type):
(WebKit):
(WebKit::WebIDBKeyPath::array):
(WebKit::WebIDBKeyPath::string):
(WebKit::WebIDBKeyPath::WebIDBKeyPath):
(WebKit::WebIDBKeyPath::operator=):
(WebKit::WebIDBKeyPath::operator const WebCore::IDBKeyPath&):

  • src/WebIDBObjectStoreImpl.cpp: Remove temporary method and overload.

(WebKit::WebIDBObjectStoreImpl::keyPath):
(WebKit::WebIDBObjectStoreImpl::createIndex):

  • src/WebIDBObjectStoreImpl.h: Remove temporary method and overload.

(WebIDBObjectStoreImpl):

  • tests/IDBBindingUtilitiesTest.cpp: Use IDBKeyPath.

(WebCore::checkKeyFromValueAndKeyPathInternal):
(WebCore::injectKey):

  • tests/IDBLevelDBCodingTest.cpp: Added EncodeIDBKeyPath and DecodeIDBKeyPath tests.

(IDBLevelDBCoding::TEST):
(IDBLevelDBCoding):

  • tests/IDBKeyPathTest.cpp:

(WebCore::checkKeyPath): Test IDBKeyPath validity.

LayoutTests:

  • storage/indexeddb/keypath-basics-expected.txt:
  • storage/indexeddb/resources/keypath-basics.js:
Location:
trunk
Files:
63 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r117816 r117817  
     12012-05-21  Joshua Bell  <jsbell@chromium.org>
     2
     3        IndexedDB: Store key paths in IDBKeyPath type instead of String
     4        https://bugs.webkit.org/show_bug.cgi?id=85298
     5
     6        Reviewed by Tony Chang, Kentaro Hara and James Robinson.
     7
     8        * storage/indexeddb/keypath-basics-expected.txt:
     9        * storage/indexeddb/resources/keypath-basics.js:
     10
    1112012-05-21  Joshua Bell  <jsbell@chromium.org>
    212
  • trunk/LayoutTests/storage/indexeddb/keypath-basics-expected.txt

    r114672 r117817  
    1010request = db.setVersion('1')
    1111Deleted all object stores.
    12 globalKeyPath = 'null'
    13 db.createObjectStore('name', {keyPath: globalKeyPath})
     12store = db.createObjectStore('name')
     13PASS store.keyPath is null
    1414Deleted all object stores.
    15 globalKeyPath = 'undefined'
    16 db.createObjectStore('name', {keyPath: globalKeyPath})
     15store = db.createObjectStore('name', {keyPath: null})
     16PASS store.keyPath is null
     17index = store.createIndex('name', null)
     18PASS index.keyPath is 'null'
    1719Deleted all object stores.
    18 globalKeyPath = ''
    19 db.createObjectStore('name', {keyPath: globalKeyPath})
     20store = db.createObjectStore('name', {keyPath: undefined})
     21PASS store.keyPath is null
     22index = store.createIndex('name', undefined)
     23PASS index.keyPath is 'undefined'
    2024Deleted all object stores.
    21 globalKeyPath = 'foo'
    22 db.createObjectStore('name', {keyPath: globalKeyPath})
     25store = db.createObjectStore('name', {keyPath: ''})
     26PASS store.keyPath is ''
     27index = store.createIndex('name', '')
     28PASS index.keyPath is ''
    2329Deleted all object stores.
    24 globalKeyPath = 'foo.bar.baz'
    25 db.createObjectStore('name', {keyPath: globalKeyPath})
     30store = db.createObjectStore('name', {keyPath: 'foo'})
     31PASS store.keyPath is 'foo'
     32index = store.createIndex('name', 'foo')
     33PASS index.keyPath is 'foo'
    2634Deleted all object stores.
    27 globalKeyPath = 'null'
    28 store = db.createObjectStore('storeName')
    29 store.createIndex('name', globalKeyPath)
    30 Deleted all object stores.
    31 globalKeyPath = 'undefined'
    32 store = db.createObjectStore('storeName')
    33 store.createIndex('name', globalKeyPath)
    34 Deleted all object stores.
    35 globalKeyPath = ''
    36 store = db.createObjectStore('storeName')
    37 store.createIndex('name', globalKeyPath)
    38 Deleted all object stores.
    39 globalKeyPath = 'foo'
    40 store = db.createObjectStore('storeName')
    41 store.createIndex('name', globalKeyPath)
    42 Deleted all object stores.
    43 globalKeyPath = 'foo.bar.baz'
    44 store = db.createObjectStore('storeName')
    45 store.createIndex('name', globalKeyPath)
     35store = db.createObjectStore('name', {keyPath: 'foo.bar.baz'})
     36PASS store.keyPath is 'foo.bar.baz'
     37index = store.createIndex('name', 'foo.bar.baz')
     38PASS index.keyPath is 'foo.bar.baz'
    4639Deleted all object stores.
    4740Deleted all object stores.
  • trunk/LayoutTests/storage/indexeddb/resources/keypath-basics.js

    r114672 r117817  
    2828    deleteAllObjectStores(db);
    2929
    30     testKeyPaths = [null, undefined, ''];
    31     testKeyPaths.forEach(function (keyPath) {
    32         globalKeyPath = keyPath;
    33         debug("globalKeyPath = '" + globalKeyPath + "'");
    34         evalAndLog("db.createObjectStore('name', {keyPath: globalKeyPath})");
    35         deleteAllObjectStores(db);
    36     });
     30    evalAndLog("store = db.createObjectStore('name')");
     31    shouldBeNull("store.keyPath");
     32    deleteAllObjectStores(db);
    3733
    38     testKeyPaths = ['foo', 'foo.bar.baz'];
    39     testKeyPaths.forEach(function (keyPath) {
    40         globalKeyPath = keyPath;
    41         debug("globalKeyPath = '" + globalKeyPath + "'");
    42         evalAndLog("db.createObjectStore('name', {keyPath: globalKeyPath})");
    43         deleteAllObjectStores(db);
    44     });
     34    testKeyPaths = [
     35        { keyPath: "null", storeExpected: "null", indexExpected: "'null'" },
     36        { keyPath: "undefined", storeExpected: "null", indexExpected: "'undefined'" },
     37        { keyPath: "''", storeExpected: "''", indexExpected: "''" },
     38        { keyPath: "'foo'", storeExpected: "'foo'", indexExpected: "'foo'" },
     39        { keyPath: "'foo.bar.baz'", storeExpected: "'foo.bar.baz'", indexExpected: "'foo.bar.baz'" }
     40    ];
    4541
    46     testKeyPaths = [null, undefined, '', 'foo', 'foo.bar.baz'];
    47     testKeyPaths.forEach(function (keyPath) {
    48         globalKeyPath = keyPath;
    49         debug("globalKeyPath = '" + globalKeyPath + "'");
    50         store = evalAndLog("store = db.createObjectStore('storeName')");
    51         evalAndLog("store.createIndex('name', globalKeyPath)");
     42    testKeyPaths.forEach(function (testCase) {
     43        evalAndLog("store = db.createObjectStore('name', {keyPath: " + testCase.keyPath + "})");
     44        shouldBe("store.keyPath", testCase.storeExpected);
     45        evalAndLog("index = store.createIndex('name', " + testCase.keyPath + ")");
     46        shouldBe("index.keyPath", testCase.indexExpected);
    5247        deleteAllObjectStores(db);
    5348    });
  • trunk/Source/WebCore/ChangeLog

    r117814 r117817  
     12012-05-21  Joshua Bell  <jsbell@chromium.org>
     2
     3        IndexedDB: Store key paths in IDBKeyPath type instead of String
     4        https://bugs.webkit.org/show_bug.cgi?id=85298
     5
     6        Reviewed by Tony Chang, Kentaro Hara and James Robinson.
     7
     8        Migrate from storing key paths as (nullable) Strings to a dedicated IDBKeyPath
     9        type. Prep work for supporting array-type key paths: http://webkit.org/b/84207
     10
     11        Only functional change is handling of null/undefined parameters for key paths,
     12        to align with IDB spec, covered by layout test.
     13
     14        Test: storage/indexeddb/keypath-basics.html
     15        Test: WebKit/chromium/IDBLevelDBCodingTest.cpp
     16
     17        * Modules/indexeddb/IDBAny.cpp: Allow IDBAny to yield DOMStrings.
     18        (WebCore::IDBAny::createString):
     19        (WebCore):
     20        (WebCore::IDBAny::string):
     21        (WebCore::IDBAny::set):
     22        * Modules/indexeddb/IDBAny.h:
     23        (IDBAny):
     24        * Modules/indexeddb/IDBBackingStore.h: Switch from String to IDBKeyPath.
     25        (IDBBackingStore):
     26        * Modules/indexeddb/IDBDatabase.cpp: Switch from String to IDBKeyPath.
     27        (WebCore::IDBDatabase::createObjectStore):
     28        * Modules/indexeddb/IDBDatabaseBackendImpl.cpp: Switch from String to IDBKeyPath.
     29        (WebCore::IDBDatabaseBackendImpl::createObjectStore):
     30        (WebCore::IDBDatabaseBackendImpl::loadObjectStores):
     31        * Modules/indexeddb/IDBDatabaseBackendImpl.h: Switch from String to IDBKeyPath.
     32        (IDBDatabaseBackendImpl):
     33        * Modules/indexeddb/IDBDatabaseBackendInterface.h: Switch from String to IDBKeyPath.
     34        (WebCore):
     35        (IDBDatabaseBackendInterface):
     36        * Modules/indexeddb/IDBIndex.h: Switch from String to IDBAny (via IDBKeyPath).
     37        (WebCore::IDBIndex::keyPath):
     38        * Modules/indexeddb/IDBIndex.idl: Switch from DOMString? to IDBAny.
     39        * Modules/indexeddb/IDBIndexBackendImpl.cpp: Switch from String to IDBKeyPath.
     40        (WebCore::IDBIndexBackendImpl::IDBIndexBackendImpl):
     41        * Modules/indexeddb/IDBIndexBackendImpl.h: Switch from String to IDBKeyPath.
     42        (WebCore::IDBIndexBackendImpl::create):
     43        (WebCore::IDBIndexBackendImpl::keyPath):
     44        (IDBIndexBackendImpl):
     45        * Modules/indexeddb/IDBIndexBackendInterface.h: Switch from String to IDBKeyPath.
     46        (WebCore):
     47        (IDBIndexBackendInterface):
     48        * Modules/indexeddb/IDBKeyPath.cpp: Non-trivial method implementations.
     49        (WebCore::IDBKeyPath::isValid):
     50        (WebCore):
     51        (WebCore::IDBKeyPath::operator PassRefPtr<IDBAny>):
     52        * Modules/indexeddb/IDBKeyPath.h: Introduce IDBKeyPath type.
     53        (IDBKeyPath):
     54        (WebCore::IDBKeyPath::IDBKeyPath):
     55        (WebCore::IDBKeyPath::type):
     56        (WebCore::IDBKeyPath::array):
     57        (WebCore::IDBKeyPath::string):
     58        (WebCore::IDBKeyPath::isNull):
     59        (WebCore):
     60        * Modules/indexeddb/IDBKeyPathBackendImpl.cpp: Switch from String to IDBKeyPath.
     61        (WebCore::IDBKeyPathBackendImpl::createIDBKeysFromSerializedValuesAndKeyPath):
     62        (WebCore::IDBKeyPathBackendImpl::injectIDBKeyIntoSerializedValue):
     63        * Modules/indexeddb/IDBKeyPathBackendImpl.h: Switch from String to IDBKeyPath.
     64        (WebCore):
     65        (IDBKeyPathBackendImpl):
     66        * Modules/indexeddb/IDBLevelDBBackingStore.cpp: Switch from String to IDBKeyPath, with back-compat.
     67        (WebCore):
     68        (WebCore::putIDBKeyPath):
     69        (WebCore::IDBLevelDBBackingStore::getObjectStores):
     70        (WebCore::IDBLevelDBBackingStore::createObjectStore):
     71        (WebCore::IDBLevelDBBackingStore::getIndexes):
     72        (WebCore::IDBLevelDBBackingStore::createIndex):
     73        * Modules/indexeddb/IDBLevelDBBackingStore.h:
     74        (IDBLevelDBBackingStore):
     75        * Modules/indexeddb/IDBLevelDBCoding.cpp: New coding scheme for key paths (with back-compat).
     76        (IDBLevelDBCoding):
     77        (WebCore::IDBLevelDBCoding::encodeIDBKeyPath):
     78        (WebCore::IDBLevelDBCoding::decodeIDBKeyPath):
     79        * Modules/indexeddb/IDBLevelDBCoding.h: Add key-path-specific methods.
     80        (WebCore):
     81        (IDBLevelDBCoding):
     82        * Modules/indexeddb/IDBObjectStore.cpp: Switch from String to IDBKeyPath.
     83        (WebCore::IDBObjectStore::keyPath):
     84        (WebCore::IDBObjectStore::createIndex):
     85        (WebCore):
     86        * Modules/indexeddb/IDBObjectStore.h: Switch from String to IDBAny (via IDBKeyPath).
     87        (IDBObjectStore):
     88        * Modules/indexeddb/IDBObjectStore.idl: Switch from DOMString? to IDBAny.
     89        * Modules/indexeddb/IDBObjectStoreBackendImpl.cpp: Switch from String to IDBKeyPath.
     90        (WebCore::IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl):
     91        (WebCore::fetchKeyFromKeyPath):
     92        (WebCore::injectKeyIntoKeyPath):
     93        (WebCore::IDBObjectStoreBackendImpl::createIndex):
     94        (WebCore::IDBObjectStoreBackendImpl::loadIndexes):
     95        * Modules/indexeddb/IDBObjectStoreBackendImpl.h: Switch from String to IDBKeyPath.
     96        (WebCore::IDBObjectStoreBackendImpl::create):
     97        (WebCore::IDBObjectStoreBackendImpl::keyPath):
     98        (IDBObjectStoreBackendImpl):
     99        * Modules/indexeddb/IDBObjectStoreBackendInterface.h: Switch from String to IDBKeyPath.
     100        (WebCore):
     101        (IDBObjectStoreBackendInterface):
     102        * bindings/v8/Dictionary.cpp: Add getter for DOMString[] (i.e. Vector<String>)
     103        (WebCore):
     104        (WebCore::Dictionary::get):
     105        * bindings/v8/Dictionary.h:
     106        (Dictionary):
     107        * bindings/v8/IDBBindingUtilities.cpp: Switch from String to IDBKeyPath.
     108        (WebCore::createIDBKeyFromSerializedValueAndKeyPath):
     109        (WebCore::injectIDBKeyIntoSerializedValue):
     110        * bindings/v8/IDBBindingUtilities.h: Switch from String to IDBKeyPath.
     111        (WebCore):
     112        * bindings/v8/custom/V8IDBAnyCustom.cpp: Support String/DOMString.
     113        (WebCore::toV8):
     114        * dom/DOMStringList.h: Allow easy (const) access to strings.
     115        (WebCore::DOMStringList::operator const Vector<String>&):
     116        (DOMStringList):
     117        * inspector/InspectorIndexedDBAgent.cpp: Temporary shim for non-strings: see http://webkit.org/b/84303
     118        (WebCore):
     119        * platform/chromium/PlatformSupport.h: Switch from String to IDBKeyPath.
     120        (WebCore):
     121        (PlatformSupport):
     122        * storage/chromium/IDBKeyPathBackendImpl.cpp: Switch from String to IDBKeyPath.
     123        (WebCore::IDBKeyPathBackendImpl::createIDBKeysFromSerializedValuesAndKeyPath):
     124        (WebCore::IDBKeyPathBackendImpl::injectIDBKeyIntoSerializedValue):
     125
    11262012-05-21  Zhenyao Mo  <zmo@google.com>
    2127
  • trunk/Source/WebCore/Modules/indexeddb/IDBAny.cpp

    r109493 r117817  
    5050}
    5151
     52PassRefPtr<IDBAny> IDBAny::createString(const String& value)
     53{
     54    RefPtr<IDBAny> idbAny = adoptRef(new IDBAny());
     55    idbAny->set(value);
     56    return idbAny.release();
     57}
     58
    5259IDBAny::IDBAny()
    5360    : m_type(UndefinedType)
     
    119126}
    120127
     128const String& IDBAny::string()
     129{
     130    ASSERT(m_type == StringType);
     131    return m_string;
     132}
     133
    121134void IDBAny::setNull()
    122135{
     
    195208}
    196209
     210void IDBAny::set(const String& value)
     211{
     212    ASSERT(m_type == UndefinedType);
     213    m_type = StringType;
     214    m_string = value;
     215}
     216
    197217} // namespace WebCore
    198218
  • trunk/Source/WebCore/Modules/indexeddb/IDBAny.h

    r109493 r117817  
    2929#if ENABLE(INDEXED_DATABASE)
    3030
     31#include "PlatformString.h"
    3132#include <wtf/PassRefPtr.h>
    3233#include <wtf/RefCounted.h>
     
    5051    static PassRefPtr<IDBAny> createInvalid();
    5152    static PassRefPtr<IDBAny> createNull();
     53    static PassRefPtr<IDBAny> createString(const String&);
    5254    template<typename T>
    5355    static PassRefPtr<IDBAny> create(T* idbObject)
     
    7880        IDBObjectStoreType,
    7981        IDBTransactionType,
    80         SerializedScriptValueType
     82        SerializedScriptValueType,
     83        StringType,
    8184    };
    8285
     
    9396    PassRefPtr<IDBTransaction> idbTransaction();
    9497    PassRefPtr<SerializedScriptValue> serializedScriptValue();
     98    const String& string();
    9599
    96100    // Set can only be called once.
     
    106110    void set(PassRefPtr<IDBTransaction>);
    107111    void set(PassRefPtr<SerializedScriptValue>);
     112    void set(const String&);
    108113
    109114private:
     
    123128    RefPtr<IDBTransaction> m_idbTransaction;
    124129    RefPtr<SerializedScriptValue> m_serializedScriptValue;
     130    String m_string;
    125131};
    126132
  • trunk/Source/WebCore/Modules/indexeddb/IDBBackingStore.h

    r116562 r117817  
    5353    virtual bool deleteDatabase(const String& name) = 0;
    5454
    55     virtual void getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<String>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags) = 0;
    56     virtual bool createObjectStore(int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement, int64_t& assignedObjectStoreId) = 0;
     55    virtual void getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags) = 0;
     56    virtual bool createObjectStore(int64_t databaseId, const String& name, const IDBKeyPath&, bool autoIncrement, int64_t& assignedObjectStoreId) = 0;
    5757    virtual void deleteObjectStore(int64_t databaseId, int64_t objectStoreId) = 0;
    5858
     
    7878    virtual bool forEachObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, ObjectStoreRecordCallback&) = 0;
    7979
    80     virtual void getIndexes(int64_t databaseId, int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<String>& foundKeyPaths, Vector<bool>& foundUniqueFlags, Vector<bool>& foundMultiEntryFlags) = 0;
    81     virtual bool createIndex(int64_t databaseId, int64_t objectStoreId, const String& name, const String& keyPath, bool isUnique, bool isMultiEntry, int64_t& indexId) = 0;
     80    virtual void getIndexes(int64_t databaseId, int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundUniqueFlags, Vector<bool>& foundMultiEntryFlags) = 0;
     81    virtual bool createIndex(int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath&, bool isUnique, bool isMultiEntry, int64_t& indexId) = 0;
    8282    virtual void deleteIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId) = 0;
    8383    virtual bool putIndexDataForRecord(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const ObjectStoreRecordIdentifier*) = 0;
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp

    r116337 r117817  
    9393    }
    9494
    95     String keyPath;
    96     bool keyPathExists = options.getWithUndefinedOrNullCheck("keyPath", keyPath);
    97     if (keyPathExists && !IDBIsValidKeyPath(keyPath)) {
     95    IDBKeyPath keyPath;
     96    if (!options.isUndefinedOrNull()) {
     97        String keyPathString;
     98        if (options.getWithUndefinedOrNullCheck("keyPath", keyPathString))
     99            keyPath = IDBKeyPath(keyPathString);
     100    }
     101
     102    if (!keyPath.isNull() && !keyPath.isValid()) {
    98103        ec = IDBDatabaseException::NON_TRANSIENT_ERR;
    99104        return 0;
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp

    r113622 r117817  
    138138}
    139139
    140 PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseBackendImpl::createObjectStore(const String& name, const String& keyPath, bool autoIncrement, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec)
     140PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseBackendImpl::createObjectStore(const String& name, const IDBKeyPath& keyPath, bool autoIncrement, IDBTransactionBackendInterface* transactionPtr, ExceptionCode& ec)
    141141{
    142142    ASSERT(transactionPtr->mode() == IDBTransaction::VERSION_CHANGE);
     
    377377    Vector<int64_t> ids;
    378378    Vector<String> names;
    379     Vector<String> keyPaths;
     379    Vector<IDBKeyPath> keyPaths;
    380380    Vector<bool> autoIncrementFlags;
    381381    m_backingStore->getObjectStores(m_id, ids, names, keyPaths, autoIncrementFlags);
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.h

    r110539 r117817  
    6666    virtual PassRefPtr<DOMStringList> objectStoreNames() const;
    6767
    68     virtual PassRefPtr<IDBObjectStoreBackendInterface> createObjectStore(const String& name, const String& keyPath, bool autoIncrement, IDBTransactionBackendInterface*, ExceptionCode&);
     68    virtual PassRefPtr<IDBObjectStoreBackendInterface> createObjectStore(const String& name, const IDBKeyPath&, bool autoIncrement, IDBTransactionBackendInterface*, ExceptionCode&);
    6969    virtual void deleteObjectStore(const String& name, IDBTransactionBackendInterface*, ExceptionCode&);
    7070    virtual void setVersion(const String& version, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>, ExceptionCode&);
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendInterface.h

    r109493 r117817  
    3939class IDBCallbacks;
    4040class IDBDatabaseCallbacks;
     41class IDBKeyPath;
    4142class IDBObjectStoreBackendInterface;
    4243class IDBTransactionBackendInterface;
     
    5657    virtual PassRefPtr<DOMStringList> objectStoreNames() const = 0;
    5758
    58     virtual PassRefPtr<IDBObjectStoreBackendInterface> createObjectStore(const String& name, const String& keyPath, bool autoIncrement, IDBTransactionBackendInterface*, ExceptionCode&) = 0;
     59    virtual PassRefPtr<IDBObjectStoreBackendInterface> createObjectStore(const String& name, const IDBKeyPath&, bool autoIncrement, IDBTransactionBackendInterface*, ExceptionCode&) = 0;
    5960    virtual void deleteObjectStore(const String& name, IDBTransactionBackendInterface*, ExceptionCode&) = 0;
    6061    virtual void setVersion(const String& version, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>, ExceptionCode&) = 0;
  • trunk/Source/WebCore/Modules/indexeddb/IDBIndex.h

    r116337 r117817  
    2929#include "IDBCursor.h"
    3030#include "IDBIndexBackendInterface.h"
     31#include "IDBKeyPath.h"
    3132#include "IDBKeyRange.h"
    3233#include "IDBRequest.h"
     
    5152    String name() const { return m_backend->name(); }
    5253    IDBObjectStore* objectStore() const { return m_objectStore.get(); }
    53     String keyPath() const { return m_backend->keyPath(); }
     54    PassRefPtr<IDBAny> keyPath() const { return m_backend->keyPath(); }
    5455    bool unique() const { return m_backend->unique(); }
    5556    bool multiEntry() const { return m_backend->multiEntry(); }
  • trunk/Source/WebCore/Modules/indexeddb/IDBIndex.idl

    r116337 r117817  
    3131        readonly attribute DOMString name;
    3232        readonly attribute IDBObjectStore objectStore;
    33         readonly attribute DOMString keyPath;
     33        readonly attribute IDBAny keyPath;
    3434        readonly attribute boolean unique;
    3535        readonly attribute boolean multiEntry;
  • trunk/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.cpp

    r117512 r117817  
    4242namespace WebCore {
    4343
    44 IDBIndexBackendImpl::IDBIndexBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, IDBObjectStoreBackendImpl* objectStoreBackend, int64_t id, const String& name, const String& keyPath, bool unique, bool multiEntry)
     44IDBIndexBackendImpl::IDBIndexBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, IDBObjectStoreBackendImpl* objectStoreBackend, int64_t id, const String& name, const IDBKeyPath& keyPath, bool unique, bool multiEntry)
    4545    : m_backingStore(backingStore)
    4646    , m_databaseId(databaseId)
     
    5454}
    5555
    56 IDBIndexBackendImpl::IDBIndexBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, IDBObjectStoreBackendImpl* objectStoreBackend, const String& name, const String& keyPath, bool unique, bool multiEntry)
     56IDBIndexBackendImpl::IDBIndexBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, IDBObjectStoreBackendImpl* objectStoreBackend, const String& name, const IDBKeyPath& keyPath, bool unique, bool multiEntry)
    5757    : m_backingStore(backingStore)
    5858    , m_databaseId(databaseId)
  • trunk/Source/WebCore/Modules/indexeddb/IDBIndexBackendImpl.h

    r117512 r117817  
    3131#include "IDBCursorBackendInterface.h"
    3232#include "IDBIndexBackendInterface.h"
     33#include "IDBKeyPath.h"
    3334
    3435namespace WebCore {
     
    4142class IDBIndexBackendImpl : public IDBIndexBackendInterface {
    4243public:
    43     static PassRefPtr<IDBIndexBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, IDBObjectStoreBackendImpl* objectStoreBackend, int64_t id, const String& name, const String& keyPath, bool unique, bool multiEntry)
     44    static PassRefPtr<IDBIndexBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, IDBObjectStoreBackendImpl* objectStoreBackend, int64_t id, const String& name, const IDBKeyPath& keyPath, bool unique, bool multiEntry)
    4445    {
    4546        return adoptRef(new IDBIndexBackendImpl(backingStore, databaseId, objectStoreBackend, id, name, keyPath, unique, multiEntry));
    4647    }
    47     static PassRefPtr<IDBIndexBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, IDBObjectStoreBackendImpl* objectStoreBackend, const String& name, const String& keyPath, bool unique, bool multiEntry)
     48    static PassRefPtr<IDBIndexBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, IDBObjectStoreBackendImpl* objectStoreBackend, const String& name, const IDBKeyPath& keyPath, bool unique, bool multiEntry)
    4849    {
    4950        return adoptRef(new IDBIndexBackendImpl(backingStore, databaseId, objectStoreBackend, name, keyPath, unique, multiEntry));
     
    6364    // Implements IDBIndexBackendInterface.
    6465    virtual String name() { return m_name; }
    65     virtual String keyPath() { return m_keyPath; }
     66    virtual IDBKeyPath keyPath() { return m_keyPath; }
    6667    virtual bool unique() { return m_unique; }
    6768    virtual bool multiEntry() { return m_multiEntry; }
     
    7677
    7778private:
    78     IDBIndexBackendImpl(IDBBackingStore*, int64_t databaseId, IDBObjectStoreBackendImpl*, int64_t id, const String& name, const String& keyPath, bool unique, bool multiEntry);
    79     IDBIndexBackendImpl(IDBBackingStore*, int64_t databaseId, IDBObjectStoreBackendImpl*, const String& name, const String& keyPath, bool unique, bool multiEntry);
     79    IDBIndexBackendImpl(IDBBackingStore*, int64_t databaseId, IDBObjectStoreBackendImpl*, int64_t id, const String& name, const IDBKeyPath&, bool unique, bool multiEntry);
     80    IDBIndexBackendImpl(IDBBackingStore*, int64_t databaseId, IDBObjectStoreBackendImpl*, const String& name, const IDBKeyPath&, bool unique, bool multiEntry);
    8081
    8182    static void openCursorInternal(ScriptExecutionContext*, PassRefPtr<IDBIndexBackendImpl>, PassRefPtr<IDBKeyRange>, unsigned short direction, IDBCursorBackendInterface::CursorType, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBTransactionBackendInterface>);
     
    9798    int64_t m_id;
    9899    String m_name;
    99     String m_keyPath;
     100    IDBKeyPath m_keyPath;
    100101    bool m_unique;
    101102    bool m_multiEntry;
  • trunk/Source/WebCore/Modules/indexeddb/IDBIndexBackendInterface.h

    r117512 r117817  
    3737class IDBCallbacks;
    3838class IDBKey;
     39class IDBKeyPath;
    3940class IDBKeyRange;
    4041class IDBTransactionBackendInterface;
     
    4748
    4849    virtual String name() = 0;
    49     virtual String keyPath() = 0;
     50    virtual IDBKeyPath keyPath() = 0;
    5051    virtual bool unique() = 0;
    5152    virtual bool multiEntry() = 0;
  • trunk/Source/WebCore/Modules/indexeddb/IDBKeyPath.cpp

    r109493 r117817  
    2929#if ENABLE(INDEXED_DATABASE)
    3030
     31#include "DOMStringList.h"
    3132#include <wtf/ASCIICType.h>
    3233#include <wtf/dtoa.h>
     
    180181}
    181182
     183IDBKeyPath::IDBKeyPath(const String& string)
     184    : m_type(StringType)
     185    , m_string(string)
     186{
     187    ASSERT(!m_string.isNull());
     188}
     189
     190IDBKeyPath::IDBKeyPath(const Vector<String>& array)
     191    : m_type(ArrayType)
     192    , m_array(array)
     193{
     194#ifndef NDEBUG
     195    for (size_t i = 0; i < m_array.size(); ++i)
     196        ASSERT(!m_array[i].isNull());
     197#endif
     198}
     199
     200bool IDBKeyPath::isValid() const
     201{
     202    switch (m_type) {
     203    case NullType:
     204        return false;
     205
     206    case StringType:
     207        return IDBIsValidKeyPath(m_string);
     208
     209    case ArrayType:
     210        for (size_t i = 0; i < m_array.size(); ++i) {
     211            if (!IDBIsValidKeyPath(m_array[i]))
     212                return false;
     213        }
     214        return true;
     215    }
     216    ASSERT_NOT_REACHED();
     217    return false;
     218}
     219
     220IDBKeyPath::operator PassRefPtr<IDBAny>() const
     221{
     222    switch (m_type) {
     223    case NullType:
     224        return IDBAny::createNull();
     225    case StringType:
     226        return IDBAny::createString(m_string);
     227    case ArrayType:
     228        RefPtr<DOMStringList> keyPaths = DOMStringList::create();
     229        for (Vector<String>::const_iterator it = m_array.begin(); it != m_array.end(); ++it)
     230        keyPaths->append(*it);
     231        return IDBAny::create(static_cast<PassRefPtr<DOMStringList> >(keyPaths));
     232    }
     233    ASSERT_NOT_REACHED();
     234    return 0;
     235}
     236
     237
    182238} // namespace WebCore
    183239
  • trunk/Source/WebCore/Modules/indexeddb/IDBKeyPath.h

    r109493 r117817  
    2929#if ENABLE(INDEXED_DATABASE)
    3030
    31 #include <wtf/PassRefPtr.h>
    32 #include <wtf/RefCounted.h>
     31#include "IDBAny.h"
     32#include "PlatformString.h"
    3333#include <wtf/Vector.h>
    34 #include <wtf/text/WTFString.h>
    3534
    3635namespace WebCore {
     
    4342};
    4443
    45 bool IDBIsValidKeyPath(const String&);
    4644void IDBParseKeyPath(const String&, Vector<String>&, IDBKeyPathParseError&);
     45
     46class IDBKeyPath {
     47public:
     48    IDBKeyPath() : m_type(NullType) { }
     49    IDBKeyPath(const String&);
     50    IDBKeyPath(const Vector<String>& array);
     51
     52    enum Type {
     53        NullType = 0,
     54        StringType,
     55        ArrayType
     56    };
     57
     58    Type type() const { return m_type; }
     59
     60    const Vector<String>& array() const
     61    {
     62        ASSERT(m_type == ArrayType);
     63        return m_array;
     64    }
     65
     66    const String& string() const
     67    {
     68        ASSERT(m_type == StringType);
     69        return m_string;
     70    }
     71
     72    bool isNull() const { return m_type == NullType; }
     73    bool isValid() const;
     74    operator PassRefPtr<IDBAny>() const;
     75
     76private:
     77    Type m_type;
     78    String m_string;
     79    Vector<String> m_array;
     80};
    4781
    4882} // namespace WebCore
  • trunk/Source/WebCore/Modules/indexeddb/IDBKeyPathBackendImpl.cpp

    r110539 r117817  
    3939namespace WebCore {
    4040
    41 void IDBKeyPathBackendImpl::createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue>, 0>&, const String&, Vector<RefPtr<IDBKey>, 0>&)
     41void IDBKeyPathBackendImpl::createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue>, 0>&, const IDBKeyPath&, Vector<RefPtr<IDBKey>, 0>&)
    4242{
    4343    // FIXME: Implement this method once JSC supports WireFormat for SerializedScriptValue.
    4444}
    4545
    46 PassRefPtr<SerializedScriptValue> IDBKeyPathBackendImpl::injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const String&)
     46PassRefPtr<SerializedScriptValue> IDBKeyPathBackendImpl::injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const IDBKeyPath&)
    4747{
    4848    // FIXME: Implement this method once JSC supports WireFormat for SerializedScriptValue.
  • trunk/Source/WebCore/Modules/indexeddb/IDBKeyPathBackendImpl.h

    r109493 r117817  
    3434
    3535class IDBKey;
     36class IDBKeyPath;
    3637class SerializedScriptValue;
    3738
    3839class IDBKeyPathBackendImpl {
    3940public:
    40     static void createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue>, 0>& values, const String& keyPath, Vector<RefPtr<IDBKey>, 0>& keys);
    41     static PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const String& keyPath);
     41    static void createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue>, 0>& values, const IDBKeyPath&, Vector<RefPtr<IDBKey>, 0>& keys);
     42    static PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const IDBKeyPath&);
    4243};
    4344
  • trunk/Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.cpp

    r116562 r117817  
    3333#include "FileSystem.h"
    3434#include "IDBFactoryBackendImpl.h"
     35#include "IDBKeyPath.h"
    3536#include "IDBKeyRange.h"
    3637#include "IDBLevelDBCoding.h"
     
    99100}
    100101
     102template <typename DBOrTransaction>
     103static bool putIDBKeyPath(DBOrTransaction* db, const Vector<char> key, const IDBKeyPath& value)
     104{
     105    if (!db->put(key, encodeIDBKeyPath(value)))
     106        return false;
     107    return true;
     108}
     109
    101110static int compareKeys(const LevelDBSlice& a, const LevelDBSlice& b)
    102111{
     
    328337}
    329338
    330 void IDBLevelDBBackingStore::getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<String>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags)
     339void IDBLevelDBBackingStore::getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags)
    331340{
    332341    const Vector<char> startKey = ObjectStoreMetaDataKey::encode(databaseId, 1, 0);
     
    364373            return;
    365374        }
    366         String keyPath = decodeString(it->value().begin(), it->value().end());
    367         bool hasKeyPath = true;
     375        IDBKeyPath keyPath = decodeIDBKeyPath(it->value().begin(), it->value().end());
    368376
    369377        it->next();
     
    394402        it->next(); // [optional] has key path (is not null)
    395403        if (checkObjectStoreAndMetaDataType(it.get(), stopKey, objectStoreId, ObjectStoreMetaDataKey::kHasKeyPath)) {
    396             hasKeyPath = decodeBool(it->value().begin(), it->value().end());
    397             if (!hasKeyPath && !keyPath.isEmpty()) {
     404            bool hasKeyPath = decodeBool(it->value().begin(), it->value().end());
     405            // This check accounts for two layers of legacy coding:
     406            // (1) Initially, hasKeyPath was added to distinguish null vs. string.
     407            // (2) Later, null vs. string vs. array was stored in the keyPath itself.
     408            // So this check is only relevant for string-type keyPaths.
     409            if (!hasKeyPath && (keyPath.type() == IDBKeyPath::StringType && !keyPath.string().isEmpty())) {
    398410                LOG_ERROR("Internal Indexed DB error.");
    399411                return;
    400412            }
     413            if (!hasKeyPath)
     414                keyPath = IDBKeyPath();
    401415            it->next();
    402416        }
     
    404418        foundIds.append(objectStoreId);
    405419        foundNames.append(objectStoreName);
    406         foundKeyPaths.append(hasKeyPath ? keyPath : String());
     420        foundKeyPaths.append(keyPath);
    407421        foundAutoIncrementFlags.append(autoIncrement);
    408422    }
     
    425439}
    426440
    427 bool IDBLevelDBBackingStore::createObjectStore(int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement, int64_t& assignedObjectStoreId)
     441bool IDBLevelDBBackingStore::createObjectStore(int64_t databaseId, const String& name, const IDBKeyPath& keyPath, bool autoIncrement, int64_t& assignedObjectStoreId)
    428442{
    429443    ASSERT(m_currentTransaction);
     
    447461    }
    448462
    449     ok = putString(m_currentTransaction.get(), keyPathKey, keyPath);
     463    ok = putIDBKeyPath(m_currentTransaction.get(), keyPathKey, keyPath);
    450464    if (!ok) {
    451465        LOG_ERROR("Internal Indexed DB error.");
     
    718732
    719733
    720 void IDBLevelDBBackingStore::getIndexes(int64_t databaseId, int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<String>& foundKeyPaths, Vector<bool>& foundUniqueFlags, Vector<bool>& foundMultiEntryFlags)
     734void IDBLevelDBBackingStore::getIndexes(int64_t databaseId, int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundUniqueFlags, Vector<bool>& foundMultiEntryFlags)
    721735{
    722736    const Vector<char> startKey = IndexMetaDataKey::encode(databaseId, objectStoreId, 0, 0);
     
    761775            return;
    762776        }
    763         String keyPath = decodeString(it->value().begin(), it->value().end());
     777        IDBKeyPath keyPath = decodeIDBKeyPath(it->value().begin(), it->value().end());
    764778
    765779        it->next(); // [optional] multiEntry flag
     
    794808}
    795809
    796 bool IDBLevelDBBackingStore::createIndex(int64_t databaseId, int64_t objectStoreId, const String& name, const String& keyPath, bool isUnique, bool isMultiEntry, int64_t& indexId)
     810bool IDBLevelDBBackingStore::createIndex(int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath& keyPath, bool isUnique, bool isMultiEntry, int64_t& indexId)
    797811{
    798812    ASSERT(m_currentTransaction);
     
    818832    }
    819833
    820     ok = putString(m_currentTransaction.get(), keyPathKey, keyPath);
     834    ok = putIDBKeyPath(m_currentTransaction.get(), keyPathKey, keyPath);
    821835    if (!ok) {
    822836        LOG_ERROR("Internal Indexed DB error.");
  • trunk/Source/WebCore/Modules/indexeddb/IDBLevelDBBackingStore.h

    r116562 r117817  
    5151    virtual bool deleteDatabase(const String& name);
    5252
    53     virtual void getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<String>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags);
    54     virtual bool createObjectStore(int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement, int64_t& assignedObjectStoreId);
     53    virtual void getObjectStores(int64_t databaseId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundAutoIncrementFlags);
     54    virtual bool createObjectStore(int64_t databaseId, const String& name, const IDBKeyPath&, bool autoIncrement, int64_t& assignedObjectStoreId);
    5555    virtual void deleteObjectStore(int64_t databaseId, int64_t objectStoreId);
    5656    virtual PassRefPtr<ObjectStoreRecordIdentifier> createInvalidRecordIdentifier();
     
    6464    virtual bool forEachObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, ObjectStoreRecordCallback&);
    6565
    66     virtual void getIndexes(int64_t databaseId, int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<String>& foundKeyPaths, Vector<bool>& foundUniqueFlags, Vector<bool>& foundMultiEntryFlags);
    67     virtual bool createIndex(int64_t databaseId, int64_t objectStoreId, const String& name, const String& keyPath, bool isUnique, bool isMultiEntry, int64_t& indexId);
     66    virtual void getIndexes(int64_t databaseId, int64_t objectStoreId, Vector<int64_t>& foundIds, Vector<String>& foundNames, Vector<IDBKeyPath>& foundKeyPaths, Vector<bool>& foundUniqueFlags, Vector<bool>& foundMultiEntryFlags);
     67    virtual bool createIndex(int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath&, bool isUnique, bool isMultiEntry, int64_t& indexId);
    6868    virtual void deleteIndex(int64_t databaseId, int64_t objectStoreId, int64_t indexId);
    6969    virtual bool putIndexDataForRecord(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKey&, const ObjectStoreRecordIdentifier*);
  • trunk/Source/WebCore/Modules/indexeddb/IDBLevelDBCoding.cpp

    r116333 r117817  
    3131
    3232#include "IDBKey.h"
     33#include "IDBKeyPath.h"
    3334#include "LevelDBSlice.h"
    3435#include <wtf/text/StringBuilder.h>
     
    142143static const unsigned char kIDBKeyArrayTypeByte = 4;
    143144static const unsigned char kIDBKeyMinKeyTypeByte = 5;
     145
     146static const unsigned char kIDBKeyPathTypeCodedByte1 = 0;
     147static const unsigned char kIDBKeyPathTypeCodedByte2 = 0;
    144148
    145149static const unsigned char kObjectStoreDataIndexId = 1;
     
    627631}
    628632
     633Vector<char> encodeIDBKeyPath(const IDBKeyPath& keyPath)
     634{
     635    // May be typed, or may be a raw string. An invalid leading
     636    // byte is used to identify typed coding. New records are
     637    // always written as typed.
     638    Vector<char> ret;
     639    ret.append(kIDBKeyPathTypeCodedByte1);
     640    ret.append(kIDBKeyPathTypeCodedByte2);
     641    ret.append(static_cast<char>(keyPath.type()));
     642    switch (keyPath.type()) {
     643    case IDBKeyPath::NullType:
     644        break;
     645    case IDBKeyPath::StringType:
     646        ret.append(encodeStringWithLength(keyPath.string()));
     647        break;
     648    case IDBKeyPath::ArrayType: {
     649        const Vector<String>& array = keyPath.array();
     650        size_t count = array.size();
     651        ret.append(encodeVarInt(count));
     652        for (size_t i = 0; i < count; ++i)
     653            ret.append(encodeStringWithLength(array[i]));
     654        break;
     655    }
     656    }
     657    return ret;
     658}
     659
     660IDBKeyPath decodeIDBKeyPath(const char* p, const char* limit)
     661{
     662    // May be typed, or may be a raw string. An invalid leading
     663    // byte sequence is used to identify typed coding. New records are
     664    // always written as typed.
     665    if (p == limit || (limit - p >= 2 && (*p != kIDBKeyPathTypeCodedByte1 || *(p + 1) != kIDBKeyPathTypeCodedByte2)))
     666        return IDBKeyPath(decodeString(p, limit));
     667    p += 2;
     668
     669    ASSERT(p != limit);
     670    IDBKeyPath::Type type = static_cast<IDBKeyPath::Type>(*p++);
     671    switch (type) {
     672    case IDBKeyPath::NullType:
     673        ASSERT(p == limit);
     674        return IDBKeyPath();
     675    case IDBKeyPath::StringType: {
     676        String string;
     677        p = decodeStringWithLength(p, limit, string);
     678        ASSERT(p == limit);
     679        return IDBKeyPath(string);
     680    }
     681    case IDBKeyPath::ArrayType: {
     682        Vector<String> array;
     683        int64_t count;
     684        p = decodeVarInt(p, limit, count);
     685        ASSERT(p);
     686        ASSERT(count >= 0);
     687        while (count--) {
     688            String string;
     689            p = decodeStringWithLength(p, limit, string);
     690            ASSERT(p);
     691            array.append(string);
     692        }
     693        ASSERT(p == limit);
     694        return IDBKeyPath(array);
     695    }
     696    }
     697    ASSERT_NOT_REACHED();
     698    return IDBKeyPath();
     699}
     700
    629701namespace {
    630702template<typename KeyType>
  • trunk/Source/WebCore/Modules/indexeddb/IDBLevelDBCoding.h

    r116170 r117817  
    3737
    3838class IDBKey;
     39class IDBKeyPath;
    3940class LevelDBSlice;
    4041
     
    6465const char* extractEncodedIDBKey(const char* start, const char* limit, Vector<char>* result);
    6566int compareEncodedIDBKeys(const Vector<char>&, const Vector<char>&);
     67Vector<char> encodeIDBKeyPath(const IDBKeyPath&);
     68IDBKeyPath decodeIDBKeyPath(const char*, const char*);
    6669
    6770int compare(const LevelDBSlice&, const LevelDBSlice&, bool indexKeys = false);
  • trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp

    r117509 r117817  
    6161}
    6262
    63 String IDBObjectStore::keyPath() const
     63PassRefPtr<IDBAny> IDBObjectStore::keyPath() const
    6464{
    6565    IDB_TRACE("IDBObjectStore::keyPath");
     
    212212PassRefPtr<IDBIndex> IDBObjectStore::createIndex(const String& name, const String& keyPath, const Dictionary& options, ExceptionCode& ec)
    213213{
     214    return createIndex(name, IDBKeyPath(keyPath), options, ec);
     215}
     216
     217PassRefPtr<IDBIndex> IDBObjectStore::createIndex(const String& name, const IDBKeyPath& keyPath, const Dictionary& options, ExceptionCode& ec)
     218{
    214219    IDB_TRACE("IDBObjectStore::createIndex");
    215     if (!IDBIsValidKeyPath(keyPath)) {
     220    if (!keyPath.isValid()) {
    216221        ec = IDBDatabaseException::NON_TRANSIENT_ERR;
    217222        return 0;
  • trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h

    r117509 r117817  
    5858    // Implement the IDBObjectStore IDL
    5959    String name() const;
    60     String keyPath() const;
     60    PassRefPtr<IDBAny> keyPath() const;
    6161    PassRefPtr<DOMStringList> indexNames() const;
    6262    IDBTransaction* transaction() const;
     
    8080
    8181    PassRefPtr<IDBIndex> createIndex(const String& name, const String& keyPath, const Dictionary&, ExceptionCode&);
     82    PassRefPtr<IDBIndex> createIndex(const String&, const IDBKeyPath&, const Dictionary&, ExceptionCode&);
     83
    8284    PassRefPtr<IDBIndex> index(const String& name, ExceptionCode&);
    8385    void deleteIndex(const String& name, ExceptionCode&);
  • trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.idl

    r117509 r117817  
    3030    ] IDBObjectStore {
    3131        readonly attribute [TreatReturnedNullStringAs=Null] DOMString name;
    32         readonly attribute [TreatReturnedNullStringAs=Null] DOMString keyPath;
     32        readonly attribute IDBAny keyPath;
    3333        readonly attribute DOMStringList indexNames;
    3434        readonly attribute IDBTransaction transaction;
  • trunk/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp

    r117808 r117817  
    5252}
    5353
    54 IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, int64_t id, const String& name, const String& keyPath, bool autoIncrement)
     54IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, int64_t id, const String& name, const IDBKeyPath& keyPath, bool autoIncrement)
    5555    : m_backingStore(backingStore)
    5656    , m_databaseId(databaseId)
     
    6464}
    6565
    66 IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement)
     66IDBObjectStoreBackendImpl::IDBObjectStoreBackendImpl(IDBBackingStore* backingStore, int64_t databaseId, const String& name, const IDBKeyPath& keyPath, bool autoIncrement)
    6767    : m_backingStore(backingStore)
    6868    , m_databaseId(databaseId)
     
    138138}
    139139
    140 static PassRefPtr<IDBKey> fetchKeyFromKeyPath(SerializedScriptValue* value, const String& keyPath)
     140static PassRefPtr<IDBKey> fetchKeyFromKeyPath(SerializedScriptValue* value, const IDBKeyPath& keyPath)
    141141{
    142142    IDB_TRACE("IDBObjectStoreBackendImpl::fetchKeyFromKeyPath");
     143    ASSERT(!keyPath.isNull());
     144
    143145    Vector<RefPtr<SerializedScriptValue> > values;
    144146    values.append(value);
     
    151153}
    152154
    153 static PassRefPtr<SerializedScriptValue> injectKeyIntoKeyPath(PassRefPtr<IDBKey> key, PassRefPtr<SerializedScriptValue> value, const String& keyPath)
     155static PassRefPtr<SerializedScriptValue> injectKeyIntoKeyPath(PassRefPtr<IDBKey> key, PassRefPtr<SerializedScriptValue> value, const IDBKeyPath& keyPath)
    154156{
    155157    IDB_TRACE("IDBObjectStoreBackendImpl::injectKeyIntoKeyPath");
     
    498500}
    499501
    500 PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreBackendImpl::createIndex(const String& name, const String& keyPath, bool unique, bool multiEntry, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
     502PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreBackendImpl::createIndex(const String& name, const IDBKeyPath& keyPath, bool unique, bool multiEntry, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
    501503{
    502504    if (name.isNull()) {
     
    649651    Vector<int64_t> ids;
    650652    Vector<String> names;
    651     Vector<String> keyPaths;
     653    Vector<IDBKeyPath> keyPaths;
    652654    Vector<bool> uniqueFlags;
    653655    Vector<bool> multiEntryFlags;
  • trunk/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.h

    r117334 r117817  
    2727#define IDBObjectStoreBackendImpl_h
    2828
     29#include "IDBKeyPath.h"
    2930#include "IDBObjectStoreBackendInterface.h"
    3031#include <wtf/HashMap.h>
     
    4344class IDBObjectStoreBackendImpl : public IDBObjectStoreBackendInterface {
    4445public:
    45     static PassRefPtr<IDBObjectStoreBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, int64_t id, const String& name, const String& keyPath, bool autoIncrement)
     46    static PassRefPtr<IDBObjectStoreBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, int64_t id, const String& name, const IDBKeyPath& keyPath, bool autoIncrement)
    4647    {
    4748        return adoptRef(new IDBObjectStoreBackendImpl(backingStore, databaseId, id, name, keyPath, autoIncrement));
    4849    }
    49     static PassRefPtr<IDBObjectStoreBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement)
     50    static PassRefPtr<IDBObjectStoreBackendImpl> create(IDBBackingStore* backingStore, int64_t databaseId, const String& name, const IDBKeyPath& keyPath, bool autoIncrement)
    5051    {
    5152        return adoptRef(new IDBObjectStoreBackendImpl(backingStore, databaseId, name, keyPath, autoIncrement));
     
    6263
    6364    virtual String name() const { return m_name; }
    64     virtual String keyPath() const { return m_keyPath; }
     65    virtual IDBKeyPath keyPath() const { return m_keyPath; }
    6566    virtual PassRefPtr<DOMStringList> indexNames() const;
    6667    virtual bool autoIncrement() const { return m_autoIncrement; }
     
    7374    virtual void clear(PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&);
    7475
    75     virtual PassRefPtr<IDBIndexBackendInterface> createIndex(const String& name, const String& keyPath, bool unique, bool multiEntry, IDBTransactionBackendInterface*, ExceptionCode&);
     76    virtual PassRefPtr<IDBIndexBackendInterface> createIndex(const String& name, const IDBKeyPath&, bool unique, bool multiEntry, IDBTransactionBackendInterface*, ExceptionCode&);
    7677    virtual PassRefPtr<IDBIndexBackendInterface> index(const String& name, ExceptionCode&);
    7778    virtual void deleteIndex(const String& name, IDBTransactionBackendInterface*, ExceptionCode&);
     
    8384
    8485private:
    85     IDBObjectStoreBackendImpl(IDBBackingStore*, int64_t databaseId, int64_t id, const String& name, const String& keyPath, bool autoIncrement);
    86     IDBObjectStoreBackendImpl(IDBBackingStore*, int64_t databaseId, const String& name, const String& keyPath, bool autoIncrement);
     86    IDBObjectStoreBackendImpl(IDBBackingStore*, int64_t databaseId, int64_t id, const String& name, const IDBKeyPath&, bool autoIncrement);
     87    IDBObjectStoreBackendImpl(IDBBackingStore*, int64_t databaseId, const String& name, const IDBKeyPath&, bool autoIncrement);
    8788
    8889    void loadIndexes();
     
    113114    int64_t m_id;
    114115    String m_name;
    115     String m_keyPath;
     116    IDBKeyPath m_keyPath;
    116117    bool m_autoIncrement;
    117118
  • trunk/Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendInterface.h

    r117509 r117817  
    3838class IDBIndexBackendInterface;
    3939class IDBKey;
     40class IDBKeyPath;
    4041class IDBKeyRange;
    4142class IDBTransactionBackendInterface;
     
    4950
    5051    virtual String name() const = 0;
    51     virtual String keyPath() const = 0;
     52    virtual IDBKeyPath keyPath() const = 0;
    5253    virtual PassRefPtr<DOMStringList> indexNames() const = 0;
    5354    virtual bool autoIncrement() const = 0;
     
    6667    virtual void clear(PassRefPtr<IDBCallbacks>, IDBTransactionBackendInterface*, ExceptionCode&) = 0;
    6768
    68     virtual PassRefPtr<IDBIndexBackendInterface> createIndex(const String& name, const String& keyPath, bool unique, bool multiEntry, IDBTransactionBackendInterface*, ExceptionCode&) = 0;
     69    virtual PassRefPtr<IDBIndexBackendInterface> createIndex(const String& name, const IDBKeyPath&, bool unique, bool multiEntry, IDBTransactionBackendInterface*, ExceptionCode&) = 0;
    6970    virtual PassRefPtr<IDBIndexBackendInterface> index(const String& name, ExceptionCode&) = 0;
    7071    virtual void deleteIndex(const String& name, IDBTransactionBackendInterface*, ExceptionCode&) = 0;
  • trunk/Source/WebCore/bindings/v8/Dictionary.cpp

    r115264 r117817  
    425425}
    426426
     427bool Dictionary::get(const String& key, Vector<String>& value) const
     428{
     429    v8::Local<v8::Value> v8Value;
     430    if (!getKey(key, v8Value))
     431        return false;
     432
     433    if (!v8Value->IsArray())
     434        return false;
     435
     436    v8::Local<v8::Array> v8Array = v8::Local<v8::Array>::Cast(v8Value);
     437    for (size_t i = 0; i < v8Array->Length(); ++i) {
     438        v8::Local<v8::Value> indexedValue = v8Array->Get(v8::Uint32::New(i));
     439        value.append(v8ValueToWebCoreString(indexedValue));
     440    }
     441
     442    return true;
     443}
    427444
    428445bool Dictionary::getOwnPropertiesAsStringHashMap(WTF::HashMap<String, String>& hashMap) const
  • trunk/Source/WebCore/bindings/v8/Dictionary.h

    r115264 r117817  
    3434#include <wtf/HashMap.h>
    3535#include <wtf/HashSet.h>
     36#include <wtf/Vector.h>
    3637#include <wtf/text/AtomicString.h>
    3738
    3839namespace WebCore {
    3940
    40 class DOMStringList;
    4141class DOMWindow;
    4242class IDBKeyRange;
     
    8686    bool get(const String&, HashSet<AtomicString>&) const;
    8787    bool get(const String&, Dictionary&) const;
     88    bool get(const String&, Vector<String>&) const;
    8889    bool getOwnPropertiesAsStringHashMap(WTF::HashMap<String, String>&) const;
    8990
  • trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.cpp

    r113395 r117817  
    154154} // anonymous namespace
    155155
    156 PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue> value, const Vector<String>& keyPath)
     156PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue> value, const IDBKeyPath& keyPath)
    157157{
    158158    IDB_TRACE("createIDBKeyFromSerializedValueAndKeyPath");
     159    ASSERT(keyPath.type() == IDBKeyPath::StringType);
     160    Vector<String> keyPathElements;
     161    IDBKeyPathParseError error;
     162    IDBParseKeyPath(keyPath.string(), keyPathElements, error);
     163    ASSERT(error == IDBKeyPathParseErrorNone);
     164
    159165    V8AuxiliaryContext context;
    160166    v8::Handle<v8::Value> v8Value(value->deserialize());
    161     v8::Handle<v8::Value> v8Key(getNthValueOnKeyPath(v8Value, keyPath, keyPath.size()));
     167    v8::Handle<v8::Value> v8Key(getNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.size()));
    162168    if (v8Key.IsEmpty())
    163169        return 0;
     
    165171}
    166172
    167 PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey> key, PassRefPtr<SerializedScriptValue> value, const Vector<String>& keyPath)
     173PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey> key, PassRefPtr<SerializedScriptValue> value, const IDBKeyPath& keyPath)
    168174{
    169175    IDB_TRACE("injectIDBKeyIntoSerializedValue");
     176
     177    ASSERT(keyPath.type() == IDBKeyPath::StringType);
     178    Vector<String> keyPathElements;
     179    IDBKeyPathParseError error;
     180    IDBParseKeyPath(keyPath.string(), keyPathElements, error);
     181    ASSERT(error == IDBKeyPathParseErrorNone);
     182
     183    if (!keyPathElements.size())
     184        return 0;
     185
    170186    V8AuxiliaryContext context;
    171     if (!keyPath.size())
    172         return 0;
    173 
    174187    v8::Handle<v8::Value> v8Value(value->deserialize());
    175     v8::Handle<v8::Value> parent(ensureNthValueOnKeyPath(v8Value, keyPath, keyPath.size() - 1));
     188    v8::Handle<v8::Value> parent(ensureNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.size() - 1));
    176189    if (parent.IsEmpty())
    177190        return 0;
    178191
    179     if (!set(parent, keyPath.last(), toV8(key.get())))
     192    if (!set(parent, keyPathElements.last(), toV8(key.get())))
    180193        return 0;
    181194
  • trunk/Source/WebCore/bindings/v8/IDBBindingUtilities.h

    r95901 r117817  
    3535
    3636class IDBKey;
     37class IDBKeyPath;
    3738class SerializedScriptValue;
    3839
    3940PassRefPtr<IDBKey> createIDBKeyFromValue(v8::Handle<v8::Value>);
    40 PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue>,  const Vector<String, 0>&);
    41 PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const Vector<String, 0>&);
     41PassRefPtr<IDBKey> createIDBKeyFromSerializedValueAndKeyPath(PassRefPtr<SerializedScriptValue>, const IDBKeyPath&);
     42PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const IDBKeyPath&);
    4243
    4344}
  • trunk/Source/WebCore/bindings/v8/custom/V8IDBAnyCustom.cpp

    r117381 r117817  
    3333
    3434#include "SerializedScriptValue.h"
     35#include "V8Binding.h"
    3536#include "V8DOMStringList.h"
    3637#include "V8IDBCursor.h"
     
    7576    case IDBAny::SerializedScriptValueType:
    7677        return impl->serializedScriptValue()->deserialize(0, isolate);
     78    case IDBAny::StringType:
     79        return v8String(impl->string());
    7780    }
    7881
  • trunk/Source/WebCore/dom/DOMStringList.h

    r109305 r117817  
    5353    bool contains(const String& str) const;
    5454
     55    operator const Vector<String>&() const { return m_strings; }
     56
    5557private:
    5658    DOMStringList() { }
  • trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp

    r117338 r117817  
    4747#include "IDBIndexBackendInterface.h"
    4848#include "IDBKey.h"
     49#include "IDBKeyPath.h"
    4950#include "IDBKeyRange.h"
    5051#include "IDBObjectStoreBackendInterface.h"
     
    226227}
    227228
     229static String keyPathToString(const IDBKeyPath& keyPath)
     230{
     231    // FIXME: Replace with handlers for null/string/array types.
     232    // https://bugs.webkit.org/show_bug.cgi?id=84303
     233    switch (keyPath.type()) {
     234    case IDBKeyPath::NullType:
     235        return "(none)";
     236        break;
     237    case IDBKeyPath::StringType:
     238        return keyPath.string();
     239        break;
     240    case IDBKeyPath::ArrayType:
     241        return "[...]";
     242        break;
     243    }
     244    ASSERT_NOT_REACHED();
     245    return String();
     246}
     247
    228248class DatabaseLoaderCallback : public ExecutableWithDatabase {
    229249public:
     
    261281                RefPtr<ObjectStoreIndex> objectStoreIndex = ObjectStoreIndex::create()
    262282                    .setName(idbIndex->name())
    263                     .setKeyPath(idbIndex->keyPath())
     283                    .setKeyPath(keyPathToString(idbIndex->keyPath()))
    264284                    .setUnique(idbIndex->unique())
    265285                    .setMultiEntry(idbIndex->multiEntry());
     
    269289            RefPtr<ObjectStore> objectStore = ObjectStore::create()
    270290                .setName(idbObjectStore->name())
    271                 .setKeyPath(idbObjectStore->keyPath())
     291                .setKeyPath(keyPathToString(idbObjectStore->keyPath()))
    272292                .setIndexes(indexes);
    273293            objectStores->addItem(objectStore);
  • trunk/Source/WebCore/platform/chromium/PlatformSupport.h

    r117766 r117817  
    7979class IDBFactoryBackendInterface;
    8080class IDBKey;
     81class IDBKeyPath;
    8182class IntRect;
    8283class KURL;
     
    179180    static PassRefPtr<IDBFactoryBackendInterface> idbFactory();
    180181    // Extracts keyPath from values and returns the corresponding keys.
    181     static void createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue> >& values, const String& keyPath, Vector<RefPtr<IDBKey> >& keys);
     182    static void createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue> >& values, const IDBKeyPath&, Vector<RefPtr<IDBKey> >& keys);
    182183    // Injects key via keyPath into value. Returns true on success.
    183     static PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const String& keyPath);
     184    static PassRefPtr<SerializedScriptValue> injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey>, PassRefPtr<SerializedScriptValue>, const IDBKeyPath&);
    184185
    185186    // JavaScript ---------------------------------------------------------
  • trunk/Source/WebCore/storage/chromium/IDBKeyPathBackendImpl.cpp

    r95901 r117817  
    3535namespace WebCore {
    3636
    37 void IDBKeyPathBackendImpl::createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue>, 0>& values,  const String& keyPath, Vector<RefPtr<IDBKey>, 0>& keys)
     37void IDBKeyPathBackendImpl::createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue>, 0>& values, const IDBKeyPath& keyPath, Vector<RefPtr<IDBKey>, 0>& keys)
    3838{
    3939    PlatformSupport::createIDBKeysFromSerializedValuesAndKeyPath(values, keyPath, keys);
    4040}
    4141
    42 PassRefPtr<SerializedScriptValue> IDBKeyPathBackendImpl::injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey> key, PassRefPtr<SerializedScriptValue> value, const String& keyPath)
     42PassRefPtr<SerializedScriptValue> IDBKeyPathBackendImpl::injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey> key, PassRefPtr<SerializedScriptValue> value, const IDBKeyPath& keyPath)
    4343{
    4444    return PlatformSupport::injectIDBKeyIntoSerializedValue(key, value, keyPath);
  • trunk/Source/WebKit/chromium/ChangeLog

    r117802 r117817  
     12012-05-21  Joshua Bell  <jsbell@chromium.org>
     2
     3        IndexedDB: Store key paths in IDBKeyPath type instead of String
     4        https://bugs.webkit.org/show_bug.cgi?id=85298
     5
     6        Reviewed by Tony Chang, Kentaro Hara and James Robinson.
     7
     8        No functional changes, just finish migration from String to IDBKeyPath
     9        for storing key paths, for eventual array support http://webkit.org/b/84207
     10
     11        * public/WebIDBDatabase.h: Remove temporary overload.
     12        (WebKit):
     13        (WebKit::WebIDBDatabase::objectStoreNames):
     14        * public/WebIDBIndex.h: Remove temporary method.
     15        (WebKit::WebIDBIndex::keyPath):
     16        * public/WebIDBKeyPath.h: Remove obsolete methods, wrap WebCore::IDBKeyPath
     17        (WebIDBKeyPath):
     18        (WebKit::WebIDBKeyPath::WebIDBKeyPath):
     19        * public/WebIDBObjectStore.h: Remove temporary method and overload.
     20        (WebKit::WebIDBObjectStore::keyPath):
     21        * public/platform/WebKitPlatformSupport.h: Remove temporary overloads.
     22        (WebKit):
     23        * src/AssertMatchingEnums.cpp: WebIDBKeyPath vs. IDBKeyPath enums.
     24        * src/IDBDatabaseBackendProxy.cpp: Switch from String to IDBKeyPath.
     25        (WebKit::IDBDatabaseBackendProxy::createObjectStore):
     26        * src/IDBDatabaseBackendProxy.h: Switch from String to IDBKeyPath.
     27        (IDBDatabaseBackendProxy):
     28        * src/IDBIndexBackendProxy.cpp: Switch from String to IDBKeyPath.
     29        (WebKit::IDBIndexBackendProxy::keyPath):
     30        * src/IDBIndexBackendProxy.h: Switch from String to IDBKeyPath.
     31        (IDBIndexBackendProxy):
     32        * src/IDBObjectStoreBackendProxy.cpp: Switch from String to IDBKeyPath.
     33        (WebKit::IDBObjectStoreBackendProxy::keyPath):
     34        (WebKit::IDBObjectStoreBackendProxy::createIndex):
     35        * src/IDBObjectStoreBackendProxy.h: Switch from String to IDBKeyPath.
     36        (IDBObjectStoreBackendProxy):
     37        * src/PlatformSupport.cpp: Switch from String to IDBKeyPath.
     38        (WebCore::PlatformSupport::createIDBKeysFromSerializedValuesAndKeyPath):
     39        (WebCore::PlatformSupport::injectIDBKeyIntoSerializedValue):
     40        * src/WebIDBDatabaseImpl.cpp: Switch from String to IDBKeyPath.
     41        (WebKit::WebIDBDatabaseImpl::createObjectStore):
     42        * src/WebIDBDatabaseImpl.h: Remove temporary overload.
     43        (WebIDBDatabaseImpl):
     44        * src/WebIDBIndexImpl.cpp: Remove temporary method.
     45        * src/WebIDBIndexImpl.h: Remove temporary method.
     46        (WebIDBIndexImpl):
     47        * src/WebIDBKeyPath.cpp: Remove most logic; just a wrapper for WebCore::IDBKeyPath.
     48        (WebKit::WebIDBKeyPath::~WebIDBKeyPath):
     49        (WebKit::WebIDBKeyPath::create):
     50        (WebKit::WebIDBKeyPath::createNull):
     51        (WebKit::WebIDBKeyPath::isValid):
     52        (WebKit::WebIDBKeyPath::type):
     53        (WebKit):
     54        (WebKit::WebIDBKeyPath::array):
     55        (WebKit::WebIDBKeyPath::string):
     56        (WebKit::WebIDBKeyPath::WebIDBKeyPath):
     57        (WebKit::WebIDBKeyPath::operator=):
     58        (WebKit::WebIDBKeyPath::operator const WebCore::IDBKeyPath&):
     59        * src/WebIDBObjectStoreImpl.cpp: Remove temporary method and overload.
     60        (WebKit::WebIDBObjectStoreImpl::keyPath):
     61        (WebKit::WebIDBObjectStoreImpl::createIndex):
     62        * src/WebIDBObjectStoreImpl.h: Remove temporary method and overload.
     63        (WebIDBObjectStoreImpl):
     64        * tests/IDBBindingUtilitiesTest.cpp: Use IDBKeyPath.
     65        (WebCore::checkKeyFromValueAndKeyPathInternal):
     66        (WebCore::injectKey):
     67        * tests/IDBLevelDBCodingTest.cpp: Added EncodeIDBKeyPath and DecodeIDBKeyPath tests.
     68        (IDBLevelDBCoding::TEST):
     69        (IDBLevelDBCoding):
     70        * tests/IDBKeyPathTest.cpp:
     71        (WebCore::checkKeyPath): Test IDBKeyPath validity.
     72
    1732012-05-18  Michael Nordman  <michaeln@google.com>
    274
  • trunk/Source/WebKit/chromium/public/WebIDBDatabase.h

    r115339 r117817  
    2929#include "WebDOMStringList.h"
    3030#include "WebExceptionCode.h"
    31 #include "WebIDBKeyPath.h"
    3231#include "platform/WebCommon.h"
    3332
     
    3736class WebIDBCallbacks;
    3837class WebIDBDatabaseCallbacks;
     38class WebIDBKeyPath;
    3939class WebIDBObjectStore;
    4040class WebIDBTransaction;
     
    5959        WEBKIT_ASSERT_NOT_REACHED();
    6060        return WebDOMStringList();
    61     }
    62     // FIXME: Remove WebString keyPath overload once callers are updated.
    63     // http://webkit.org/b/84207
    64     virtual WebIDBObjectStore* createObjectStore(const WebString& name, const WebString& keyPath, bool autoIncrement, const WebIDBTransaction& transaction, WebExceptionCode& ec)
    65     {
    66         return createObjectStore(name, WebIDBKeyPath(keyPath), autoIncrement, transaction, ec);
    6761    }
    6862    virtual WebIDBObjectStore* createObjectStore(const WebString&, const WebIDBKeyPath&, bool, const WebIDBTransaction&, WebExceptionCode&)
  • trunk/Source/WebKit/chromium/public/WebIDBIndex.h

    r117727 r117817  
    5050    virtual WebIDBKeyPath keyPath() const
    5151    {
    52         return WebIDBKeyPath(keyPathString());
    53     }
    54     // FIXME: Remove method once callers are updated.
    55     // http://webkit.org/b/84207
    56     virtual WebString keyPathString() const
    57     {
    5852        WEBKIT_ASSERT_NOT_REACHED();
    59         return WebString();
     53        return WebIDBKeyPath::createNull();
    6054    }
    6155    virtual bool unique() const
  • trunk/Source/WebKit/chromium/public/WebIDBKeyPath.h

    r115339 r117817  
    3737}
    3838
     39namespace WebCore { class IDBKeyPath; }
     40
    3941namespace WebKit {
    4042
     
    4547    WEBKIT_EXPORT static WebIDBKeyPath createNull();
    4648    WEBKIT_EXPORT WebIDBKeyPath(const WebIDBKeyPath&);
    47     ~WebIDBKeyPath() { reset(); }
     49    WEBKIT_EXPORT ~WebIDBKeyPath();
    4850
    4951    enum Type {
     
    5557    WEBKIT_EXPORT bool isValid() const;
    5658    WEBKIT_EXPORT Type type() const;
    57     // FIXME: Array-type key paths not yet supported. http://webkit.org/b/84207
    58     WebVector<WebString> array() const { WEBKIT_ASSERT_NOT_REACHED(); return WebVector<WebString>(); }
    59     WEBKIT_EXPORT WebString string() const;
    60 
    61     // FIXME: Remove these once callers are updated. http://webkit.org/b/84207
    62     WEBKIT_EXPORT WebIDBKeyPath(const WebString&);
    63     operator const WebString () const { return string(); }
    64     WEBKIT_EXPORT int parseError() const;
    65     WEBKIT_EXPORT void assign(const WebIDBKeyPath&);
    66     WEBKIT_EXPORT void reset();
     59    WEBKIT_EXPORT WebVector<WebString> array() const; // Only valid for ArrayType.
     60    WEBKIT_EXPORT WebString string() const; // Only valid for StringType.
    6761
    6862#if WEBKIT_IMPLEMENTATION
    69     operator const WTF::Vector<WTF::String, 0>& () const;
     63    WebIDBKeyPath(const WebCore::IDBKeyPath&);
     64    WebIDBKeyPath& operator=(const WebCore::IDBKeyPath&);
     65    operator const WebCore::IDBKeyPath&() const;
    7066#endif
    7167
    7268private:
    73     WebIDBKeyPath();
    74 
    75 #if WEBKIT_IMPLEMENTATION
    76     WebIDBKeyPath(const WTF::Vector<WTF::String, 0>&, int parseError);
    77 #endif
    78 
    79     WebPrivateOwnPtr<WTF::Vector<WTF::String, 0> > m_private;
    80     int m_parseError;
     69    WebPrivateOwnPtr<WebCore::IDBKeyPath> m_private;
    8170};
    8271
  • trunk/Source/WebKit/chromium/public/WebIDBObjectStore.h

    r117341 r117817  
    3131#include "WebIDBCallbacks.h"
    3232#include "WebIDBKeyPath.h"
    33 #include "WebIDBTransaction.h"
    3433#include "platform/WebCommon.h"
    3534#include "platform/WebString.h"
     
    5251    virtual WebIDBKeyPath keyPath() const
    5352    {
    54         return WebIDBKeyPath(keyPathString());
    55     }
    56     virtual WebString keyPathString() const
    57     {
    5853        WEBKIT_ASSERT_NOT_REACHED();
    59         return WebString();
     54        return WebIDBKeyPath::createNull();
    6055    }
    6156    virtual WebDOMStringList indexNames() const
     
    8277    virtual void deleteFunction(const WebIDBKeyRange&, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&) { WEBKIT_ASSERT_NOT_REACHED(); }
    8378    virtual void clear(WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&) { WEBKIT_ASSERT_NOT_REACHED(); }
    84 
    85     // FIXME: Remove WebString keyPath overload once callers are updated.
    86     // http://webkit.org/b/84207
    87     virtual WebIDBIndex* createIndex(const WebString& name, const WebString& keyPath, bool unique, bool multiEntry, const WebIDBTransaction& transaction, WebExceptionCode& ec)
    88     {
    89         return createIndex(name, WebIDBKeyPath(keyPath), unique, multiEntry, transaction, ec);
    90     }
    9179    virtual WebIDBIndex* createIndex(const WebString&, const WebIDBKeyPath&, bool, bool, const WebIDBTransaction&, WebExceptionCode&)
    9280    {
  • trunk/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h

    r117797 r117817  
    3232#define WebKitPlatformSupport_h
    3333
    34 #include "../WebIDBKeyPath.h" // FIXME: Remove with: http://webkit.org/b/84207
    3534#include "WebCommon.h"
    3635#include "WebGraphicsContext3D.h"
     
    5453class WebIDBFactory; // FIXME: Does this belong in platform?
    5554class WebIDBKey; // FIXME: Does this belong in platform?
     55class WebIDBKeyPath; // FIXME: Does this belong in platform?
    5656class WebMessagePortChannel; // FIXME: Does this belong in platform?
    5757class WebPluginListBuilder; // FIXME: Does this belong in platform?
     
    107107
    108108    virtual WebIDBFactory* idbFactory() { return 0; }
    109     // FIXME: Remove WebString keyPath overload once callers are updated.
    110     // http://webkit.org/b/84207
    111     virtual void createIDBKeysFromSerializedValuesAndKeyPath(const WebVector<WebSerializedScriptValue>& values,  const WebString& keyPath, WebVector<WebIDBKey>& keys) { createIDBKeysFromSerializedValuesAndKeyPath(values, WebIDBKeyPath(keyPath), keys); }
    112109    virtual void createIDBKeysFromSerializedValuesAndKeyPath(const WebVector<WebSerializedScriptValue>& values,  const WebIDBKeyPath& keyPath, WebVector<WebIDBKey>& keys) { }
    113     // FIXME: Remove WebString keyPath overload once callers are updated.
    114     // http://webkit.org/b/84207
    115     virtual WebSerializedScriptValue injectIDBKeyIntoSerializedValue(const WebIDBKey& key, const WebSerializedScriptValue& value, const WebString& keyPath) { return injectIDBKeyIntoSerializedValue(key, value, WebIDBKeyPath(keyPath)); }
    116110    virtual WebSerializedScriptValue injectIDBKeyIntoSerializedValue(const WebIDBKey& key, const WebSerializedScriptValue& value, const WebIDBKeyPath& keyPath) { return WebSerializedScriptValue(); }
    117111
  • trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp

    r117529 r117817  
    5353#include "IDBFactoryBackendInterface.h"
    5454#include "IDBKey.h"
     55#include "IDBKeyPath.h"
    5556#include "IceOptions.h"
    5657#include "IconURL.h"
     
    8788#include "WebIDBFactory.h"
    8889#include "WebIDBKey.h"
     90#include "WebIDBKeyPath.h"
    8991#include "WebIconURL.h"
    9092#include "WebInputElement.h"
     
    468470COMPILE_ASSERT_MATCHING_ENUM(WebIDBDatabaseExceptionQuotaError, IDBDatabaseException::QUOTA_ERR);
    469471
     472#if ENABLE(INDEXED_DATABASE)
    470473COMPILE_ASSERT_MATCHING_ENUM(WebIDBKey::InvalidType, IDBKey::InvalidType);
    471474COMPILE_ASSERT_MATCHING_ENUM(WebIDBKey::ArrayType, IDBKey::ArrayType);
     
    473476COMPILE_ASSERT_MATCHING_ENUM(WebIDBKey::DateType, IDBKey::DateType);
    474477COMPILE_ASSERT_MATCHING_ENUM(WebIDBKey::NumberType, IDBKey::NumberType);
     478
     479COMPILE_ASSERT_MATCHING_ENUM(WebIDBKeyPath::NullType, IDBKeyPath::NullType);
     480COMPILE_ASSERT_MATCHING_ENUM(WebIDBKeyPath::StringType, IDBKeyPath::StringType);
     481COMPILE_ASSERT_MATCHING_ENUM(WebIDBKeyPath::ArrayType, IDBKeyPath::ArrayType);
     482#endif
    475483
    476484#if ENABLE(FILE_SYSTEM)
  • trunk/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.cpp

    r95901 r117817  
    7676}
    7777
    78 PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseBackendProxy::createObjectStore(const String& name, const String& keyPath, bool autoIncrement, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
     78PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseBackendProxy::createObjectStore(const String& name, const IDBKeyPath& keyPath, bool autoIncrement, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
    7979{
    8080    // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer,
  • trunk/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.h

    r95901 r117817  
    4747    virtual PassRefPtr<WebCore::DOMStringList> objectStoreNames() const;
    4848
    49     virtual PassRefPtr<WebCore::IDBObjectStoreBackendInterface> createObjectStore(const String& name, const String& keyPath, bool autoIncrement, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&);
     49    virtual PassRefPtr<WebCore::IDBObjectStoreBackendInterface> createObjectStore(const String& name, const WebCore::IDBKeyPath&, bool autoIncrement, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&);
    5050    virtual void deleteObjectStore(const String& name, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&);
    5151    virtual void setVersion(const String& version, PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::IDBDatabaseCallbacks>, WebCore::ExceptionCode&);
  • trunk/Source/WebKit/chromium/src/IDBIndexBackendProxy.cpp

    r117512 r117817  
    3030
    3131#include "IDBCallbacks.h"
     32#include "IDBKeyPath.h"
    3233#include "IDBKeyRange.h"
    3334#include "IDBTransactionBackendProxy.h"
     
    6162}
    6263
    63 String IDBIndexBackendProxy::keyPath()
     64IDBKeyPath IDBIndexBackendProxy::keyPath()
    6465{
    65     return m_webIDBIndex->keyPath().string();
     66    return m_webIDBIndex->keyPath();
    6667}
    6768
  • trunk/Source/WebKit/chromium/src/IDBIndexBackendProxy.h

    r117512 r117817  
    3030
    3131#include "IDBIndexBackendInterface.h"
     32#include "IDBKeyPath.h"
    3233#include <wtf/OwnPtr.h>
    3334#include <wtf/PassOwnPtr.h>
     
    4344
    4445    virtual String name();
    45     virtual String keyPath();
     46    virtual WebCore::IDBKeyPath keyPath();
    4647    virtual bool unique();
    4748    virtual bool multiEntry();
  • trunk/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.cpp

    r117509 r117817  
    6565}
    6666
    67 String IDBObjectStoreBackendProxy::keyPath() const
     67IDBKeyPath IDBObjectStoreBackendProxy::keyPath() const
    6868{
    69     return m_webIDBObjectStore->keyPath().string();
     69    return m_webIDBObjectStore->keyPath();
    7070}
    7171
     
    120120}
    121121
    122 PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreBackendProxy::createIndex(const String& name, const String& keyPath, bool unique, bool multiEntry, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
     122PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreBackendProxy::createIndex(const String& name, const IDBKeyPath& keyPath, bool unique, bool multiEntry, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)
    123123{
    124124    // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer,
  • trunk/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.h

    r117509 r117817  
    2929#if ENABLE(INDEXED_DATABASE)
    3030
     31#include "IDBKeyPath.h"
    3132#include "IDBObjectStoreBackendInterface.h"
    3233#include <wtf/OwnPtr.h>
     
    4445
    4546    virtual String name() const;
    46     virtual String keyPath() const;
     47    virtual WebCore::IDBKeyPath keyPath() const;
    4748    virtual PassRefPtr<WebCore::DOMStringList> indexNames() const;
    4849    virtual bool autoIncrement() const;
     
    5455    virtual void clear(PassRefPtr<WebCore::IDBCallbacks>, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&);
    5556
    56     PassRefPtr<WebCore::IDBIndexBackendInterface> createIndex(const String& name, const String& keyPath, bool unique, bool multiEntry, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&);
     57    PassRefPtr<WebCore::IDBIndexBackendInterface> createIndex(const String& name, const WebCore::IDBKeyPath&, bool unique, bool multiEntry, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&);
    5758    PassRefPtr<WebCore::IDBIndexBackendInterface> index(const String& name, WebCore::ExceptionCode&);
    5859    void deleteIndex(const String& name, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&);
  • trunk/Source/WebKit/chromium/src/PlatformSupport.cpp

    r117766 r117817  
    4141#include "WebFrameImpl.h"
    4242#include "WebIDBKey.h"
     43#include "WebIDBKeyPath.h"
    4344#include "WebKit.h"
    4445#include "WebPluginContainerImpl.h"
     
    496497}
    497498
    498 void PlatformSupport::createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue> >& values, const String& keyPath, Vector<RefPtr<IDBKey> >& keys)
     499void PlatformSupport::createIDBKeysFromSerializedValuesAndKeyPath(const Vector<RefPtr<SerializedScriptValue> >& values, const IDBKeyPath& keyPath, Vector<RefPtr<IDBKey> >& keys)
    499500{
    500501    WebVector<WebSerializedScriptValue> webValues = values;
     
    508509}
    509510
    510 PassRefPtr<SerializedScriptValue> PlatformSupport::injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey> key, PassRefPtr<SerializedScriptValue> value, const String& keyPath)
     511PassRefPtr<SerializedScriptValue> PlatformSupport::injectIDBKeyIntoSerializedValue(PassRefPtr<IDBKey> key, PassRefPtr<SerializedScriptValue> value, const IDBKeyPath& keyPath)
    511512{
    512513    return webKitPlatformSupport()->injectIDBKeyIntoSerializedValue(key, value, keyPath);
  • trunk/Source/WebKit/chromium/src/WebIDBDatabaseImpl.cpp

    r104481 r117817  
    6767}
    6868
    69 WebIDBObjectStore* WebIDBDatabaseImpl::createObjectStore(const WebString& name, const WebString& keyPath, bool autoIncrement, const WebIDBTransaction& transaction, WebExceptionCode& ec)
     69WebIDBObjectStore* WebIDBDatabaseImpl::createObjectStore(const WebString& name, const WebIDBKeyPath& keyPath, bool autoIncrement, const WebIDBTransaction& transaction, WebExceptionCode& ec)
    7070{
    7171    RefPtr<IDBObjectStoreBackendInterface> objectStore = m_databaseBackend->createObjectStore(name, keyPath, autoIncrement, transaction.getIDBTransactionBackendInterface(), ec);
  • trunk/Source/WebKit/chromium/src/WebIDBDatabaseImpl.h

    r115339 r117817  
    5454    virtual WebDOMStringList objectStoreNames() const;
    5555
    56     // FIXME: Remove WebString keyPath overload once callers are updated.
    57     // http://webkit.org/b/84207
    58     virtual WebIDBObjectStore* createObjectStore(const WebString&, const WebString&, bool, const WebIDBTransaction&, WebExceptionCode&);
    59     virtual WebIDBObjectStore* createObjectStore(const WebString& name, const WebIDBKeyPath& keyPath, bool autoIncrement, const WebIDBTransaction& transaction, WebExceptionCode& ec) { return createObjectStore(name, keyPath.string(), autoIncrement, transaction, ec); }
     56    virtual WebIDBObjectStore* createObjectStore(const WebString& name, const WebIDBKeyPath&, bool autoIncrement, const WebIDBTransaction&, WebExceptionCode&);
    6057    virtual void deleteObjectStore(const WebString& name, const WebIDBTransaction&, WebExceptionCode&);
    6158    virtual void setVersion(const WebString& version, WebIDBCallbacks*, WebExceptionCode&);
  • trunk/Source/WebKit/chromium/src/WebIDBIndexImpl.cpp

    r117512 r117817  
    5959}
    6060
    61 // FIXME: Remove this method once callers are updated.
    62 // http://webkit.org/b/84207
    63 WebString WebIDBIndexImpl::keyPathString() const
    64 {
    65     return m_backend->keyPath();
    66 }
    67 
    6861bool WebIDBIndexImpl::unique() const
    6962{
  • trunk/Source/WebKit/chromium/src/WebIDBIndexImpl.h

    r117512 r117817  
    4646    virtual WebString name() const;
    4747    virtual WebIDBKeyPath keyPath() const;
    48     // FIXME: Remove this method once callers are updated.
    49     // http://webkit.org/b/84207
    50     virtual WebString keyPathString() const;
    5148    virtual bool unique() const;
    5249    virtual bool multiEntry() const;
  • trunk/Source/WebKit/chromium/src/WebIDBKeyPath.cpp

    r115339 r117817  
    3838namespace WebKit {
    3939
    40 WebIDBKeyPath WebIDBKeyPath::create(const WebVector<WebString>&)
     40WebIDBKeyPath::~WebIDBKeyPath()
    4141{
    42     // FIXME: Array-type key paths not yet supported. http://webkit.org/b/84207
    43     WEBKIT_ASSERT_NOT_REACHED();
    44     return createNull();
     42    m_private.reset(0);
    4543}
    4644
    4745WebIDBKeyPath WebIDBKeyPath::create(const WebString& keyPath)
    4846{
    49     if (keyPath.isNull())
    50         return createNull();
     47    return WebIDBKeyPath(IDBKeyPath(keyPath));
     48}
    5149
    52     WTF::Vector<WTF::String> idbElements;
    53     IDBKeyPathParseError idbError;
    54     IDBParseKeyPath(keyPath, idbElements, idbError);
    55     return WebIDBKeyPath(idbElements, static_cast<int>(idbError));
     50WebIDBKeyPath WebIDBKeyPath::create(const WebVector<WebString>& keyPath)
     51{
     52    Vector<String> strings;
     53    for (size_t i = 0; i < keyPath.size(); ++i)
     54        strings.append(keyPath[i]);
     55    return WebIDBKeyPath(IDBKeyPath(strings));
    5656}
    5757
    5858WebIDBKeyPath WebIDBKeyPath::createNull()
    5959{
    60     return WebIDBKeyPath(WebString());
    61 }
    62 
    63 WebIDBKeyPath::WebIDBKeyPath(const WebIDBKeyPath& keyPath)
    64 {
    65     assign(keyPath);
    66 }
    67 
    68 WebIDBKeyPath::WebIDBKeyPath(const WTF::Vector<WTF::String>& elements, int parseError)
    69     : m_private(new WTF::Vector<WTF::String>(elements))
    70     , m_parseError(parseError)
    71 {
     60    return WebIDBKeyPath(IDBKeyPath());
    7261}
    7362
    7463bool WebIDBKeyPath::isValid() const
    7564{
    76     return m_parseError == IDBKeyPathParseErrorNone;
     65    ASSERT(m_private.get());
     66    return m_private->isValid();
    7767}
    7868
    7969WebIDBKeyPath::Type WebIDBKeyPath::type() const
    8070{
    81     return m_private.get() ? StringType : NullType;
     71    ASSERT(m_private.get());
     72    return Type(m_private->type());
     73}
     74
     75
     76WebVector<WebString> WebIDBKeyPath::array() const
     77{
     78    ASSERT(m_private.get());
     79    ASSERT(m_private->type() == IDBKeyPath::ArrayType);
     80    return m_private->array();
    8281}
    8382
    8483WebString WebIDBKeyPath::string() const
    8584{
    86     if (!m_private.get())
    87         return WebString();
    88 
    89     // FIXME: Store the complete string instead of rebuilding it.
    90     // http://webkit.org/b/84207
    91     WTF::String string("");
    92     WTF::Vector<WTF::String>& array = *m_private.get();
    93     for (size_t i = 0; i < array.size(); ++i) {
    94         if (i)
    95             string.append(".");
    96         string.append(array[i]);
    97     }
    98     return WebString(string);
     85    ASSERT(m_private.get());
     86    ASSERT(m_private->type() == IDBKeyPath::StringType);
     87    return m_private->string();
    9988}
    10089
    101 WebIDBKeyPath::WebIDBKeyPath(const WebString& keyPath)
    102     : m_parseError(IDBKeyPathParseErrorNone)
     90WebIDBKeyPath::WebIDBKeyPath(const WebIDBKeyPath& keyPath)
     91    : m_private(new IDBKeyPath(keyPath))
    10392{
    104     if (!keyPath.isNull()) {
    105         m_private.reset(new WTF::Vector<WTF::String>());
    106         IDBKeyPathParseError idbParseError;
    107         IDBParseKeyPath(keyPath, *m_private.get(), idbParseError);
    108         m_parseError = idbParseError;
    109     }
     93    ASSERT(m_private.get());
    11094}
    11195
    112 int WebIDBKeyPath::parseError() const
     96WebIDBKeyPath::WebIDBKeyPath(const WebCore::IDBKeyPath& value)
     97    : m_private(new IDBKeyPath(value))
    11398{
    114     return m_parseError;
     99    ASSERT(m_private.get());
    115100}
    116101
    117 void WebIDBKeyPath::assign(const WebIDBKeyPath& keyPath)
     102WebIDBKeyPath& WebIDBKeyPath::operator=(const WebCore::IDBKeyPath& value)
    118103{
    119     m_parseError = keyPath.m_parseError;
    120     if (keyPath.m_private.get())
    121         m_private.reset(new WTF::Vector<WTF::String>(keyPath));
    122     else
    123         m_private.reset(0);
     104    ASSERT(m_private.get());
     105    m_private.reset(new IDBKeyPath(value));
     106    return *this;
    124107}
    125108
    126 void WebIDBKeyPath::reset()
    127 {
    128     m_private.reset(0);
    129 }
    130 
    131 WebIDBKeyPath::operator const WTF::Vector<WTF::String, 0>&() const
     109WebIDBKeyPath::operator const WebCore::IDBKeyPath&() const
    132110{
    133111    ASSERT(m_private.get());
    134     return *m_private.get();
     112    return *(m_private.get());
    135113}
    136114
  • trunk/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.cpp

    r117509 r117817  
    3232#include "IDBCallbacksProxy.h"
    3333#include "IDBIndexBackendInterface.h"
     34#include "IDBKeyPath.h"
    3435#include "IDBKeyRange.h"
    3536#include "IDBObjectStoreBackendInterface.h"
     
    5960
    6061WebIDBKeyPath WebIDBObjectStoreImpl::keyPath() const
    61 {
    62     return WebIDBKeyPath(m_objectStore->keyPath());
    63 }
    64 
    65 // FIXME: Remove this method once callers are updated.
    66 // http://webkit.org/b/84207
    67 WebString WebIDBObjectStoreImpl::keyPathString() const
    6862{
    6963    return m_objectStore->keyPath();
     
    10599}
    106100
    107 WebIDBIndex* WebIDBObjectStoreImpl::createIndex(const WebString& name, const WebString& keyPath, bool unique, bool multiEntry, const WebIDBTransaction& transaction, WebExceptionCode& ec)
     101WebIDBIndex* WebIDBObjectStoreImpl::createIndex(const WebString& name, const WebIDBKeyPath& keyPath, bool unique, bool multiEntry, const WebIDBTransaction& transaction, WebExceptionCode& ec)
    108102{
    109103    RefPtr<IDBIndexBackendInterface> index = m_objectStore->createIndex(name, keyPath, unique, multiEntry, transaction.getIDBTransactionBackendInterface(), ec);
  • trunk/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.h

    r117509 r117817  
    4848    WebString name() const;
    4949    WebIDBKeyPath keyPath() const;
    50     // FIXME: Remove this method once callers are updated.
    51     // http://webkit.org/b/84207
    52     WebString keyPathString() const;
    5350    WebDOMStringList indexNames() const;
    5451    bool autoIncrement() const;
     
    6057    void clear(WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&);
    6158
    62     // FIXME: Remove WebString keyPath overload once callers are updated.
    63     // http://webkit.org/b/84207
    64     WebIDBIndex* createIndex(const WebString&, const WebString&, bool, bool, const WebIDBTransaction&, WebExceptionCode&);
    65     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); }
     59    WebIDBIndex* createIndex(const WebString& name, const WebIDBKeyPath&, bool unique, bool multiEntry, const WebIDBTransaction&, WebExceptionCode&);
    6660    WebIDBIndex* index(const WebString& name, WebExceptionCode&);
    6761    void deleteIndex(const WebString& name, const WebIDBTransaction&, WebExceptionCode&);
  • trunk/Source/WebKit/chromium/tests/IDBBindingUtilitiesTest.cpp

    r110104 r117817  
    4242PassRefPtr<IDBKey> checkKeyFromValueAndKeyPathInternal(SerializedScriptValue* value, const String& keyPath)
    4343{
    44     Vector<String> idbKeyPath;
    45     IDBKeyPathParseError parseError;
    46     IDBParseKeyPath(keyPath, idbKeyPath, parseError);
    47     EXPECT_EQ(IDBKeyPathParseErrorNone, parseError);
     44    IDBKeyPath idbKeyPath(keyPath);
     45    EXPECT_TRUE(idbKeyPath.isValid());
    4846    return createIDBKeyFromSerializedValueAndKeyPath(value, idbKeyPath);
    4947}
     
    5755PassRefPtr<SerializedScriptValue> injectKey(PassRefPtr<IDBKey> key, PassRefPtr<SerializedScriptValue> value, const String& keyPath)
    5856{
    59     Vector<String> idbKeyPath;
    60     IDBKeyPathParseError parseError;
    61     IDBParseKeyPath(keyPath, idbKeyPath, parseError);
    62     EXPECT_EQ(IDBKeyPathParseErrorNone, parseError);
     57    IDBKeyPath idbKeyPath(keyPath);
     58    EXPECT_TRUE(idbKeyPath.isValid());
    6359    return injectIDBKeyIntoSerializedValue(key, value, idbKeyPath);
    6460}
  • trunk/Source/WebKit/chromium/tests/IDBKeyPathTest.cpp

    r95901 r117817  
    3838void checkKeyPath(const String& keyPath, const Vector<String>& expected, int parserError)
    3939{
     40    IDBKeyPath idbKeyPath(keyPath);
     41    ASSERT_EQ(idbKeyPath.type(), IDBKeyPath::StringType);
     42    ASSERT_EQ(idbKeyPath.isValid(), (parserError == IDBKeyPathParseErrorNone));
     43
    4044    IDBKeyPathParseError error;
    4145    Vector<String> keyPathElements;
  • trunk/Source/WebKit/chromium/tests/IDBLevelDBCodingTest.cpp

    r116333 r117817  
    3131
    3232#include "IDBKey.h"
     33#include "IDBKeyPath.h"
    3334#include "LevelDBSlice.h"
    3435#include <gtest/gtest.h>
     
    417418    EXPECT_EQ(v.data() + v.size(), p);
    418419    EXPECT_EQ(0, decodeIDBKey(v.data(), v.data() + v.size() - 1, decodedKey));
     420}
     421
     422TEST(IDBLevelDBCodingTest, EncodeIDBKeyPath)
     423{
     424    const unsigned char kIDBKeyPathTypeCodedByte1 = 0;
     425    const unsigned char kIDBKeyPathTypeCodedByte2 = 0;
     426    {
     427        IDBKeyPath keyPath;
     428        EXPECT_EQ(keyPath.type(), IDBKeyPath::NullType);
     429        Vector<char> v = encodeIDBKeyPath(keyPath);
     430        EXPECT_EQ(v.size(), 3U);
     431        EXPECT_EQ(v[0], kIDBKeyPathTypeCodedByte1);
     432        EXPECT_EQ(v[1], kIDBKeyPathTypeCodedByte2);
     433        EXPECT_EQ(v[2], IDBKeyPath::NullType);
     434    }
     435
     436    {
     437        Vector<String> testCases;
     438        testCases.append("");
     439        testCases.append("foo");
     440        testCases.append("foo.bar");
     441
     442        for (size_t i = 0; i < testCases.size(); ++i) {
     443            IDBKeyPath keyPath = IDBKeyPath(testCases[i]);
     444            Vector<char> v = encodeIDBKeyPath(keyPath);
     445            EXPECT_EQ(v.size(), encodeStringWithLength(testCases[i]).size() + 3);
     446            const char* p = v.data();
     447            const char* limit = v.data() + v.size();
     448            EXPECT_EQ(*p++, kIDBKeyPathTypeCodedByte1);
     449            EXPECT_EQ(*p++, kIDBKeyPathTypeCodedByte2);
     450            EXPECT_EQ(*p++, IDBKeyPath::StringType);
     451            String string;
     452            p = decodeStringWithLength(p, limit, string);
     453            EXPECT_EQ(string, testCases[i]);
     454            EXPECT_EQ(p, limit);
     455        }
     456    }
     457
     458    {
     459        Vector<String> testCase;
     460        testCase.append("");
     461        testCase.append("foo");
     462        testCase.append("foo.bar");
     463
     464        IDBKeyPath keyPath(testCase);
     465        EXPECT_EQ(keyPath.type(), IDBKeyPath::ArrayType);
     466        Vector<char> v = encodeIDBKeyPath(keyPath);
     467        const char* p = v.data();
     468        const char* limit = v.data() + v.size();
     469        EXPECT_EQ(*p++, kIDBKeyPathTypeCodedByte1);
     470        EXPECT_EQ(*p++, kIDBKeyPathTypeCodedByte2);
     471        EXPECT_EQ(*p++, IDBKeyPath::ArrayType);
     472        int64_t count;
     473        p = decodeVarInt(p, limit, count);
     474        EXPECT_EQ(count, static_cast<int64_t>(testCase.size()));
     475        for (size_t i = 0; i < static_cast<size_t>(count); ++i) {
     476            String string;
     477            p = decodeStringWithLength(p, limit, string);
     478            EXPECT_EQ(string, testCase[i]);
     479        }
     480        EXPECT_EQ(p, limit);
     481    }
     482}
     483
     484TEST(IDBLevelDBCodingTest, DecodeIDBKeyPath)
     485{
     486    const unsigned char kIDBKeyPathTypeCodedByte1 = 0;
     487    const unsigned char kIDBKeyPathTypeCodedByte2 = 0;
     488    {
     489        // Legacy encoding of string key paths.
     490        Vector<String> testCases;
     491        testCases.append("");
     492        testCases.append("foo");
     493        testCases.append("foo.bar");
     494
     495        for (size_t i = 0; i < testCases.size(); ++i) {
     496            Vector<char> v = encodeString(testCases[i]);
     497            IDBKeyPath keyPath = decodeIDBKeyPath(v.data(), v.data() + v.size());
     498            EXPECT_EQ(keyPath.type(), IDBKeyPath::StringType);
     499            EXPECT_EQ(testCases[i], keyPath.string());
     500        }
     501    }
     502    {
     503        Vector<char> v;
     504        v.append(kIDBKeyPathTypeCodedByte1);
     505        v.append(kIDBKeyPathTypeCodedByte2);
     506        v.append(IDBKeyPath::NullType);
     507        IDBKeyPath keyPath = decodeIDBKeyPath(v.data(), v.data() + v.size());
     508        EXPECT_EQ(keyPath.type(), IDBKeyPath::NullType);
     509        EXPECT_TRUE(keyPath.isNull());
     510    }
     511    {
     512        Vector<String> testCases;
     513        testCases.append("");
     514        testCases.append("foo");
     515        testCases.append("foo.bar");
     516
     517        for (size_t i = 0; i < testCases.size(); ++i) {
     518            Vector<char> v;
     519            v.append(kIDBKeyPathTypeCodedByte1);
     520            v.append(kIDBKeyPathTypeCodedByte2);
     521            v.append(IDBKeyPath::StringType);
     522            v.append(encodeStringWithLength(testCases[i]));
     523            IDBKeyPath keyPath = decodeIDBKeyPath(v.data(), v.data() + v.size());
     524            EXPECT_EQ(keyPath.type(), IDBKeyPath::StringType);
     525            EXPECT_EQ(testCases[i], keyPath.string());
     526        }
     527    }
     528    {
     529        Vector<String> testCase;
     530        testCase.append("");
     531        testCase.append("foo");
     532        testCase.append("foo.bar");
     533
     534        Vector<char> v;
     535        v.append(kIDBKeyPathTypeCodedByte1);
     536        v.append(kIDBKeyPathTypeCodedByte2);
     537        v.append(IDBKeyPath::ArrayType);
     538        v.append(encodeVarInt(testCase.size()));
     539        for (size_t i = 0; i < testCase.size(); ++i)
     540            v.append(encodeStringWithLength(testCase[i]));
     541        IDBKeyPath keyPath = decodeIDBKeyPath(v.data(), v.data() + v.size());
     542        EXPECT_EQ(keyPath.type(), IDBKeyPath::ArrayType);
     543        EXPECT_EQ(keyPath.array().size(), testCase.size());
     544        for (size_t i = 0; i < testCase.size(); ++i)
     545            EXPECT_EQ(keyPath.array()[i], testCase[i]);
     546    }
    419547}
    420548
Note: See TracChangeset for help on using the changeset viewer.