| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/indexed_db/indexed_db_database.h" | 5 #include "content/browser/indexed_db/indexed_db_database.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <set> | 10 #include <set> |
| 11 | 11 |
| 12 #include "base/auto_reset.h" | 12 #include "base/auto_reset.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
| 17 #include "base/numerics/safe_conversions.h" | 17 #include "base/numerics/safe_conversions.h" |
| 18 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
| 19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 21 #include "content/browser/indexed_db/indexed_db_blob_info.h" | 21 #include "content/browser/indexed_db/indexed_db_blob_info.h" |
| 22 #include "content/browser/indexed_db/indexed_db_class_factory.h" | 22 #include "content/browser/indexed_db/indexed_db_class_factory.h" |
| 23 #include "content/browser/indexed_db/indexed_db_connection.h" | 23 #include "content/browser/indexed_db/indexed_db_connection.h" |
| 24 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 24 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
| 25 #include "content/browser/indexed_db/indexed_db_cursor.h" | 25 #include "content/browser/indexed_db/indexed_db_cursor.h" |
| 26 #include "content/browser/indexed_db/indexed_db_factory.h" | 26 #include "content/browser/indexed_db/indexed_db_factory.h" |
| 27 #include "content/browser/indexed_db/indexed_db_index_writer.h" | 27 #include "content/browser/indexed_db/indexed_db_index_writer.h" |
| 28 #include "content/browser/indexed_db/indexed_db_observation.h" | |
| 29 #include "content/browser/indexed_db/indexed_db_observer_changes.h" | |
| 30 #include "content/browser/indexed_db/indexed_db_pending_connection.h" | 28 #include "content/browser/indexed_db/indexed_db_pending_connection.h" |
| 31 #include "content/browser/indexed_db/indexed_db_return_value.h" | 29 #include "content/browser/indexed_db/indexed_db_return_value.h" |
| 32 #include "content/browser/indexed_db/indexed_db_tracing.h" | 30 #include "content/browser/indexed_db/indexed_db_tracing.h" |
| 33 #include "content/browser/indexed_db/indexed_db_transaction.h" | 31 #include "content/browser/indexed_db/indexed_db_transaction.h" |
| 34 #include "content/browser/indexed_db/indexed_db_value.h" | 32 #include "content/browser/indexed_db/indexed_db_value.h" |
| 35 #include "content/common/indexed_db/indexed_db_constants.h" | 33 #include "content/common/indexed_db/indexed_db_constants.h" |
| 36 #include "content/common/indexed_db/indexed_db_key_path.h" | 34 #include "content/common/indexed_db/indexed_db_key_path.h" |
| 37 #include "content/common/indexed_db/indexed_db_key_range.h" | 35 #include "content/common/indexed_db/indexed_db_key_range.h" |
| 38 #include "content/public/common/content_switches.h" | 36 #include "content/public/common/content_switches.h" |
| 39 #include "storage/browser/blob/blob_data_handle.h" | 37 #include "storage/browser/blob/blob_data_handle.h" |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 int64_t object_store_id, | 898 int64_t object_store_id, |
| 901 blink::WebIDBOperationType type, | 899 blink::WebIDBOperationType type, |
| 902 const IndexedDBKeyRange& key_range) { | 900 const IndexedDBKeyRange& key_range) { |
| 903 for (auto* connection : connections_) { | 901 for (auto* connection : connections_) { |
| 904 bool recorded = false; | 902 bool recorded = false; |
| 905 for (const auto& observer : connection->active_observers()) { | 903 for (const auto& observer : connection->active_observers()) { |
| 906 if (!observer->IsRecordingType(type) || | 904 if (!observer->IsRecordingType(type) || |
| 907 !observer->IsRecordingObjectStore(object_store_id)) | 905 !observer->IsRecordingObjectStore(object_store_id)) |
| 908 continue; | 906 continue; |
| 909 if (!recorded) { | 907 if (!recorded) { |
| 910 if (type == blink::WebIDBClear) { | 908 auto observation = ::indexed_db::mojom::Observation::New(); |
| 911 transaction->AddObservation( | 909 observation->object_store_id = object_store_id; |
| 912 connection->id(), | 910 observation->type = type; |
| 913 base::MakeUnique<IndexedDBObservation>(object_store_id, type)); | 911 if (type != blink::WebIDBClear) |
| 914 } else { | 912 observation->key_range = key_range; |
| 915 transaction->AddObservation(connection->id(), | 913 transaction->AddObservation(connection->id(), std::move(observation)); |
| 916 base::MakeUnique<IndexedDBObservation>( | |
| 917 object_store_id, type, key_range)); | |
| 918 } | |
| 919 recorded = true; | 914 recorded = true; |
| 920 } | 915 } |
| 921 transaction->RecordObserverForLastObservation(connection->id(), | 916 transaction->RecordObserverForLastObservation(connection->id(), |
| 922 observer->id()); | 917 observer->id()); |
| 923 } | 918 } |
| 924 } | 919 } |
| 925 } | 920 } |
| 926 | 921 |
| 927 void IndexedDBDatabase::SendObservations( | 922 void IndexedDBDatabase::SendObservations( |
| 928 std::map<int32_t, std::unique_ptr<IndexedDBObserverChanges>> changes_map) { | 923 std::map<int32_t, ::indexed_db::mojom::ObserverChangesPtr> changes_map) { |
| 929 for (auto* conn : connections_) { | 924 for (auto* conn : connections_) { |
| 930 auto it = changes_map.find(conn->id()); | 925 auto it = changes_map.find(conn->id()); |
| 931 if (it != changes_map.end()) | 926 if (it != changes_map.end()) |
| 932 conn->callbacks()->OnDatabaseChange(std::move(it->second)); | 927 conn->callbacks()->OnDatabaseChange(std::move(it->second)); |
| 933 } | 928 } |
| 934 } | 929 } |
| 935 | 930 |
| 936 void IndexedDBDatabase::GetAll(int64_t transaction_id, | 931 void IndexedDBDatabase::GetAll(int64_t transaction_id, |
| 937 int64_t object_store_id, | 932 int64_t object_store_id, |
| 938 int64_t index_id, | 933 int64_t index_id, |
| (...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2125 | 2120 |
| 2126 void IndexedDBDatabase::VersionChangeAbortOperation( | 2121 void IndexedDBDatabase::VersionChangeAbortOperation( |
| 2127 int64_t previous_version, | 2122 int64_t previous_version, |
| 2128 IndexedDBTransaction* transaction) { | 2123 IndexedDBTransaction* transaction) { |
| 2129 DCHECK(!transaction); | 2124 DCHECK(!transaction); |
| 2130 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); | 2125 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); |
| 2131 metadata_.version = previous_version; | 2126 metadata_.version = previous_version; |
| 2132 } | 2127 } |
| 2133 | 2128 |
| 2134 } // namespace content | 2129 } // namespace content |
| OLD | NEW |