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 std::unordered_map<int32_t, std::pair<int64_t, std::vector<int64_t>>>& |
| 186 transactions) { |
182 for (const auto& map_entry : observation_index_map) { | 187 for (const auto& map_entry : observation_index_map) { |
183 auto it = m_observers.find(map_entry.first); | 188 auto it = m_observers.find(map_entry.first); |
184 if (it != m_observers.end()) { | 189 if (it != m_observers.end()) { |
185 IDBObserver* observer = it->value; | 190 IDBObserver* observer = it->value; |
| 191 |
| 192 IDBTransaction* transaction = nullptr; |
| 193 auto it = transactions.find(map_entry.first); |
| 194 if (it != transactions.end()) { |
| 195 const std::pair<int64_t, std::vector<int64_t>>& obs_txn = it->second; |
| 196 HashSet<String> stores; |
| 197 for (int64_t store_id : obs_txn.second) { |
| 198 stores.add(m_metadata.objectStores.get(store_id)->name); |
| 199 } |
| 200 |
| 201 transaction = IDBTransaction::createObserver( |
| 202 getExecutionContext(), obs_txn.first, stores, this); |
| 203 } |
| 204 |
186 observer->callback()->call( | 205 observer->callback()->call( |
187 observer, | 206 observer, IDBObserverChanges::create(this, transaction, observations, |
188 IDBObserverChanges::create(this, observations, map_entry.second)); | 207 map_entry.second)); |
| 208 if (transaction) |
| 209 transaction->setActive(false); |
189 } | 210 } |
190 } | 211 } |
191 } | 212 } |
192 | 213 |
193 DOMStringList* IDBDatabase::objectStoreNames() const { | 214 DOMStringList* IDBDatabase::objectStoreNames() const { |
194 DOMStringList* objectStoreNames = | 215 DOMStringList* objectStoreNames = |
195 DOMStringList::create(DOMStringList::IndexedDB); | 216 DOMStringList::create(DOMStringList::IndexedDB); |
196 for (const auto& it : m_metadata.objectStores) | 217 for (const auto& it : m_metadata.objectStores) |
197 objectStoreNames->append(it.value->name); | 218 objectStoreNames->append(it.value->name); |
198 objectStoreNames->sort(); | 219 objectStoreNames->sort(); |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 | 601 |
581 void IDBDatabase::recordApiCallsHistogram(IndexedDatabaseMethods method) { | 602 void IDBDatabase::recordApiCallsHistogram(IndexedDatabaseMethods method) { |
582 DEFINE_THREAD_SAFE_STATIC_LOCAL( | 603 DEFINE_THREAD_SAFE_STATIC_LOCAL( |
583 EnumerationHistogram, apiCallsHistogram, | 604 EnumerationHistogram, apiCallsHistogram, |
584 new EnumerationHistogram("WebCore.IndexedDB.FrontEndAPICalls", | 605 new EnumerationHistogram("WebCore.IndexedDB.FrontEndAPICalls", |
585 IDBMethodsMax)); | 606 IDBMethodsMax)); |
586 apiCallsHistogram.count(method); | 607 apiCallsHistogram.count(method); |
587 } | 608 } |
588 | 609 |
589 } // namespace blink | 610 } // namespace blink |
OLD | NEW |