Chromium Code Reviews| OLD | NEW |
|---|---|
| 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; |
|
cmumford
2017/01/17 20:58:10
Add newline before.
dmurph
2017/01/17 23:28:04
Done.
Actually, as per working with Victor, we re
| |
| 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 Loading... | |
| 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. | |
| 163 if (next_observer_transaction_id_ == kMaxObserverTransactionId) | |
| 164 next_observer_transaction_id_ = 1ll << 32; | |
| 165 DCHECK_EQ(next_observer_transaction_id_ & 0xFFFFFFFF, 0) | |
| 166 << "Highest order bits reserved for renderer-created transactions"; | |
| 167 return next_observer_transaction_id_++; | |
| 168 } | |
| 169 | |
| 161 } // namespace content | 170 } // namespace content |
| OLD | NEW |