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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 // No IDBObjectStore instance was created for the deleted store in this | 232 // No IDBObjectStore instance was created for the deleted store in this |
233 // transaction. This happens if IDBDatabase.deleteObjectStore() is called | 233 // transaction. This happens if IDBDatabase.deleteObjectStore() is called |
234 // with the name of a store that wasn't instantated. We need to be able to | 234 // with the name of a store that wasn't instantated. We need to be able to |
235 // revert the metadata change if the transaction aborts, in order to return | 235 // revert the metadata change if the transaction aborts, in order to return |
236 // correct values from IDB{Database, Transaction}.objectStoreNames. | 236 // correct values from IDB{Database, Transaction}.objectStoreNames. |
237 DCHECK(m_database->metadata().objectStores.contains(objectStoreId)); | 237 DCHECK(m_database->metadata().objectStores.contains(objectStoreId)); |
238 RefPtr<IDBObjectStoreMetadata> metadata = | 238 RefPtr<IDBObjectStoreMetadata> metadata = |
239 m_database->metadata().objectStores.get(objectStoreId); | 239 m_database->metadata().objectStores.get(objectStoreId); |
240 DCHECK(metadata.get()); | 240 DCHECK(metadata.get()); |
241 DCHECK_EQ(metadata->name, name); | 241 DCHECK_EQ(metadata->name, name); |
242 m_deletedObjectStores.append(std::move(metadata)); | 242 m_deletedObjectStores.push_back(std::move(metadata)); |
243 } else { | 243 } else { |
244 IDBObjectStore* objectStore = it->value; | 244 IDBObjectStore* objectStore = it->value; |
245 m_objectStoreMap.remove(name); | 245 m_objectStoreMap.remove(name); |
246 objectStore->markDeleted(); | 246 objectStore->markDeleted(); |
247 if (objectStore->id() > m_oldDatabaseMetadata.maxObjectStoreId) { | 247 if (objectStore->id() > m_oldDatabaseMetadata.maxObjectStoreId) { |
248 // The store was created and deleted in this transaction, so it will | 248 // The store was created and deleted in this transaction, so it will |
249 // not be restored even if the transaction aborts. We have just | 249 // not be restored even if the transaction aborts. We have just |
250 // removed our last reference to it. | 250 // removed our last reference to it. |
251 DCHECK(!m_oldStoreMetadata.contains(objectStore)); | 251 DCHECK(!m_oldStoreMetadata.contains(objectStore)); |
252 objectStore->clearIndexCache(); | 252 objectStore->clearIndexCache(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 const IDBObjectStoreMetadata* oldStoreMetadata = | 299 const IDBObjectStoreMetadata* oldStoreMetadata = |
300 objectStoreIterator->value.get(); | 300 objectStoreIterator->value.get(); |
301 DCHECK(oldStoreMetadata); | 301 DCHECK(oldStoreMetadata); |
302 if (!oldStoreMetadata->indexes.contains(index->id())) { | 302 if (!oldStoreMetadata->indexes.contains(index->id())) { |
303 // The index's object store was created before this transaction, but the | 303 // The index's object store was created before this transaction, but the |
304 // index was created (and deleted) in this transaction, so it will not | 304 // index was created (and deleted) in this transaction, so it will not |
305 // be restored if the transaction aborts. | 305 // be restored if the transaction aborts. |
306 return; | 306 return; |
307 } | 307 } |
308 | 308 |
309 m_deletedIndexes.append(index); | 309 m_deletedIndexes.push_back(index); |
310 } | 310 } |
311 | 311 |
312 void IDBTransaction::setActive(bool active) { | 312 void IDBTransaction::setActive(bool active) { |
313 DCHECK_NE(m_state, Finished) << "A finished transaction tried to setActive(" | 313 DCHECK_NE(m_state, Finished) << "A finished transaction tried to setActive(" |
314 << (active ? "true" : "false") << ")"; | 314 << (active ? "true" : "false") << ")"; |
315 if (m_state == Finishing) | 315 if (m_state == Finishing) |
316 return; | 316 return; |
317 DCHECK_NE(active, (m_state == Active)); | 317 DCHECK_NE(active, (m_state == Active)); |
318 m_state = active ? Active : Inactive; | 318 m_state = active ? Active : Inactive; |
319 | 319 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 m_state = Finished; | 461 m_state = Finished; |
462 return DispatchEventResult::CanceledBeforeDispatch; | 462 return DispatchEventResult::CanceledBeforeDispatch; |
463 } | 463 } |
464 DCHECK_NE(m_state, Finished); | 464 DCHECK_NE(m_state, Finished); |
465 DCHECK(m_hasPendingActivity); | 465 DCHECK(m_hasPendingActivity); |
466 DCHECK(getExecutionContext()); | 466 DCHECK(getExecutionContext()); |
467 DCHECK_EQ(event->target(), this); | 467 DCHECK_EQ(event->target(), this); |
468 m_state = Finished; | 468 m_state = Finished; |
469 | 469 |
470 HeapVector<Member<EventTarget>> targets; | 470 HeapVector<Member<EventTarget>> targets; |
471 targets.append(this); | 471 targets.push_back(this); |
472 targets.append(db()); | 472 targets.push_back(db()); |
473 | 473 |
474 // FIXME: When we allow custom event dispatching, this will probably need to | 474 // FIXME: When we allow custom event dispatching, this will probably need to |
475 // change. | 475 // change. |
476 DCHECK(event->type() == EventTypeNames::complete || | 476 DCHECK(event->type() == EventTypeNames::complete || |
477 event->type() == EventTypeNames::abort); | 477 event->type() == EventTypeNames::abort); |
478 DispatchEventResult dispatchResult = | 478 DispatchEventResult dispatchResult = |
479 IDBEventDispatcher::dispatch(event, targets); | 479 IDBEventDispatcher::dispatch(event, targets); |
480 // FIXME: Try to construct a test where |this| outlives openDBRequest and we | 480 // FIXME: Try to construct a test where |this| outlives openDBRequest and we |
481 // get a crash. | 481 // get a crash. |
482 if (m_openDBRequest) { | 482 if (m_openDBRequest) { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 IDBObjectStore* objectStore = it.key; | 568 IDBObjectStore* objectStore = it.key; |
569 objectStore->clearIndexCache(); | 569 objectStore->clearIndexCache(); |
570 } | 570 } |
571 m_oldStoreMetadata.clear(); | 571 m_oldStoreMetadata.clear(); |
572 | 572 |
573 m_deletedIndexes.clear(); | 573 m_deletedIndexes.clear(); |
574 m_deletedObjectStores.clear(); | 574 m_deletedObjectStores.clear(); |
575 } | 575 } |
576 | 576 |
577 } // namespace blink | 577 } // namespace blink |
OLD | NEW |