Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: content/browser/indexed_db/indexed_db_database.cc

Issue 2511403003: Send IndexedDB observations through IDBDatabaseCallbacks. (Closed)
Patch Set: Rebased. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 int64_t object_store_id, 899 int64_t object_store_id,
902 blink::WebIDBOperationType type, 900 blink::WebIDBOperationType type,
903 const IndexedDBKeyRange& key_range) { 901 const IndexedDBKeyRange& key_range) {
904 for (auto* connection : connections_) { 902 for (auto* connection : connections_) {
905 bool recorded = false; 903 bool recorded = false;
906 for (const auto& observer : connection->active_observers()) { 904 for (const auto& observer : connection->active_observers()) {
907 if (!observer->IsRecordingType(type) || 905 if (!observer->IsRecordingType(type) ||
908 !observer->IsRecordingObjectStore(object_store_id)) 906 !observer->IsRecordingObjectStore(object_store_id))
909 continue; 907 continue;
910 if (!recorded) { 908 if (!recorded) {
911 if (type == blink::WebIDBClear) { 909 auto observation = ::indexed_db::mojom::Observation::New();
912 transaction->AddObservation( 910 observation->object_store_id = object_store_id;
913 connection->id(), 911 observation->type = type;
914 base::MakeUnique<IndexedDBObservation>(object_store_id, type)); 912 if (type != blink::WebIDBClear)
915 } else { 913 observation->key_range = key_range;
916 transaction->AddObservation(connection->id(), 914 transaction->AddObservation(connection->id(), std::move(observation));
917 base::MakeUnique<IndexedDBObservation>(
918 object_store_id, type, key_range));
919 }
920 recorded = true; 915 recorded = true;
921 } 916 }
922 transaction->RecordObserverForLastObservation(connection->id(), 917 transaction->RecordObserverForLastObservation(connection->id(),
923 observer->id()); 918 observer->id());
924 } 919 }
925 } 920 }
926 } 921 }
927 922
928 void IndexedDBDatabase::SendObservations( 923 void IndexedDBDatabase::SendObservations(
929 std::map<int32_t, std::unique_ptr<IndexedDBObserverChanges>> changes_map) { 924 std::map<int32_t, ::indexed_db::mojom::ObserverChangesPtr> changes_map) {
930 for (auto* conn : connections_) { 925 for (auto* conn : connections_) {
931 auto it = changes_map.find(conn->id()); 926 auto it = changes_map.find(conn->id());
932 if (it != changes_map.end()) 927 if (it != changes_map.end())
933 conn->callbacks()->OnDatabaseChange(std::move(it->second)); 928 conn->callbacks()->OnDatabaseChange(std::move(it->second));
934 } 929 }
935 } 930 }
936 931
937 void IndexedDBDatabase::GetAll(int64_t transaction_id, 932 void IndexedDBDatabase::GetAll(int64_t transaction_id,
938 int64_t object_store_id, 933 int64_t object_store_id,
939 int64_t index_id, 934 int64_t index_id,
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 2121
2127 void IndexedDBDatabase::VersionChangeAbortOperation( 2122 void IndexedDBDatabase::VersionChangeAbortOperation(
2128 int64_t previous_version, 2123 int64_t previous_version,
2129 IndexedDBTransaction* transaction) { 2124 IndexedDBTransaction* transaction) {
2130 DCHECK(!transaction); 2125 DCHECK(!transaction);
2131 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); 2126 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation");
2132 metadata_.version = previous_version; 2127 metadata_.version = previous_version;
2133 } 2128 }
2134 2129
2135 } // namespace content 2130 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698