| 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 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 #include "bindings/core/v8/ExceptionState.h" | 32 #include "bindings/core/v8/ExceptionState.h" |
| 33 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 33 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 34 #include "bindings/modules/v8/IDBBindingUtilities.h" | 34 #include "bindings/modules/v8/IDBBindingUtilities.h" |
| 35 #include "core/dom/ExecutionContext.h" | 35 #include "core/dom/ExecutionContext.h" |
| 36 #include "core/events/EventQueue.h" | 36 #include "core/events/EventQueue.h" |
| 37 #include "modules/IndexedDBNames.h" | 37 #include "modules/IndexedDBNames.h" |
| 38 #include "modules/indexeddb/IDBCursorWithValue.h" | 38 #include "modules/indexeddb/IDBCursorWithValue.h" |
| 39 #include "modules/indexeddb/IDBDatabase.h" | 39 #include "modules/indexeddb/IDBDatabase.h" |
| 40 #include "modules/indexeddb/IDBEventDispatcher.h" | 40 #include "modules/indexeddb/IDBEventDispatcher.h" |
| 41 #include "modules/indexeddb/IDBPendingTransactionMonitor.h" | |
| 42 #include "modules/indexeddb/IDBTracing.h" | 41 #include "modules/indexeddb/IDBTracing.h" |
| 43 #include "platform/SharedBuffer.h" | 42 #include "platform/SharedBuffer.h" |
| 44 #include "public/platform/WebBlobInfo.h" | 43 #include "public/platform/WebBlobInfo.h" |
| 45 | 44 |
| 46 using blink::WebIDBCursor; | 45 using blink::WebIDBCursor; |
| 47 | 46 |
| 48 namespace blink { | 47 namespace blink { |
| 49 | 48 |
| 50 IDBRequest* IDBRequest::create(ScriptState* scriptState, IDBAny* source, IDBTran
saction* transaction) | 49 IDBRequest* IDBRequest::create(ScriptState* scriptState, IDBAny* source, IDBTran
saction* transaction) |
| 51 { | 50 { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 setBlobInfo(blobInfo); | 207 setBlobInfo(blobInfo); |
| 209 | 208 |
| 210 onSuccessInternal(IDBAny::create(cursor)); | 209 onSuccessInternal(IDBAny::create(cursor)); |
| 211 } | 210 } |
| 212 | 211 |
| 213 void IDBRequest::setBlobInfo(PassOwnPtr<Vector<WebBlobInfo>> blobInfo) | 212 void IDBRequest::setBlobInfo(PassOwnPtr<Vector<WebBlobInfo>> blobInfo) |
| 214 { | 213 { |
| 215 ASSERT(!m_blobInfo); | 214 ASSERT(!m_blobInfo); |
| 216 m_blobInfo = blobInfo; | 215 m_blobInfo = blobInfo; |
| 217 if (m_blobInfo && m_blobInfo->size() > 0) | 216 if (m_blobInfo && m_blobInfo->size() > 0) |
| 218 V8PerIsolateData::from(scriptState()->isolate())->ensureIDBPendingTransa
ctionMonitor()->registerRequest(*this); | 217 ThreadState::current()->registerObjectWithPreFinalizer(*this); |
| 219 } | 218 } |
| 220 | 219 |
| 221 void IDBRequest::handleBlobAcks() | 220 void IDBRequest::handleBlobAcks() |
| 222 { | 221 { |
| 223 if (m_blobInfo.get() && m_blobInfo->size()) { | 222 if (m_blobInfo.get() && m_blobInfo->size()) { |
| 224 m_transaction->db()->ackReceivedBlobs(m_blobInfo.get()); | 223 m_transaction->db()->ackReceivedBlobs(m_blobInfo.get()); |
| 225 m_blobInfo.clear(); | 224 m_blobInfo.clear(); |
| 226 V8PerIsolateData::from(scriptState()->isolate())->ensureIDBPendingTransa
ctionMonitor()->unregisterRequest(*this); | 225 ThreadState::current()->unregisterObjectWithPreFinalizer(*this); |
| 227 } | 226 } |
| 228 } | 227 } |
| 229 | 228 |
| 230 bool IDBRequest::shouldEnqueueEvent() const | 229 bool IDBRequest::shouldEnqueueEvent() const |
| 231 { | 230 { |
| 232 if (m_contextStopped || !executionContext()) | 231 if (m_contextStopped || !executionContext()) |
| 233 return false; | 232 return false; |
| 234 ASSERT(m_readyState == PENDING || m_readyState == DONE); | 233 ASSERT(m_readyState == PENDING || m_readyState == DONE); |
| 235 if (m_requestAborted) | 234 if (m_requestAborted) |
| 236 return false; | 235 return false; |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 // it stays alive). | 453 // it stays alive). |
| 455 targets.append(m_transaction->db()); | 454 targets.append(m_transaction->db()); |
| 456 } | 455 } |
| 457 | 456 |
| 458 // Cursor properties should not be updated until the success event is being
dispatched. | 457 // Cursor properties should not be updated until the success event is being
dispatched. |
| 459 IDBCursor* cursorToNotify = 0; | 458 IDBCursor* cursorToNotify = 0; |
| 460 if (event->type() == EventTypeNames::success) { | 459 if (event->type() == EventTypeNames::success) { |
| 461 cursorToNotify = getResultCursor(); | 460 cursorToNotify = getResultCursor(); |
| 462 if (cursorToNotify) { | 461 if (cursorToNotify) { |
| 463 if (m_blobInfo && m_blobInfo->size() > 0) | 462 if (m_blobInfo && m_blobInfo->size() > 0) |
| 464 V8PerIsolateData::from(scriptState()->isolate())->ensureIDBPendi
ngTransactionMonitor()->unregisterRequest(*this); | 463 ThreadState::current()->unregisterObjectWithPreFinalizer(*this); |
| 465 cursorToNotify->setValueReady(m_cursorKey.release(), m_cursorPrimary
Key.release(), m_cursorValue.release(), m_blobInfo.release()); | 464 cursorToNotify->setValueReady(m_cursorKey.release(), m_cursorPrimary
Key.release(), m_cursorValue.release(), m_blobInfo.release()); |
| 466 } | 465 } |
| 467 } | 466 } |
| 468 | 467 |
| 469 if (event->type() == EventTypeNames::upgradeneeded) { | 468 if (event->type() == EventTypeNames::upgradeneeded) { |
| 470 ASSERT(!m_didFireUpgradeNeededEvent); | 469 ASSERT(!m_didFireUpgradeNeededEvent); |
| 471 m_didFireUpgradeNeededEvent = true; | 470 m_didFireUpgradeNeededEvent = true; |
| 472 } | 471 } |
| 473 | 472 |
| 474 // FIXME: When we allow custom event dispatching, this will probably need to
change. | 473 // FIXME: When we allow custom event dispatching, this will probably need to
change. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 | 550 |
| 552 void IDBRequest::dequeueEvent(Event* event) | 551 void IDBRequest::dequeueEvent(Event* event) |
| 553 { | 552 { |
| 554 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { | 553 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { |
| 555 if (m_enqueuedEvents[i].get() == event) | 554 if (m_enqueuedEvents[i].get() == event) |
| 556 m_enqueuedEvents.remove(i); | 555 m_enqueuedEvents.remove(i); |
| 557 } | 556 } |
| 558 } | 557 } |
| 559 | 558 |
| 560 } // namespace blink | 559 } // namespace blink |
| OLD | NEW |