| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 ASSERT(m_state != Finished); | 128 ASSERT(m_state != Finished); |
| 129 ASSERT(error); | 129 ASSERT(error); |
| 130 | 130 |
| 131 // The first error to be set is the true cause of the | 131 // The first error to be set is the true cause of the |
| 132 // transaction abort. | 132 // transaction abort. |
| 133 if (!m_error) { | 133 if (!m_error) { |
| 134 m_error = error; | 134 m_error = error; |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 | 137 |
| 138 PassRefPtr<IDBObjectStore> IDBTransaction::objectStore(const String& name, Excep
tionState& es) | 138 PassRefPtr<IDBObjectStore> IDBTransaction::objectStore(const String& name, Excep
tionState& exceptionState) |
| 139 { | 139 { |
| 140 if (m_state == Finished) { | 140 if (m_state == Finished) { |
| 141 es.throwDOMException(InvalidStateError, IDBDatabase::transactionFinished
ErrorMessage); | 141 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::transac
tionFinishedErrorMessage); |
| 142 return 0; | 142 return 0; |
| 143 } | 143 } |
| 144 | 144 |
| 145 IDBObjectStoreMap::iterator it = m_objectStoreMap.find(name); | 145 IDBObjectStoreMap::iterator it = m_objectStoreMap.find(name); |
| 146 if (it != m_objectStoreMap.end()) | 146 if (it != m_objectStoreMap.end()) |
| 147 return it->value; | 147 return it->value; |
| 148 | 148 |
| 149 if (!isVersionChange() && !m_objectStoreNames.contains(name)) { | 149 if (!isVersionChange() && !m_objectStoreNames.contains(name)) { |
| 150 es.throwDOMException(NotFoundError, IDBDatabase::noSuchObjectStoreErrorM
essage); | 150 exceptionState.throwDOMException(NotFoundError, IDBDatabase::noSuchObjec
tStoreErrorMessage); |
| 151 return 0; | 151 return 0; |
| 152 } | 152 } |
| 153 | 153 |
| 154 int64_t objectStoreId = m_database->findObjectStoreId(name); | 154 int64_t objectStoreId = m_database->findObjectStoreId(name); |
| 155 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { | 155 if (objectStoreId == IDBObjectStoreMetadata::InvalidId) { |
| 156 ASSERT(isVersionChange()); | 156 ASSERT(isVersionChange()); |
| 157 es.throwDOMException(NotFoundError, IDBDatabase::noSuchObjectStoreErrorM
essage); | 157 exceptionState.throwDOMException(NotFoundError, IDBDatabase::noSuchObjec
tStoreErrorMessage); |
| 158 return 0; | 158 return 0; |
| 159 } | 159 } |
| 160 | 160 |
| 161 const IDBDatabaseMetadata& metadata = m_database->metadata(); | 161 const IDBDatabaseMetadata& metadata = m_database->metadata(); |
| 162 | 162 |
| 163 RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(metadata.objectS
tores.get(objectStoreId), this); | 163 RefPtr<IDBObjectStore> objectStore = IDBObjectStore::create(metadata.objectS
tores.get(objectStoreId), this); |
| 164 objectStoreCreated(name, objectStore); | 164 objectStoreCreated(name, objectStore); |
| 165 return objectStore.release(); | 165 return objectStore.release(); |
| 166 } | 166 } |
| 167 | 167 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 193 ASSERT_WITH_MESSAGE(m_state != Finished, "A finished transaction tried to se
tActive(%s)", active ? "true" : "false"); | 193 ASSERT_WITH_MESSAGE(m_state != Finished, "A finished transaction tried to se
tActive(%s)", active ? "true" : "false"); |
| 194 if (m_state == Finishing) | 194 if (m_state == Finishing) |
| 195 return; | 195 return; |
| 196 ASSERT(active != (m_state == Active)); | 196 ASSERT(active != (m_state == Active)); |
| 197 m_state = active ? Active : Inactive; | 197 m_state = active ? Active : Inactive; |
| 198 | 198 |
| 199 if (!active && m_requestList.isEmpty()) | 199 if (!active && m_requestList.isEmpty()) |
| 200 backendDB()->commit(m_id); | 200 backendDB()->commit(m_id); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void IDBTransaction::abort(ExceptionState& es) | 203 void IDBTransaction::abort(ExceptionState& exceptionState) |
| 204 { | 204 { |
| 205 if (m_state == Finishing || m_state == Finished) { | 205 if (m_state == Finishing || m_state == Finished) { |
| 206 es.throwDOMException(InvalidStateError, IDBDatabase::transactionFinished
ErrorMessage); | 206 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::transac
tionFinishedErrorMessage); |
| 207 return; | 207 return; |
| 208 } | 208 } |
| 209 | 209 |
| 210 m_state = Finishing; | 210 m_state = Finishing; |
| 211 | 211 |
| 212 if (!m_contextStopped) { | 212 if (!m_contextStopped) { |
| 213 while (!m_requestList.isEmpty()) { | 213 while (!m_requestList.isEmpty()) { |
| 214 RefPtr<IDBRequest> request = *m_requestList.begin(); | 214 RefPtr<IDBRequest> request = *m_requestList.begin(); |
| 215 m_requestList.remove(request); | 215 m_requestList.remove(request); |
| 216 request->abort(); | 216 request->abort(); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 } | 287 } |
| 288 | 288 |
| 289 bool IDBTransaction::hasPendingActivity() const | 289 bool IDBTransaction::hasPendingActivity() const |
| 290 { | 290 { |
| 291 // FIXME: In an ideal world, we should return true as long as anyone has a o
r can | 291 // FIXME: In an ideal world, we should return true as long as anyone has a o
r can |
| 292 // get a handle to us or any child request object and any of those ha
ve | 292 // get a handle to us or any child request object and any of those ha
ve |
| 293 // event listeners. This is in order to handle user generated events
properly. | 293 // event listeners. This is in order to handle user generated events
properly. |
| 294 return m_hasPendingActivity && !m_contextStopped; | 294 return m_hasPendingActivity && !m_contextStopped; |
| 295 } | 295 } |
| 296 | 296 |
| 297 IndexedDB::TransactionMode IDBTransaction::stringToMode(const String& modeString
, ExceptionState& es) | 297 IndexedDB::TransactionMode IDBTransaction::stringToMode(const String& modeString
, ExceptionState& exceptionState) |
| 298 { | 298 { |
| 299 if (modeString.isNull() | 299 if (modeString.isNull() |
| 300 || modeString == IDBTransaction::modeReadOnly()) | 300 || modeString == IDBTransaction::modeReadOnly()) |
| 301 return IndexedDB::TransactionReadOnly; | 301 return IndexedDB::TransactionReadOnly; |
| 302 if (modeString == IDBTransaction::modeReadWrite()) | 302 if (modeString == IDBTransaction::modeReadWrite()) |
| 303 return IndexedDB::TransactionReadWrite; | 303 return IndexedDB::TransactionReadWrite; |
| 304 | 304 |
| 305 es.throwUninformativeAndGenericTypeError(); | 305 exceptionState.throwUninformativeAndGenericTypeError(); |
| 306 return IndexedDB::TransactionReadOnly; | 306 return IndexedDB::TransactionReadOnly; |
| 307 } | 307 } |
| 308 | 308 |
| 309 const AtomicString& IDBTransaction::modeToString(IndexedDB::TransactionMode mode
) | 309 const AtomicString& IDBTransaction::modeToString(IndexedDB::TransactionMode mode
) |
| 310 { | 310 { |
| 311 switch (mode) { | 311 switch (mode) { |
| 312 case IndexedDB::TransactionReadOnly: | 312 case IndexedDB::TransactionReadOnly: |
| 313 return IDBTransaction::modeReadOnly(); | 313 return IDBTransaction::modeReadOnly(); |
| 314 break; | 314 break; |
| 315 | 315 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 event->setTarget(this); | 390 event->setTarget(this); |
| 391 eventQueue->enqueueEvent(event); | 391 eventQueue->enqueueEvent(event); |
| 392 } | 392 } |
| 393 | 393 |
| 394 IDBDatabaseBackendInterface* IDBTransaction::backendDB() const | 394 IDBDatabaseBackendInterface* IDBTransaction::backendDB() const |
| 395 { | 395 { |
| 396 return db()->backend(); | 396 return db()->backend(); |
| 397 } | 397 } |
| 398 | 398 |
| 399 } // namespace WebCore | 399 } // namespace WebCore |
| OLD | NEW |