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

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

Issue 2062203004: IDBObserver: Lifetime Management: Adding Observer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Units tests added Created 4 years, 5 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 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 ASSERT_TRUE(s.ok()); 231 ASSERT_TRUE(s.ok());
232 232
233 request_ = new MockIndexedDBCallbacks(); 233 request_ = new MockIndexedDBCallbacks();
234 callbacks_ = new MockIndexedDBDatabaseCallbacks(); 234 callbacks_ = new MockIndexedDBDatabaseCallbacks();
235 const int64_t transaction_id = 1; 235 const int64_t transaction_id = 1;
236 db_->OpenConnection(IndexedDBPendingConnection( 236 db_->OpenConnection(IndexedDBPendingConnection(
237 request_, callbacks_, kFakeChildProcessId, transaction_id, 237 request_, callbacks_, kFakeChildProcessId, transaction_id,
238 IndexedDBDatabaseMetadata::DEFAULT_VERSION)); 238 IndexedDBDatabaseMetadata::DEFAULT_VERSION));
239 EXPECT_EQ(IndexedDBDatabaseMetadata::NO_VERSION, db_->metadata().version); 239 EXPECT_EQ(IndexedDBDatabaseMetadata::NO_VERSION, db_->metadata().version);
240 240
241 connection_ = new IndexedDBConnection(db_, callbacks_);
241 transaction_ = IndexedDBClassFactory::Get()->CreateIndexedDBTransaction( 242 transaction_ = IndexedDBClassFactory::Get()->CreateIndexedDBTransaction(
242 transaction_id, callbacks_, std::set<int64_t>() /*scope*/, 243 transaction_id, connection_, std::set<int64_t>() /*scope*/,
243 blink::WebIDBTransactionModeVersionChange, db_.get(), 244 blink::WebIDBTransactionModeVersionChange,
244 new IndexedDBFakeBackingStore::FakeTransaction(commit_success_)); 245 new IndexedDBFakeBackingStore::FakeTransaction(commit_success_));
245 db_->TransactionCreated(transaction_.get()); 246 db_->TransactionCreated(transaction_.get());
246 247
247 // Add a dummy task which takes the place of the VersionChangeOperation 248 // Add a dummy task which takes the place of the VersionChangeOperation
248 // which kicks off the upgrade. This ensures that the transaction has 249 // which kicks off the upgrade. This ensures that the transaction has
249 // processed at least one task before the CreateObjectStore call. 250 // processed at least one task before the CreateObjectStore call.
250 transaction_->ScheduleTask(base::Bind(&DummyOperation)); 251 transaction_->ScheduleTask(base::Bind(&DummyOperation));
251 } 252 }
252 253
253 void RunPostedTasks() { base::RunLoop().RunUntilIdle(); } 254 void RunPostedTasks() { base::RunLoop().RunUntilIdle(); }
254 255
255 protected: 256 protected:
256 scoped_refptr<IndexedDBFakeBackingStore> backing_store_; 257 scoped_refptr<IndexedDBFakeBackingStore> backing_store_;
257 scoped_refptr<IndexedDBDatabase> db_; 258 scoped_refptr<IndexedDBDatabase> db_;
258 scoped_refptr<MockIndexedDBCallbacks> request_; 259 scoped_refptr<MockIndexedDBCallbacks> request_;
259 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks_; 260 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks_;
260 scoped_refptr<IndexedDBTransaction> transaction_; 261 scoped_refptr<IndexedDBTransaction> transaction_;
262 IndexedDBConnection* connection_;
Marijn Kruisselbrink 2016/06/30 00:17:25 this should probably be a unique_ptr<IndexedDBConn
palakj1 2016/06/30 01:07:04 Done.
261 263
262 leveldb::Status commit_success_; 264 leveldb::Status commit_success_;
263 265
264 private: 266 private:
265 base::MessageLoop message_loop_; 267 base::MessageLoop message_loop_;
266 scoped_refptr<MockIndexedDBFactory> factory_; 268 scoped_refptr<MockIndexedDBFactory> factory_;
267 269
268 DISALLOW_COPY_AND_ASSIGN(IndexedDBDatabaseOperationTest); 270 DISALLOW_COPY_AND_ASSIGN(IndexedDBDatabaseOperationTest);
269 }; 271 };
270 272
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 EXPECT_EQ(1ULL, db_->metadata().object_stores.size()); 391 EXPECT_EQ(1ULL, db_->metadata().object_stores.size());
390 392
391 // This will execute the Put then Delete. 393 // This will execute the Put then Delete.
392 RunPostedTasks(); 394 RunPostedTasks();
393 EXPECT_EQ(0ULL, db_->metadata().object_stores.size()); 395 EXPECT_EQ(0ULL, db_->metadata().object_stores.size());
394 396
395 transaction_->Commit(); // Cleans up the object hierarchy. 397 transaction_->Commit(); // Cleans up the object hierarchy.
396 } 398 }
397 399
398 } // namespace content 400 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698