| 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 13 matching lines...) Expand all Loading... |
| 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/core/v8/ExceptionState.h" | 29 #include "bindings/core/v8/ExceptionState.h" |
| 30 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 30 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 31 #include "core/dom/ExecutionContext.h" | 31 #include "core/dom/ExecutionContext.h" |
| 32 #include "core/events/EventQueue.h" | 32 #include "core/events/EventQueue.h" |
| 33 #include "core/inspector/ScriptCallStack.h" | 33 #include "core/inspector/ScriptCallStack.h" |
| 34 #include "modules/IndexedDBNames.h" |
| 34 #include "modules/indexeddb/IDBDatabase.h" | 35 #include "modules/indexeddb/IDBDatabase.h" |
| 35 #include "modules/indexeddb/IDBEventDispatcher.h" | 36 #include "modules/indexeddb/IDBEventDispatcher.h" |
| 36 #include "modules/indexeddb/IDBIndex.h" | 37 #include "modules/indexeddb/IDBIndex.h" |
| 37 #include "modules/indexeddb/IDBObjectStore.h" | 38 #include "modules/indexeddb/IDBObjectStore.h" |
| 38 #include "modules/indexeddb/IDBOpenDBRequest.h" | 39 #include "modules/indexeddb/IDBOpenDBRequest.h" |
| 39 #include "modules/indexeddb/IDBPendingTransactionMonitor.h" | 40 #include "modules/indexeddb/IDBPendingTransactionMonitor.h" |
| 40 #include "modules/indexeddb/IDBTracing.h" | 41 #include "modules/indexeddb/IDBTracing.h" |
| 41 | 42 |
| 42 using blink::WebIDBDatabase; | 43 using blink::WebIDBDatabase; |
| 43 | 44 |
| 44 namespace blink { | 45 namespace blink { |
| 45 | 46 |
| 46 IDBTransaction* IDBTransaction::create(ExecutionContext* context, int64_t id, co
nst Vector<String>& objectStoreNames, blink::WebIDBTransactionMode mode, IDBData
base* db) | 47 IDBTransaction* IDBTransaction::create(ExecutionContext* context, int64_t id, co
nst Vector<String>& objectStoreNames, blink::WebIDBTransactionMode mode, IDBData
base* db) |
| 47 { | 48 { |
| 48 IDBOpenDBRequest* openDBRequest = 0; | 49 IDBOpenDBRequest* openDBRequest = 0; |
| 49 IDBTransaction* transaction = adoptRefCountedGarbageCollectedWillBeNoop(new
IDBTransaction(context, id, objectStoreNames, mode, db, openDBRequest, IDBDataba
seMetadata())); | 50 IDBTransaction* transaction = adoptRefCountedGarbageCollectedWillBeNoop(new
IDBTransaction(context, id, objectStoreNames, mode, db, openDBRequest, IDBDataba
seMetadata())); |
| 50 transaction->suspendIfNeeded(); | 51 transaction->suspendIfNeeded(); |
| 51 return transaction; | 52 return transaction; |
| 52 } | 53 } |
| 53 | 54 |
| 54 IDBTransaction* IDBTransaction::create(ExecutionContext* context, int64_t id, ID
BDatabase* db, IDBOpenDBRequest* openDBRequest, const IDBDatabaseMetadata& previ
ousMetadata) | 55 IDBTransaction* IDBTransaction::create(ExecutionContext* context, int64_t id, ID
BDatabase* db, IDBOpenDBRequest* openDBRequest, const IDBDatabaseMetadata& previ
ousMetadata) |
| 55 { | 56 { |
| 56 IDBTransaction* transaction = adoptRefCountedGarbageCollectedWillBeNoop(new
IDBTransaction(context, id, Vector<String>(), blink::WebIDBTransactionModeVersio
nChange, db, openDBRequest, previousMetadata)); | 57 IDBTransaction* transaction = adoptRefCountedGarbageCollectedWillBeNoop(new
IDBTransaction(context, id, Vector<String>(), blink::WebIDBTransactionModeVersio
nChange, db, openDBRequest, previousMetadata)); |
| 57 transaction->suspendIfNeeded(); | 58 transaction->suspendIfNeeded(); |
| 58 return transaction; | 59 return transaction; |
| 59 } | 60 } |
| 60 | 61 |
| 61 const AtomicString& IDBTransaction::modeReadOnly() | |
| 62 { | |
| 63 DEFINE_STATIC_LOCAL(AtomicString, readonly, ("readonly", AtomicString::Const
ructFromLiteral)); | |
| 64 return readonly; | |
| 65 } | |
| 66 | |
| 67 const AtomicString& IDBTransaction::modeReadWrite() | |
| 68 { | |
| 69 DEFINE_STATIC_LOCAL(AtomicString, readwrite, ("readwrite", AtomicString::Con
structFromLiteral)); | |
| 70 return readwrite; | |
| 71 } | |
| 72 | |
| 73 const AtomicString& IDBTransaction::modeVersionChange() | |
| 74 { | |
| 75 DEFINE_STATIC_LOCAL(AtomicString, versionchange, ("versionchange", AtomicStr
ing::ConstructFromLiteral)); | |
| 76 return versionchange; | |
| 77 } | |
| 78 | |
| 79 IDBTransaction::IDBTransaction(ExecutionContext* context, int64_t id, const Vect
or<String>& objectStoreNames, blink::WebIDBTransactionMode mode, IDBDatabase* db
, IDBOpenDBRequest* openDBRequest, const IDBDatabaseMetadata& previousMetadata) | 62 IDBTransaction::IDBTransaction(ExecutionContext* context, int64_t id, const Vect
or<String>& objectStoreNames, blink::WebIDBTransactionMode mode, IDBDatabase* db
, IDBOpenDBRequest* openDBRequest, const IDBDatabaseMetadata& previousMetadata) |
| 80 : ActiveDOMObject(context) | 63 : ActiveDOMObject(context) |
| 81 , m_id(id) | 64 , m_id(id) |
| 82 , m_database(db) | 65 , m_database(db) |
| 83 , m_objectStoreNames(objectStoreNames) | 66 , m_objectStoreNames(objectStoreNames) |
| 84 , m_openDBRequest(openDBRequest) | 67 , m_openDBRequest(openDBRequest) |
| 85 , m_mode(mode) | 68 , m_mode(mode) |
| 86 , m_state(Active) | 69 , m_state(Active) |
| 87 , m_hasPendingActivity(true) | 70 , m_hasPendingActivity(true) |
| 88 , m_contextStopped(false) | 71 , m_contextStopped(false) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 110 visitor->trace(m_database); | 93 visitor->trace(m_database); |
| 111 visitor->trace(m_openDBRequest); | 94 visitor->trace(m_openDBRequest); |
| 112 visitor->trace(m_error); | 95 visitor->trace(m_error); |
| 113 visitor->trace(m_requestList); | 96 visitor->trace(m_requestList); |
| 114 visitor->trace(m_objectStoreMap); | 97 visitor->trace(m_objectStoreMap); |
| 115 visitor->trace(m_deletedObjectStores); | 98 visitor->trace(m_deletedObjectStores); |
| 116 visitor->trace(m_objectStoreCleanupMap); | 99 visitor->trace(m_objectStoreCleanupMap); |
| 117 EventTargetWithInlineData::trace(visitor); | 100 EventTargetWithInlineData::trace(visitor); |
| 118 } | 101 } |
| 119 | 102 |
| 120 const String& IDBTransaction::mode() const | |
| 121 { | |
| 122 return modeToString(m_mode); | |
| 123 } | |
| 124 | |
| 125 void IDBTransaction::setError(PassRefPtrWillBeRawPtr<DOMError> error) | 103 void IDBTransaction::setError(PassRefPtrWillBeRawPtr<DOMError> error) |
| 126 { | 104 { |
| 127 ASSERT(m_state != Finished); | 105 ASSERT(m_state != Finished); |
| 128 ASSERT(error); | 106 ASSERT(error); |
| 129 | 107 |
| 130 // The first error to be set is the true cause of the | 108 // The first error to be set is the true cause of the |
| 131 // transaction abort. | 109 // transaction abort. |
| 132 if (!m_error) { | 110 if (!m_error) { |
| 133 m_error = error; | 111 m_error = error; |
| 134 } | 112 } |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 bool IDBTransaction::hasPendingActivity() const | 272 bool IDBTransaction::hasPendingActivity() const |
| 295 { | 273 { |
| 296 // FIXME: In an ideal world, we should return true as long as anyone has a o
r can | 274 // FIXME: In an ideal world, we should return true as long as anyone has a o
r can |
| 297 // get a handle to us or any child request object and any of those ha
ve | 275 // get a handle to us or any child request object and any of those ha
ve |
| 298 // event listeners. This is in order to handle user generated events
properly. | 276 // event listeners. This is in order to handle user generated events
properly. |
| 299 return m_hasPendingActivity && !m_contextStopped; | 277 return m_hasPendingActivity && !m_contextStopped; |
| 300 } | 278 } |
| 301 | 279 |
| 302 blink::WebIDBTransactionMode IDBTransaction::stringToMode(const String& modeStri
ng, ExceptionState& exceptionState) | 280 blink::WebIDBTransactionMode IDBTransaction::stringToMode(const String& modeStri
ng, ExceptionState& exceptionState) |
| 303 { | 281 { |
| 304 if (modeString == IDBTransaction::modeReadOnly()) | 282 if (modeString == IndexedDBNames::readonly) |
| 305 return blink::WebIDBTransactionModeReadOnly; | 283 return blink::WebIDBTransactionModeReadOnly; |
| 306 if (modeString == IDBTransaction::modeReadWrite()) | 284 if (modeString == IndexedDBNames::readwrite) |
| 307 return blink::WebIDBTransactionModeReadWrite; | 285 return blink::WebIDBTransactionModeReadWrite; |
| 308 | 286 |
| 309 exceptionState.throwTypeError("The mode provided ('" + modeString + "') is n
ot one of 'readonly' or 'readwrite'."); | 287 exceptionState.throwTypeError("The mode provided ('" + modeString + "') is n
ot one of 'readonly' or 'readwrite'."); |
| 310 return blink::WebIDBTransactionModeReadOnly; | 288 return blink::WebIDBTransactionModeReadOnly; |
| 311 } | 289 } |
| 312 | 290 |
| 313 const AtomicString& IDBTransaction::modeToString(blink::WebIDBTransactionMode mo
de) | 291 const String& IDBTransaction::mode() const |
| 314 { | 292 { |
| 315 switch (mode) { | 293 switch (m_mode) { |
| 316 case blink::WebIDBTransactionModeReadOnly: | 294 case blink::WebIDBTransactionModeReadOnly: |
| 317 return IDBTransaction::modeReadOnly(); | 295 return IndexedDBNames::readonly; |
| 318 break; | |
| 319 | 296 |
| 320 case blink::WebIDBTransactionModeReadWrite: | 297 case blink::WebIDBTransactionModeReadWrite: |
| 321 return IDBTransaction::modeReadWrite(); | 298 return IndexedDBNames::readwrite; |
| 322 break; | |
| 323 | 299 |
| 324 case blink::WebIDBTransactionModeVersionChange: | 300 case blink::WebIDBTransactionModeVersionChange: |
| 325 return IDBTransaction::modeVersionChange(); | 301 return IndexedDBNames::versionchange; |
| 326 break; | |
| 327 } | 302 } |
| 328 | 303 |
| 329 ASSERT_NOT_REACHED(); | 304 ASSERT_NOT_REACHED(); |
| 330 return IDBTransaction::modeReadOnly(); | 305 return IndexedDBNames::readonly; |
| 331 } | 306 } |
| 332 | 307 |
| 333 const AtomicString& IDBTransaction::interfaceName() const | 308 const AtomicString& IDBTransaction::interfaceName() const |
| 334 { | 309 { |
| 335 return EventTargetNames::IDBTransaction; | 310 return EventTargetNames::IDBTransaction; |
| 336 } | 311 } |
| 337 | 312 |
| 338 ExecutionContext* IDBTransaction::executionContext() const | 313 ExecutionContext* IDBTransaction::executionContext() const |
| 339 { | 314 { |
| 340 return ActiveDOMObject::executionContext(); | 315 return ActiveDOMObject::executionContext(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 event->setTarget(this); | 373 event->setTarget(this); |
| 399 eventQueue->enqueueEvent(event); | 374 eventQueue->enqueueEvent(event); |
| 400 } | 375 } |
| 401 | 376 |
| 402 blink::WebIDBDatabase* IDBTransaction::backendDB() const | 377 blink::WebIDBDatabase* IDBTransaction::backendDB() const |
| 403 { | 378 { |
| 404 return m_database->backend(); | 379 return m_database->backend(); |
| 405 } | 380 } |
| 406 | 381 |
| 407 } // namespace blink | 382 } // namespace blink |
| OLD | NEW |