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 29 matching lines...) Expand all Loading... |
40 #include "modules/indexeddb/IDBKeyPath.h" | 40 #include "modules/indexeddb/IDBKeyPath.h" |
41 #include "modules/indexeddb/IDBObserver.h" | 41 #include "modules/indexeddb/IDBObserver.h" |
42 #include "modules/indexeddb/IDBObserverChanges.h" | 42 #include "modules/indexeddb/IDBObserverChanges.h" |
43 #include "modules/indexeddb/IDBTracing.h" | 43 #include "modules/indexeddb/IDBTracing.h" |
44 #include "modules/indexeddb/IDBVersionChangeEvent.h" | 44 #include "modules/indexeddb/IDBVersionChangeEvent.h" |
45 #include "modules/indexeddb/WebIDBDatabaseCallbacksImpl.h" | 45 #include "modules/indexeddb/WebIDBDatabaseCallbacksImpl.h" |
46 #include "platform/Histogram.h" | 46 #include "platform/Histogram.h" |
47 #include "public/platform/modules/indexeddb/WebIDBKeyPath.h" | 47 #include "public/platform/modules/indexeddb/WebIDBKeyPath.h" |
48 #include "public/platform/modules/indexeddb/WebIDBTypes.h" | 48 #include "public/platform/modules/indexeddb/WebIDBTypes.h" |
49 #include "wtf/Atomics.h" | 49 #include "wtf/Atomics.h" |
| 50 |
50 #include <limits> | 51 #include <limits> |
51 #include <memory> | 52 #include <memory> |
52 | 53 |
53 using blink::WebIDBDatabase; | 54 using blink::WebIDBDatabase; |
54 | 55 |
55 namespace blink { | 56 namespace blink { |
56 | 57 |
| 58 const char IDBDatabase::cannotObserveVersionChangeTransaction[] = |
| 59 "An observer cannot target a version change transaction."; |
57 const char IDBDatabase::indexDeletedErrorMessage[] = | 60 const char IDBDatabase::indexDeletedErrorMessage[] = |
58 "The index or its object store has been deleted."; | 61 "The index or its object store has been deleted."; |
59 const char IDBDatabase::indexNameTakenErrorMessage[] = | 62 const char IDBDatabase::indexNameTakenErrorMessage[] = |
60 "An index with the specified name already exists."; | 63 "An index with the specified name already exists."; |
61 const char IDBDatabase::isKeyCursorErrorMessage[] = | 64 const char IDBDatabase::isKeyCursorErrorMessage[] = |
62 "The cursor is a key cursor."; | 65 "The cursor is a key cursor."; |
63 const char IDBDatabase::noKeyOrKeyRangeErrorMessage[] = | 66 const char IDBDatabase::noKeyOrKeyRangeErrorMessage[] = |
64 "No key or key range specified."; | 67 "No key or key range specified."; |
65 const char IDBDatabase::noSuchIndexErrorMessage[] = | 68 const char IDBDatabase::noSuchIndexErrorMessage[] = |
66 "The specified index was not found."; | 69 "The specified index was not found."; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 } | 174 } |
172 | 175 |
173 void IDBDatabase::onComplete(int64_t transactionId) { | 176 void IDBDatabase::onComplete(int64_t transactionId) { |
174 DCHECK(m_transactions.contains(transactionId)); | 177 DCHECK(m_transactions.contains(transactionId)); |
175 m_transactions.get(transactionId)->onComplete(); | 178 m_transactions.get(transactionId)->onComplete(); |
176 } | 179 } |
177 | 180 |
178 void IDBDatabase::onChanges( | 181 void IDBDatabase::onChanges( |
179 const std::unordered_map<int32_t, std::vector<int32_t>>& | 182 const std::unordered_map<int32_t, std::vector<int32_t>>& |
180 observation_index_map, | 183 observation_index_map, |
181 const WebVector<WebIDBObservation>& observations) { | 184 const WebVector<WebIDBObservation>& observations, |
| 185 const IDBDatabaseCallbacks::TransactionMap& transactions) { |
182 for (const auto& map_entry : observation_index_map) { | 186 for (const auto& map_entry : observation_index_map) { |
183 auto it = m_observers.find(map_entry.first); | 187 auto it = m_observers.find(map_entry.first); |
184 if (it != m_observers.end()) { | 188 if (it != m_observers.end()) { |
185 IDBObserver* observer = it->value; | 189 IDBObserver* observer = it->value; |
| 190 |
| 191 IDBTransaction* transaction = nullptr; |
| 192 auto it = transactions.find(map_entry.first); |
| 193 if (it != transactions.end()) { |
| 194 const std::pair<int64_t, std::vector<int64_t>>& obs_txn = it->second; |
| 195 HashSet<String> stores; |
| 196 for (int64_t store_id : obs_txn.second) { |
| 197 stores.add(m_metadata.objectStores.get(store_id)->name); |
| 198 } |
| 199 |
| 200 transaction = IDBTransaction::createObserver( |
| 201 getExecutionContext(), obs_txn.first, stores, this); |
| 202 } |
| 203 |
186 observer->callback()->call( | 204 observer->callback()->call( |
187 observer, | 205 observer, IDBObserverChanges::create(this, transaction, observations, |
188 IDBObserverChanges::create(this, observations, map_entry.second)); | 206 map_entry.second)); |
| 207 if (transaction) |
| 208 transaction->setActive(false); |
189 } | 209 } |
190 } | 210 } |
191 } | 211 } |
192 | 212 |
193 DOMStringList* IDBDatabase::objectStoreNames() const { | 213 DOMStringList* IDBDatabase::objectStoreNames() const { |
194 DOMStringList* objectStoreNames = | 214 DOMStringList* objectStoreNames = |
195 DOMStringList::create(DOMStringList::IndexedDB); | 215 DOMStringList::create(DOMStringList::IndexedDB); |
196 for (const auto& it : m_metadata.objectStores) | 216 for (const auto& it : m_metadata.objectStores) |
197 objectStoreNames->append(it.value->name); | 217 objectStoreNames->append(it.value->name); |
198 objectStoreNames->sort(); | 218 objectStoreNames->sort(); |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 | 600 |
581 void IDBDatabase::recordApiCallsHistogram(IndexedDatabaseMethods method) { | 601 void IDBDatabase::recordApiCallsHistogram(IndexedDatabaseMethods method) { |
582 DEFINE_THREAD_SAFE_STATIC_LOCAL( | 602 DEFINE_THREAD_SAFE_STATIC_LOCAL( |
583 EnumerationHistogram, apiCallsHistogram, | 603 EnumerationHistogram, apiCallsHistogram, |
584 new EnumerationHistogram("WebCore.IndexedDB.FrontEndAPICalls", | 604 new EnumerationHistogram("WebCore.IndexedDB.FrontEndAPICalls", |
585 IDBMethodsMax)); | 605 IDBMethodsMax)); |
586 apiCallsHistogram.count(method); | 606 apiCallsHistogram.count(method); |
587 } | 607 } |
588 | 608 |
589 } // namespace blink | 609 } // namespace blink |
OLD | NEW |