| 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 } | 373 } |
| 373 | 374 |
| 374 void IDBTransaction::RegisterRequest(IDBRequest* request) { | 375 void IDBTransaction::RegisterRequest(IDBRequest* request) { |
| 375 DCHECK(request); | 376 DCHECK(request); |
| 376 DCHECK_EQ(state_, kActive); | 377 DCHECK_EQ(state_, kActive); |
| 377 request_list_.insert(request); | 378 request_list_.insert(request); |
| 378 } | 379 } |
| 379 | 380 |
| 380 void IDBTransaction::UnregisterRequest(IDBRequest* request) { | 381 void IDBTransaction::UnregisterRequest(IDBRequest* request) { |
| 381 DCHECK(request); | 382 DCHECK(request); |
| 383 DCHECK_EQ(request->QueueItem(), nullptr); |
| 382 // If we aborted the request, it will already have been removed. | 384 // If we aborted the request, it will already have been removed. |
| 383 request_list_.erase(request); | 385 request_list_.erase(request); |
| 384 } | 386 } |
| 385 | 387 |
| 388 void IDBTransaction::EnqueueResult( |
| 389 std::unique_ptr<IDBRequestQueueItem> result) { |
| 390 DCHECK(result); |
| 391 DCHECK(HasQueuedResults() || !result->IsReady()); |
| 392 |
| 393 result_queue_.push_back(std::move(result)); |
| 394 // StartLoading() may complete post-processing synchronously, so the result |
| 395 // needs to be in the queue before StartLoading() is called. |
| 396 result_queue_.back()->StartLoading(); |
| 397 } |
| 398 |
| 399 void IDBTransaction::OnResultReady() { |
| 400 while (!result_queue_.empty()) { |
| 401 IDBRequestQueueItem* result = result_queue_.front().get(); |
| 402 if (!result->IsReady()) |
| 403 break; |
| 404 |
| 405 result->FireCallback(); |
| 406 result_queue_.pop_front(); |
| 407 } |
| 408 } |
| 409 |
| 386 void IDBTransaction::OnAbort(DOMException* error) { | 410 void IDBTransaction::OnAbort(DOMException* error) { |
| 387 IDB_TRACE("IDBTransaction::onAbort"); | 411 IDB_TRACE("IDBTransaction::onAbort"); |
| 388 if (!GetExecutionContext()) { | 412 if (!GetExecutionContext()) { |
| 389 Finished(); | 413 Finished(); |
| 390 return; | 414 return; |
| 391 } | 415 } |
| 392 | 416 |
| 393 DCHECK_NE(state_, kFinished); | 417 DCHECK_NE(state_, kFinished); |
| 394 if (state_ != kFinishing) { | 418 if (state_ != kFinishing) { |
| 395 // Abort was not triggered by front-end. | 419 // Abort was not triggered by front-end. |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 IDBObjectStore* object_store = it.key; | 638 IDBObjectStore* object_store = it.key; |
| 615 object_store->ClearIndexCache(); | 639 object_store->ClearIndexCache(); |
| 616 } | 640 } |
| 617 old_store_metadata_.clear(); | 641 old_store_metadata_.clear(); |
| 618 | 642 |
| 619 deleted_indexes_.clear(); | 643 deleted_indexes_.clear(); |
| 620 deleted_object_stores_.clear(); | 644 deleted_object_stores_.clear(); |
| 621 } | 645 } |
| 622 | 646 |
| 623 } // namespace blink | 647 } // namespace blink |
| OLD | NEW |