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/basictypes.h" | |
8 #include "base/logging.h" | 7 #include "base/logging.h" |
9 #include "content/browser/indexed_db/indexed_db_transaction.h" | 8 #include "content/browser/indexed_db/indexed_db_transaction.h" |
10 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" | 9 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" |
11 | 10 |
12 namespace content { | 11 namespace content { |
13 | 12 |
14 IndexedDBTransactionCoordinator::IndexedDBTransactionCoordinator() {} | 13 IndexedDBTransactionCoordinator::IndexedDBTransactionCoordinator() {} |
15 | 14 |
16 IndexedDBTransactionCoordinator::~IndexedDBTransactionCoordinator() { | 15 IndexedDBTransactionCoordinator::~IndexedDBTransactionCoordinator() { |
17 DCHECK(!queued_transactions_.size()); | 16 DCHECK(!queued_transactions_.size()); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 return; | 79 return; |
81 | 80 |
82 DCHECK(!IsRunningVersionChangeTransaction()); | 81 DCHECK(!IsRunningVersionChangeTransaction()); |
83 | 82 |
84 // The locked_scope set accumulates the ids of object stores in the scope of | 83 // The locked_scope set accumulates the ids of object stores in the scope of |
85 // running read/write transactions. Other read-write transactions with | 84 // running read/write transactions. Other read-write transactions with |
86 // stores in this set may not be started. Read-only transactions may start, | 85 // stores in this set may not be started. Read-only transactions may start, |
87 // taking a snapshot of the database, which does not include uncommitted | 86 // taking a snapshot of the database, which does not include uncommitted |
88 // data. ("Version change" transactions are exclusive, but handled by the | 87 // data. ("Version change" transactions are exclusive, but handled by the |
89 // connection sequencing in IndexedDBDatabase.) | 88 // connection sequencing in IndexedDBDatabase.) |
90 std::set<int64> locked_scope; | 89 std::set<int64_t> locked_scope; |
91 for (const auto& transaction : started_transactions_) { | 90 for (const auto& transaction : started_transactions_) { |
92 if (transaction->mode() == blink::WebIDBTransactionModeReadWrite) { | 91 if (transaction->mode() == blink::WebIDBTransactionModeReadWrite) { |
93 // Started read/write transactions have exclusive access to the object | 92 // Started read/write transactions have exclusive access to the object |
94 // stores within their scopes. | 93 // stores within their scopes. |
95 locked_scope.insert(transaction->scope().begin(), | 94 locked_scope.insert(transaction->scope().begin(), |
96 transaction->scope().end()); | 95 transaction->scope().end()); |
97 } | 96 } |
98 } | 97 } |
99 | 98 |
100 TransactionSet::const_iterator it = queued_transactions_.begin(); | 99 TransactionSet::const_iterator it = queued_transactions_.begin(); |
(...skipping 28 matching lines...) Expand all Loading... |
129 else if (*it2 < *it1) | 128 else if (*it2 < *it1) |
130 ++it2; | 129 ++it2; |
131 else | 130 else |
132 return true; | 131 return true; |
133 } | 132 } |
134 return false; | 133 return false; |
135 } | 134 } |
136 | 135 |
137 bool IndexedDBTransactionCoordinator::CanStartTransaction( | 136 bool IndexedDBTransactionCoordinator::CanStartTransaction( |
138 IndexedDBTransaction* const transaction, | 137 IndexedDBTransaction* const transaction, |
139 const std::set<int64>& locked_scope) const { | 138 const std::set<int64_t>& locked_scope) const { |
140 DCHECK(queued_transactions_.count(transaction)); | 139 DCHECK(queued_transactions_.count(transaction)); |
141 switch (transaction->mode()) { | 140 switch (transaction->mode()) { |
142 case blink::WebIDBTransactionModeVersionChange: | 141 case blink::WebIDBTransactionModeVersionChange: |
143 DCHECK_EQ(1u, queued_transactions_.size()); | 142 DCHECK_EQ(1u, queued_transactions_.size()); |
144 DCHECK(started_transactions_.empty()); | 143 DCHECK(started_transactions_.empty()); |
145 DCHECK(locked_scope.empty()); | 144 DCHECK(locked_scope.empty()); |
146 return true; | 145 return true; |
147 | 146 |
148 case blink::WebIDBTransactionModeReadOnly: | 147 case blink::WebIDBTransactionModeReadOnly: |
149 case blink::WebIDBTransactionModeReadWrite: | 148 case blink::WebIDBTransactionModeReadWrite: |
150 return !DoSetsIntersect(transaction->scope(), locked_scope); | 149 return !DoSetsIntersect(transaction->scope(), locked_scope); |
151 } | 150 } |
152 NOTREACHED(); | 151 NOTREACHED(); |
153 return false; | 152 return false; |
154 } | 153 } |
155 | 154 |
156 } // namespace content | 155 } // namespace content |
OLD | NEW |