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

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

Issue 320833002: [IndexedDB] Use consistent enums on both sides of IPC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated review comments. Created 6 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
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 DCHECK(!stack_.empty()); 47 DCHECK(!stack_.empty());
48 Operation task(stack_.top()); 48 Operation task(stack_.top());
49 stack_.pop(); 49 stack_.pop();
50 return task; 50 return task;
51 } 51 }
52 52
53 IndexedDBTransaction::IndexedDBTransaction( 53 IndexedDBTransaction::IndexedDBTransaction(
54 int64 id, 54 int64 id,
55 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks, 55 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks,
56 const std::set<int64>& object_store_ids, 56 const std::set<int64>& object_store_ids,
57 indexed_db::TransactionMode mode, 57 blink::WebIDBTransactionMode mode,
58 IndexedDBDatabase* database, 58 IndexedDBDatabase* database,
59 IndexedDBBackingStore::Transaction* backing_store_transaction) 59 IndexedDBBackingStore::Transaction* backing_store_transaction)
60 : id_(id), 60 : id_(id),
61 object_store_ids_(object_store_ids), 61 object_store_ids_(object_store_ids),
62 mode_(mode), 62 mode_(mode),
63 used_(false), 63 used_(false),
64 state_(CREATED), 64 state_(CREATED),
65 commit_pending_(false), 65 commit_pending_(false),
66 callbacks_(callbacks), 66 callbacks_(callbacks),
67 database_(database), 67 database_(database),
(...skipping 11 matching lines...) Expand all
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(IndexedDBDatabase::TaskType type, 89 void IndexedDBTransaction::ScheduleTask(blink::WebIDBTaskType type,
90 Operation task) { 90 Operation task) {
91 DCHECK_NE(state_, COMMITTING); 91 DCHECK_NE(state_, COMMITTING);
92 if (state_ == FINISHED) 92 if (state_ == FINISHED)
93 return; 93 return;
94 94
95 timeout_timer_.Stop(); 95 timeout_timer_.Stop();
96 used_ = true; 96 used_ = true;
97 if (type == IndexedDBDatabase::NORMAL_TASK) { 97 if (type == blink::WebIDBTaskTypeNormal) {
98 task_queue_.push(task); 98 task_queue_.push(task);
99 ++diagnostics_.tasks_scheduled; 99 ++diagnostics_.tasks_scheduled;
100 } else { 100 } else {
101 preemptive_task_queue_.push(task); 101 preemptive_task_queue_.push(task);
102 } 102 }
103 RunTasksIfStarted(); 103 RunTasksIfStarted();
104 } 104 }
105 105
106 void IndexedDBTransaction::ScheduleAbortTask(Operation abort_task) { 106 void IndexedDBTransaction::ScheduleAbortTask(Operation abort_task) {
107 DCHECK_NE(FINISHED, state_); 107 DCHECK_NE(FINISHED, state_);
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 362
363 // The transaction may have been aborted while processing tasks. 363 // The transaction may have been aborted while processing tasks.
364 if (state_ == FINISHED) 364 if (state_ == FINISHED)
365 return; 365 return;
366 366
367 DCHECK(state_ == STARTED); 367 DCHECK(state_ == STARTED);
368 368
369 // Otherwise, start a timer in case the front-end gets wedged and 369 // Otherwise, start a timer in case the front-end gets wedged and
370 // never requests further activity. Read-only transactions don't 370 // never requests further activity. Read-only transactions don't
371 // block other transactions, so don't time those out. 371 // block other transactions, so don't time those out.
372 if (mode_ != indexed_db::TRANSACTION_READ_ONLY) { 372 if (mode_ != blink::WebIDBTransactionModeReadOnly) {
373 timeout_timer_.Start( 373 timeout_timer_.Start(
374 FROM_HERE, 374 FROM_HERE,
375 base::TimeDelta::FromSeconds(kInactivityTimeoutPeriodSeconds), 375 base::TimeDelta::FromSeconds(kInactivityTimeoutPeriodSeconds),
376 base::Bind(&IndexedDBTransaction::Timeout, this)); 376 base::Bind(&IndexedDBTransaction::Timeout, this));
377 } 377 }
378 } 378 }
379 379
380 void IndexedDBTransaction::Timeout() { 380 void IndexedDBTransaction::Timeout() {
381 Abort(IndexedDBDatabaseError( 381 Abort(IndexedDBDatabaseError(
382 blink::WebIDBDatabaseExceptionTimeoutError, 382 blink::WebIDBDatabaseExceptionTimeoutError,
383 base::ASCIIToUTF16("Transaction timed out due to inactivity."))); 383 base::ASCIIToUTF16("Transaction timed out due to inactivity.")));
384 } 384 }
385 385
386 void IndexedDBTransaction::CloseOpenCursors() { 386 void IndexedDBTransaction::CloseOpenCursors() {
387 for (std::set<IndexedDBCursor*>::iterator i = open_cursors_.begin(); 387 for (std::set<IndexedDBCursor*>::iterator i = open_cursors_.begin();
388 i != open_cursors_.end(); 388 i != open_cursors_.end();
389 ++i) 389 ++i)
390 (*i)->Close(); 390 (*i)->Close();
391 open_cursors_.clear(); 391 open_cursors_.clear();
392 } 392 }
393 393
394 } // namespace content 394 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698