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.h" | 5 #include "content/browser/indexed_db/indexed_db_transaction.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 timeout_timer_.Stop(); | 147 timeout_timer_.Stop(); |
148 | 148 |
149 state_ = FINISHED; | 149 state_ = FINISHED; |
150 should_process_queue_ = false; | 150 should_process_queue_ = false; |
151 | 151 |
152 if (backing_store_transaction_begun_) | 152 if (backing_store_transaction_begun_) |
153 transaction_->Rollback(); | 153 transaction_->Rollback(); |
154 | 154 |
155 // Run the abort tasks, if any. | 155 // Run the abort tasks, if any. |
156 while (!abort_task_stack_.empty()) | 156 while (!abort_task_stack_.empty()) |
157 abort_task_stack_.pop().Run(0); | 157 abort_task_stack_.pop().Run(NULL); |
158 | 158 |
159 preemptive_task_queue_.clear(); | 159 preemptive_task_queue_.clear(); |
160 task_queue_.clear(); | 160 task_queue_.clear(); |
161 | 161 |
162 // Backing store resources (held via cursors) must be released | 162 // Backing store resources (held via cursors) must be released |
163 // before script callbacks are fired, as the script callbacks may | 163 // before script callbacks are fired, as the script callbacks may |
164 // release references and allow the backing store itself to be | 164 // release references and allow the backing store itself to be |
165 // released, and order is critical. | 165 // released, and order is critical. |
166 CloseOpenCursors(); | 166 CloseOpenCursors(); |
167 transaction_->Reset(); | 167 transaction_->Reset(); |
(...skipping 27 matching lines...) Expand all Loading... |
195 } | 195 } |
196 | 196 |
197 void IndexedDBTransaction::UnregisterOpenCursor(IndexedDBCursor* cursor) { | 197 void IndexedDBTransaction::UnregisterOpenCursor(IndexedDBCursor* cursor) { |
198 open_cursors_.erase(cursor); | 198 open_cursors_.erase(cursor); |
199 } | 199 } |
200 | 200 |
201 void IndexedDBTransaction::Start() { | 201 void IndexedDBTransaction::Start() { |
202 // TransactionCoordinator has started this transaction. | 202 // TransactionCoordinator has started this transaction. |
203 DCHECK_EQ(CREATED, state_); | 203 DCHECK_EQ(CREATED, state_); |
204 state_ = STARTED; | 204 state_ = STARTED; |
205 database_->TransactionStarted(this); | |
206 diagnostics_.start_time = base::Time::Now(); | 205 diagnostics_.start_time = base::Time::Now(); |
207 | 206 |
208 if (!used_) | 207 if (!used_) |
209 return; | 208 return; |
210 | 209 |
211 RunTasksIfStarted(); | 210 RunTasksIfStarted(); |
212 } | 211 } |
213 | 212 |
214 void IndexedDBTransaction::Commit() { | 213 void IndexedDBTransaction::Commit() { |
215 IDB_TRACE("IndexedDBTransaction::Commit"); | 214 IDB_TRACE("IndexedDBTransaction::Commit"); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 // front-end is notified, as the transaction completion unblocks | 250 // front-end is notified, as the transaction completion unblocks |
252 // operations like closing connections. | 251 // operations like closing connections. |
253 database_->transaction_coordinator().DidFinishTransaction(this); | 252 database_->transaction_coordinator().DidFinishTransaction(this); |
254 | 253 |
255 if (committed) { | 254 if (committed) { |
256 abort_task_stack_.clear(); | 255 abort_task_stack_.clear(); |
257 callbacks_->OnComplete(id_); | 256 callbacks_->OnComplete(id_); |
258 database_->TransactionFinished(this, true); | 257 database_->TransactionFinished(this, true); |
259 } else { | 258 } else { |
260 while (!abort_task_stack_.empty()) | 259 while (!abort_task_stack_.empty()) |
261 abort_task_stack_.pop().Run(0); | 260 abort_task_stack_.pop().Run(NULL); |
262 | 261 |
263 callbacks_->OnAbort( | 262 callbacks_->OnAbort( |
264 id_, | 263 id_, |
265 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError, | 264 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError, |
266 "Internal error committing transaction.")); | 265 "Internal error committing transaction.")); |
267 database_->TransactionFinished(this, false); | 266 database_->TransactionFinished(this, false); |
268 database_->TransactionCommitFailed(); | 267 database_->TransactionCommitFailed(); |
269 } | 268 } |
270 | 269 |
271 database_ = NULL; | 270 database_ = NULL; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 | 333 |
335 void IndexedDBTransaction::CloseOpenCursors() { | 334 void IndexedDBTransaction::CloseOpenCursors() { |
336 for (std::set<IndexedDBCursor*>::iterator i = open_cursors_.begin(); | 335 for (std::set<IndexedDBCursor*>::iterator i = open_cursors_.begin(); |
337 i != open_cursors_.end(); | 336 i != open_cursors_.end(); |
338 ++i) | 337 ++i) |
339 (*i)->Close(); | 338 (*i)->Close(); |
340 open_cursors_.clear(); | 339 open_cursors_.clear(); |
341 } | 340 } |
342 | 341 |
343 } // namespace content | 342 } // namespace content |
OLD | NEW |