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

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

Issue 2140193002: IndexedDB: Saving data loss status in IndexedDBPendingConnection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@idb-data-loss
Patch Set: Deleted commented out code. 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 factory.get(), 69 factory.get(),
70 IndexedDBDatabase::Identifier(), 70 IndexedDBDatabase::Identifier(),
71 &s); 71 &s);
72 ASSERT_TRUE(s.ok()); 72 ASSERT_TRUE(s.ok());
73 EXPECT_FALSE(backing_store->HasOneRef()); // local and db 73 EXPECT_FALSE(backing_store->HasOneRef()); // local and db
74 74
75 scoped_refptr<MockIndexedDBCallbacks> request1(new MockIndexedDBCallbacks()); 75 scoped_refptr<MockIndexedDBCallbacks> request1(new MockIndexedDBCallbacks());
76 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks1( 76 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks1(
77 new MockIndexedDBDatabaseCallbacks()); 77 new MockIndexedDBDatabaseCallbacks());
78 const int64_t transaction_id1 = 1; 78 const int64_t transaction_id1 = 1;
79 IndexedDBPendingConnection connection1( 79 std::unique_ptr<IndexedDBPendingConnection> connection1(
80 request1, callbacks1, kFakeChildProcessId, transaction_id1, 80 new IndexedDBPendingConnection(
81 IndexedDBDatabaseMetadata::DEFAULT_VERSION); 81 request1, callbacks1, kFakeChildProcessId, transaction_id1,
82 db->OpenConnection(connection1); 82 IndexedDBDatabaseMetadata::DEFAULT_VERSION));
83 db->OpenConnection(std::move(connection1));
83 84
84 EXPECT_FALSE(backing_store->HasOneRef()); // db, connection count > 0 85 EXPECT_FALSE(backing_store->HasOneRef()); // db, connection count > 0
85 86
86 scoped_refptr<MockIndexedDBCallbacks> request2(new MockIndexedDBCallbacks()); 87 scoped_refptr<MockIndexedDBCallbacks> request2(new MockIndexedDBCallbacks());
87 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks2( 88 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks2(
88 new MockIndexedDBDatabaseCallbacks()); 89 new MockIndexedDBDatabaseCallbacks());
89 const int64_t transaction_id2 = 2; 90 const int64_t transaction_id2 = 2;
90 IndexedDBPendingConnection connection2( 91 std::unique_ptr<IndexedDBPendingConnection> connection2(
91 request2, callbacks2, kFakeChildProcessId, transaction_id2, 92 new IndexedDBPendingConnection(
92 IndexedDBDatabaseMetadata::DEFAULT_VERSION); 93 request2, callbacks2, kFakeChildProcessId, transaction_id2,
93 db->OpenConnection(connection2); 94 IndexedDBDatabaseMetadata::DEFAULT_VERSION));
95 db->OpenConnection(std::move(connection2));
94 96
95 EXPECT_FALSE(backing_store->HasOneRef()); // local and connection 97 EXPECT_FALSE(backing_store->HasOneRef()); // local and connection
96 98
97 request1->connection()->ForceClose(); 99 request1->connection()->ForceClose();
98 EXPECT_FALSE(request1->connection()->IsConnected()); 100 EXPECT_FALSE(request1->connection()->IsConnected());
99 101
100 EXPECT_FALSE(backing_store->HasOneRef()); // local and connection 102 EXPECT_FALSE(backing_store->HasOneRef()); // local and connection
101 103
102 request2->connection()->ForceClose(); 104 request2->connection()->ForceClose();
103 EXPECT_FALSE(request2->connection()->IsConnected()); 105 EXPECT_FALSE(request2->connection()->IsConnected());
(...skipping 17 matching lines...) Expand all
121 factory.get(), 123 factory.get(),
122 IndexedDBDatabase::Identifier(), 124 IndexedDBDatabase::Identifier(),
123 &s); 125 &s);
124 ASSERT_TRUE(s.ok()); 126 ASSERT_TRUE(s.ok());
125 EXPECT_FALSE(backing_store->HasOneRef()); // local and db 127 EXPECT_FALSE(backing_store->HasOneRef()); // local and db
126 128
127 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks( 129 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks(
128 new MockIndexedDBDatabaseCallbacks()); 130 new MockIndexedDBDatabaseCallbacks());
129 scoped_refptr<MockIndexedDBCallbacks> request(new MockIndexedDBCallbacks()); 131 scoped_refptr<MockIndexedDBCallbacks> request(new MockIndexedDBCallbacks());
130 const int64_t upgrade_transaction_id = 3; 132 const int64_t upgrade_transaction_id = 3;
131 IndexedDBPendingConnection connection( 133 std::unique_ptr<IndexedDBPendingConnection> connection(
132 request, callbacks, kFakeChildProcessId, upgrade_transaction_id, 134 new IndexedDBPendingConnection(
133 IndexedDBDatabaseMetadata::DEFAULT_VERSION); 135 request, callbacks, kFakeChildProcessId, upgrade_transaction_id,
134 database->OpenConnection(connection); 136 IndexedDBDatabaseMetadata::DEFAULT_VERSION));
137 database->OpenConnection(std::move(connection));
135 EXPECT_EQ(database.get(), request->connection()->database()); 138 EXPECT_EQ(database.get(), request->connection()->database());
136 139
137 const int64_t transaction_id = 123; 140 const int64_t transaction_id = 123;
138 const std::vector<int64_t> scope; 141 const std::vector<int64_t> scope;
139 database->CreateTransaction(transaction_id, 142 database->CreateTransaction(transaction_id,
140 request->connection(), 143 request->connection(),
141 scope, 144 scope,
142 blink::WebIDBTransactionModeReadOnly); 145 blink::WebIDBTransactionModeReadOnly);
143 146
144 request->connection()->ForceClose(); 147 request->connection()->ForceClose();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 factory.get(), 185 factory.get(),
183 IndexedDBDatabase::Identifier(), 186 IndexedDBDatabase::Identifier(),
184 &s); 187 &s);
185 ASSERT_TRUE(s.ok()); 188 ASSERT_TRUE(s.ok());
186 EXPECT_FALSE(backing_store->HasOneRef()); // local and db 189 EXPECT_FALSE(backing_store->HasOneRef()); // local and db
187 190
188 scoped_refptr<MockIndexedDBCallbacks> request1(new MockIndexedDBCallbacks()); 191 scoped_refptr<MockIndexedDBCallbacks> request1(new MockIndexedDBCallbacks());
189 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks1( 192 scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks1(
190 new MockIndexedDBDatabaseCallbacks()); 193 new MockIndexedDBDatabaseCallbacks());
191 const int64_t transaction_id1 = 1; 194 const int64_t transaction_id1 = 1;
192 IndexedDBPendingConnection connection( 195 std::unique_ptr<IndexedDBPendingConnection> connection(
193 request1, callbacks1, kFakeChildProcessId, transaction_id1, 196 new IndexedDBPendingConnection(
194 IndexedDBDatabaseMetadata::DEFAULT_VERSION); 197 request1, callbacks1, kFakeChildProcessId, transaction_id1,
195 db->OpenConnection(connection); 198 IndexedDBDatabaseMetadata::DEFAULT_VERSION));
199 db->OpenConnection(std::move(connection));
196 200
197 EXPECT_EQ(db->ConnectionCount(), 1UL); 201 EXPECT_EQ(db->ConnectionCount(), 1UL);
198 EXPECT_EQ(db->ActiveOpenDeleteCount(), 0UL); 202 EXPECT_EQ(db->ActiveOpenDeleteCount(), 0UL);
199 EXPECT_EQ(db->PendingOpenDeleteCount(), 0UL); 203 EXPECT_EQ(db->PendingOpenDeleteCount(), 0UL);
200 EXPECT_FALSE(backing_store->HasOneRef()); // local and db 204 EXPECT_FALSE(backing_store->HasOneRef()); // local and db
201 205
202 scoped_refptr<MockDeleteCallbacks> request2(new MockDeleteCallbacks()); 206 scoped_refptr<MockDeleteCallbacks> request2(new MockDeleteCallbacks());
203 db->DeleteDatabase(request2); 207 db->DeleteDatabase(request2);
204 EXPECT_EQ(db->ConnectionCount(), 1UL); 208 EXPECT_EQ(db->ConnectionCount(), 1UL);
205 EXPECT_EQ(db->ActiveOpenDeleteCount(), 1UL); 209 EXPECT_EQ(db->ActiveOpenDeleteCount(), 1UL);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 db_ = IndexedDBDatabase::Create(ASCIIToUTF16("db"), 243 db_ = IndexedDBDatabase::Create(ASCIIToUTF16("db"),
240 backing_store_.get(), 244 backing_store_.get(),
241 factory_.get(), 245 factory_.get(),
242 IndexedDBDatabase::Identifier(), 246 IndexedDBDatabase::Identifier(),
243 &s); 247 &s);
244 ASSERT_TRUE(s.ok()); 248 ASSERT_TRUE(s.ok());
245 249
246 request_ = new MockIndexedDBCallbacks(); 250 request_ = new MockIndexedDBCallbacks();
247 callbacks_ = new MockIndexedDBDatabaseCallbacks(); 251 callbacks_ = new MockIndexedDBDatabaseCallbacks();
248 const int64_t transaction_id = 1; 252 const int64_t transaction_id = 1;
249 db_->OpenConnection(IndexedDBPendingConnection( 253 std::unique_ptr<IndexedDBPendingConnection> connection(
250 request_, callbacks_, kFakeChildProcessId, transaction_id, 254 new IndexedDBPendingConnection(
251 IndexedDBDatabaseMetadata::DEFAULT_VERSION)); 255 request_, callbacks_, kFakeChildProcessId, transaction_id,
256 IndexedDBDatabaseMetadata::DEFAULT_VERSION));
257 db_->OpenConnection(std::move(connection));
252 EXPECT_EQ(IndexedDBDatabaseMetadata::NO_VERSION, db_->metadata().version); 258 EXPECT_EQ(IndexedDBDatabaseMetadata::NO_VERSION, db_->metadata().version);
253 259
254 connection_ = base::WrapUnique(new IndexedDBConnection(db_, callbacks_)); 260 connection_ = base::WrapUnique(new IndexedDBConnection(db_, callbacks_));
255 transaction_ = IndexedDBClassFactory::Get()->CreateIndexedDBTransaction( 261 transaction_ = IndexedDBClassFactory::Get()->CreateIndexedDBTransaction(
256 transaction_id, connection_->GetWeakPtr(), 262 transaction_id, connection_->GetWeakPtr(),
257 std::set<int64_t>() /*scope*/, 263 std::set<int64_t>() /*scope*/,
258 blink::WebIDBTransactionModeVersionChange, 264 blink::WebIDBTransactionModeVersionChange,
259 new IndexedDBFakeBackingStore::FakeTransaction(commit_success_)); 265 new IndexedDBFakeBackingStore::FakeTransaction(commit_success_));
260 db_->TransactionCreated(transaction_.get()); 266 db_->TransactionCreated(transaction_.get());
261 267
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 EXPECT_EQ(1ULL, db_->metadata().object_stores.size()); 411 EXPECT_EQ(1ULL, db_->metadata().object_stores.size());
406 412
407 // This will execute the Put then Delete. 413 // This will execute the Put then Delete.
408 RunPostedTasks(); 414 RunPostedTasks();
409 EXPECT_EQ(0ULL, db_->metadata().object_stores.size()); 415 EXPECT_EQ(0ULL, db_->metadata().object_stores.size());
410 416
411 transaction_->Commit(); // Cleans up the object hierarchy. 417 transaction_->Commit(); // Cleans up the object hierarchy.
412 } 418 }
413 419
414 } // namespace content 420 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_database.cc ('k') | content/browser/indexed_db/indexed_db_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698