| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 if (!backendDB()) { | 112 if (!backendDB()) { |
| 113 exceptionState.throwDOMException(InvalidStateError, | 113 exceptionState.throwDOMException(InvalidStateError, |
| 114 IDBDatabase::databaseClosedErrorMessage); | 114 IDBDatabase::databaseClosedErrorMessage); |
| 115 return; | 115 return; |
| 116 } | 116 } |
| 117 | 117 |
| 118 backendDB()->renameObjectStore(m_transaction->id(), id(), name); | 118 backendDB()->renameObjectStore(m_transaction->id(), id(), name); |
| 119 m_transaction->objectStoreRenamed(m_metadata.name, name); | 119 m_transaction->objectStoreRenamed(m_metadata.name, name); |
| 120 m_metadata.name = name; | 120 m_metadata.name = name; |
| 121 | 121 |
| 122 // The name inside the database's version of the object store metadata is used
by IDBDatabase.objectStoreNames(). | 122 // The name inside the database's version of the object store metadata is used |
| 123 // If the transaction is aborted, this name will be reverted when the metadata
is overwritten with the previousMetadata in IDBTransaction. | 123 // by IDBDatabase.objectStoreNames(). If the transaction is aborted, this |
| 124 // name will be reverted when the metadata is overwritten with the |
| 125 // previousMetadata in IDBTransaction. |
| 124 m_transaction->db()->objectStoreRenamed(id(), name); | 126 m_transaction->db()->objectStoreRenamed(id(), name); |
| 125 } | 127 } |
| 126 | 128 |
| 127 ScriptValue IDBObjectStore::keyPath(ScriptState* scriptState) const { | 129 ScriptValue IDBObjectStore::keyPath(ScriptState* scriptState) const { |
| 128 return ScriptValue::from(scriptState, metadata().keyPath); | 130 return ScriptValue::from(scriptState, metadata().keyPath); |
| 129 } | 131 } |
| 130 | 132 |
| 131 DOMStringList* IDBObjectStore::indexNames() const { | 133 DOMStringList* IDBObjectStore::indexNames() const { |
| 132 IDB_TRACE("IDBObjectStore::indexNames"); | 134 IDB_TRACE("IDBObjectStore::indexNames"); |
| 133 DOMStringList* indexNames = DOMStringList::create(DOMStringList::IndexedDB); | 135 DOMStringList* indexNames = DOMStringList::create(DOMStringList::IndexedDB); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 const bool usesInLineKeys = !keyPath.isNull(); | 424 const bool usesInLineKeys = !keyPath.isNull(); |
| 423 const bool hasKeyGenerator = autoIncrement(); | 425 const bool hasKeyGenerator = autoIncrement(); |
| 424 | 426 |
| 425 if (putMode != WebIDBPutModeCursorUpdate && usesInLineKeys && key) { | 427 if (putMode != WebIDBPutModeCursorUpdate && usesInLineKeys && key) { |
| 426 exceptionState.throwDOMException(DataError, | 428 exceptionState.throwDOMException(DataError, |
| 427 "The object store uses in-line keys and " | 429 "The object store uses in-line keys and " |
| 428 "the key parameter was provided."); | 430 "the key parameter was provided."); |
| 429 return nullptr; | 431 return nullptr; |
| 430 } | 432 } |
| 431 | 433 |
| 432 // This test logically belongs in IDBCursor, but must operate on the cloned va
lue. | 434 // This test logically belongs in IDBCursor, but must operate on the cloned |
| 435 // value. |
| 433 if (putMode == WebIDBPutModeCursorUpdate && usesInLineKeys) { | 436 if (putMode == WebIDBPutModeCursorUpdate && usesInLineKeys) { |
| 434 DCHECK(key); | 437 DCHECK(key); |
| 435 if (clone.isEmpty()) | 438 if (clone.isEmpty()) |
| 436 clone = | 439 clone = |
| 437 deserializeScriptValue(scriptState, serializedValue.get(), &blobInfo); | 440 deserializeScriptValue(scriptState, serializedValue.get(), &blobInfo); |
| 438 IDBKey* keyPathKey = ScriptValue::to<IDBKey*>(scriptState->isolate(), clone, | 441 IDBKey* keyPathKey = ScriptValue::to<IDBKey*>(scriptState->isolate(), clone, |
| 439 exceptionState, keyPath); | 442 exceptionState, keyPath); |
| 440 if (exceptionState.hadException()) | 443 if (exceptionState.hadException()) |
| 441 return nullptr; | 444 return nullptr; |
| 442 if (!keyPathKey || !keyPathKey->isEqual(key)) { | 445 if (!keyPathKey || !keyPathKey->isEqual(key)) { |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 | 766 |
| 764 DCHECK(!exceptionState.hadException()); | 767 DCHECK(!exceptionState.hadException()); |
| 765 if (exceptionState.hadException()) | 768 if (exceptionState.hadException()) |
| 766 return nullptr; | 769 return nullptr; |
| 767 | 770 |
| 768 IDBRequest* indexRequest = | 771 IDBRequest* indexRequest = |
| 769 openCursor(scriptState, nullptr, WebIDBCursorDirectionNext, | 772 openCursor(scriptState, nullptr, WebIDBCursorDirectionNext, |
| 770 WebIDBTaskTypePreemptive); | 773 WebIDBTaskTypePreemptive); |
| 771 indexRequest->preventPropagation(); | 774 indexRequest->preventPropagation(); |
| 772 | 775 |
| 773 // This is kept alive by being the success handler of the request, which is in
turn kept alive by the owning transaction. | 776 // This is kept alive by being the success handler of the request, which is in |
| 777 // turn kept alive by the owning transaction. |
| 774 IndexPopulator* indexPopulator = | 778 IndexPopulator* indexPopulator = |
| 775 IndexPopulator::create(scriptState, transaction()->db(), | 779 IndexPopulator::create(scriptState, transaction()->db(), |
| 776 m_transaction->id(), id(), indexMetadata); | 780 m_transaction->id(), id(), indexMetadata); |
| 777 indexRequest->setOnsuccess(indexPopulator); | 781 indexRequest->setOnsuccess(indexPopulator); |
| 778 return index; | 782 return index; |
| 779 } | 783 } |
| 780 | 784 |
| 781 IDBIndex* IDBObjectStore::index(const String& name, | 785 IDBIndex* IDBObjectStore::index(const String& name, |
| 782 ExceptionState& exceptionState) { | 786 ExceptionState& exceptionState) { |
| 783 IDB_TRACE("IDBObjectStore::index"); | 787 IDB_TRACE("IDBObjectStore::index"); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 } | 1039 } |
| 1036 } | 1040 } |
| 1037 return IDBIndexMetadata::InvalidId; | 1041 return IDBIndexMetadata::InvalidId; |
| 1038 } | 1042 } |
| 1039 | 1043 |
| 1040 WebIDBDatabase* IDBObjectStore::backendDB() const { | 1044 WebIDBDatabase* IDBObjectStore::backendDB() const { |
| 1041 return m_transaction->backendDB(); | 1045 return m_transaction->backendDB(); |
| 1042 } | 1046 } |
| 1043 | 1047 |
| 1044 } // namespace blink | 1048 } // namespace blink |
| OLD | NEW |