| 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 26 matching lines...) Expand all Loading... |
| 37 #include "modules/indexeddb/IDBIndex.h" | 37 #include "modules/indexeddb/IDBIndex.h" |
| 38 #include "modules/indexeddb/IDBObjectStore.h" | 38 #include "modules/indexeddb/IDBObjectStore.h" |
| 39 #include "modules/indexeddb/IDBOpenDBRequest.h" | 39 #include "modules/indexeddb/IDBOpenDBRequest.h" |
| 40 #include "modules/indexeddb/IDBPendingTransactionMonitor.h" | 40 #include "modules/indexeddb/IDBPendingTransactionMonitor.h" |
| 41 #include "modules/indexeddb/IDBTracing.h" | 41 #include "modules/indexeddb/IDBTracing.h" |
| 42 | 42 |
| 43 using blink::WebIDBDatabase; | 43 using blink::WebIDBDatabase; |
| 44 | 44 |
| 45 namespace blink { | 45 namespace blink { |
| 46 | 46 |
| 47 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, WebIDBTransactionMode mode, IDBDatabase* d
b) |
| 48 { | 48 { |
| 49 IDBOpenDBRequest* openDBRequest = 0; | 49 IDBOpenDBRequest* openDBRequest = 0; |
| 50 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())); |
| 51 transaction->suspendIfNeeded(); | 51 transaction->suspendIfNeeded(); |
| 52 return transaction; | 52 return transaction; |
| 53 } | 53 } |
| 54 | 54 |
| 55 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) |
| 56 { | 56 { |
| 57 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>(), WebIDBTransactionModeVersionChange
, db, openDBRequest, previousMetadata)); |
| 58 transaction->suspendIfNeeded(); | 58 transaction->suspendIfNeeded(); |
| 59 return transaction; | 59 return transaction; |
| 60 } | 60 } |
| 61 | 61 |
| 62 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, WebIDBTransactionMode mode, IDBDatabase* db, IDBOp
enDBRequest* openDBRequest, const IDBDatabaseMetadata& previousMetadata) |
| 63 : ActiveDOMObject(context) | 63 : ActiveDOMObject(context) |
| 64 , m_id(id) | 64 , m_id(id) |
| 65 , m_database(db) | 65 , m_database(db) |
| 66 , m_objectStoreNames(objectStoreNames) | 66 , m_objectStoreNames(objectStoreNames) |
| 67 , m_openDBRequest(openDBRequest) | 67 , m_openDBRequest(openDBRequest) |
| 68 , m_mode(mode) | 68 , m_mode(mode) |
| 69 , m_state(Active) | 69 , m_state(Active) |
| 70 , m_hasPendingActivity(true) | 70 , m_hasPendingActivity(true) |
| 71 , m_contextStopped(false) | 71 , m_contextStopped(false) |
| 72 , m_previousMetadata(previousMetadata) | 72 , m_previousMetadata(previousMetadata) |
| 73 { | 73 { |
| 74 ScriptWrappable::init(this); | 74 ScriptWrappable::init(this); |
| 75 if (mode == blink::WebIDBTransactionModeVersionChange) { | 75 if (mode == WebIDBTransactionModeVersionChange) { |
| 76 // Not active until the callback. | 76 // Not active until the callback. |
| 77 m_state = Inactive; | 77 m_state = Inactive; |
| 78 } | 78 } |
| 79 | 79 |
| 80 if (m_state == Active) | 80 if (m_state == Active) |
| 81 IDBPendingTransactionMonitor::from(*context).addNewTransaction(*this); | 81 IDBPendingTransactionMonitor::from(*context).addNewTransaction(*this); |
| 82 m_database->transactionCreated(this); | 82 m_database->transactionCreated(this); |
| 83 } | 83 } |
| 84 | 84 |
| 85 IDBTransaction::~IDBTransaction() | 85 IDBTransaction::~IDBTransaction() |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 } | 270 } |
| 271 | 271 |
| 272 bool IDBTransaction::hasPendingActivity() const | 272 bool IDBTransaction::hasPendingActivity() const |
| 273 { | 273 { |
| 274 // 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 |
| 275 // 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 |
| 276 // 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. |
| 277 return m_hasPendingActivity && !m_contextStopped; | 277 return m_hasPendingActivity && !m_contextStopped; |
| 278 } | 278 } |
| 279 | 279 |
| 280 blink::WebIDBTransactionMode IDBTransaction::stringToMode(const String& modeStri
ng, ExceptionState& exceptionState) | 280 WebIDBTransactionMode IDBTransaction::stringToMode(const String& modeString, Exc
eptionState& exceptionState) |
| 281 { | 281 { |
| 282 if (modeString == IndexedDBNames::readonly) | 282 if (modeString == IndexedDBNames::readonly) |
| 283 return blink::WebIDBTransactionModeReadOnly; | 283 return WebIDBTransactionModeReadOnly; |
| 284 if (modeString == IndexedDBNames::readwrite) | 284 if (modeString == IndexedDBNames::readwrite) |
| 285 return blink::WebIDBTransactionModeReadWrite; | 285 return WebIDBTransactionModeReadWrite; |
| 286 | 286 |
| 287 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'."); |
| 288 return blink::WebIDBTransactionModeReadOnly; | 288 return WebIDBTransactionModeReadOnly; |
| 289 } | 289 } |
| 290 | 290 |
| 291 const String& IDBTransaction::mode() const | 291 const String& IDBTransaction::mode() const |
| 292 { | 292 { |
| 293 switch (m_mode) { | 293 switch (m_mode) { |
| 294 case blink::WebIDBTransactionModeReadOnly: | 294 case WebIDBTransactionModeReadOnly: |
| 295 return IndexedDBNames::readonly; | 295 return IndexedDBNames::readonly; |
| 296 | 296 |
| 297 case blink::WebIDBTransactionModeReadWrite: | 297 case WebIDBTransactionModeReadWrite: |
| 298 return IndexedDBNames::readwrite; | 298 return IndexedDBNames::readwrite; |
| 299 | 299 |
| 300 case blink::WebIDBTransactionModeVersionChange: | 300 case WebIDBTransactionModeVersionChange: |
| 301 return IndexedDBNames::versionchange; | 301 return IndexedDBNames::versionchange; |
| 302 } | 302 } |
| 303 | 303 |
| 304 ASSERT_NOT_REACHED(); | 304 ASSERT_NOT_REACHED(); |
| 305 return IndexedDBNames::readonly; | 305 return IndexedDBNames::readonly; |
| 306 } | 306 } |
| 307 | 307 |
| 308 const AtomicString& IDBTransaction::interfaceName() const | 308 const AtomicString& IDBTransaction::interfaceName() const |
| 309 { | 309 { |
| 310 return EventTargetNames::IDBTransaction; | 310 return EventTargetNames::IDBTransaction; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 { | 367 { |
| 368 ASSERT_WITH_MESSAGE(m_state != Finished, "A finished transaction tried to en
queue an event of type %s.", event->type().utf8().data()); | 368 ASSERT_WITH_MESSAGE(m_state != Finished, "A finished transaction tried to en
queue an event of type %s.", event->type().utf8().data()); |
| 369 if (m_contextStopped || !executionContext()) | 369 if (m_contextStopped || !executionContext()) |
| 370 return; | 370 return; |
| 371 | 371 |
| 372 EventQueue* eventQueue = executionContext()->eventQueue(); | 372 EventQueue* eventQueue = executionContext()->eventQueue(); |
| 373 event->setTarget(this); | 373 event->setTarget(this); |
| 374 eventQueue->enqueueEvent(event); | 374 eventQueue->enqueueEvent(event); |
| 375 } | 375 } |
| 376 | 376 |
| 377 blink::WebIDBDatabase* IDBTransaction::backendDB() const | 377 WebIDBDatabase* IDBTransaction::backendDB() const |
| 378 { | 378 { |
| 379 return m_database->backend(); | 379 return m_database->backend(); |
| 380 } | 380 } |
| 381 | 381 |
| 382 } // namespace blink | 382 } // namespace blink |
| OLD | NEW |