| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_database.h" | 5 #include "content/browser/indexed_db/indexed_db_database.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 187 |
| 188 scoped_refptr<MockIndexedDBCallbacks> request1(new MockIndexedDBCallbacks()); | 188 scoped_refptr<MockIndexedDBCallbacks> request1(new MockIndexedDBCallbacks()); |
| 189 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks1( | 189 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks1( |
| 190 new MockIndexedDBDatabaseCallbacks()); | 190 new MockIndexedDBDatabaseCallbacks()); |
| 191 const int64_t transaction_id1 = 1; | 191 const int64_t transaction_id1 = 1; |
| 192 IndexedDBPendingConnection connection( | 192 IndexedDBPendingConnection connection( |
| 193 request1, callbacks1, kFakeChildProcessId, transaction_id1, | 193 request1, callbacks1, kFakeChildProcessId, transaction_id1, |
| 194 IndexedDBDatabaseMetadata::DEFAULT_VERSION); | 194 IndexedDBDatabaseMetadata::DEFAULT_VERSION); |
| 195 db->OpenConnection(connection); | 195 db->OpenConnection(connection); |
| 196 | 196 |
| 197 EXPECT_EQ(db->ConnectionCount(), 1UL); |
| 198 EXPECT_EQ(db->ActiveOpenDeleteCount(), 0UL); |
| 199 EXPECT_EQ(db->PendingOpenDeleteCount(), 0UL); |
| 197 EXPECT_FALSE(backing_store->HasOneRef()); // local and db | 200 EXPECT_FALSE(backing_store->HasOneRef()); // local and db |
| 198 | 201 |
| 199 scoped_refptr<MockDeleteCallbacks> request2(new MockDeleteCallbacks()); | 202 scoped_refptr<MockDeleteCallbacks> request2(new MockDeleteCallbacks()); |
| 200 db->DeleteDatabase(request2); | 203 db->DeleteDatabase(request2); |
| 204 EXPECT_EQ(db->ConnectionCount(), 1UL); |
| 205 EXPECT_EQ(db->ActiveOpenDeleteCount(), 1UL); |
| 206 EXPECT_EQ(db->PendingOpenDeleteCount(), 0UL); |
| 201 | 207 |
| 202 EXPECT_FALSE(request2->blocked_called()); | 208 EXPECT_FALSE(request2->blocked_called()); |
| 203 db->VersionChangeIgnored(); | 209 db->VersionChangeIgnored(); |
| 204 EXPECT_TRUE(request2->blocked_called()); | 210 EXPECT_TRUE(request2->blocked_called()); |
| 211 EXPECT_EQ(db->ConnectionCount(), 1UL); |
| 212 EXPECT_EQ(db->ActiveOpenDeleteCount(), 1UL); |
| 213 EXPECT_EQ(db->PendingOpenDeleteCount(), 0UL); |
| 205 | 214 |
| 206 EXPECT_FALSE(backing_store->HasOneRef()); // local and db | 215 EXPECT_FALSE(backing_store->HasOneRef()); // local and db |
| 207 | 216 |
| 208 db->Close(request1->connection(), true /* forced */); | 217 db->Close(request1->connection(), true /* forced */); |
| 218 EXPECT_EQ(db->ConnectionCount(), 0UL); |
| 219 EXPECT_EQ(db->ActiveOpenDeleteCount(), 0UL); |
| 220 EXPECT_EQ(db->PendingOpenDeleteCount(), 0UL); |
| 209 | 221 |
| 210 EXPECT_FALSE(db->backing_store()); | 222 EXPECT_FALSE(db->backing_store()); |
| 211 EXPECT_TRUE(backing_store->HasOneRef()); // local | 223 EXPECT_TRUE(backing_store->HasOneRef()); // local |
| 212 EXPECT_TRUE(request2->success_called()); | 224 EXPECT_TRUE(request2->success_called()); |
| 213 } | 225 } |
| 214 | 226 |
| 215 void DummyOperation(IndexedDBTransaction* transaction) { | 227 void DummyOperation(IndexedDBTransaction* transaction) { |
| 216 } | 228 } |
| 217 | 229 |
| 218 class IndexedDBDatabaseOperationTest : public testing::Test { | 230 class IndexedDBDatabaseOperationTest : public testing::Test { |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 EXPECT_EQ(1ULL, db_->metadata().object_stores.size()); | 405 EXPECT_EQ(1ULL, db_->metadata().object_stores.size()); |
| 394 | 406 |
| 395 // This will execute the Put then Delete. | 407 // This will execute the Put then Delete. |
| 396 RunPostedTasks(); | 408 RunPostedTasks(); |
| 397 EXPECT_EQ(0ULL, db_->metadata().object_stores.size()); | 409 EXPECT_EQ(0ULL, db_->metadata().object_stores.size()); |
| 398 | 410 |
| 399 transaction_->Commit(); // Cleans up the object hierarchy. | 411 transaction_->Commit(); // Cleans up the object hierarchy. |
| 400 } | 412 } |
| 401 | 413 |
| 402 } // namespace content | 414 } // namespace content |
| OLD | NEW |