| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 IndexedDBDatabase::Identifier(), | 69 IndexedDBDatabase::Identifier(), |
| 70 &s); | 70 &s); |
| 71 ASSERT_TRUE(s.ok()); | 71 ASSERT_TRUE(s.ok()); |
| 72 EXPECT_FALSE(backing_store->HasOneRef()); // local and db | 72 EXPECT_FALSE(backing_store->HasOneRef()); // local and db |
| 73 | 73 |
| 74 scoped_refptr<MockIndexedDBCallbacks> request1(new MockIndexedDBCallbacks()); | 74 scoped_refptr<MockIndexedDBCallbacks> request1(new MockIndexedDBCallbacks()); |
| 75 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks1( | 75 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks1( |
| 76 new MockIndexedDBDatabaseCallbacks()); | 76 new MockIndexedDBDatabaseCallbacks()); |
| 77 const int64_t transaction_id1 = 1; | 77 const int64_t transaction_id1 = 1; |
| 78 IndexedDBPendingConnection connection1( | 78 IndexedDBPendingConnection connection1( |
| 79 request1, | 79 request1, callbacks1, kFakeChildProcessId, transaction_id1, |
| 80 callbacks1, | 80 IndexedDBDatabaseMetadata::DEFAULT_VERSION); |
| 81 kFakeChildProcessId, | |
| 82 transaction_id1, | |
| 83 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); | |
| 84 db->OpenConnection(connection1); | 81 db->OpenConnection(connection1); |
| 85 | 82 |
| 86 EXPECT_FALSE(backing_store->HasOneRef()); // db, connection count > 0 | 83 EXPECT_FALSE(backing_store->HasOneRef()); // db, connection count > 0 |
| 87 | 84 |
| 88 scoped_refptr<MockIndexedDBCallbacks> request2(new MockIndexedDBCallbacks()); | 85 scoped_refptr<MockIndexedDBCallbacks> request2(new MockIndexedDBCallbacks()); |
| 89 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks2( | 86 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks2( |
| 90 new MockIndexedDBDatabaseCallbacks()); | 87 new MockIndexedDBDatabaseCallbacks()); |
| 91 const int64_t transaction_id2 = 2; | 88 const int64_t transaction_id2 = 2; |
| 92 IndexedDBPendingConnection connection2( | 89 IndexedDBPendingConnection connection2( |
| 93 request2, | 90 request2, callbacks2, kFakeChildProcessId, transaction_id2, |
| 94 callbacks2, | 91 IndexedDBDatabaseMetadata::DEFAULT_VERSION); |
| 95 kFakeChildProcessId, | |
| 96 transaction_id2, | |
| 97 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); | |
| 98 db->OpenConnection(connection2); | 92 db->OpenConnection(connection2); |
| 99 | 93 |
| 100 EXPECT_FALSE(backing_store->HasOneRef()); // local and connection | 94 EXPECT_FALSE(backing_store->HasOneRef()); // local and connection |
| 101 | 95 |
| 102 request1->connection()->ForceClose(); | 96 request1->connection()->ForceClose(); |
| 103 EXPECT_FALSE(request1->connection()->IsConnected()); | 97 EXPECT_FALSE(request1->connection()->IsConnected()); |
| 104 | 98 |
| 105 EXPECT_FALSE(backing_store->HasOneRef()); // local and connection | 99 EXPECT_FALSE(backing_store->HasOneRef()); // local and connection |
| 106 | 100 |
| 107 request2->connection()->ForceClose(); | 101 request2->connection()->ForceClose(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 127 IndexedDBDatabase::Identifier(), | 121 IndexedDBDatabase::Identifier(), |
| 128 &s); | 122 &s); |
| 129 ASSERT_TRUE(s.ok()); | 123 ASSERT_TRUE(s.ok()); |
| 130 EXPECT_FALSE(backing_store->HasOneRef()); // local and db | 124 EXPECT_FALSE(backing_store->HasOneRef()); // local and db |
| 131 | 125 |
| 132 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks( | 126 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks( |
| 133 new MockIndexedDBDatabaseCallbacks()); | 127 new MockIndexedDBDatabaseCallbacks()); |
| 134 scoped_refptr<MockIndexedDBCallbacks> request(new MockIndexedDBCallbacks()); | 128 scoped_refptr<MockIndexedDBCallbacks> request(new MockIndexedDBCallbacks()); |
| 135 const int64_t upgrade_transaction_id = 3; | 129 const int64_t upgrade_transaction_id = 3; |
| 136 IndexedDBPendingConnection connection( | 130 IndexedDBPendingConnection connection( |
| 137 request, | 131 request, callbacks, kFakeChildProcessId, upgrade_transaction_id, |
| 138 callbacks, | 132 IndexedDBDatabaseMetadata::DEFAULT_VERSION); |
| 139 kFakeChildProcessId, | |
| 140 upgrade_transaction_id, | |
| 141 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); | |
| 142 database->OpenConnection(connection); | 133 database->OpenConnection(connection); |
| 143 EXPECT_EQ(database.get(), request->connection()->database()); | 134 EXPECT_EQ(database.get(), request->connection()->database()); |
| 144 | 135 |
| 145 const int64_t transaction_id = 123; | 136 const int64_t transaction_id = 123; |
| 146 const std::vector<int64_t> scope; | 137 const std::vector<int64_t> scope; |
| 147 database->CreateTransaction(transaction_id, | 138 database->CreateTransaction(transaction_id, |
| 148 request->connection(), | 139 request->connection(), |
| 149 scope, | 140 scope, |
| 150 blink::WebIDBTransactionModeReadOnly); | 141 blink::WebIDBTransactionModeReadOnly); |
| 151 | 142 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 IndexedDBDatabase::Identifier(), | 182 IndexedDBDatabase::Identifier(), |
| 192 &s); | 183 &s); |
| 193 ASSERT_TRUE(s.ok()); | 184 ASSERT_TRUE(s.ok()); |
| 194 EXPECT_FALSE(backing_store->HasOneRef()); // local and db | 185 EXPECT_FALSE(backing_store->HasOneRef()); // local and db |
| 195 | 186 |
| 196 scoped_refptr<MockIndexedDBCallbacks> request1(new MockIndexedDBCallbacks()); | 187 scoped_refptr<MockIndexedDBCallbacks> request1(new MockIndexedDBCallbacks()); |
| 197 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks1( | 188 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks1( |
| 198 new MockIndexedDBDatabaseCallbacks()); | 189 new MockIndexedDBDatabaseCallbacks()); |
| 199 const int64_t transaction_id1 = 1; | 190 const int64_t transaction_id1 = 1; |
| 200 IndexedDBPendingConnection connection( | 191 IndexedDBPendingConnection connection( |
| 201 request1, | 192 request1, callbacks1, kFakeChildProcessId, transaction_id1, |
| 202 callbacks1, | 193 IndexedDBDatabaseMetadata::DEFAULT_VERSION); |
| 203 kFakeChildProcessId, | |
| 204 transaction_id1, | |
| 205 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); | |
| 206 db->OpenConnection(connection); | 194 db->OpenConnection(connection); |
| 207 | 195 |
| 208 EXPECT_FALSE(backing_store->HasOneRef()); // local and db | 196 EXPECT_FALSE(backing_store->HasOneRef()); // local and db |
| 209 | 197 |
| 210 scoped_refptr<MockDeleteCallbacks> request2(new MockDeleteCallbacks()); | 198 scoped_refptr<MockDeleteCallbacks> request2(new MockDeleteCallbacks()); |
| 211 db->DeleteDatabase(request2); | 199 db->DeleteDatabase(request2); |
| 212 | 200 |
| 213 EXPECT_FALSE(request2->blocked_called()); | 201 EXPECT_FALSE(request2->blocked_called()); |
| 214 db->VersionChangeIgnored(); | 202 db->VersionChangeIgnored(); |
| 215 EXPECT_TRUE(request2->blocked_called()); | 203 EXPECT_TRUE(request2->blocked_called()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 239 backing_store_.get(), | 227 backing_store_.get(), |
| 240 factory_.get(), | 228 factory_.get(), |
| 241 IndexedDBDatabase::Identifier(), | 229 IndexedDBDatabase::Identifier(), |
| 242 &s); | 230 &s); |
| 243 ASSERT_TRUE(s.ok()); | 231 ASSERT_TRUE(s.ok()); |
| 244 | 232 |
| 245 request_ = new MockIndexedDBCallbacks(); | 233 request_ = new MockIndexedDBCallbacks(); |
| 246 callbacks_ = new MockIndexedDBDatabaseCallbacks(); | 234 callbacks_ = new MockIndexedDBDatabaseCallbacks(); |
| 247 const int64_t transaction_id = 1; | 235 const int64_t transaction_id = 1; |
| 248 db_->OpenConnection(IndexedDBPendingConnection( | 236 db_->OpenConnection(IndexedDBPendingConnection( |
| 249 request_, | 237 request_, callbacks_, kFakeChildProcessId, transaction_id, |
| 250 callbacks_, | 238 IndexedDBDatabaseMetadata::DEFAULT_VERSION)); |
| 251 kFakeChildProcessId, | 239 EXPECT_EQ(IndexedDBDatabaseMetadata::NO_VERSION, db_->metadata().version); |
| 252 transaction_id, | |
| 253 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION)); | |
| 254 EXPECT_EQ(IndexedDBDatabaseMetadata::NO_INT_VERSION, | |
| 255 db_->metadata().int_version); | |
| 256 | 240 |
| 257 transaction_ = IndexedDBClassFactory::Get()->CreateIndexedDBTransaction( | 241 transaction_ = IndexedDBClassFactory::Get()->CreateIndexedDBTransaction( |
| 258 transaction_id, callbacks_, std::set<int64_t>() /*scope*/, | 242 transaction_id, callbacks_, std::set<int64_t>() /*scope*/, |
| 259 blink::WebIDBTransactionModeVersionChange, db_.get(), | 243 blink::WebIDBTransactionModeVersionChange, db_.get(), |
| 260 new IndexedDBFakeBackingStore::FakeTransaction(commit_success_)); | 244 new IndexedDBFakeBackingStore::FakeTransaction(commit_success_)); |
| 261 db_->TransactionCreated(transaction_.get()); | 245 db_->TransactionCreated(transaction_.get()); |
| 262 | 246 |
| 263 // Add a dummy task which takes the place of the VersionChangeOperation | 247 // Add a dummy task which takes the place of the VersionChangeOperation |
| 264 // which kicks off the upgrade. This ensures that the transaction has | 248 // which kicks off the upgrade. This ensures that the transaction has |
| 265 // processed at least one task before the CreateObjectStore call. | 249 // processed at least one task before the CreateObjectStore call. |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 EXPECT_EQ(1ULL, db_->metadata().object_stores.size()); | 389 EXPECT_EQ(1ULL, db_->metadata().object_stores.size()); |
| 406 | 390 |
| 407 // This will execute the Put then Delete. | 391 // This will execute the Put then Delete. |
| 408 RunPostedTasks(); | 392 RunPostedTasks(); |
| 409 EXPECT_EQ(0ULL, db_->metadata().object_stores.size()); | 393 EXPECT_EQ(0ULL, db_->metadata().object_stores.size()); |
| 410 | 394 |
| 411 transaction_->Commit(); // Cleans up the object hierarchy. | 395 transaction_->Commit(); // Cleans up the object hierarchy. |
| 412 } | 396 } |
| 413 | 397 |
| 414 } // namespace content | 398 } // namespace content |
| OLD | NEW |