| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 m_pendingCursor.clear(); | 233 m_pendingCursor.clear(); |
| 234 enqueueEvent(Event::createCancelableBubble(EventTypeNames::error)); | 234 enqueueEvent(Event::createCancelableBubble(EventTypeNames::error)); |
| 235 } | 235 } |
| 236 | 236 |
| 237 void IDBRequest::onSuccess(const Vector<String>& stringList) | 237 void IDBRequest::onSuccess(const Vector<String>& stringList) |
| 238 { | 238 { |
| 239 IDB_TRACE("IDBRequest::onSuccess(StringList)"); | 239 IDB_TRACE("IDBRequest::onSuccess(StringList)"); |
| 240 if (!shouldEnqueueEvent()) | 240 if (!shouldEnqueueEvent()) |
| 241 return; | 241 return; |
| 242 | 242 |
| 243 RefPtrWillBeRawPtr<DOMStringList> domStringList = DOMStringList::create(DOMS
tringList::IndexedDB); | 243 RawPtr<DOMStringList> domStringList = DOMStringList::create(DOMStringList::I
ndexedDB); |
| 244 for (size_t i = 0; i < stringList.size(); ++i) | 244 for (size_t i = 0; i < stringList.size(); ++i) |
| 245 domStringList->append(stringList[i]); | 245 domStringList->append(stringList[i]); |
| 246 onSuccessInternal(IDBAny::create(domStringList.release())); | 246 onSuccessInternal(IDBAny::create(domStringList.release())); |
| 247 } | 247 } |
| 248 | 248 |
| 249 void IDBRequest::onSuccess(PassOwnPtr<WebIDBCursor> backend, IDBKey* key, IDBKey
* primaryKey, PassRefPtr<IDBValue> value) | 249 void IDBRequest::onSuccess(PassOwnPtr<WebIDBCursor> backend, IDBKey* key, IDBKey
* primaryKey, PassRefPtr<IDBValue> value) |
| 250 { | 250 { |
| 251 IDB_TRACE("IDBRequest::onSuccess(IDBCursor)"); | 251 IDB_TRACE("IDBRequest::onSuccess(IDBCursor)"); |
| 252 if (!shouldEnqueueEvent()) | 252 if (!shouldEnqueueEvent()) |
| 253 return; | 253 return; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 const AtomicString& IDBRequest::interfaceName() const | 404 const AtomicString& IDBRequest::interfaceName() const |
| 405 { | 405 { |
| 406 return EventTargetNames::IDBRequest; | 406 return EventTargetNames::IDBRequest; |
| 407 } | 407 } |
| 408 | 408 |
| 409 ExecutionContext* IDBRequest::getExecutionContext() const | 409 ExecutionContext* IDBRequest::getExecutionContext() const |
| 410 { | 410 { |
| 411 return ActiveDOMObject::getExecutionContext(); | 411 return ActiveDOMObject::getExecutionContext(); |
| 412 } | 412 } |
| 413 | 413 |
| 414 DispatchEventResult IDBRequest::dispatchEventInternal(PassRefPtrWillBeRawPtr<Eve
nt> event) | 414 DispatchEventResult IDBRequest::dispatchEventInternal(RawPtr<Event> event) |
| 415 { | 415 { |
| 416 IDB_TRACE("IDBRequest::dispatchEvent"); | 416 IDB_TRACE("IDBRequest::dispatchEvent"); |
| 417 if (m_contextStopped || !getExecutionContext()) | 417 if (m_contextStopped || !getExecutionContext()) |
| 418 return DispatchEventResult::CanceledBeforeDispatch; | 418 return DispatchEventResult::CanceledBeforeDispatch; |
| 419 ASSERT(m_readyState == PENDING); | 419 ASSERT(m_readyState == PENDING); |
| 420 ASSERT(m_hasPendingActivity); | 420 ASSERT(m_hasPendingActivity); |
| 421 ASSERT(m_enqueuedEvents.size()); | 421 ASSERT(m_enqueuedEvents.size()); |
| 422 ASSERT(event->target() == this); | 422 ASSERT(event->target() == this); |
| 423 | 423 |
| 424 ScriptState::Scope scope(m_scriptState.get()); | 424 ScriptState::Scope scope(m_scriptState.get()); |
| 425 | 425 |
| 426 if (event->type() != EventTypeNames::blocked) | 426 if (event->type() != EventTypeNames::blocked) |
| 427 m_readyState = DONE; | 427 m_readyState = DONE; |
| 428 dequeueEvent(event.get()); | 428 dequeueEvent(event.get()); |
| 429 | 429 |
| 430 WillBeHeapVector<RefPtrWillBeMember<EventTarget>> targets; | 430 HeapVector<Member<EventTarget>> targets; |
| 431 targets.append(this); | 431 targets.append(this); |
| 432 if (m_transaction && !m_preventPropagation) { | 432 if (m_transaction && !m_preventPropagation) { |
| 433 targets.append(m_transaction); | 433 targets.append(m_transaction); |
| 434 // If there ever are events that are associated with a database but | 434 // If there ever are events that are associated with a database but |
| 435 // that do not have a transaction, then this will not work and we need | 435 // that do not have a transaction, then this will not work and we need |
| 436 // this object to actually hold a reference to the database (to ensure | 436 // this object to actually hold a reference to the database (to ensure |
| 437 // it stays alive). | 437 // it stays alive). |
| 438 targets.append(m_transaction->db()); | 438 targets.append(m_transaction->db()); |
| 439 } | 439 } |
| 440 | 440 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 ASSERT(m_readyState == DONE); | 503 ASSERT(m_readyState == DONE); |
| 504 ASSERT(getExecutionContext()); | 504 ASSERT(getExecutionContext()); |
| 505 m_transaction.clear(); | 505 m_transaction.clear(); |
| 506 | 506 |
| 507 if (m_contextStopped) | 507 if (m_contextStopped) |
| 508 return; | 508 return; |
| 509 | 509 |
| 510 m_readyState = PENDING; | 510 m_readyState = PENDING; |
| 511 } | 511 } |
| 512 | 512 |
| 513 void IDBRequest::enqueueEvent(PassRefPtrWillBeRawPtr<Event> event) | 513 void IDBRequest::enqueueEvent(RawPtr<Event> event) |
| 514 { | 514 { |
| 515 ASSERT(m_readyState == PENDING || m_readyState == DONE); | 515 ASSERT(m_readyState == PENDING || m_readyState == DONE); |
| 516 | 516 |
| 517 if (m_contextStopped || !getExecutionContext()) | 517 if (m_contextStopped || !getExecutionContext()) |
| 518 return; | 518 return; |
| 519 | 519 |
| 520 DCHECK(m_readyState == PENDING || m_didFireUpgradeNeededEvent) << "When queu
eing event " << event->type() << ", m_readyState was " << m_readyState; | 520 DCHECK(m_readyState == PENDING || m_didFireUpgradeNeededEvent) << "When queu
eing event " << event->type() << ", m_readyState was " << m_readyState; |
| 521 | 521 |
| 522 EventQueue* eventQueue = getExecutionContext()->getEventQueue(); | 522 EventQueue* eventQueue = getExecutionContext()->getEventQueue(); |
| 523 event->setTarget(this); | 523 event->setTarget(this); |
| 524 | 524 |
| 525 // Keep track of enqueued events in case we need to abort prior to dispatch, | 525 // Keep track of enqueued events in case we need to abort prior to dispatch, |
| 526 // in which case these must be cancelled. If the events not dispatched for | 526 // in which case these must be cancelled. If the events not dispatched for |
| 527 // other reasons they must be removed from this list via dequeueEvent(). | 527 // other reasons they must be removed from this list via dequeueEvent(). |
| 528 if (eventQueue->enqueueEvent(event.get())) | 528 if (eventQueue->enqueueEvent(event.get())) |
| 529 m_enqueuedEvents.append(event); | 529 m_enqueuedEvents.append(event); |
| 530 } | 530 } |
| 531 | 531 |
| 532 void IDBRequest::dequeueEvent(Event* event) | 532 void IDBRequest::dequeueEvent(Event* event) |
| 533 { | 533 { |
| 534 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { | 534 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { |
| 535 if (m_enqueuedEvents[i].get() == event) | 535 if (m_enqueuedEvents[i].get() == event) |
| 536 m_enqueuedEvents.remove(i); | 536 m_enqueuedEvents.remove(i); |
| 537 } | 537 } |
| 538 } | 538 } |
| 539 | 539 |
| 540 } // namespace blink | 540 } // namespace blink |
| OLD | NEW |