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

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

Issue 2773823002: Use a two-part data format version in IndexedDB metadata. (Closed)
Patch Set: jsbell, cmumford Created 3 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stdint.h> 5 #include <stdint.h>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 IndexedDBFactory* factory = idb_context->GetIDBFactory(); 183 IndexedDBFactory* factory = idb_context->GetIDBFactory();
184 184
185 test_path = idb_context->GetFilePathForTesting(kTestOrigin); 185 test_path = idb_context->GetFilePathForTesting(kTestOrigin);
186 186
187 std::unique_ptr<IndexedDBPendingConnection> open_connection( 187 std::unique_ptr<IndexedDBPendingConnection> open_connection(
188 base::MakeUnique<IndexedDBPendingConnection>( 188 base::MakeUnique<IndexedDBPendingConnection>(
189 open_callbacks, open_db_callbacks, 0 /* child_process_id */, 189 open_callbacks, open_db_callbacks, 0 /* child_process_id */,
190 0 /* host_transaction_id */, 0 /* version */)); 190 0 /* host_transaction_id */, 0 /* version */));
191 factory->Open(base::ASCIIToUTF16("opendb"), std::move(open_connection), 191 factory->Open(base::ASCIIToUTF16("opendb"), std::move(open_connection),
192 nullptr /* request_context */, Origin(kTestOrigin), 192 nullptr /* request_context */, Origin(kTestOrigin),
193 idb_context->data_path()); 193 idb_context->data_path(), IndexedDBDataFormatVersion());
194 std::unique_ptr<IndexedDBPendingConnection> closed_connection( 194 std::unique_ptr<IndexedDBPendingConnection> closed_connection(
195 base::MakeUnique<IndexedDBPendingConnection>( 195 base::MakeUnique<IndexedDBPendingConnection>(
196 closed_callbacks, closed_db_callbacks, 0 /* child_process_id */, 196 closed_callbacks, closed_db_callbacks, 0 /* child_process_id */,
197 0 /* host_transaction_id */, 0 /* version */)); 197 0 /* host_transaction_id */, 0 /* version */));
198 factory->Open(base::ASCIIToUTF16("closeddb"), std::move(closed_connection), 198 factory->Open(base::ASCIIToUTF16("closeddb"), std::move(closed_connection),
199 nullptr /* request_context */, Origin(kTestOrigin), 199 nullptr /* request_context */, Origin(kTestOrigin),
200 idb_context->data_path()); 200 idb_context->data_path(), IndexedDBDataFormatVersion());
201 201
202 closed_callbacks->connection()->Close(); 202 closed_callbacks->connection()->Close();
203 203
204 // TODO(jsbell): Remove static_cast<> when overloads are eliminated. 204 // TODO(jsbell): Remove static_cast<> when overloads are eliminated.
205 idb_context->TaskRunner()->PostTask( 205 idb_context->TaskRunner()->PostTask(
206 FROM_HERE, 206 FROM_HERE,
207 base::Bind(static_cast<void (IndexedDBContextImpl::*)(const Origin&)>( 207 base::Bind(static_cast<void (IndexedDBContextImpl::*)(const Origin&)>(
208 &IndexedDBContextImpl::DeleteForOrigin), 208 &IndexedDBContextImpl::DeleteForOrigin),
209 idb_context, kTestOrigin)); 209 idb_context, kTestOrigin));
210 FlushIndexedDBTaskRunner(); 210 FlushIndexedDBTaskRunner();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks()); 262 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks());
263 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks( 263 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks(
264 new MockIndexedDBDatabaseCallbacks()); 264 new MockIndexedDBDatabaseCallbacks());
265 const int64_t transaction_id = 1; 265 const int64_t transaction_id = 1;
266 std::unique_ptr<IndexedDBPendingConnection> connection( 266 std::unique_ptr<IndexedDBPendingConnection> connection(
267 base::MakeUnique<IndexedDBPendingConnection>( 267 base::MakeUnique<IndexedDBPendingConnection>(
268 callbacks, db_callbacks, 0 /* child_process_id */, transaction_id, 268 callbacks, db_callbacks, 0 /* child_process_id */, transaction_id,
269 IndexedDBDatabaseMetadata::DEFAULT_VERSION)); 269 IndexedDBDatabaseMetadata::DEFAULT_VERSION));
270 factory->Open(base::ASCIIToUTF16("db"), std::move(connection), 270 factory->Open(base::ASCIIToUTF16("db"), std::move(connection),
271 nullptr /* request_context */, Origin(kTestOrigin), 271 nullptr /* request_context */, Origin(kTestOrigin),
272 temp_dir.GetPath()); 272 temp_dir.GetPath(), IndexedDBDataFormatVersion());
273 273
274 EXPECT_TRUE(callbacks->connection()); 274 EXPECT_TRUE(callbacks->connection());
275 275
276 // ConnectionOpened() is usually called by the dispatcher. 276 // ConnectionOpened() is usually called by the dispatcher.
277 context->ConnectionOpened(kTestOrigin, callbacks->connection()); 277 context->ConnectionOpened(kTestOrigin, callbacks->connection());
278 278
279 EXPECT_TRUE(factory->IsBackingStoreOpen(kTestOrigin)); 279 EXPECT_TRUE(factory->IsBackingStoreOpen(kTestOrigin));
280 280
281 // Simulate the write failure. 281 // Simulate the write failure.
282 leveldb::Status status = leveldb::Status::IOError("Simulated failure"); 282 leveldb::Status status = leveldb::Status::IOError("Simulated failure");
283 context->GetIDBFactory()->HandleBackingStoreFailure(kTestOrigin); 283 context->GetIDBFactory()->HandleBackingStoreFailure(kTestOrigin);
284 284
285 EXPECT_TRUE(db_callbacks->forced_close_called()); 285 EXPECT_TRUE(db_callbacks->forced_close_called());
286 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin)); 286 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin));
287 } 287 }
288 288
289 } // namespace content 289 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698