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

Unified Diff: content/browser/indexed_db/indexed_db_transaction_unittest.cc

Issue 277583002: IndexedDB: Prevent store/index deletion from racing ahead of use (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: base::Closure copies const-refs, so this is better Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/indexed_db/indexed_db_transaction_unittest.cc
diff --git a/content/browser/indexed_db/indexed_db_transaction_unittest.cc b/content/browser/indexed_db/indexed_db_transaction_unittest.cc
index cf35852fa1837af047e35051a65c20c14bb6966b..74f402919324f45c0efc283b73e6b7be564b74b0 100644
--- a/content/browser/indexed_db/indexed_db_transaction_unittest.cc
+++ b/content/browser/indexed_db/indexed_db_transaction_unittest.cc
@@ -14,6 +14,21 @@
namespace content {
+class AbortObserver {
+ public:
+ AbortObserver() : abort_task_called_(false) {}
+
+ void AbortTask(IndexedDBTransaction* transaction) {
+ abort_task_called_ = true;
+ }
+
+ bool abort_task_called() const { return abort_task_called_; }
+
+ private:
+ bool abort_task_called_;
+ DISALLOW_COPY_AND_ASSIGN(AbortObserver);
+};
+
class IndexedDBTransactionTest : public testing::Test {
public:
IndexedDBTransactionTest() {
@@ -37,6 +52,11 @@ class IndexedDBTransactionTest : public testing::Test {
void RunPostedTasks() { message_loop_.RunUntilIdle(); }
void DummyOperation(IndexedDBTransaction* transaction) {}
+ void AbortableOperation(AbortObserver* observer,
+ IndexedDBTransaction* transaction) {
+ transaction->ScheduleAbortTask(
+ base::Bind(&AbortObserver::AbortTask, base::Unretained(observer)));
+ }
protected:
scoped_refptr<IndexedDBFakeBackingStore> backing_store_;
@@ -132,21 +152,6 @@ TEST_F(IndexedDBTransactionTest, NoTimeoutReadOnly) {
EXPECT_FALSE(transaction->IsTimeoutTimerRunning());
}
-class AbortObserver {
- public:
- AbortObserver() : abort_task_called_(false) {}
-
- void AbortTask(IndexedDBTransaction* transaction) {
- abort_task_called_ = true;
- }
-
- bool abort_task_called() const { return abort_task_called_; }
-
- private:
- bool abort_task_called_;
- DISALLOW_COPY_AND_ASSIGN(AbortObserver);
-};
-
TEST_P(IndexedDBTransactionTestMode, ScheduleNormalTask) {
const int64 id = 0;
const std::set<int64> scope;
@@ -285,9 +290,9 @@ TEST_P(IndexedDBTransactionTestMode, AbortTasks) {
AbortObserver observer;
transaction->ScheduleTask(
- base::Bind(&IndexedDBTransactionTest::DummyOperation,
- base::Unretained(this)),
- base::Bind(&AbortObserver::AbortTask, base::Unretained(&observer)));
+ base::Bind(&IndexedDBTransactionTest::AbortableOperation,
+ base::Unretained(this),
+ base::Unretained(&observer)));
// Pump the message loop so that the transaction completes all pending tasks,
// otherwise it will defer the commit.

Powered by Google App Engine
This is Rietveld 408576698