Chromium Code Reviews| Index: third_party/WebKit/Source/modules/indexeddb/IDBRequest.cpp |
| diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBRequest.cpp b/third_party/WebKit/Source/modules/indexeddb/IDBRequest.cpp |
| index 1ddd3180fd4822f5ae6ebb4cba1a9eca170e02ab..a23b9644ec91938f253083f6ffb82f98a3f40d51 100644 |
| --- a/third_party/WebKit/Source/modules/indexeddb/IDBRequest.cpp |
| +++ b/third_party/WebKit/Source/modules/indexeddb/IDBRequest.cpp |
| @@ -41,6 +41,7 @@ |
| #include "modules/indexeddb/IDBCursorWithValue.h" |
| #include "modules/indexeddb/IDBDatabase.h" |
| #include "modules/indexeddb/IDBEventDispatcher.h" |
| +#include "modules/indexeddb/IDBRequestLoader.h" |
| #include "modules/indexeddb/IDBTracing.h" |
| #include "modules/indexeddb/IDBValue.h" |
| #include "modules/indexeddb/WebIDBCallbacksImpl.h" |
| @@ -239,9 +240,90 @@ bool IDBRequest::ShouldEnqueueEvent() const { |
| return true; |
| } |
| +void IDBRequest::QueueResult(DOMException* error) { |
| + outgoing_blob_handles_.clear(); |
| + |
| + if (!transaction_ || !transaction_->HasQueuedResult()) |
| + return OnError(error); |
| + |
| + transaction_->EnqueueResult(new IDBRequestQueueItem(this, error)); |
| +} |
| + |
| +void IDBRequest::QueueResult(IDBKey* key) { |
| + outgoing_blob_handles_.clear(); |
| + |
| + DCHECK(transaction_); |
| + if (!transaction_->HasQueuedResult()) |
| + return OnSuccess(key); |
| + |
| + transaction_->EnqueueResult(new IDBRequestQueueItem(this, key)); |
| +} |
| + |
| +void IDBRequest::QueueResult(std::unique_ptr<WebIDBCursor> backend, |
| + IDBKey* key, |
| + IDBKey* primary_key, |
| + PassRefPtr<IDBValue> value) { |
| + bool needs_unwrapping = IDBRequestLoader::NeedsUnwrapping(value.Get()); |
| + |
| + DCHECK(transaction_); |
| + if (!transaction_->HasQueuedResult() && !needs_unwrapping) |
| + return OnSuccess(std::move(backend), key, primary_key, std::move(value)); |
| + |
| + IDBRequestQueueItem* queue_item = new IDBRequestQueueItem( |
| + this, std::move(backend), key, primary_key, std::move(value)); |
| + if (needs_unwrapping) |
| + queue_item->AttachLoader(); |
| + transaction_->EnqueueResult(queue_item); |
| + queue_item->StartLoading(); |
| +} |
| +void IDBRequest::QueueResult(PassRefPtr<IDBValue> value) { |
| + bool needs_unwrapping = IDBRequestLoader::NeedsUnwrapping(value.Get()); |
| + |
| + DCHECK(transaction_); |
| + if (!transaction_->HasQueuedResult() && !needs_unwrapping) |
| + return OnSuccess(std::move(value)); |
| + |
| + IDBRequestQueueItem* queue_item = |
| + new IDBRequestQueueItem(this, std::move(value)); |
| + if (needs_unwrapping) |
| + queue_item->AttachLoader(); |
| + transaction_->EnqueueResult(queue_item); |
| + queue_item->StartLoading(); |
| +} |
| + |
| +void IDBRequest::QueueResult(const Vector<RefPtr<IDBValue>>& values) { |
| + bool needs_unwrapping = IDBRequestLoader::NeedUnwrapping(values); |
| + |
| + DCHECK(transaction_); |
| + if (!transaction_->HasQueuedResult() && !needs_unwrapping) |
| + return OnSuccess(values); |
| + |
| + IDBRequestQueueItem* queue_item = new IDBRequestQueueItem(this, values); |
| + if (needs_unwrapping) |
| + queue_item->AttachLoader(); |
| + transaction_->EnqueueResult(queue_item); |
| + queue_item->StartLoading(); |
| +} |
| + |
| +void IDBRequest::QueueResult(IDBKey* key, |
| + IDBKey* primary_key, |
| + PassRefPtr<IDBValue> value) { |
| + bool needs_unwrapping = IDBRequestLoader::NeedsUnwrapping(value.Get()); |
| + |
| + DCHECK(transaction_); |
| + if (!transaction_->HasQueuedResult() && !needs_unwrapping) |
| + return OnSuccess(key, primary_key, std::move(value)); |
| + |
| + IDBRequestQueueItem* queue_item = |
| + new IDBRequestQueueItem(this, key, primary_key, std::move(value)); |
| + if (needs_unwrapping) |
| + queue_item->AttachLoader(); |
| + transaction_->EnqueueResult(queue_item); |
| + queue_item->StartLoading(); |
| +} |
| + |
| void IDBRequest::OnError(DOMException* error) { |
| IDB_TRACE("IDBRequest::onError()"); |
| - ClearPutOperationBlobs(); |
|
dmurph
2017/05/04 22:27:07
Would we put these in the QueueResult callsa as we
pwnall
2017/05/11 23:54:23
I called clear() directly on the vector. It seemed
|
| if (!ShouldEnqueueEvent()) |
| return; |
| @@ -290,7 +372,6 @@ void IDBRequest::OnSuccess(std::unique_ptr<WebIDBCursor> backend, |
| void IDBRequest::OnSuccess(IDBKey* idb_key) { |
| IDB_TRACE("IDBRequest::onSuccess(IDBKey)"); |
| - ClearPutOperationBlobs(); |
| if (!ShouldEnqueueEvent()) |
| return; |
| @@ -362,7 +443,7 @@ void IDBRequest::OnSuccess() { |
| void IDBRequest::OnSuccessInternal(IDBAny* result) { |
| DCHECK(GetExecutionContext()); |
| DCHECK(!pending_cursor_); |
| - DCHECK(transit_blob_handles_.IsEmpty()); |
| + DCHECK(outgoing_blob_handles_.IsEmpty()); |
| SetResult(result); |
| EnqueueEvent(Event::Create(EventTypeNames::success)); |
| } |