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_transaction_coordinator.h" | 5 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/browser/indexed_db/indexed_db_transaction.h" | 8 #include "content/browser/indexed_db/indexed_db_transaction.h" |
9 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" | 9 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 namespace { | |
13 | |
14 // Only this many transactions can be active at any time before they are queued. | |
15 // Limited prevent transaction trashing. Ten is chosen to reduce performance | |
cmumford
2017/02/16 23:36:14
"Limited to prevent"
pwnall
2017/02/16 23:38:28
Is this accurate? I thought we're limiting txns to
dmurph
2017/02/16 23:50:27
That's a side effect of the transaction trashing.
| |
16 // regressions. | |
17 // TODO(dmurph): Choose this number better, or implement a scheduler. | |
pwnall
2017/02/16 23:38:28
crbug in the todo?
dmurph
2017/02/16 23:50:27
Done.
| |
18 static const size_t kMaxStartedTransactions = 10; | |
19 | |
20 } // namespace | |
12 | 21 |
13 IndexedDBTransactionCoordinator::IndexedDBTransactionCoordinator() {} | 22 IndexedDBTransactionCoordinator::IndexedDBTransactionCoordinator() {} |
14 | 23 |
15 IndexedDBTransactionCoordinator::~IndexedDBTransactionCoordinator() { | 24 IndexedDBTransactionCoordinator::~IndexedDBTransactionCoordinator() { |
16 DCHECK(queued_transactions_.empty()); | 25 DCHECK(queued_transactions_.empty()); |
17 DCHECK(started_transactions_.empty()); | 26 DCHECK(started_transactions_.empty()); |
18 } | 27 } |
19 | 28 |
20 void IndexedDBTransactionCoordinator::DidCreateTransaction( | 29 void IndexedDBTransactionCoordinator::DidCreateTransaction( |
21 IndexedDBTransaction* transaction) { | 30 IndexedDBTransaction* transaction) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 ++it2; | 148 ++it2; |
140 else | 149 else |
141 return true; | 150 return true; |
142 } | 151 } |
143 return false; | 152 return false; |
144 } | 153 } |
145 | 154 |
146 bool IndexedDBTransactionCoordinator::CanStartTransaction( | 155 bool IndexedDBTransactionCoordinator::CanStartTransaction( |
147 IndexedDBTransaction* const transaction, | 156 IndexedDBTransaction* const transaction, |
148 const std::set<int64_t>& locked_scope) const { | 157 const std::set<int64_t>& locked_scope) const { |
158 if (started_transactions_.size() >= kMaxStartedTransactions) { | |
159 return false; | |
160 } | |
149 DCHECK(queued_transactions_.count(transaction)); | 161 DCHECK(queued_transactions_.count(transaction)); |
150 switch (transaction->mode()) { | 162 switch (transaction->mode()) { |
151 case blink::WebIDBTransactionModeVersionChange: | 163 case blink::WebIDBTransactionModeVersionChange: |
152 DCHECK_EQ(1u, queued_transactions_.size()); | 164 DCHECK_EQ(1u, queued_transactions_.size()); |
153 DCHECK(started_transactions_.empty()); | 165 DCHECK(started_transactions_.empty()); |
154 DCHECK(locked_scope.empty()); | 166 DCHECK(locked_scope.empty()); |
155 return true; | 167 return true; |
156 | 168 |
157 case blink::WebIDBTransactionModeReadOnly: | 169 case blink::WebIDBTransactionModeReadOnly: |
158 case blink::WebIDBTransactionModeReadWrite: | 170 case blink::WebIDBTransactionModeReadWrite: |
159 return !DoSetsIntersect(transaction->scope(), locked_scope); | 171 return !DoSetsIntersect(transaction->scope(), locked_scope); |
160 } | 172 } |
161 NOTREACHED(); | 173 NOTREACHED(); |
162 return false; | 174 return false; |
163 } | 175 } |
164 | 176 |
165 } // namespace content | 177 } // namespace content |
OLD | NEW |