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

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

Issue 16581002: IndexedDB: Eliminate interfaces for IndexedDB{Factory,Database,Cursor} (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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 <vector> 7 #include <vector>
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/browser/indexed_db/indexed_db_backing_store.h" 10 #include "content/browser/indexed_db/indexed_db_backing_store.h"
11 #include "content/browser/indexed_db/indexed_db_cursor_impl.h" 11 #include "content/browser/indexed_db/indexed_db_cursor.h"
12 #include "content/browser/indexed_db/indexed_db_database.h"
12 #include "content/browser/indexed_db/indexed_db_database_callbacks_wrapper.h" 13 #include "content/browser/indexed_db/indexed_db_database_callbacks_wrapper.h"
13 #include "content/browser/indexed_db/indexed_db_database_impl.h"
14 #include "content/browser/indexed_db/indexed_db_tracing.h" 14 #include "content/browser/indexed_db/indexed_db_tracing.h"
15 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h" 15 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h"
16 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" 16 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 IndexedDBTransaction::TaskQueue::TaskQueue() {} 20 IndexedDBTransaction::TaskQueue::TaskQueue() {}
21 IndexedDBTransaction::TaskQueue::~TaskQueue() { clear(); } 21 IndexedDBTransaction::TaskQueue::~TaskQueue() { clear(); }
22 22
23 void IndexedDBTransaction::TaskQueue::clear() { 23 void IndexedDBTransaction::TaskQueue::clear() {
(...skipping 23 matching lines...) Expand all
47 scoped_ptr<Operation> task(stack_.top()); 47 scoped_ptr<Operation> task(stack_.top());
48 stack_.pop(); 48 stack_.pop();
49 return task.Pass(); 49 return task.Pass();
50 } 50 }
51 51
52 scoped_refptr<IndexedDBTransaction> IndexedDBTransaction::Create( 52 scoped_refptr<IndexedDBTransaction> IndexedDBTransaction::Create(
53 int64 id, 53 int64 id,
54 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> callbacks, 54 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> callbacks,
55 const std::vector<int64>& object_store_ids, 55 const std::vector<int64>& object_store_ids,
56 indexed_db::TransactionMode mode, 56 indexed_db::TransactionMode mode,
57 IndexedDBDatabaseImpl* database) { 57 IndexedDBDatabase* database) {
58 std::set<int64> object_store_hash_set; 58 std::set<int64> object_store_hash_set;
59 for (size_t i = 0; i < object_store_ids.size(); ++i) 59 for (size_t i = 0; i < object_store_ids.size(); ++i)
60 object_store_hash_set.insert(object_store_ids[i]); 60 object_store_hash_set.insert(object_store_ids[i]);
61 61
62 return make_scoped_refptr(new IndexedDBTransaction( 62 return make_scoped_refptr(new IndexedDBTransaction(
63 id, callbacks, object_store_hash_set, mode, database)); 63 id, callbacks, object_store_hash_set, mode, database));
64 } 64 }
65 65
66 IndexedDBTransaction::IndexedDBTransaction( 66 IndexedDBTransaction::IndexedDBTransaction(
67 int64 id, 67 int64 id,
68 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> callbacks, 68 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> callbacks,
69 const std::set<int64>& object_store_ids, 69 const std::set<int64>& object_store_ids,
70 indexed_db::TransactionMode mode, 70 indexed_db::TransactionMode mode,
71 IndexedDBDatabaseImpl* database) 71 IndexedDBDatabase* database)
72 : id_(id), 72 : id_(id),
73 object_store_ids_(object_store_ids), 73 object_store_ids_(object_store_ids),
74 mode_(mode), 74 mode_(mode),
75 state_(UNUSED), 75 state_(UNUSED),
76 commit_pending_(false), 76 commit_pending_(false),
77 callbacks_(callbacks), 77 callbacks_(callbacks),
78 database_(database), 78 database_(database),
79 transaction_(database->BackingStore().get()), 79 transaction_(database->BackingStore().get()),
80 pending_preemptive_events_(0) { 80 pending_preemptive_events_(0) {
81 database_->transaction_coordinator().DidCreateTransaction(this); 81 database_->transaction_coordinator().DidCreateTransaction(this);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 } 169 }
170 170
171 bool IndexedDBTransaction::IsTaskQueueEmpty() const { 171 bool IndexedDBTransaction::IsTaskQueueEmpty() const {
172 return preemptive_task_queue_.empty() && task_queue_.empty(); 172 return preemptive_task_queue_.empty() && task_queue_.empty();
173 } 173 }
174 174
175 bool IndexedDBTransaction::HasPendingTasks() const { 175 bool IndexedDBTransaction::HasPendingTasks() const {
176 return pending_preemptive_events_ || !IsTaskQueueEmpty(); 176 return pending_preemptive_events_ || !IsTaskQueueEmpty();
177 } 177 }
178 178
179 void IndexedDBTransaction::RegisterOpenCursor(IndexedDBCursorImpl* cursor) { 179 void IndexedDBTransaction::RegisterOpenCursor(IndexedDBCursor* cursor) {
180 open_cursors_.insert(cursor); 180 open_cursors_.insert(cursor);
181 } 181 }
182 182
183 void IndexedDBTransaction::UnregisterOpenCursor(IndexedDBCursorImpl* cursor) { 183 void IndexedDBTransaction::UnregisterOpenCursor(IndexedDBCursor* cursor) {
184 open_cursors_.erase(cursor); 184 open_cursors_.erase(cursor);
185 } 185 }
186 186
187 void IndexedDBTransaction::Run() { 187 void IndexedDBTransaction::Run() {
188 // TransactionCoordinator has started this transaction. Schedule a timer 188 // TransactionCoordinator has started this transaction. Schedule a timer
189 // to process the first task. 189 // to process the first task.
190 DCHECK(state_ == START_PENDING || state_ == RUNNING); 190 DCHECK(state_ == START_PENDING || state_ == RUNNING);
191 DCHECK(!task_timer_.IsRunning()); 191 DCHECK(!task_timer_.IsRunning());
192 192
193 task_timer_.Start(FROM_HERE, 193 task_timer_.Start(FROM_HERE,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 pending_preemptive_events_ ? &preemptive_task_queue_ : &task_queue_; 289 pending_preemptive_events_ ? &preemptive_task_queue_ : &task_queue_;
290 } 290 }
291 291
292 // If there are no pending tasks, we haven't already committed/aborted, 292 // If there are no pending tasks, we haven't already committed/aborted,
293 // and the front-end requested a commit, it is now safe to do so. 293 // and the front-end requested a commit, it is now safe to do so.
294 if (!HasPendingTasks() && state_ != FINISHED && commit_pending_) 294 if (!HasPendingTasks() && state_ != FINISHED && commit_pending_)
295 Commit(); 295 Commit();
296 } 296 }
297 297
298 void IndexedDBTransaction::CloseOpenCursors() { 298 void IndexedDBTransaction::CloseOpenCursors() {
299 for (std::set<IndexedDBCursorImpl*>::iterator i = open_cursors_.begin(); 299 for (std::set<IndexedDBCursor*>::iterator i = open_cursors_.begin();
300 i != open_cursors_.end(); 300 i != open_cursors_.end();
301 ++i) 301 ++i)
302 (*i)->Close(); 302 (*i)->Close();
303 open_cursors_.clear(); 303 open_cursors_.clear();
304 } 304 }
305 305
306 } // namespace content 306 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_transaction.h ('k') | content/browser/indexed_db/webidbfactory_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698