Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: content/browser/indexed_db/indexed_db_transaction.cc

Issue 19117005: IndexedDB: Coding conventions and cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 } 43 }
44 44
45 scoped_ptr<IndexedDBTransaction::Operation> 45 scoped_ptr<IndexedDBTransaction::Operation>
46 IndexedDBTransaction::TaskStack::pop() { 46 IndexedDBTransaction::TaskStack::pop() {
47 DCHECK(!stack_.empty()); 47 DCHECK(!stack_.empty());
48 scoped_ptr<Operation> task(stack_.top()); 48 scoped_ptr<Operation> task(stack_.top());
49 stack_.pop(); 49 stack_.pop();
50 return task.Pass(); 50 return task.Pass();
51 } 51 }
52 52
53 scoped_refptr<IndexedDBTransaction> IndexedDBTransaction::Create(
54 int64 id,
55 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks,
56 const std::vector<int64>& object_store_ids,
57 indexed_db::TransactionMode mode,
58 IndexedDBDatabase* database) {
59 std::set<int64> object_store_hash_set;
jsbell 2013/07/13 00:18:32 This vector -> set conversion is replaced at the c
60 for (size_t i = 0; i < object_store_ids.size(); ++i)
61 object_store_hash_set.insert(object_store_ids[i]);
62
63 return make_scoped_refptr(new IndexedDBTransaction(
64 id, callbacks, object_store_hash_set, mode, database));
65 }
66
67 IndexedDBTransaction::IndexedDBTransaction( 53 IndexedDBTransaction::IndexedDBTransaction(
68 int64 id, 54 int64 id,
69 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks, 55 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks,
70 const std::set<int64>& object_store_ids, 56 const std::set<int64>& object_store_ids,
71 indexed_db::TransactionMode mode, 57 indexed_db::TransactionMode mode,
72 IndexedDBDatabase* database) 58 IndexedDBDatabase* database)
73 : id_(id), 59 : id_(id),
74 object_store_ids_(object_store_ids), 60 object_store_ids_(object_store_ids),
75 mode_(mode), 61 mode_(mode),
76 state_(UNUSED), 62 state_(UNUSED),
(...skipping 27 matching lines...) Expand all
104 preemptive_task_queue_.push(task); 90 preemptive_task_queue_.push(task);
105 91
106 if (abort_task) 92 if (abort_task)
107 abort_task_stack_.push(abort_task); 93 abort_task_stack_.push(abort_task);
108 94
109 if (state_ == UNUSED) { 95 if (state_ == UNUSED) {
110 Start(); 96 Start();
111 } else if (state_ == RUNNING && !should_process_queue_) { 97 } else if (state_ == RUNNING && !should_process_queue_) {
112 should_process_queue_ = true; 98 should_process_queue_ = true;
113 base::MessageLoop::current()->PostTask( 99 base::MessageLoop::current()->PostTask(
114 FROM_HERE, 100 FROM_HERE, base::Bind(&IndexedDBTransaction::ProcessTaskQueue, this));
115 base::Bind(&IndexedDBTransaction::ProcessTaskQueue, this));
116 } 101 }
117 } 102 }
118 103
119 void IndexedDBTransaction::Abort() { 104 void IndexedDBTransaction::Abort() {
120 Abort(IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, 105 Abort(IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError,
121 "Internal error (unknown cause)")); 106 "Internal error (unknown cause)"));
122 } 107 }
123 108
124 void IndexedDBTransaction::Abort(const IndexedDBDatabaseError& error) { 109 void IndexedDBTransaction::Abort(const IndexedDBDatabaseError& error) {
125 IDB_TRACE("IndexedDBTransaction::Abort"); 110 IDB_TRACE("IndexedDBTransaction::Abort");
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 open_cursors_.erase(cursor); 172 open_cursors_.erase(cursor);
188 } 173 }
189 174
190 void IndexedDBTransaction::Run() { 175 void IndexedDBTransaction::Run() {
191 // TransactionCoordinator has started this transaction. 176 // TransactionCoordinator has started this transaction.
192 DCHECK(state_ == START_PENDING || state_ == RUNNING); 177 DCHECK(state_ == START_PENDING || state_ == RUNNING);
193 DCHECK(!should_process_queue_); 178 DCHECK(!should_process_queue_);
194 179
195 should_process_queue_ = true; 180 should_process_queue_ = true;
196 base::MessageLoop::current()->PostTask( 181 base::MessageLoop::current()->PostTask(
197 FROM_HERE, 182 FROM_HERE, base::Bind(&IndexedDBTransaction::ProcessTaskQueue, this));
198 base::Bind(&IndexedDBTransaction::ProcessTaskQueue, this));
199 } 183 }
200 184
201 void IndexedDBTransaction::Start() { 185 void IndexedDBTransaction::Start() {
202 DCHECK_EQ(state_, UNUSED); 186 DCHECK_EQ(state_, UNUSED);
203 187
204 state_ = START_PENDING; 188 state_ = START_PENDING;
205 database_->transaction_coordinator().DidStartTransaction(this); 189 database_->transaction_coordinator().DidStartTransaction(this);
206 database_->TransactionStarted(this); 190 database_->TransactionStarted(this);
207 } 191 }
208 192
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 288
305 void IndexedDBTransaction::CloseOpenCursors() { 289 void IndexedDBTransaction::CloseOpenCursors() {
306 for (std::set<IndexedDBCursor*>::iterator i = open_cursors_.begin(); 290 for (std::set<IndexedDBCursor*>::iterator i = open_cursors_.begin();
307 i != open_cursors_.end(); 291 i != open_cursors_.end();
308 ++i) 292 ++i)
309 (*i)->Close(); 293 (*i)->Close();
310 open_cursors_.clear(); 294 open_cursors_.clear();
311 } 295 }
312 296
313 } // namespace content 297 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698