Chromium Code Reviews| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 IndexedDBTransaction::~IndexedDBTransaction() { | 79 IndexedDBTransaction::~IndexedDBTransaction() { |
| 80 // It shouldn't be possible for this object to get deleted until it's either | 80 // It shouldn't be possible for this object to get deleted until it's either |
| 81 // complete or aborted. | 81 // complete or aborted. |
| 82 DCHECK_EQ(state_, FINISHED); | 82 DCHECK_EQ(state_, FINISHED); |
| 83 DCHECK(preemptive_task_queue_.empty()); | 83 DCHECK(preemptive_task_queue_.empty()); |
| 84 DCHECK_EQ(pending_preemptive_events_, 0); | 84 DCHECK_EQ(pending_preemptive_events_, 0); |
| 85 DCHECK(task_queue_.empty()); | 85 DCHECK(task_queue_.empty()); |
| 86 DCHECK(abort_task_stack_.empty()); | 86 DCHECK(abort_task_stack_.empty()); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void IndexedDBTransaction::ScheduleTask(Operation task, Operation abort_task) { | |
| 90 if (state_ == FINISHED) | |
| 91 return; | |
| 92 | |
| 93 timeout_timer_.Stop(); | |
| 94 used_ = true; | |
| 95 task_queue_.push(task); | |
| 96 ++diagnostics_.tasks_scheduled; | |
| 97 abort_task_stack_.push(abort_task); | |
| 98 RunTasksIfStarted(); | |
| 99 } | |
| 100 | |
| 101 void IndexedDBTransaction::ScheduleTask(IndexedDBDatabase::TaskType type, | 89 void IndexedDBTransaction::ScheduleTask(IndexedDBDatabase::TaskType type, |
| 102 Operation task) { | 90 Operation task) { |
| 103 if (state_ == FINISHED) | 91 if (state_ == FINISHED) |
| 104 return; | 92 return; |
| 105 | 93 |
| 106 timeout_timer_.Stop(); | 94 timeout_timer_.Stop(); |
| 107 used_ = true; | 95 used_ = true; |
| 108 if (type == IndexedDBDatabase::NORMAL_TASK) { | 96 if (type == IndexedDBDatabase::NORMAL_TASK) { |
| 109 task_queue_.push(task); | 97 task_queue_.push(task); |
| 110 ++diagnostics_.tasks_scheduled; | 98 ++diagnostics_.tasks_scheduled; |
| 111 } else { | 99 } else { |
| 112 preemptive_task_queue_.push(task); | 100 preemptive_task_queue_.push(task); |
| 113 } | 101 } |
| 114 RunTasksIfStarted(); | 102 RunTasksIfStarted(); |
|
cmumford
2014/05/13 21:56:24
Will PostTask (run by RunTasksIfStarted) ever run
ericu
2014/05/14 01:08:00
No, PostTask always queues a task for asynchronous
| |
| 115 } | 103 } |
| 116 | 104 |
| 105 void IndexedDBTransaction::ScheduleAbortTask(Operation abort_task) { | |
| 106 DCHECK_NE(FINISHED, state_); | |
| 107 DCHECK(used_); | |
| 108 abort_task_stack_.push(abort_task); | |
| 109 } | |
| 110 | |
| 117 void IndexedDBTransaction::RunTasksIfStarted() { | 111 void IndexedDBTransaction::RunTasksIfStarted() { |
| 118 DCHECK(used_); | 112 DCHECK(used_); |
| 119 | 113 |
| 120 // Not started by the coordinator yet. | 114 // Not started by the coordinator yet. |
| 121 if (state_ != STARTED) | 115 if (state_ != STARTED) |
| 122 return; | 116 return; |
| 123 | 117 |
| 124 // A task is already posted. | 118 // A task is already posted. |
| 125 if (should_process_queue_) | 119 if (should_process_queue_) |
| 126 return; | 120 return; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 | 332 |
| 339 void IndexedDBTransaction::CloseOpenCursors() { | 333 void IndexedDBTransaction::CloseOpenCursors() { |
| 340 for (std::set<IndexedDBCursor*>::iterator i = open_cursors_.begin(); | 334 for (std::set<IndexedDBCursor*>::iterator i = open_cursors_.begin(); |
| 341 i != open_cursors_.end(); | 335 i != open_cursors_.end(); |
| 342 ++i) | 336 ++i) |
| 343 (*i)->Close(); | 337 (*i)->Close(); |
| 344 open_cursors_.clear(); | 338 open_cursors_.clear(); |
| 345 } | 339 } |
| 346 | 340 |
| 347 } // namespace content | 341 } // namespace content |
| OLD | NEW |