Chromium Code Reviews| 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 |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "modules/indexeddb/IDBTransaction.h" | 27 #include "modules/indexeddb/IDBTransaction.h" |
| 28 | 28 |
| 29 #include "bindings/v8/ExceptionState.h" | |
| 29 #include "core/dom/DOMError.h" | 30 #include "core/dom/DOMError.h" |
| 30 #include "core/dom/EventQueue.h" | 31 #include "core/dom/EventQueue.h" |
| 31 #include "core/dom/ExceptionCode.h" | 32 #include "core/dom/ExceptionCode.h" |
| 32 #include "core/dom/ExceptionCodePlaceholder.h" | 33 #include "core/dom/ExceptionCodePlaceholder.h" |
| 33 #include "core/dom/ScriptExecutionContext.h" | 34 #include "core/dom/ScriptExecutionContext.h" |
| 34 #include "core/inspector/ScriptCallStack.h" | 35 #include "core/inspector/ScriptCallStack.h" |
| 35 #include "modules/indexeddb/IDBDatabase.h" | 36 #include "modules/indexeddb/IDBDatabase.h" |
| 36 #include "modules/indexeddb/IDBEventDispatcher.h" | 37 #include "modules/indexeddb/IDBEventDispatcher.h" |
| 37 #include "modules/indexeddb/IDBIndex.h" | 38 #include "modules/indexeddb/IDBIndex.h" |
| 38 #include "modules/indexeddb/IDBObjectStore.h" | 39 #include "modules/indexeddb/IDBObjectStore.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 ASSERT(m_state != Finished); | 130 ASSERT(m_state != Finished); |
| 130 ASSERT(error); | 131 ASSERT(error); |
| 131 | 132 |
| 132 // The first error to be set is the true cause of the | 133 // The first error to be set is the true cause of the |
| 133 // transaction abort. | 134 // transaction abort. |
| 134 if (!m_error) { | 135 if (!m_error) { |
| 135 m_error = error; | 136 m_error = error; |
| 136 } | 137 } |
| 137 } | 138 } |
| 138 | 139 |
| 139 PassRefPtr<IDBObjectStore> IDBTransaction::objectStore(const String& name, Excep tionCode& ec) | 140 PassRefPtr<IDBObjectStore> IDBTransaction::objectStore(const String& name, Excep tionState& es) |
| 140 { | 141 { |
| 141 if (m_state == Finished) { | 142 if (m_state == Finished) { |
| 142 ec = INVALID_STATE_ERR; | 143 es.throwDOMException(INVALID_STATE_ERR); |
| 143 return 0; | 144 return 0; |
| 144 } | 145 } |
| 145 | 146 |
| 146 IDBObjectStoreMap::iterator it = m_objectStoreMap.find(name); | 147 IDBObjectStoreMap::iterator it = m_objectStoreMap.find(name); |
| 147 if (it != m_objectStoreMap.end()) | 148 if (it != m_objectStoreMap.end()) |
| 148 return it->value; | 149 return it->value; |
| 149 | 150 |
| 150 if (!isVersionChange() && !m_objectStoreNames.contains(name)) { | 151 if (!isVersionChange() && !m_objectStoreNames.contains(name)) { |
| 151 // FIXME: Should use (NotFoundError, "..."). | 152 // FIXME: Should use constant |
| 152 ec = IDBNotFoundError; | 153 es.throwDOMException(NOT_FOUND_ERR, "An operation failed because the req uested database object could not be found."); |
| 153 return 0; | 154 return 0; |
| 154 } | 155 } |
| 155 | 156 |
| 156 int64_t objectStoreId = m_database->findObjectStoreId(name); | 157 int64_t objectStoreId = m_database->findObjectStoreId(name); |
| 157 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { | 158 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { |
| 158 ASSERT(isVersionChange()); | 159 ASSERT(isVersionChange()); |
| 159 // FIXME: Should use (NotFoundError, "..."). | 160 // FIXME: Should use constant |
| 160 ec = IDBNotFoundError; | 161 es.throwDOMException(NOT_FOUND_ERR, "An operation failed because the req uested database object could not be found."); |
| 161 return 0; | 162 return 0; |
| 162 } | 163 } |
| 163 | 164 |
| 164 const IDBDatabaseMetadata& metadata = m_database->metadata(); | 165 const IDBDatabaseMetadata& metadata = m_database->metadata(); |
| 165 | 166 |
| 166 RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(metadata.objectS tores.get(objectStoreId), this); | 167 RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(metadata.objectS tores.get(objectStoreId), this); |
| 167 objectStoreCreated(name, objectStore); | 168 objectStoreCreated(name, objectStore); |
| 168 return objectStore.release(); | 169 return objectStore.release(); |
| 169 } | 170 } |
| 170 | 171 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 } | 327 } |
| 327 | 328 |
| 328 bool IDBTransaction::hasPendingActivity() const | 329 bool IDBTransaction::hasPendingActivity() const |
| 329 { | 330 { |
| 330 // FIXME: In an ideal world, we should return true as long as anyone has a o r can | 331 // FIXME: In an ideal world, we should return true as long as anyone has a o r can |
| 331 // get a handle to us or any child request object and any of those ha ve | 332 // get a handle to us or any child request object and any of those ha ve |
| 332 // event listeners. This is in order to handle user generated events properly. | 333 // event listeners. This is in order to handle user generated events properly. |
| 333 return m_hasPendingActivity && !m_contextStopped; | 334 return m_hasPendingActivity && !m_contextStopped; |
| 334 } | 335 } |
| 335 | 336 |
| 336 IndexedDB::TransactionMode IDBTransaction::stringToMode(const String& modeString , ExceptionCode& ec) | 337 IndexedDB::TransactionMode IDBTransaction::stringToMode(const String& modeString , ExceptionCode& ec) |
|
jsbell
2013/07/02 18:48:08
Still needs updating, obviously. (Hence the DO NOT
| |
| 337 { | 338 { |
| 338 if (modeString.isNull() | 339 if (modeString.isNull() |
| 339 || modeString == IDBTransaction::modeReadOnly()) | 340 || modeString == IDBTransaction::modeReadOnly()) |
| 340 return IndexedDB::TransactionReadOnly; | 341 return IndexedDB::TransactionReadOnly; |
| 341 if (modeString == IDBTransaction::modeReadWrite()) | 342 if (modeString == IDBTransaction::modeReadWrite()) |
| 342 return IndexedDB::TransactionReadWrite; | 343 return IndexedDB::TransactionReadWrite; |
| 343 | 344 |
| 344 ec = TypeError; | 345 ec = TypeError; |
|
jsbell
2013/07/02 18:48:08
This will become es.throwTypeError(), but es.throw
| |
| 345 return IndexedDB::TransactionReadOnly; | 346 return IndexedDB::TransactionReadOnly; |
| 346 } | 347 } |
| 347 | 348 |
| 348 const AtomicString& IDBTransaction::modeToString(IndexedDB::TransactionMode mode ) | 349 const AtomicString& IDBTransaction::modeToString(IndexedDB::TransactionMode mode ) |
| 349 { | 350 { |
| 350 switch (mode) { | 351 switch (mode) { |
| 351 case IndexedDB::TransactionReadOnly: | 352 case IndexedDB::TransactionReadOnly: |
| 352 return IDBTransaction::modeReadOnly(); | 353 return IDBTransaction::modeReadOnly(); |
| 353 break; | 354 break; |
| 354 | 355 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 446 { | 447 { |
| 447 return &m_eventTargetData; | 448 return &m_eventTargetData; |
| 448 } | 449 } |
| 449 | 450 |
| 450 IDBDatabaseBackendInterface* IDBTransaction::backendDB() const | 451 IDBDatabaseBackendInterface* IDBTransaction::backendDB() const |
| 451 { | 452 { |
| 452 return db()->backend(); | 453 return db()->backend(); |
| 453 } | 454 } |
| 454 | 455 |
| 455 } // namespace WebCore | 456 } // namespace WebCore |
| OLD | NEW |