| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 base::MessageLoop::current()->PostTask( | 124 base::MessageLoop::current()->PostTask( |
| 125 FROM_HERE, base::Bind(&IndexedDBTransaction::ProcessTaskQueue, this)); | 125 FROM_HERE, base::Bind(&IndexedDBTransaction::ProcessTaskQueue, this)); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void IndexedDBTransaction::Abort() { | 128 void IndexedDBTransaction::Abort() { |
| 129 Abort(IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError, | 129 Abort(IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError, |
| 130 "Internal error (unknown cause)")); | 130 "Internal error (unknown cause)")); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void IndexedDBTransaction::Abort(const IndexedDBDatabaseError& error) { | 133 void IndexedDBTransaction::Abort(const IndexedDBDatabaseError& error) { |
| 134 IDB_TRACE("IndexedDBTransaction::Abort"); | 134 IDB_TRACE1("IndexedDBTransaction::Abort", "txn.id", id()); |
| 135 if (state_ == FINISHED) | 135 if (state_ == FINISHED) |
| 136 return; | 136 return; |
| 137 | 137 |
| 138 // The last reference to this object may be released while performing the | 138 // The last reference to this object may be released while performing the |
| 139 // abort steps below. We therefore take a self reference to keep ourselves | 139 // abort steps below. We therefore take a self reference to keep ourselves |
| 140 // alive while executing this method. | 140 // alive while executing this method. |
| 141 scoped_refptr<IndexedDBTransaction> protect(this); | 141 scoped_refptr<IndexedDBTransaction> protect(this); |
| 142 | 142 |
| 143 timeout_timer_.Stop(); | 143 timeout_timer_.Stop(); |
| 144 | 144 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 return; | 229 return; |
| 230 DCHECK_EQ(state_, COMMITTING); | 230 DCHECK_EQ(state_, COMMITTING); |
| 231 if (success) | 231 if (success) |
| 232 CommitPhaseTwo(); | 232 CommitPhaseTwo(); |
| 233 else | 233 else |
| 234 Abort(IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionDataError, | 234 Abort(IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionDataError, |
| 235 "Failed to write blobs.")); | 235 "Failed to write blobs.")); |
| 236 } | 236 } |
| 237 | 237 |
| 238 void IndexedDBTransaction::Commit() { | 238 void IndexedDBTransaction::Commit() { |
| 239 IDB_TRACE("IndexedDBTransaction::Commit"); | 239 IDB_TRACE1("IndexedDBTransaction::Commit", "txn.id", id()); |
| 240 | 240 |
| 241 // In multiprocess ports, front-end may have requested a commit but | 241 // In multiprocess ports, front-end may have requested a commit but |
| 242 // an abort has already been initiated asynchronously by the | 242 // an abort has already been initiated asynchronously by the |
| 243 // back-end. | 243 // back-end. |
| 244 if (state_ == FINISHED) | 244 if (state_ == FINISHED) |
| 245 return; | 245 return; |
| 246 DCHECK_NE(state_, COMMITTING); | 246 DCHECK_NE(state_, COMMITTING); |
| 247 | 247 |
| 248 DCHECK(!used_ || state_ == STARTED); | 248 DCHECK(!used_ || state_ == STARTED); |
| 249 commit_pending_ = true; | 249 commit_pending_ = true; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError, | 312 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError, |
| 313 "Internal error committing transaction.")); | 313 "Internal error committing transaction.")); |
| 314 database_->TransactionFinished(this, false); | 314 database_->TransactionFinished(this, false); |
| 315 database_->TransactionCommitFailed(); | 315 database_->TransactionCommitFailed(); |
| 316 } | 316 } |
| 317 | 317 |
| 318 database_ = NULL; | 318 database_ = NULL; |
| 319 } | 319 } |
| 320 | 320 |
| 321 void IndexedDBTransaction::ProcessTaskQueue() { | 321 void IndexedDBTransaction::ProcessTaskQueue() { |
| 322 IDB_TRACE("IndexedDBTransaction::ProcessTaskQueue"); | 322 IDB_TRACE1("IndexedDBTransaction::ProcessTaskQueue", "txn.id", id()); |
| 323 | 323 |
| 324 // May have been aborted. | 324 // May have been aborted. |
| 325 if (!should_process_queue_) | 325 if (!should_process_queue_) |
| 326 return; | 326 return; |
| 327 | 327 |
| 328 DCHECK(!IsTaskQueueEmpty()); | 328 DCHECK(!IsTaskQueueEmpty()); |
| 329 should_process_queue_ = false; | 329 should_process_queue_ = false; |
| 330 | 330 |
| 331 if (!backing_store_transaction_begun_) { | 331 if (!backing_store_transaction_begun_) { |
| 332 transaction_->Begin(); | 332 transaction_->Begin(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 | 386 |
| 387 void IndexedDBTransaction::CloseOpenCursors() { | 387 void IndexedDBTransaction::CloseOpenCursors() { |
| 388 for (std::set<IndexedDBCursor*>::iterator i = open_cursors_.begin(); | 388 for (std::set<IndexedDBCursor*>::iterator i = open_cursors_.begin(); |
| 389 i != open_cursors_.end(); | 389 i != open_cursors_.end(); |
| 390 ++i) | 390 ++i) |
| 391 (*i)->Close(); | 391 (*i)->Close(); |
| 392 open_cursors_.clear(); | 392 open_cursors_.clear(); |
| 393 } | 393 } |
| 394 | 394 |
| 395 } // namespace content | 395 } // namespace content |
| OLD | NEW |