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

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

Issue 2601983002: [IndexedDB] Adding transaction and value support to observers (Closed)
Patch Set: Moved transaction creation to SendObservations Created 3 years, 11 months 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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_connection.h" 5 #include "content/browser/indexed_db/indexed_db_connection.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "content/browser/indexed_db/indexed_db_class_factory.h" 9 #include "content/browser/indexed_db/indexed_db_class_factory.h"
10 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" 10 #include "content/browser/indexed_db/indexed_db_database_callbacks.h"
11 #include "content/browser/indexed_db/indexed_db_observer.h" 11 #include "content/browser/indexed_db/indexed_db_observer.h"
12 #include "content/browser/indexed_db/indexed_db_tracing.h" 12 #include "content/browser/indexed_db/indexed_db_tracing.h"
13 #include "content/browser/indexed_db/indexed_db_transaction.h" 13 #include "content/browser/indexed_db/indexed_db_transaction.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 namespace { 17 namespace {
18 18 static const int64_t kMaxObserverTransactionId = -1ll;
19 static int32_t next_id; 19 static int32_t next_id;
20 20
21 } // namespace 21 } // namespace
22 22
23 IndexedDBConnection::IndexedDBConnection( 23 IndexedDBConnection::IndexedDBConnection(
24 int child_process_id, 24 int child_process_id,
25 scoped_refptr<IndexedDBDatabase> database, 25 scoped_refptr<IndexedDBDatabase> database,
26 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks) 26 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks)
27 : id_(next_id++), 27 : id_(next_id++),
28 child_process_id_(child_process_id), 28 child_process_id_(child_process_id),
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 base::WeakPtr<IndexedDBTransaction> transaction_ptr = 151 base::WeakPtr<IndexedDBTransaction> transaction_ptr =
152 transaction->ptr_factory_.GetWeakPtr(); 152 transaction->ptr_factory_.GetWeakPtr();
153 transactions_[transaction->id()] = std::move(transaction); 153 transactions_[transaction->id()] = std::move(transaction);
154 return transaction_ptr; 154 return transaction_ptr;
155 } 155 }
156 156
157 void IndexedDBConnection::RemoveTransaction(int64_t id) { 157 void IndexedDBConnection::RemoveTransaction(int64_t id) {
158 transactions_.erase(id); 158 transactions_.erase(id);
159 } 159 }
160 160
161 int64_t IndexedDBConnection::NewObserverTransactionId() {
162 // If we ever overflow, just reset the ID.
jsbell 2017/01/13 00:14:12 At 1000 transaction/sec that's 285000 years. But g
dmurph 2017/01/13 01:50:42 haha sgtm.
163 if (next_observer_transaction_id_ == kMaxObserverTransactionId) {
jsbell 2017/01/13 00:14:12 nit: no need for {}
dmurph 2017/01/13 01:50:42 Done.
164 next_observer_transaction_id_ = 1ll << 32;
165 }
166 return next_observer_transaction_id_++;
jsbell 2017/01/13 00:14:12 Maybe DCHECK that the high bits are not 0 ? (whic
dmurph 2017/01/13 01:50:42 Done.
167 }
168
161 } // namespace content 169 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698