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 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 | 83 |
| 84 } // namespace | 84 } // namespace |
| 85 | 85 |
| 86 IDBTransaction::IDBTransaction(ScriptState* scriptState, int64_t id, const HashS et<String>& objectStoreNames, WebIDBTransactionMode mode, IDBDatabase* db, IDBOp enDBRequest* openDBRequest, const IDBDatabaseMetadata& previousMetadata) | 86 IDBTransaction::IDBTransaction(ScriptState* scriptState, int64_t id, const HashS et<String>& objectStoreNames, WebIDBTransactionMode mode, IDBDatabase* db, IDBOp enDBRequest* openDBRequest, const IDBDatabaseMetadata& previousMetadata) |
| 87 : ActiveDOMObject(scriptState->executionContext()) | 87 : ActiveDOMObject(scriptState->executionContext()) |
| 88 , m_id(id) | 88 , m_id(id) |
| 89 , m_database(db) | 89 , m_database(db) |
| 90 , m_objectStoreNames(objectStoreNames) | 90 , m_objectStoreNames(objectStoreNames) |
| 91 , m_openDBRequest(openDBRequest) | 91 , m_openDBRequest(openDBRequest) |
| 92 , m_mode(mode) | 92 , m_mode(mode) |
| 93 , m_state(Active) | |
| 94 , m_hasPendingActivity(true) | |
| 95 , m_contextStopped(false) | |
| 96 , m_previousMetadata(previousMetadata) | 93 , m_previousMetadata(previousMetadata) |
| 97 { | 94 { |
| 98 if (mode == WebIDBTransactionModeVersionChange) { | 95 if (mode == WebIDBTransactionModeVersionChange) { |
| 99 // Not active until the callback. | 96 // Not active until the callback. |
| 100 m_state = Inactive; | 97 m_state = Inactive; |
| 101 } | 98 } |
| 102 | 99 |
| 103 if (m_state == Active) | 100 if (m_state == Active) |
| 104 V8PerIsolateData::from(scriptState->isolate())->addEndOfScopeTask(Deacti vateTransactionTask::create(this)); | 101 V8PerIsolateData::from(scriptState->isolate())->addEndOfScopeTask(Deacti vateTransactionTask::create(this)); |
| 105 m_database->transactionCreated(this); | 102 m_database->transactionCreated(this); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 if (m_state == Finishing || m_state == Finished) { | 202 if (m_state == Finishing || m_state == Finished) { |
| 206 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::transac tionFinishedErrorMessage); | 203 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::transac tionFinishedErrorMessage); |
| 207 return; | 204 return; |
| 208 } | 205 } |
| 209 | 206 |
| 210 m_state = Finishing; | 207 m_state = Finishing; |
| 211 | 208 |
| 212 if (m_contextStopped) | 209 if (m_contextStopped) |
| 213 return; | 210 return; |
| 214 | 211 |
| 215 while (!m_requestList.isEmpty()) { | 212 for (IDBRequest* request : m_requestList) |
|
cmumford
2015/09/03 23:21:03
I seem to remember that aborting one request can s
jsbell
2015/09/03 23:29:54
Looking at what IDBRequest::abort() does, it shoul
| |
| 216 IDBRequest* request = *m_requestList.begin(); | |
| 217 m_requestList.remove(request); | |
| 218 request->abort(); | 213 request->abort(); |
| 219 } | 214 m_requestList.clear(); |
| 220 | 215 |
| 221 if (backendDB()) | 216 if (backendDB()) |
| 222 backendDB()->abort(m_id); | 217 backendDB()->abort(m_id); |
| 223 } | 218 } |
| 224 | 219 |
| 225 void IDBTransaction::registerRequest(IDBRequest* request) | 220 void IDBTransaction::registerRequest(IDBRequest* request) |
| 226 { | 221 { |
| 227 ASSERT(request); | 222 ASSERT(request); |
| 228 ASSERT(m_state == Active); | 223 ASSERT(m_state == Active); |
| 229 m_requestList.add(request); | 224 m_requestList.add(request); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 244 return; | 239 return; |
| 245 } | 240 } |
| 246 | 241 |
| 247 ASSERT(m_state != Finished); | 242 ASSERT(m_state != Finished); |
| 248 if (m_state != Finishing) { | 243 if (m_state != Finishing) { |
| 249 ASSERT(error); | 244 ASSERT(error); |
| 250 setError(error); | 245 setError(error); |
| 251 | 246 |
| 252 // Abort was not triggered by front-end, so outstanding requests must | 247 // Abort was not triggered by front-end, so outstanding requests must |
| 253 // be aborted now. | 248 // be aborted now. |
| 254 while (!m_requestList.isEmpty()) { | 249 for (IDBRequest* request : m_requestList) |
| 255 IDBRequest* request = *m_requestList.begin(); | |
| 256 m_requestList.remove(request); | |
| 257 request->abort(); | 250 request->abort(); |
| 258 } | 251 m_requestList.clear(); |
| 252 | |
| 259 m_state = Finishing; | 253 m_state = Finishing; |
| 260 } | 254 } |
| 261 | 255 |
| 262 if (isVersionChange()) { | 256 if (isVersionChange()) { |
| 263 for (IDBObjectStoreMetadataMap::iterator it = m_objectStoreCleanupMap.be gin(); it != m_objectStoreCleanupMap.end(); ++it) | 257 for (auto& it : m_objectStoreCleanupMap) |
| 264 it->key->setMetadata(it->value); | 258 it.key->setMetadata(it.value); |
| 265 m_database->setMetadata(m_previousMetadata); | 259 m_database->setMetadata(m_previousMetadata); |
| 266 m_database->close(); | 260 m_database->close(); |
| 267 } | 261 } |
| 268 m_objectStoreCleanupMap.clear(); | 262 m_objectStoreCleanupMap.clear(); |
| 269 | 263 |
| 270 // Enqueue events before notifying database, as database may close which enq ueues more events and order matters. | 264 // Enqueue events before notifying database, as database may close which enq ueues more events and order matters. |
| 271 enqueueEvent(Event::createBubble(EventTypeNames::abort)); | 265 enqueueEvent(Event::createBubble(EventTypeNames::abort)); |
| 272 | 266 |
| 273 m_database->transactionFinished(this); | 267 m_database->transactionFinished(this); |
| 274 } | 268 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 m_state = Finished; | 351 m_state = Finished; |
| 358 return false; | 352 return false; |
| 359 } | 353 } |
| 360 ASSERT(m_state != Finished); | 354 ASSERT(m_state != Finished); |
| 361 ASSERT(m_hasPendingActivity); | 355 ASSERT(m_hasPendingActivity); |
| 362 ASSERT(executionContext()); | 356 ASSERT(executionContext()); |
| 363 ASSERT(event->target() == this); | 357 ASSERT(event->target() == this); |
| 364 m_state = Finished; | 358 m_state = Finished; |
| 365 | 359 |
| 366 // Break reference cycles. | 360 // Break reference cycles. |
| 367 for (IDBObjectStoreMap::iterator it = m_objectStoreMap.begin(); it != m_obje ctStoreMap.end(); ++it) | 361 for (auto& it : m_objectStoreMap) |
| 368 it->value->transactionFinished(); | 362 it.value->transactionFinished(); |
| 369 m_objectStoreMap.clear(); | 363 m_objectStoreMap.clear(); |
| 370 for (IDBObjectStoreSet::iterator it = m_deletedObjectStores.begin(); it != m _deletedObjectStores.end(); ++it) | 364 for (auto& it : m_deletedObjectStores) |
| 371 (*it)->transactionFinished(); | 365 it->transactionFinished(); |
| 372 m_deletedObjectStores.clear(); | 366 m_deletedObjectStores.clear(); |
| 373 | 367 |
| 374 WillBeHeapVector<RefPtrWillBeMember<EventTarget>> targets; | 368 WillBeHeapVector<RefPtrWillBeMember<EventTarget>> targets; |
| 375 targets.append(this); | 369 targets.append(this); |
| 376 targets.append(db()); | 370 targets.append(db()); |
| 377 | 371 |
| 378 // FIXME: When we allow custom event dispatching, this will probably need to change. | 372 // FIXME: When we allow custom event dispatching, this will probably need to change. |
| 379 ASSERT(event->type() == EventTypeNames::complete || event->type() == EventTy peNames::abort); | 373 ASSERT(event->type() == EventTypeNames::complete || event->type() == EventTy peNames::abort); |
| 380 bool returnValue = IDBEventDispatcher::dispatch(event.get(), targets); | 374 bool returnValue = IDBEventDispatcher::dispatch(event.get(), targets); |
| 381 // FIXME: Try to construct a test where |this| outlives openDBRequest and we | 375 // FIXME: Try to construct a test where |this| outlives openDBRequest and we |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 408 event->setTarget(this); | 402 event->setTarget(this); |
| 409 eventQueue->enqueueEvent(event); | 403 eventQueue->enqueueEvent(event); |
| 410 } | 404 } |
| 411 | 405 |
| 412 WebIDBDatabase* IDBTransaction::backendDB() const | 406 WebIDBDatabase* IDBTransaction::backendDB() const |
| 413 { | 407 { |
| 414 return m_database->backend(); | 408 return m_database->backend(); |
| 415 } | 409 } |
| 416 | 410 |
| 417 } // namespace blink | 411 } // namespace blink |
| OLD | NEW |