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 | |
385 // TODO(pwnall): Finish figuring out the abort path. | |
386 // DCHECK_EQ(request->QueueItem(), nullptr); | |
387 IDBRequestQueueItem* queue_item = request->QueueItem(); | |
388 if (queue_item) { | |
389 queue_item->CancelLoading(); | |
390 } | |
391 | |
383 // If we aborted the request, it will already have been removed. | 392 // If we aborted the request, it will already have been removed. |
384 request_list_.erase(request); | 393 request_list_.erase(request); |
385 } | 394 } |
386 | 395 |
396 void IDBTransaction::EnqueueResult( | |
397 std::unique_ptr<IDBRequestQueueItem> result) { | |
398 DCHECK(result); | |
399 DCHECK(HasQueuedResults() || !result->IsReady()); | |
400 | |
401 result_queue_.push_back(std::move(result)); | |
402 // StartLoading() may complete post-processing synchronously, so the result | |
403 // needs to be in the queue before StartLoading() is called. | |
404 result_queue_.back()->StartLoading(); | |
405 } | |
406 | |
407 void IDBTransaction::OnResultReady() { | |
dmurph
2017/05/23 18:16:39
Can you rename this to SendPendingReadyResponses()
pwnall
2017/05/25 13:27:11
Let's figure out a good name in the next pass.
| |
408 while (!result_queue_.empty()) { | |
409 IDBRequestQueueItem* result = result_queue_.front().get(); | |
410 if (!result->IsReady()) | |
411 break; | |
412 | |
413 result->EnqueueResponse(); | |
dmurph
2017/05/23 18:16:39
If you change to callbacks.... you can make this j
pwnall
2017/05/25 13:27:12
Per in person discussion, I've introduced a WTF::C
| |
414 result_queue_.pop_front(); | |
415 } | |
416 } | |
417 | |
387 void IDBTransaction::OnAbort(DOMException* error) { | 418 void IDBTransaction::OnAbort(DOMException* error) { |
388 IDB_TRACE("IDBTransaction::onAbort"); | 419 IDB_TRACE("IDBTransaction::onAbort"); |
389 if (!GetExecutionContext()) { | 420 if (!GetExecutionContext()) { |
390 Finished(); | 421 Finished(); |
391 return; | 422 return; |
392 } | 423 } |
393 | 424 |
394 DCHECK_NE(state_, kFinished); | 425 DCHECK_NE(state_, kFinished); |
395 if (state_ != kFinishing) { | 426 if (state_ != kFinishing) { |
396 // Abort was not triggered by front-end. | 427 // 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; | 646 IDBObjectStore* object_store = it.key; |
616 object_store->ClearIndexCache(); | 647 object_store->ClearIndexCache(); |
617 } | 648 } |
618 old_store_metadata_.clear(); | 649 old_store_metadata_.clear(); |
619 | 650 |
620 deleted_indexes_.clear(); | 651 deleted_indexes_.clear(); |
621 deleted_object_stores_.clear(); | 652 deleted_object_stores_.clear(); |
622 } | 653 } |
623 | 654 |
624 } // namespace blink | 655 } // namespace blink |
OLD | NEW |