| 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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 } | 412 } |
| 413 | 413 |
| 414 namespace { | 414 namespace { |
| 415 // This class creates the index keys for a given index by extracting | 415 // This class creates the index keys for a given index by extracting |
| 416 // them from the SerializedScriptValue, for all the existing values in | 416 // them from the SerializedScriptValue, for all the existing values in |
| 417 // the objectStore. It only needs to be kept alive by virtue of being | 417 // the objectStore. It only needs to be kept alive by virtue of being |
| 418 // a listener on an IDBRequest object, in the same way that JavaScript | 418 // a listener on an IDBRequest object, in the same way that JavaScript |
| 419 // cursor success handlers are kept alive. | 419 // cursor success handlers are kept alive. |
| 420 class IndexPopulator final : public EventListener { | 420 class IndexPopulator final : public EventListener { |
| 421 public: | 421 public: |
| 422 static PassRefPtr<IndexPopulator> create(ScriptState* scriptState, IDBDataba
se* database, int64_t transactionId, int64_t objectStoreId, const IDBIndexMetada
ta& indexMetadata) | 422 static PassRefPtrWillBeRawPtr<IndexPopulator> create(ScriptState* scriptStat
e, IDBDatabase* database, int64_t transactionId, int64_t objectStoreId, const ID
BIndexMetadata& indexMetadata) |
| 423 { | 423 { |
| 424 return adoptRef(new IndexPopulator(scriptState, database, transactionId,
objectStoreId, indexMetadata)); | 424 return adoptRefWillBeNoop(new IndexPopulator(scriptState, database, tran
sactionId, objectStoreId, indexMetadata)); |
| 425 } | 425 } |
| 426 | 426 |
| 427 bool operator==(const EventListener& other) override | 427 bool operator==(const EventListener& other) override |
| 428 { | 428 { |
| 429 return this == &other; | 429 return this == &other; |
| 430 } | 430 } |
| 431 | 431 |
| 432 DEFINE_INLINE_VIRTUAL_TRACE() |
| 433 { |
| 434 visitor->trace(m_database); |
| 435 EventListener::trace(visitor); |
| 436 } |
| 437 |
| 432 private: | 438 private: |
| 433 IndexPopulator(ScriptState* scriptState, IDBDatabase* database, int64_t tran
sactionId, int64_t objectStoreId, const IDBIndexMetadata& indexMetadata) | 439 IndexPopulator(ScriptState* scriptState, IDBDatabase* database, int64_t tran
sactionId, int64_t objectStoreId, const IDBIndexMetadata& indexMetadata) |
| 434 : EventListener(CPPEventListenerType) | 440 : EventListener(CPPEventListenerType) |
| 435 , m_scriptState(scriptState) | 441 , m_scriptState(scriptState) |
| 436 , m_database(database) | 442 , m_database(database) |
| 437 , m_transactionId(transactionId) | 443 , m_transactionId(transactionId) |
| 438 , m_objectStoreId(objectStoreId) | 444 , m_objectStoreId(objectStoreId) |
| 439 , m_indexMetadata(indexMetadata) | 445 , m_indexMetadata(indexMetadata) |
| 440 { | 446 { |
| 441 } | 447 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 } else { | 479 } else { |
| 474 // Now that we are done indexing, tell the backend to go | 480 // Now that we are done indexing, tell the backend to go |
| 475 // back to processing tasks of type NormalTask. | 481 // back to processing tasks of type NormalTask. |
| 476 m_database->backend()->setIndexesReady(m_transactionId, m_objectStor
eId, indexIds); | 482 m_database->backend()->setIndexesReady(m_transactionId, m_objectStor
eId, indexIds); |
| 477 m_database.clear(); | 483 m_database.clear(); |
| 478 } | 484 } |
| 479 | 485 |
| 480 } | 486 } |
| 481 | 487 |
| 482 RefPtr<ScriptState> m_scriptState; | 488 RefPtr<ScriptState> m_scriptState; |
| 483 Persistent<IDBDatabase> m_database; | 489 PersistentWillBeMember<IDBDatabase> m_database; |
| 484 const int64_t m_transactionId; | 490 const int64_t m_transactionId; |
| 485 const int64_t m_objectStoreId; | 491 const int64_t m_objectStoreId; |
| 486 const IDBIndexMetadata m_indexMetadata; | 492 const IDBIndexMetadata m_indexMetadata; |
| 487 }; | 493 }; |
| 488 } | 494 } |
| 489 | 495 |
| 490 IDBIndex* IDBObjectStore::createIndex(ScriptState* scriptState, const String& na
me, const IDBKeyPath& keyPath, const IDBIndexParameters& options, ExceptionState
& exceptionState) | 496 IDBIndex* IDBObjectStore::createIndex(ScriptState* scriptState, const String& na
me, const IDBKeyPath& keyPath, const IDBIndexParameters& options, ExceptionState
& exceptionState) |
| 491 { | 497 { |
| 492 IDB_TRACE("IDBObjectStore::createIndex"); | 498 IDB_TRACE("IDBObjectStore::createIndex"); |
| 493 if (!m_transaction->isVersionChange()) { | 499 if (!m_transaction->isVersionChange()) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 m_transaction->db()->indexCreated(id(), metadata); | 542 m_transaction->db()->indexCreated(id(), metadata); |
| 537 | 543 |
| 538 ASSERT(!exceptionState.hadException()); | 544 ASSERT(!exceptionState.hadException()); |
| 539 if (exceptionState.hadException()) | 545 if (exceptionState.hadException()) |
| 540 return nullptr; | 546 return nullptr; |
| 541 | 547 |
| 542 IDBRequest* indexRequest = openCursor(scriptState, nullptr, WebIDBCursorDire
ctionNext, WebIDBTaskTypePreemptive); | 548 IDBRequest* indexRequest = openCursor(scriptState, nullptr, WebIDBCursorDire
ctionNext, WebIDBTaskTypePreemptive); |
| 543 indexRequest->preventPropagation(); | 549 indexRequest->preventPropagation(); |
| 544 | 550 |
| 545 // This is kept alive by being the success handler of the request, which is
in turn kept alive by the owning transaction. | 551 // This is kept alive by being the success handler of the request, which is
in turn kept alive by the owning transaction. |
| 546 RefPtr<IndexPopulator> indexPopulator = IndexPopulator::create(scriptState,
transaction()->db(), m_transaction->id(), id(), metadata); | 552 RefPtrWillBeRawPtr<IndexPopulator> indexPopulator = IndexPopulator::create(s
criptState, transaction()->db(), m_transaction->id(), id(), metadata); |
| 547 indexRequest->setOnsuccess(indexPopulator); | 553 indexRequest->setOnsuccess(indexPopulator); |
| 548 return index; | 554 return index; |
| 549 } | 555 } |
| 550 | 556 |
| 551 IDBIndex* IDBObjectStore::index(const String& name, ExceptionState& exceptionSta
te) | 557 IDBIndex* IDBObjectStore::index(const String& name, ExceptionState& exceptionSta
te) |
| 552 { | 558 { |
| 553 IDB_TRACE("IDBObjectStore::index"); | 559 IDB_TRACE("IDBObjectStore::index"); |
| 554 if (isDeleted()) { | 560 if (isDeleted()) { |
| 555 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 561 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
| 556 return nullptr; | 562 return nullptr; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 } | 750 } |
| 745 return IDBIndexMetadata::InvalidId; | 751 return IDBIndexMetadata::InvalidId; |
| 746 } | 752 } |
| 747 | 753 |
| 748 WebIDBDatabase* IDBObjectStore::backendDB() const | 754 WebIDBDatabase* IDBObjectStore::backendDB() const |
| 749 { | 755 { |
| 750 return m_transaction->backendDB(); | 756 return m_transaction->backendDB(); |
| 751 } | 757 } |
| 752 | 758 |
| 753 } // namespace blink | 759 } // namespace blink |
| OLD | NEW |