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

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

Issue 2316043002: //content: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Just rebased Created 4 years, 3 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 <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/logging.h" 10 #include "base/logging.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 DISALLOW_COPY_AND_ASSIGN(IndexedDBFactoryTest); 96 DISALLOW_COPY_AND_ASSIGN(IndexedDBFactoryTest);
97 }; 97 };
98 98
99 TEST_F(IndexedDBFactoryTest, BackingStoreLifetime) { 99 TEST_F(IndexedDBFactoryTest, BackingStoreLifetime) {
100 const Origin origin1(GURL("http://localhost:81")); 100 const Origin origin1(GURL("http://localhost:81"));
101 const Origin origin2(GURL("http://localhost:82")); 101 const Origin origin2(GURL("http://localhost:82"));
102 102
103 base::ScopedTempDir temp_directory; 103 base::ScopedTempDir temp_directory;
104 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); 104 ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
105 scoped_refptr<IndexedDBBackingStore> disk_store1 = 105 scoped_refptr<IndexedDBBackingStore> disk_store1 =
106 factory()->TestOpenBackingStore(origin1, temp_directory.path()); 106 factory()->TestOpenBackingStore(origin1, temp_directory.GetPath());
107 107
108 scoped_refptr<IndexedDBBackingStore> disk_store2 = 108 scoped_refptr<IndexedDBBackingStore> disk_store2 =
109 factory()->TestOpenBackingStore(origin1, temp_directory.path()); 109 factory()->TestOpenBackingStore(origin1, temp_directory.GetPath());
110 EXPECT_EQ(disk_store1.get(), disk_store2.get()); 110 EXPECT_EQ(disk_store1.get(), disk_store2.get());
111 111
112 scoped_refptr<IndexedDBBackingStore> disk_store3 = 112 scoped_refptr<IndexedDBBackingStore> disk_store3 =
113 factory()->TestOpenBackingStore(origin2, temp_directory.path()); 113 factory()->TestOpenBackingStore(origin2, temp_directory.GetPath());
114 114
115 factory()->TestCloseBackingStore(disk_store1.get()); 115 factory()->TestCloseBackingStore(disk_store1.get());
116 factory()->TestCloseBackingStore(disk_store3.get()); 116 factory()->TestCloseBackingStore(disk_store3.get());
117 117
118 EXPECT_FALSE(disk_store1->HasOneRef()); 118 EXPECT_FALSE(disk_store1->HasOneRef());
119 EXPECT_FALSE(disk_store2->HasOneRef()); 119 EXPECT_FALSE(disk_store2->HasOneRef());
120 EXPECT_TRUE(disk_store3->HasOneRef()); 120 EXPECT_TRUE(disk_store3->HasOneRef());
121 121
122 disk_store2 = nullptr; 122 disk_store2 = nullptr;
123 EXPECT_TRUE(disk_store1->HasOneRef()); 123 EXPECT_TRUE(disk_store1->HasOneRef());
124 } 124 }
125 125
126 TEST_F(IndexedDBFactoryTest, BackingStoreLazyClose) { 126 TEST_F(IndexedDBFactoryTest, BackingStoreLazyClose) {
127 const Origin origin(GURL("http://localhost:81")); 127 const Origin origin(GURL("http://localhost:81"));
128 128
129 base::ScopedTempDir temp_directory; 129 base::ScopedTempDir temp_directory;
130 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); 130 ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
131 scoped_refptr<IndexedDBBackingStore> store = 131 scoped_refptr<IndexedDBBackingStore> store =
132 factory()->TestOpenBackingStore(origin, temp_directory.path()); 132 factory()->TestOpenBackingStore(origin, temp_directory.GetPath());
133 133
134 // Give up the local refptr so that the factory has the only 134 // Give up the local refptr so that the factory has the only
135 // outstanding reference. 135 // outstanding reference.
136 IndexedDBBackingStore* store_ptr = store.get(); 136 IndexedDBBackingStore* store_ptr = store.get();
137 store = nullptr; 137 store = nullptr;
138 EXPECT_FALSE(store_ptr->close_timer()->IsRunning()); 138 EXPECT_FALSE(store_ptr->close_timer()->IsRunning());
139 factory()->TestReleaseBackingStore(store_ptr, false); 139 factory()->TestReleaseBackingStore(store_ptr, false);
140 EXPECT_TRUE(store_ptr->close_timer()->IsRunning()); 140 EXPECT_TRUE(store_ptr->close_timer()->IsRunning());
141 141
142 factory()->TestOpenBackingStore(origin, temp_directory.path()); 142 factory()->TestOpenBackingStore(origin, temp_directory.GetPath());
143 EXPECT_FALSE(store_ptr->close_timer()->IsRunning()); 143 EXPECT_FALSE(store_ptr->close_timer()->IsRunning());
144 factory()->TestReleaseBackingStore(store_ptr, false); 144 factory()->TestReleaseBackingStore(store_ptr, false);
145 EXPECT_TRUE(store_ptr->close_timer()->IsRunning()); 145 EXPECT_TRUE(store_ptr->close_timer()->IsRunning());
146 146
147 // Take back a ref ptr and ensure that the actual close 147 // Take back a ref ptr and ensure that the actual close
148 // stops a running timer. 148 // stops a running timer.
149 store = store_ptr; 149 store = store_ptr;
150 factory()->TestCloseBackingStore(store_ptr); 150 factory()->TestCloseBackingStore(store_ptr);
151 EXPECT_FALSE(store_ptr->close_timer()->IsRunning()); 151 EXPECT_FALSE(store_ptr->close_timer()->IsRunning());
152 } 152 }
(...skipping 24 matching lines...) Expand all
177 EXPECT_FALSE(mem_store2->HasOneRef()); // mem_store1 and 2 177 EXPECT_FALSE(mem_store2->HasOneRef()); // mem_store1 and 2
178 EXPECT_TRUE(mem_store3->HasOneRef()); 178 EXPECT_TRUE(mem_store3->HasOneRef());
179 179
180 mem_store2 = nullptr; 180 mem_store2 = nullptr;
181 EXPECT_TRUE(mem_store1->HasOneRef()); 181 EXPECT_TRUE(mem_store1->HasOneRef());
182 } 182 }
183 183
184 TEST_F(IndexedDBFactoryTest, RejectLongOrigins) { 184 TEST_F(IndexedDBFactoryTest, RejectLongOrigins) {
185 base::ScopedTempDir temp_directory; 185 base::ScopedTempDir temp_directory;
186 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); 186 ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
187 const base::FilePath base_path = temp_directory.path(); 187 const base::FilePath base_path = temp_directory.GetPath();
188 188
189 int limit = base::GetMaximumPathComponentLength(base_path); 189 int limit = base::GetMaximumPathComponentLength(base_path);
190 EXPECT_GT(limit, 0); 190 EXPECT_GT(limit, 0);
191 191
192 std::string origin(limit + 1, 'x'); 192 std::string origin(limit + 1, 'x');
193 Origin too_long_origin(GURL("http://" + origin + ":81/")); 193 Origin too_long_origin(GURL("http://" + origin + ":81/"));
194 scoped_refptr<IndexedDBBackingStore> diskStore1 = 194 scoped_refptr<IndexedDBBackingStore> diskStore1 =
195 factory()->TestOpenBackingStore(too_long_origin, base_path); 195 factory()->TestOpenBackingStore(too_long_origin, base_path);
196 EXPECT_FALSE(diskStore1.get()); 196 EXPECT_FALSE(diskStore1.get());
197 197
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 scoped_refptr<LookingForQuotaErrorMockCallbacks> callbacks = 251 scoped_refptr<LookingForQuotaErrorMockCallbacks> callbacks =
252 new LookingForQuotaErrorMockCallbacks; 252 new LookingForQuotaErrorMockCallbacks;
253 scoped_refptr<IndexedDBDatabaseCallbacks> dummy_database_callbacks = 253 scoped_refptr<IndexedDBDatabaseCallbacks> dummy_database_callbacks =
254 new IndexedDBDatabaseCallbacks(nullptr, 0, 0); 254 new IndexedDBDatabaseCallbacks(nullptr, 0, 0);
255 const base::string16 name(ASCIIToUTF16("name")); 255 const base::string16 name(ASCIIToUTF16("name"));
256 std::unique_ptr<IndexedDBPendingConnection> connection( 256 std::unique_ptr<IndexedDBPendingConnection> connection(
257 base::MakeUnique<IndexedDBPendingConnection>( 257 base::MakeUnique<IndexedDBPendingConnection>(
258 callbacks, dummy_database_callbacks, 0 /* child_process_id */, 258 callbacks, dummy_database_callbacks, 0 /* child_process_id */,
259 2 /* transaction_id */, 1 /* version */)); 259 2 /* transaction_id */, 1 /* version */));
260 factory->Open(name, std::move(connection), nullptr /* request_context */, 260 factory->Open(name, std::move(connection), nullptr /* request_context */,
261 origin, temp_directory.path()); 261 origin, temp_directory.GetPath());
262 EXPECT_TRUE(callbacks->error_called()); 262 EXPECT_TRUE(callbacks->error_called());
263 } 263 }
264 264
265 TEST_F(IndexedDBFactoryTest, BackingStoreReleasedOnForcedClose) { 265 TEST_F(IndexedDBFactoryTest, BackingStoreReleasedOnForcedClose) {
266 const Origin origin(GURL("http://localhost:81")); 266 const Origin origin(GURL("http://localhost:81"));
267 267
268 base::ScopedTempDir temp_directory; 268 base::ScopedTempDir temp_directory;
269 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); 269 ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
270 270
271 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks()); 271 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks());
272 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks( 272 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks(
273 new MockIndexedDBDatabaseCallbacks()); 273 new MockIndexedDBDatabaseCallbacks());
274 const int64_t transaction_id = 1; 274 const int64_t transaction_id = 1;
275 std::unique_ptr<IndexedDBPendingConnection> connection( 275 std::unique_ptr<IndexedDBPendingConnection> connection(
276 base::MakeUnique<IndexedDBPendingConnection>( 276 base::MakeUnique<IndexedDBPendingConnection>(
277 callbacks, db_callbacks, 0 /* child_process_id */, transaction_id, 277 callbacks, db_callbacks, 0 /* child_process_id */, transaction_id,
278 IndexedDBDatabaseMetadata::DEFAULT_VERSION)); 278 IndexedDBDatabaseMetadata::DEFAULT_VERSION));
279 factory()->Open(ASCIIToUTF16("db"), std::move(connection), 279 factory()->Open(ASCIIToUTF16("db"), std::move(connection),
280 nullptr /* request_context */, origin, temp_directory.path()); 280 nullptr /* request_context */, origin,
281 temp_directory.GetPath());
281 282
282 EXPECT_TRUE(callbacks->connection()); 283 EXPECT_TRUE(callbacks->connection());
283 284
284 EXPECT_TRUE(factory()->IsBackingStoreOpen(origin)); 285 EXPECT_TRUE(factory()->IsBackingStoreOpen(origin));
285 EXPECT_FALSE(factory()->IsBackingStorePendingClose(origin)); 286 EXPECT_FALSE(factory()->IsBackingStorePendingClose(origin));
286 287
287 callbacks->connection()->ForceClose(); 288 callbacks->connection()->ForceClose();
288 289
289 EXPECT_FALSE(factory()->IsBackingStoreOpen(origin)); 290 EXPECT_FALSE(factory()->IsBackingStoreOpen(origin));
290 EXPECT_FALSE(factory()->IsBackingStorePendingClose(origin)); 291 EXPECT_FALSE(factory()->IsBackingStorePendingClose(origin));
291 } 292 }
292 293
293 TEST_F(IndexedDBFactoryTest, BackingStoreReleaseDelayedOnClose) { 294 TEST_F(IndexedDBFactoryTest, BackingStoreReleaseDelayedOnClose) {
294 const Origin origin(GURL("http://localhost:81")); 295 const Origin origin(GURL("http://localhost:81"));
295 296
296 base::ScopedTempDir temp_directory; 297 base::ScopedTempDir temp_directory;
297 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); 298 ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
298 299
299 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks()); 300 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks());
300 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks( 301 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks(
301 new MockIndexedDBDatabaseCallbacks()); 302 new MockIndexedDBDatabaseCallbacks());
302 const int64_t transaction_id = 1; 303 const int64_t transaction_id = 1;
303 std::unique_ptr<IndexedDBPendingConnection> connection( 304 std::unique_ptr<IndexedDBPendingConnection> connection(
304 base::MakeUnique<IndexedDBPendingConnection>( 305 base::MakeUnique<IndexedDBPendingConnection>(
305 callbacks, db_callbacks, 0 /* child_process_id */, transaction_id, 306 callbacks, db_callbacks, 0 /* child_process_id */, transaction_id,
306 IndexedDBDatabaseMetadata::DEFAULT_VERSION)); 307 IndexedDBDatabaseMetadata::DEFAULT_VERSION));
307 factory()->Open(ASCIIToUTF16("db"), std::move(connection), 308 factory()->Open(ASCIIToUTF16("db"), std::move(connection),
308 nullptr /* request_context */, origin, temp_directory.path()); 309 nullptr /* request_context */, origin,
310 temp_directory.GetPath());
309 311
310 EXPECT_TRUE(callbacks->connection()); 312 EXPECT_TRUE(callbacks->connection());
311 IndexedDBBackingStore* store = 313 IndexedDBBackingStore* store =
312 callbacks->connection()->database()->backing_store(); 314 callbacks->connection()->database()->backing_store();
313 EXPECT_FALSE(store->HasOneRef()); // Factory and database. 315 EXPECT_FALSE(store->HasOneRef()); // Factory and database.
314 316
315 EXPECT_TRUE(factory()->IsBackingStoreOpen(origin)); 317 EXPECT_TRUE(factory()->IsBackingStoreOpen(origin));
316 callbacks->connection()->Close(); 318 callbacks->connection()->Close();
317 EXPECT_TRUE(store->HasOneRef()); // Factory. 319 EXPECT_TRUE(store->HasOneRef()); // Factory.
318 EXPECT_TRUE(factory()->IsBackingStoreOpen(origin)); 320 EXPECT_TRUE(factory()->IsBackingStoreOpen(origin));
(...skipping 15 matching lines...) Expand all
334 336
335 base::ScopedTempDir temp_directory; 337 base::ScopedTempDir temp_directory;
336 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); 338 ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
337 339
338 EXPECT_FALSE(factory()->IsBackingStoreOpen(origin)); 340 EXPECT_FALSE(factory()->IsBackingStoreOpen(origin));
339 341
340 const bool expect_connection = false; 342 const bool expect_connection = false;
341 scoped_refptr<MockIndexedDBCallbacks> callbacks( 343 scoped_refptr<MockIndexedDBCallbacks> callbacks(
342 new MockIndexedDBCallbacks(expect_connection)); 344 new MockIndexedDBCallbacks(expect_connection));
343 factory()->DeleteDatabase(ASCIIToUTF16("db"), nullptr /* request_context */, 345 factory()->DeleteDatabase(ASCIIToUTF16("db"), nullptr /* request_context */,
344 callbacks, origin, temp_directory.path()); 346 callbacks, origin, temp_directory.GetPath());
345 347
346 EXPECT_TRUE(factory()->IsBackingStoreOpen(origin)); 348 EXPECT_TRUE(factory()->IsBackingStoreOpen(origin));
347 EXPECT_TRUE(factory()->IsBackingStorePendingClose(origin)); 349 EXPECT_TRUE(factory()->IsBackingStorePendingClose(origin));
348 350
349 // Now simulate shutdown, which should stop the timer. 351 // Now simulate shutdown, which should stop the timer.
350 factory()->ContextDestroyed(); 352 factory()->ContextDestroyed();
351 353
352 EXPECT_FALSE(factory()->IsBackingStoreOpen(origin)); 354 EXPECT_FALSE(factory()->IsBackingStoreOpen(origin));
353 EXPECT_FALSE(factory()->IsBackingStorePendingClose(origin)); 355 EXPECT_FALSE(factory()->IsBackingStorePendingClose(origin));
354 } 356 }
355 357
356 TEST_F(IndexedDBFactoryTest, GetDatabaseNamesClosesBackingStore) { 358 TEST_F(IndexedDBFactoryTest, GetDatabaseNamesClosesBackingStore) {
357 const Origin origin(GURL("http://localhost:81")); 359 const Origin origin(GURL("http://localhost:81"));
358 360
359 base::ScopedTempDir temp_directory; 361 base::ScopedTempDir temp_directory;
360 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); 362 ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
361 363
362 EXPECT_FALSE(factory()->IsBackingStoreOpen(origin)); 364 EXPECT_FALSE(factory()->IsBackingStoreOpen(origin));
363 365
364 const bool expect_connection = false; 366 const bool expect_connection = false;
365 scoped_refptr<MockIndexedDBCallbacks> callbacks( 367 scoped_refptr<MockIndexedDBCallbacks> callbacks(
366 new MockIndexedDBCallbacks(expect_connection)); 368 new MockIndexedDBCallbacks(expect_connection));
367 factory()->GetDatabaseNames(callbacks, origin, temp_directory.path(), 369 factory()->GetDatabaseNames(callbacks, origin, temp_directory.GetPath(),
368 nullptr /* request_context */); 370 nullptr /* request_context */);
369 371
370 EXPECT_TRUE(factory()->IsBackingStoreOpen(origin)); 372 EXPECT_TRUE(factory()->IsBackingStoreOpen(origin));
371 EXPECT_TRUE(factory()->IsBackingStorePendingClose(origin)); 373 EXPECT_TRUE(factory()->IsBackingStorePendingClose(origin));
372 374
373 // Now simulate shutdown, which should stop the timer. 375 // Now simulate shutdown, which should stop the timer.
374 factory()->ContextDestroyed(); 376 factory()->ContextDestroyed();
375 377
376 EXPECT_FALSE(factory()->IsBackingStoreOpen(origin)); 378 EXPECT_FALSE(factory()->IsBackingStoreOpen(origin));
377 EXPECT_FALSE(factory()->IsBackingStorePendingClose(origin)); 379 EXPECT_FALSE(factory()->IsBackingStorePendingClose(origin));
378 } 380 }
379 381
380 TEST_F(IndexedDBFactoryTest, ForceCloseReleasesBackingStore) { 382 TEST_F(IndexedDBFactoryTest, ForceCloseReleasesBackingStore) {
381 const Origin origin(GURL("http://localhost:81")); 383 const Origin origin(GURL("http://localhost:81"));
382 384
383 base::ScopedTempDir temp_directory; 385 base::ScopedTempDir temp_directory;
384 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); 386 ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
385 387
386 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks()); 388 scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks());
387 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks( 389 scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks(
388 new MockIndexedDBDatabaseCallbacks()); 390 new MockIndexedDBDatabaseCallbacks());
389 const int64_t transaction_id = 1; 391 const int64_t transaction_id = 1;
390 std::unique_ptr<IndexedDBPendingConnection> connection( 392 std::unique_ptr<IndexedDBPendingConnection> connection(
391 base::MakeUnique<IndexedDBPendingConnection>( 393 base::MakeUnique<IndexedDBPendingConnection>(
392 callbacks, db_callbacks, 0 /* child_process_id */, transaction_id, 394 callbacks, db_callbacks, 0 /* child_process_id */, transaction_id,
393 IndexedDBDatabaseMetadata::DEFAULT_VERSION)); 395 IndexedDBDatabaseMetadata::DEFAULT_VERSION));
394 factory()->Open(ASCIIToUTF16("db"), std::move(connection), 396 factory()->Open(ASCIIToUTF16("db"), std::move(connection),
395 nullptr /* request_context */, origin, temp_directory.path()); 397 nullptr /* request_context */, origin,
398 temp_directory.GetPath());
396 399
397 EXPECT_TRUE(callbacks->connection()); 400 EXPECT_TRUE(callbacks->connection());
398 EXPECT_TRUE(factory()->IsBackingStoreOpen(origin)); 401 EXPECT_TRUE(factory()->IsBackingStoreOpen(origin));
399 EXPECT_FALSE(factory()->IsBackingStorePendingClose(origin)); 402 EXPECT_FALSE(factory()->IsBackingStorePendingClose(origin));
400 403
401 callbacks->connection()->Close(); 404 callbacks->connection()->Close();
402 405
403 EXPECT_TRUE(factory()->IsBackingStoreOpen(origin)); 406 EXPECT_TRUE(factory()->IsBackingStoreOpen(origin));
404 EXPECT_TRUE(factory()->IsBackingStorePendingClose(origin)); 407 EXPECT_TRUE(factory()->IsBackingStorePendingClose(origin));
405 408
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 // Open at version 2, then close. 470 // Open at version 2, then close.
468 { 471 {
469 scoped_refptr<MockIndexedDBCallbacks> callbacks( 472 scoped_refptr<MockIndexedDBCallbacks> callbacks(
470 new UpgradeNeededCallbacks()); 473 new UpgradeNeededCallbacks());
471 std::unique_ptr<IndexedDBPendingConnection> connection( 474 std::unique_ptr<IndexedDBPendingConnection> connection(
472 base::MakeUnique<IndexedDBPendingConnection>( 475 base::MakeUnique<IndexedDBPendingConnection>(
473 callbacks, db_callbacks, 0 /* child_process_id */, transaction_id, 476 callbacks, db_callbacks, 0 /* child_process_id */, transaction_id,
474 db_version)); 477 db_version));
475 factory()->Open(db_name, std::move(connection), 478 factory()->Open(db_name, std::move(connection),
476 nullptr /* request_context */, origin, 479 nullptr /* request_context */, origin,
477 temp_directory.path()); 480 temp_directory.GetPath());
478 EXPECT_TRUE(factory()->IsDatabaseOpen(origin, db_name)); 481 EXPECT_TRUE(factory()->IsDatabaseOpen(origin, db_name));
479 482
480 // Pump the message loop so the upgrade transaction can run. 483 // Pump the message loop so the upgrade transaction can run.
481 base::RunLoop().RunUntilIdle(); 484 base::RunLoop().RunUntilIdle();
482 EXPECT_TRUE(callbacks->connection()); 485 EXPECT_TRUE(callbacks->connection());
483 callbacks->connection()->database()->Commit(transaction_id); 486 callbacks->connection()->database()->Commit(transaction_id);
484 487
485 callbacks->connection()->Close(); 488 callbacks->connection()->Close();
486 EXPECT_FALSE(factory()->IsDatabaseOpen(origin, db_name)); 489 EXPECT_FALSE(factory()->IsDatabaseOpen(origin, db_name));
487 } 490 }
488 491
489 // Open at version < 2, which will fail; ensure factory doesn't retain 492 // Open at version < 2, which will fail; ensure factory doesn't retain
490 // the database object. 493 // the database object.
491 { 494 {
492 scoped_refptr<ErrorCallbacks> callbacks(new ErrorCallbacks()); 495 scoped_refptr<ErrorCallbacks> callbacks(new ErrorCallbacks());
493 std::unique_ptr<IndexedDBPendingConnection> connection( 496 std::unique_ptr<IndexedDBPendingConnection> connection(
494 base::MakeUnique<IndexedDBPendingConnection>( 497 base::MakeUnique<IndexedDBPendingConnection>(
495 callbacks, db_callbacks, 0 /* child_process_id */, transaction_id, 498 callbacks, db_callbacks, 0 /* child_process_id */, transaction_id,
496 db_version - 1)); 499 db_version - 1));
497 factory()->Open(db_name, std::move(connection), 500 factory()->Open(db_name, std::move(connection),
498 nullptr /* request_context */, origin, 501 nullptr /* request_context */, origin,
499 temp_directory.path()); 502 temp_directory.GetPath());
500 EXPECT_TRUE(callbacks->saw_error()); 503 EXPECT_TRUE(callbacks->saw_error());
501 EXPECT_FALSE(factory()->IsDatabaseOpen(origin, db_name)); 504 EXPECT_FALSE(factory()->IsDatabaseOpen(origin, db_name));
502 } 505 }
503 506
504 // Terminate all pending-close timers. 507 // Terminate all pending-close timers.
505 factory()->ForceClose(origin); 508 factory()->ForceClose(origin);
506 } 509 }
507 510
508 } // namespace content 511 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698