| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 { | 67 { |
| 68 visitor->trace(m_transaction); | 68 visitor->trace(m_transaction); |
| 69 visitor->trace(m_indexMap); | 69 visitor->trace(m_indexMap); |
| 70 } | 70 } |
| 71 | 71 |
| 72 ScriptValue IDBObjectStore::keyPath(ScriptState* scriptState) const | 72 ScriptValue IDBObjectStore::keyPath(ScriptState* scriptState) const |
| 73 { | 73 { |
| 74 return ScriptValue::from(scriptState, m_metadata.keyPath); | 74 return ScriptValue::from(scriptState, m_metadata.keyPath); |
| 75 } | 75 } |
| 76 | 76 |
| 77 PassRefPtrWillBeRawPtr<DOMStringList> IDBObjectStore::indexNames() const | 77 RawPtr<DOMStringList> IDBObjectStore::indexNames() const |
| 78 { | 78 { |
| 79 IDB_TRACE("IDBObjectStore::indexNames"); | 79 IDB_TRACE("IDBObjectStore::indexNames"); |
| 80 RefPtrWillBeRawPtr<DOMStringList> indexNames = DOMStringList::create(DOMStri
ngList::IndexedDB); | 80 RawPtr<DOMStringList> indexNames = DOMStringList::create(DOMStringList::Inde
xedDB); |
| 81 for (const auto& it : m_metadata.indexes) | 81 for (const auto& it : m_metadata.indexes) |
| 82 indexNames->append(it.value.name); | 82 indexNames->append(it.value.name); |
| 83 indexNames->sort(); | 83 indexNames->sort(); |
| 84 return indexNames.release(); | 84 return indexNames.release(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 IDBRequest* IDBObjectStore::get(ScriptState* scriptState, const ScriptValue& key
, ExceptionState& exceptionState) | 87 IDBRequest* IDBObjectStore::get(ScriptState* scriptState, const ScriptValue& key
, ExceptionState& exceptionState) |
| 88 { | 88 { |
| 89 IDB_TRACE("IDBObjectStore::get"); | 89 IDB_TRACE("IDBObjectStore::get"); |
| 90 if (isDeleted()) { | 90 if (isDeleted()) { |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 } | 408 } |
| 409 | 409 |
| 410 namespace { | 410 namespace { |
| 411 // This class creates the index keys for a given index by extracting | 411 // This class creates the index keys for a given index by extracting |
| 412 // them from the SerializedScriptValue, for all the existing values in | 412 // them from the SerializedScriptValue, for all the existing values in |
| 413 // the objectStore. It only needs to be kept alive by virtue of being | 413 // the objectStore. It only needs to be kept alive by virtue of being |
| 414 // a listener on an IDBRequest object, in the same way that JavaScript | 414 // a listener on an IDBRequest object, in the same way that JavaScript |
| 415 // cursor success handlers are kept alive. | 415 // cursor success handlers are kept alive. |
| 416 class IndexPopulator final : public EventListener { | 416 class IndexPopulator final : public EventListener { |
| 417 public: | 417 public: |
| 418 static PassRefPtrWillBeRawPtr<IndexPopulator> create(ScriptState* scriptStat
e, IDBDatabase* database, int64_t transactionId, int64_t objectStoreId, const ID
BIndexMetadata& indexMetadata) | 418 static RawPtr<IndexPopulator> create(ScriptState* scriptState, IDBDatabase*
database, int64_t transactionId, int64_t objectStoreId, const IDBIndexMetadata&
indexMetadata) |
| 419 { | 419 { |
| 420 return adoptRefWillBeNoop(new IndexPopulator(scriptState, database, tran
sactionId, objectStoreId, indexMetadata)); | 420 return (new IndexPopulator(scriptState, database, transactionId, objectS
toreId, indexMetadata)); |
| 421 } | 421 } |
| 422 | 422 |
| 423 bool operator==(const EventListener& other) const override | 423 bool operator==(const EventListener& other) const override |
| 424 { | 424 { |
| 425 return this == &other; | 425 return this == &other; |
| 426 } | 426 } |
| 427 | 427 |
| 428 DEFINE_INLINE_VIRTUAL_TRACE() | 428 DEFINE_INLINE_VIRTUAL_TRACE() |
| 429 { | 429 { |
| 430 visitor->trace(m_database); | 430 visitor->trace(m_database); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 } else { | 475 } else { |
| 476 // Now that we are done indexing, tell the backend to go | 476 // Now that we are done indexing, tell the backend to go |
| 477 // back to processing tasks of type NormalTask. | 477 // back to processing tasks of type NormalTask. |
| 478 m_database->backend()->setIndexesReady(m_transactionId, m_objectStor
eId, indexIds); | 478 m_database->backend()->setIndexesReady(m_transactionId, m_objectStor
eId, indexIds); |
| 479 m_database.clear(); | 479 m_database.clear(); |
| 480 } | 480 } |
| 481 | 481 |
| 482 } | 482 } |
| 483 | 483 |
| 484 RefPtr<ScriptState> m_scriptState; | 484 RefPtr<ScriptState> m_scriptState; |
| 485 PersistentWillBeMember<IDBDatabase> m_database; | 485 Member<IDBDatabase> m_database; |
| 486 const int64_t m_transactionId; | 486 const int64_t m_transactionId; |
| 487 const int64_t m_objectStoreId; | 487 const int64_t m_objectStoreId; |
| 488 const IDBIndexMetadata m_indexMetadata; | 488 const IDBIndexMetadata m_indexMetadata; |
| 489 }; | 489 }; |
| 490 } // namespace | 490 } // namespace |
| 491 | 491 |
| 492 IDBIndex* IDBObjectStore::createIndex(ScriptState* scriptState, const String& na
me, const IDBKeyPath& keyPath, const IDBIndexParameters& options, ExceptionState
& exceptionState) | 492 IDBIndex* IDBObjectStore::createIndex(ScriptState* scriptState, const String& na
me, const IDBKeyPath& keyPath, const IDBIndexParameters& options, ExceptionState
& exceptionState) |
| 493 { | 493 { |
| 494 IDB_TRACE("IDBObjectStore::createIndex"); | 494 IDB_TRACE("IDBObjectStore::createIndex"); |
| 495 if (!m_transaction->isVersionChange()) { | 495 if (!m_transaction->isVersionChange()) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 m_transaction->db()->indexCreated(id(), metadata); | 538 m_transaction->db()->indexCreated(id(), metadata); |
| 539 | 539 |
| 540 ASSERT(!exceptionState.hadException()); | 540 ASSERT(!exceptionState.hadException()); |
| 541 if (exceptionState.hadException()) | 541 if (exceptionState.hadException()) |
| 542 return nullptr; | 542 return nullptr; |
| 543 | 543 |
| 544 IDBRequest* indexRequest = openCursor(scriptState, nullptr, WebIDBCursorDire
ctionNext, WebIDBTaskTypePreemptive); | 544 IDBRequest* indexRequest = openCursor(scriptState, nullptr, WebIDBCursorDire
ctionNext, WebIDBTaskTypePreemptive); |
| 545 indexRequest->preventPropagation(); | 545 indexRequest->preventPropagation(); |
| 546 | 546 |
| 547 // This is kept alive by being the success handler of the request, which is
in turn kept alive by the owning transaction. | 547 // This is kept alive by being the success handler of the request, which is
in turn kept alive by the owning transaction. |
| 548 RefPtrWillBeRawPtr<IndexPopulator> indexPopulator = IndexPopulator::create(s
criptState, transaction()->db(), m_transaction->id(), id(), metadata); | 548 RawPtr<IndexPopulator> indexPopulator = IndexPopulator::create(scriptState,
transaction()->db(), m_transaction->id(), id(), metadata); |
| 549 indexRequest->setOnsuccess(indexPopulator); | 549 indexRequest->setOnsuccess(indexPopulator); |
| 550 return index; | 550 return index; |
| 551 } | 551 } |
| 552 | 552 |
| 553 IDBIndex* IDBObjectStore::index(const String& name, ExceptionState& exceptionSta
te) | 553 IDBIndex* IDBObjectStore::index(const String& name, ExceptionState& exceptionSta
te) |
| 554 { | 554 { |
| 555 IDB_TRACE("IDBObjectStore::index"); | 555 IDB_TRACE("IDBObjectStore::index"); |
| 556 if (isDeleted()) { | 556 if (isDeleted()) { |
| 557 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); | 557 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS
toreDeletedErrorMessage); |
| 558 return nullptr; | 558 return nullptr; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 } | 746 } |
| 747 return IDBIndexMetadata::InvalidId; | 747 return IDBIndexMetadata::InvalidId; |
| 748 } | 748 } |
| 749 | 749 |
| 750 WebIDBDatabase* IDBObjectStore::backendDB() const | 750 WebIDBDatabase* IDBObjectStore::backendDB() const |
| 751 { | 751 { |
| 752 return m_transaction->backendDB(); | 752 return m_transaction->backendDB(); |
| 753 } | 753 } |
| 754 | 754 |
| 755 } // namespace blink | 755 } // namespace blink |
| OLD | NEW |