| 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 18 matching lines...) Expand all Loading... |
| 29 #include "core/dom/DOMException.h" | 29 #include "core/dom/DOMException.h" |
| 30 #include "core/dom/ExceptionCode.h" | 30 #include "core/dom/ExceptionCode.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 "modules/IndexedDBNames.h" | 33 #include "modules/IndexedDBNames.h" |
| 34 #include "modules/indexeddb/IDBDatabase.h" | 34 #include "modules/indexeddb/IDBDatabase.h" |
| 35 #include "modules/indexeddb/IDBEventDispatcher.h" | 35 #include "modules/indexeddb/IDBEventDispatcher.h" |
| 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/IDBRequestQueueItem.h" |
| 39 #include "modules/indexeddb/IDBTracing.h" | 40 #include "modules/indexeddb/IDBTracing.h" |
| 40 #include "platform/bindings/ScriptState.h" | 41 #include "platform/bindings/ScriptState.h" |
| 41 #include "platform/bindings/V8PerIsolateData.h" | 42 #include "platform/bindings/V8PerIsolateData.h" |
| 42 #include "platform/wtf/PtrUtil.h" | 43 #include "platform/wtf/PtrUtil.h" |
| 43 | 44 |
| 44 #include <memory> | 45 #include <memory> |
| 45 | 46 |
| 46 using blink::WebIDBDatabase; | 47 using blink::WebIDBDatabase; |
| 47 | 48 |
| 48 namespace blink { | 49 namespace blink { |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 374 |
| 374 void IDBTransaction::RegisterRequest(IDBRequest* request) { | 375 void IDBTransaction::RegisterRequest(IDBRequest* request) { |
| 375 DCHECK(request); | 376 DCHECK(request); |
| 376 DCHECK(!request_list_.Contains(request)); | 377 DCHECK(!request_list_.Contains(request)); |
| 377 DCHECK_EQ(state_, kActive); | 378 DCHECK_EQ(state_, kActive); |
| 378 request_list_.insert(request); | 379 request_list_.insert(request); |
| 379 } | 380 } |
| 380 | 381 |
| 381 void IDBTransaction::UnregisterRequest(IDBRequest* request) { | 382 void IDBTransaction::UnregisterRequest(IDBRequest* request) { |
| 382 DCHECK(request); | 383 DCHECK(request); |
| 384 #if DCHECK_IS_ON() |
| 385 // Make sure that no pending IDBRequest gets left behind in the result queue. |
| 386 DCHECK(!request->QueueItem() || request->QueueItem()->IsReady()); |
| 387 #endif // DCHECK_IS_ON() |
| 388 |
| 383 // If we aborted the request, it will already have been removed. | 389 // If we aborted the request, it will already have been removed. |
| 384 request_list_.erase(request); | 390 request_list_.erase(request); |
| 385 } | 391 } |
| 386 | 392 |
| 393 void IDBTransaction::EnqueueResult( |
| 394 std::unique_ptr<IDBRequestQueueItem> result) { |
| 395 DCHECK(result); |
| 396 DCHECK(HasQueuedResults() || !result->IsReady()); |
| 397 |
| 398 result_queue_.push_back(std::move(result)); |
| 399 // StartLoading() may complete post-processing synchronously, so the result |
| 400 // needs to be in the queue before StartLoading() is called. |
| 401 result_queue_.back()->StartLoading(); |
| 402 } |
| 403 |
| 404 void IDBTransaction::OnResultReady() { |
| 405 while (!result_queue_.empty()) { |
| 406 IDBRequestQueueItem* result = result_queue_.front().get(); |
| 407 if (!result->IsReady()) |
| 408 break; |
| 409 |
| 410 result->EnqueueResponse(); |
| 411 result_queue_.pop_front(); |
| 412 } |
| 413 } |
| 414 |
| 387 void IDBTransaction::OnAbort(DOMException* error) { | 415 void IDBTransaction::OnAbort(DOMException* error) { |
| 388 IDB_TRACE("IDBTransaction::onAbort"); | 416 IDB_TRACE("IDBTransaction::onAbort"); |
| 389 if (!GetExecutionContext()) { | 417 if (!GetExecutionContext()) { |
| 390 Finished(); | 418 Finished(); |
| 391 return; | 419 return; |
| 392 } | 420 } |
| 393 | 421 |
| 394 DCHECK_NE(state_, kFinished); | 422 DCHECK_NE(state_, kFinished); |
| 395 if (state_ != kFinishing) { | 423 if (state_ != kFinishing) { |
| 396 // Abort was not triggered by front-end. | 424 // Abort was not triggered by front-end. |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 IDBObjectStore* object_store = it.key; | 643 IDBObjectStore* object_store = it.key; |
| 616 object_store->ClearIndexCache(); | 644 object_store->ClearIndexCache(); |
| 617 } | 645 } |
| 618 old_store_metadata_.clear(); | 646 old_store_metadata_.clear(); |
| 619 | 647 |
| 620 deleted_indexes_.clear(); | 648 deleted_indexes_.clear(); |
| 621 deleted_object_stores_.clear(); | 649 deleted_object_stores_.clear(); |
| 622 } | 650 } |
| 623 | 651 |
| 624 } // namespace blink | 652 } // namespace blink |
| OLD | NEW |