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 <set> | 7 #include <set> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 upgrade_transaction_id, | 136 upgrade_transaction_id, |
137 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); | 137 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION); |
138 database->OpenConnection(connection); | 138 database->OpenConnection(connection); |
139 EXPECT_EQ(database, request->connection()->database()); | 139 EXPECT_EQ(database, request->connection()->database()); |
140 | 140 |
141 const int64 transaction_id = 123; | 141 const int64 transaction_id = 123; |
142 const std::vector<int64> scope; | 142 const std::vector<int64> scope; |
143 database->CreateTransaction(transaction_id, | 143 database->CreateTransaction(transaction_id, |
144 request->connection(), | 144 request->connection(), |
145 scope, | 145 scope, |
146 indexed_db::TRANSACTION_READ_ONLY); | 146 blink::WebIDBTransactionModeReadOnly); |
147 | 147 |
148 request->connection()->ForceClose(); | 148 request->connection()->ForceClose(); |
149 | 149 |
150 EXPECT_TRUE(backing_store->HasOneRef()); // local | 150 EXPECT_TRUE(backing_store->HasOneRef()); // local |
151 EXPECT_TRUE(callbacks->abort_called()); | 151 EXPECT_TRUE(callbacks->abort_called()); |
152 } | 152 } |
153 | 153 |
154 class MockDeleteCallbacks : public IndexedDBCallbacks { | 154 class MockDeleteCallbacks : public IndexedDBCallbacks { |
155 public: | 155 public: |
156 MockDeleteCallbacks() | 156 MockDeleteCallbacks() |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 kFakeChildProcessId, | 244 kFakeChildProcessId, |
245 transaction_id, | 245 transaction_id, |
246 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION)); | 246 IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION)); |
247 EXPECT_EQ(IndexedDBDatabaseMetadata::NO_INT_VERSION, | 247 EXPECT_EQ(IndexedDBDatabaseMetadata::NO_INT_VERSION, |
248 db_->metadata().int_version); | 248 db_->metadata().int_version); |
249 | 249 |
250 transaction_ = new IndexedDBTransaction( | 250 transaction_ = new IndexedDBTransaction( |
251 transaction_id, | 251 transaction_id, |
252 callbacks_, | 252 callbacks_, |
253 std::set<int64>() /*scope*/, | 253 std::set<int64>() /*scope*/, |
254 indexed_db::TRANSACTION_VERSION_CHANGE, | 254 blink::WebIDBTransactionModeVersionChange, |
255 db_, | 255 db_, |
256 new IndexedDBFakeBackingStore::FakeTransaction(commit_success_)); | 256 new IndexedDBFakeBackingStore::FakeTransaction(commit_success_)); |
257 db_->TransactionCreated(transaction_); | 257 db_->TransactionCreated(transaction_); |
258 | 258 |
259 // Add a dummy task which takes the place of the VersionChangeOperation | 259 // Add a dummy task which takes the place of the VersionChangeOperation |
260 // which kicks off the upgrade. This ensures that the transaction has | 260 // which kicks off the upgrade. This ensures that the transaction has |
261 // processed at least one task before the CreateObjectStore call. | 261 // processed at least one task before the CreateObjectStore call. |
262 transaction_->ScheduleTask(base::Bind(&DummyOperation)); | 262 transaction_->ScheduleTask(base::Bind(&DummyOperation)); |
263 } | 263 } |
264 | 264 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 ScopedVector<webkit_blob::BlobDataHandle> handles; | 389 ScopedVector<webkit_blob::BlobDataHandle> handles; |
390 scoped_ptr<IndexedDBKey> key(new IndexedDBKey("key")); | 390 scoped_ptr<IndexedDBKey> key(new IndexedDBKey("key")); |
391 std::vector<IndexedDBDatabase::IndexKeys> index_keys; | 391 std::vector<IndexedDBDatabase::IndexKeys> index_keys; |
392 scoped_refptr<MockIndexedDBCallbacks> request( | 392 scoped_refptr<MockIndexedDBCallbacks> request( |
393 new MockIndexedDBCallbacks(false)); | 393 new MockIndexedDBCallbacks(false)); |
394 db_->Put(transaction_->id(), | 394 db_->Put(transaction_->id(), |
395 store_id, | 395 store_id, |
396 &value, | 396 &value, |
397 &handles, | 397 &handles, |
398 key.Pass(), | 398 key.Pass(), |
399 IndexedDBDatabase::ADD_ONLY, | 399 blink::WebIDBPutModeAddOnly, |
400 request, | 400 request, |
401 index_keys); | 401 index_keys); |
402 | 402 |
403 // Deletion is asynchronous. | 403 // Deletion is asynchronous. |
404 db_->DeleteObjectStore(transaction_->id(), | 404 db_->DeleteObjectStore(transaction_->id(), |
405 store_id); | 405 store_id); |
406 EXPECT_EQ(1ULL, db_->metadata().object_stores.size()); | 406 EXPECT_EQ(1ULL, db_->metadata().object_stores.size()); |
407 | 407 |
408 // This will execute the Put then Delete. | 408 // This will execute the Put then Delete. |
409 RunPostedTasks(); | 409 RunPostedTasks(); |
410 EXPECT_EQ(0ULL, db_->metadata().object_stores.size()); | 410 EXPECT_EQ(0ULL, db_->metadata().object_stores.size()); |
411 | 411 |
412 transaction_->Commit(); // Cleans up the object hierarchy. | 412 transaction_->Commit(); // Cleans up the object hierarchy. |
413 } | 413 } |
414 | 414 |
415 } // namespace content | 415 } // namespace content |
OLD | NEW |