| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 if (transaction->isVersionChange()) { | 152 if (transaction->isVersionChange()) { |
| 153 DCHECK(!m_versionChangeTransaction); | 153 DCHECK(!m_versionChangeTransaction); |
| 154 m_versionChangeTransaction = transaction; | 154 m_versionChangeTransaction = transaction; |
| 155 } | 155 } |
| 156 } | 156 } |
| 157 | 157 |
| 158 void IDBDatabase::transactionFinished(const IDBTransaction* transaction) { | 158 void IDBDatabase::transactionFinished(const IDBTransaction* transaction) { |
| 159 DCHECK(transaction); | 159 DCHECK(transaction); |
| 160 DCHECK(m_transactions.contains(transaction->id())); | 160 DCHECK(m_transactions.contains(transaction->id())); |
| 161 DCHECK_EQ(m_transactions.get(transaction->id()), transaction); | 161 DCHECK_EQ(m_transactions.at(transaction->id()), transaction); |
| 162 m_transactions.erase(transaction->id()); | 162 m_transactions.erase(transaction->id()); |
| 163 | 163 |
| 164 if (transaction->isVersionChange()) { | 164 if (transaction->isVersionChange()) { |
| 165 DCHECK_EQ(m_versionChangeTransaction, transaction); | 165 DCHECK_EQ(m_versionChangeTransaction, transaction); |
| 166 m_versionChangeTransaction = nullptr; | 166 m_versionChangeTransaction = nullptr; |
| 167 } | 167 } |
| 168 | 168 |
| 169 if (m_closePending && m_transactions.isEmpty()) | 169 if (m_closePending && m_transactions.isEmpty()) |
| 170 closeConnection(); | 170 closeConnection(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void IDBDatabase::onAbort(int64_t transactionId, DOMException* error) { | 173 void IDBDatabase::onAbort(int64_t transactionId, DOMException* error) { |
| 174 DCHECK(m_transactions.contains(transactionId)); | 174 DCHECK(m_transactions.contains(transactionId)); |
| 175 m_transactions.get(transactionId)->onAbort(error); | 175 m_transactions.at(transactionId)->onAbort(error); |
| 176 } | 176 } |
| 177 | 177 |
| 178 void IDBDatabase::onComplete(int64_t transactionId) { | 178 void IDBDatabase::onComplete(int64_t transactionId) { |
| 179 DCHECK(m_transactions.contains(transactionId)); | 179 DCHECK(m_transactions.contains(transactionId)); |
| 180 m_transactions.get(transactionId)->onComplete(); | 180 m_transactions.at(transactionId)->onComplete(); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void IDBDatabase::onChanges( | 183 void IDBDatabase::onChanges( |
| 184 const std::unordered_map<int32_t, std::vector<int32_t>>& | 184 const std::unordered_map<int32_t, std::vector<int32_t>>& |
| 185 observation_index_map, | 185 observation_index_map, |
| 186 const WebVector<WebIDBObservation>& observations, | 186 const WebVector<WebIDBObservation>& observations, |
| 187 const IDBDatabaseCallbacks::TransactionMap& transactions) { | 187 const IDBDatabaseCallbacks::TransactionMap& transactions) { |
| 188 for (const auto& map_entry : observation_index_map) { | 188 for (const auto& map_entry : observation_index_map) { |
| 189 auto it = m_observers.find(map_entry.first); | 189 auto it = m_observers.find(map_entry.first); |
| 190 if (it != m_observers.end()) { | 190 if (it != m_observers.end()) { |
| 191 IDBObserver* observer = it->value; | 191 IDBObserver* observer = it->value; |
| 192 | 192 |
| 193 IDBTransaction* transaction = nullptr; | 193 IDBTransaction* transaction = nullptr; |
| 194 auto it = transactions.find(map_entry.first); | 194 auto it = transactions.find(map_entry.first); |
| 195 if (it != transactions.end()) { | 195 if (it != transactions.end()) { |
| 196 const std::pair<int64_t, std::vector<int64_t>>& obs_txn = it->second; | 196 const std::pair<int64_t, std::vector<int64_t>>& obs_txn = it->second; |
| 197 HashSet<String> stores; | 197 HashSet<String> stores; |
| 198 for (int64_t store_id : obs_txn.second) { | 198 for (int64_t store_id : obs_txn.second) { |
| 199 stores.insert(m_metadata.objectStores.get(store_id)->name); | 199 stores.insert(m_metadata.objectStores.at(store_id)->name); |
| 200 } | 200 } |
| 201 | 201 |
| 202 transaction = IDBTransaction::createObserver( | 202 transaction = IDBTransaction::createObserver( |
| 203 getExecutionContext(), obs_txn.first, stores, this); | 203 getExecutionContext(), obs_txn.first, stores, this); |
| 204 } | 204 } |
| 205 | 205 |
| 206 observer->callback()->call( | 206 observer->callback()->call( |
| 207 observer, IDBObserverChanges::create(this, transaction, observations, | 207 observer, IDBObserverChanges::create(this, transaction, observations, |
| 208 map_entry.second, m_isolate)); | 208 map_entry.second, m_isolate)); |
| 209 if (transaction) | 209 if (transaction) |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 << "Object store renamed on database without a versionchange transaction"; | 535 << "Object store renamed on database without a versionchange transaction"; |
| 536 DCHECK(m_versionChangeTransaction->isActive()) | 536 DCHECK(m_versionChangeTransaction->isActive()) |
| 537 << "Object store renamed when versionchange transaction is not active"; | 537 << "Object store renamed when versionchange transaction is not active"; |
| 538 DCHECK(m_backend) << "Object store renamed after database connection closed"; | 538 DCHECK(m_backend) << "Object store renamed after database connection closed"; |
| 539 DCHECK(m_metadata.objectStores.contains(objectStoreId)); | 539 DCHECK(m_metadata.objectStores.contains(objectStoreId)); |
| 540 | 540 |
| 541 m_backend->renameObjectStore(m_versionChangeTransaction->id(), objectStoreId, | 541 m_backend->renameObjectStore(m_versionChangeTransaction->id(), objectStoreId, |
| 542 newName); | 542 newName); |
| 543 | 543 |
| 544 IDBObjectStoreMetadata* objectStoreMetadata = | 544 IDBObjectStoreMetadata* objectStoreMetadata = |
| 545 m_metadata.objectStores.get(objectStoreId); | 545 m_metadata.objectStores.at(objectStoreId); |
| 546 m_versionChangeTransaction->objectStoreRenamed(objectStoreMetadata->name, | 546 m_versionChangeTransaction->objectStoreRenamed(objectStoreMetadata->name, |
| 547 newName); | 547 newName); |
| 548 objectStoreMetadata->name = newName; | 548 objectStoreMetadata->name = newName; |
| 549 } | 549 } |
| 550 | 550 |
| 551 void IDBDatabase::revertObjectStoreCreation(int64_t objectStoreId) { | 551 void IDBDatabase::revertObjectStoreCreation(int64_t objectStoreId) { |
| 552 DCHECK(m_versionChangeTransaction) << "Object store metadata reverted on " | 552 DCHECK(m_versionChangeTransaction) << "Object store metadata reverted on " |
| 553 "database without a versionchange " | 553 "database without a versionchange " |
| 554 "transaction"; | 554 "transaction"; |
| 555 DCHECK(!m_versionChangeTransaction->isActive()) | 555 DCHECK(!m_versionChangeTransaction->isActive()) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 | 601 |
| 602 void IDBDatabase::recordApiCallsHistogram(IndexedDatabaseMethods method) { | 602 void IDBDatabase::recordApiCallsHistogram(IndexedDatabaseMethods method) { |
| 603 DEFINE_THREAD_SAFE_STATIC_LOCAL( | 603 DEFINE_THREAD_SAFE_STATIC_LOCAL( |
| 604 EnumerationHistogram, apiCallsHistogram, | 604 EnumerationHistogram, apiCallsHistogram, |
| 605 new EnumerationHistogram("WebCore.IndexedDB.FrontEndAPICalls", | 605 new EnumerationHistogram("WebCore.IndexedDB.FrontEndAPICalls", |
| 606 IDBMethodsMax)); | 606 IDBMethodsMax)); |
| 607 apiCallsHistogram.count(method); | 607 apiCallsHistogram.count(method); |
| 608 } | 608 } |
| 609 | 609 |
| 610 } // namespace blink | 610 } // namespace blink |
| OLD | NEW |