| 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 25 matching lines...) Expand all Loading... |
| 36 #include "modules/indexeddb/IDBIndex.h" | 36 #include "modules/indexeddb/IDBIndex.h" |
| 37 #include "modules/indexeddb/IDBObjectStore.h" | 37 #include "modules/indexeddb/IDBObjectStore.h" |
| 38 #include "modules/indexeddb/IDBOpenDBRequest.h" | 38 #include "modules/indexeddb/IDBOpenDBRequest.h" |
| 39 #include "modules/indexeddb/IDBPendingTransactionMonitor.h" | 39 #include "modules/indexeddb/IDBPendingTransactionMonitor.h" |
| 40 #include "modules/indexeddb/IDBTracing.h" | 40 #include "modules/indexeddb/IDBTracing.h" |
| 41 | 41 |
| 42 using blink::WebIDBDatabase; | 42 using blink::WebIDBDatabase; |
| 43 | 43 |
| 44 namespace WebCore { | 44 namespace WebCore { |
| 45 | 45 |
| 46 IDBTransaction* IDBTransaction::create(ExecutionContext* context, int64_t id, co
nst Vector<String>& objectStoreNames, WebIDBDatabase::TransactionMode mode, IDBD
atabase* db) | 46 IDBTransaction* IDBTransaction::create(ExecutionContext* context, int64_t id, co
nst Vector<String>& objectStoreNames, blink::WebIDBTransactionMode mode, IDBData
base* db) |
| 47 { | 47 { |
| 48 IDBOpenDBRequest* openDBRequest = 0; | 48 IDBOpenDBRequest* openDBRequest = 0; |
| 49 IDBTransaction* transaction = adoptRefCountedGarbageCollectedWillBeNoop(new
IDBTransaction(context, id, objectStoreNames, mode, db, openDBRequest, IDBDataba
seMetadata())); | 49 IDBTransaction* transaction = adoptRefCountedGarbageCollectedWillBeNoop(new
IDBTransaction(context, id, objectStoreNames, mode, db, openDBRequest, IDBDataba
seMetadata())); |
| 50 transaction->suspendIfNeeded(); | 50 transaction->suspendIfNeeded(); |
| 51 return transaction; | 51 return transaction; |
| 52 } | 52 } |
| 53 | 53 |
| 54 IDBTransaction* IDBTransaction::create(ExecutionContext* context, int64_t id, ID
BDatabase* db, IDBOpenDBRequest* openDBRequest, const IDBDatabaseMetadata& previ
ousMetadata) | 54 IDBTransaction* IDBTransaction::create(ExecutionContext* context, int64_t id, ID
BDatabase* db, IDBOpenDBRequest* openDBRequest, const IDBDatabaseMetadata& previ
ousMetadata) |
| 55 { | 55 { |
| 56 IDBTransaction* transaction = adoptRefCountedGarbageCollectedWillBeNoop(new
IDBTransaction(context, id, Vector<String>(), WebIDBDatabase::TransactionVersion
Change, db, openDBRequest, previousMetadata)); | 56 IDBTransaction* transaction = adoptRefCountedGarbageCollectedWillBeNoop(new
IDBTransaction(context, id, Vector<String>(), blink::WebIDBTransactionModeVersio
nChange, db, openDBRequest, previousMetadata)); |
| 57 transaction->suspendIfNeeded(); | 57 transaction->suspendIfNeeded(); |
| 58 return transaction; | 58 return transaction; |
| 59 } | 59 } |
| 60 | 60 |
| 61 const AtomicString& IDBTransaction::modeReadOnly() | 61 const AtomicString& IDBTransaction::modeReadOnly() |
| 62 { | 62 { |
| 63 DEFINE_STATIC_LOCAL(AtomicString, readonly, ("readonly", AtomicString::Const
ructFromLiteral)); | 63 DEFINE_STATIC_LOCAL(AtomicString, readonly, ("readonly", AtomicString::Const
ructFromLiteral)); |
| 64 return readonly; | 64 return readonly; |
| 65 } | 65 } |
| 66 | 66 |
| 67 const AtomicString& IDBTransaction::modeReadWrite() | 67 const AtomicString& IDBTransaction::modeReadWrite() |
| 68 { | 68 { |
| 69 DEFINE_STATIC_LOCAL(AtomicString, readwrite, ("readwrite", AtomicString::Con
structFromLiteral)); | 69 DEFINE_STATIC_LOCAL(AtomicString, readwrite, ("readwrite", AtomicString::Con
structFromLiteral)); |
| 70 return readwrite; | 70 return readwrite; |
| 71 } | 71 } |
| 72 | 72 |
| 73 const AtomicString& IDBTransaction::modeVersionChange() | 73 const AtomicString& IDBTransaction::modeVersionChange() |
| 74 { | 74 { |
| 75 DEFINE_STATIC_LOCAL(AtomicString, versionchange, ("versionchange", AtomicStr
ing::ConstructFromLiteral)); | 75 DEFINE_STATIC_LOCAL(AtomicString, versionchange, ("versionchange", AtomicStr
ing::ConstructFromLiteral)); |
| 76 return versionchange; | 76 return versionchange; |
| 77 } | 77 } |
| 78 | 78 |
| 79 IDBTransaction::IDBTransaction(ExecutionContext* context, int64_t id, const Vect
or<String>& objectStoreNames, WebIDBDatabase::TransactionMode mode, IDBDatabase*
db, IDBOpenDBRequest* openDBRequest, const IDBDatabaseMetadata& previousMetadat
a) | 79 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) | 80 : ActiveDOMObject(context) |
| 81 , m_id(id) | 81 , m_id(id) |
| 82 , m_database(db) | 82 , m_database(db) |
| 83 , m_objectStoreNames(objectStoreNames) | 83 , m_objectStoreNames(objectStoreNames) |
| 84 , m_openDBRequest(openDBRequest) | 84 , m_openDBRequest(openDBRequest) |
| 85 , m_mode(mode) | 85 , m_mode(mode) |
| 86 , m_state(Active) | 86 , m_state(Active) |
| 87 , m_hasPendingActivity(true) | 87 , m_hasPendingActivity(true) |
| 88 , m_contextStopped(false) | 88 , m_contextStopped(false) |
| 89 , m_previousMetadata(previousMetadata) | 89 , m_previousMetadata(previousMetadata) |
| 90 { | 90 { |
| 91 ScriptWrappable::init(this); | 91 ScriptWrappable::init(this); |
| 92 if (mode == WebIDBDatabase::TransactionVersionChange) { | 92 if (mode == blink::WebIDBTransactionModeVersionChange) { |
| 93 // Not active until the callback. | 93 // Not active until the callback. |
| 94 m_state = Inactive; | 94 m_state = Inactive; |
| 95 } | 95 } |
| 96 | 96 |
| 97 if (m_state == Active) | 97 if (m_state == Active) |
| 98 IDBPendingTransactionMonitor::from(*context).addNewTransaction(*this); | 98 IDBPendingTransactionMonitor::from(*context).addNewTransaction(*this); |
| 99 m_database->transactionCreated(this); | 99 m_database->transactionCreated(this); |
| 100 } | 100 } |
| 101 | 101 |
| 102 IDBTransaction::~IDBTransaction() | 102 IDBTransaction::~IDBTransaction() |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 } | 292 } |
| 293 | 293 |
| 294 bool IDBTransaction::hasPendingActivity() const | 294 bool IDBTransaction::hasPendingActivity() const |
| 295 { | 295 { |
| 296 // FIXME: In an ideal world, we should return true as long as anyone has a o
r can | 296 // 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 | 297 // 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. | 298 // event listeners. This is in order to handle user generated events
properly. |
| 299 return m_hasPendingActivity && !m_contextStopped; | 299 return m_hasPendingActivity && !m_contextStopped; |
| 300 } | 300 } |
| 301 | 301 |
| 302 WebIDBDatabase::TransactionMode IDBTransaction::stringToMode(const String& modeS
tring, ExceptionState& exceptionState) | 302 blink::WebIDBTransactionMode IDBTransaction::stringToMode(const String& modeStri
ng, ExceptionState& exceptionState) |
| 303 { | 303 { |
| 304 if (modeString.isNull() | 304 if (modeString.isNull() |
| 305 || modeString == IDBTransaction::modeReadOnly()) | 305 || modeString == IDBTransaction::modeReadOnly()) |
| 306 return WebIDBDatabase::TransactionReadOnly; | 306 return blink::WebIDBTransactionModeReadOnly; |
| 307 if (modeString == IDBTransaction::modeReadWrite()) | 307 if (modeString == IDBTransaction::modeReadWrite()) |
| 308 return WebIDBDatabase::TransactionReadWrite; | 308 return blink::WebIDBTransactionModeReadWrite; |
| 309 | 309 |
| 310 exceptionState.throwTypeError("The mode provided ('" + modeString + "') is n
ot one of 'readonly' or 'readwrite'."); | 310 exceptionState.throwTypeError("The mode provided ('" + modeString + "') is n
ot one of 'readonly' or 'readwrite'."); |
| 311 return WebIDBDatabase::TransactionReadOnly; | 311 return blink::WebIDBTransactionModeReadOnly; |
| 312 } | 312 } |
| 313 | 313 |
| 314 const AtomicString& IDBTransaction::modeToString(WebIDBDatabase::TransactionMode
mode) | 314 const AtomicString& IDBTransaction::modeToString(blink::WebIDBTransactionMode mo
de) |
| 315 { | 315 { |
| 316 switch (mode) { | 316 switch (mode) { |
| 317 case WebIDBDatabase::TransactionReadOnly: | 317 case blink::WebIDBTransactionModeReadOnly: |
| 318 return IDBTransaction::modeReadOnly(); | 318 return IDBTransaction::modeReadOnly(); |
| 319 break; | 319 break; |
| 320 | 320 |
| 321 case WebIDBDatabase::TransactionReadWrite: | 321 case blink::WebIDBTransactionModeReadWrite: |
| 322 return IDBTransaction::modeReadWrite(); | 322 return IDBTransaction::modeReadWrite(); |
| 323 break; | 323 break; |
| 324 | 324 |
| 325 case WebIDBDatabase::TransactionVersionChange: | 325 case blink::WebIDBTransactionModeVersionChange: |
| 326 return IDBTransaction::modeVersionChange(); | 326 return IDBTransaction::modeVersionChange(); |
| 327 break; | 327 break; |
| 328 } | 328 } |
| 329 | 329 |
| 330 ASSERT_NOT_REACHED(); | 330 ASSERT_NOT_REACHED(); |
| 331 return IDBTransaction::modeReadOnly(); | 331 return IDBTransaction::modeReadOnly(); |
| 332 } | 332 } |
| 333 | 333 |
| 334 const AtomicString& IDBTransaction::interfaceName() const | 334 const AtomicString& IDBTransaction::interfaceName() const |
| 335 { | 335 { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 event->setTarget(this); | 399 event->setTarget(this); |
| 400 eventQueue->enqueueEvent(event); | 400 eventQueue->enqueueEvent(event); |
| 401 } | 401 } |
| 402 | 402 |
| 403 blink::WebIDBDatabase* IDBTransaction::backendDB() const | 403 blink::WebIDBDatabase* IDBTransaction::backendDB() const |
| 404 { | 404 { |
| 405 return m_database->backend(); | 405 return m_database->backend(); |
| 406 } | 406 } |
| 407 | 407 |
| 408 } // namespace WebCore | 408 } // namespace WebCore |
| OLD | NEW |