OLD | NEW |
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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 0 /* host_transaction_id */, 0 /* version */)); | 201 0 /* host_transaction_id */, 0 /* version */)); |
202 factory->Open(base::ASCIIToUTF16("closeddb"), std::move(closed_connection), | 202 factory->Open(base::ASCIIToUTF16("closeddb"), std::move(closed_connection), |
203 nullptr /* request_context */, Origin(kTestOrigin), | 203 nullptr /* request_context */, Origin(kTestOrigin), |
204 idb_context->data_path()); | 204 idb_context->data_path()); |
205 | 205 |
206 closed_callbacks->connection()->Close(); | 206 closed_callbacks->connection()->Close(); |
207 | 207 |
208 // TODO(jsbell): Remove static_cast<> when overloads are eliminated. | 208 // TODO(jsbell): Remove static_cast<> when overloads are eliminated. |
209 idb_context->TaskRunner()->PostTask( | 209 idb_context->TaskRunner()->PostTask( |
210 FROM_HERE, | 210 FROM_HERE, |
211 base::Bind(static_cast<void (IndexedDBContextImpl::*)(const Origin&)>( | 211 base::BindOnce( |
212 &IndexedDBContextImpl::DeleteForOrigin), | 212 static_cast<void (IndexedDBContextImpl::*)(const Origin&)>( |
213 idb_context, kTestOrigin)); | 213 &IndexedDBContextImpl::DeleteForOrigin), |
| 214 idb_context, kTestOrigin)); |
214 FlushIndexedDBTaskRunner(); | 215 FlushIndexedDBTaskRunner(); |
215 base::RunLoop().RunUntilIdle(); | 216 base::RunLoop().RunUntilIdle(); |
216 } | 217 } |
217 | 218 |
218 // Make sure we wait until the destructor has run. | 219 // Make sure we wait until the destructor has run. |
219 base::RunLoop().RunUntilIdle(); | 220 base::RunLoop().RunUntilIdle(); |
220 | 221 |
221 EXPECT_TRUE(open_db_callbacks->forced_close_called()); | 222 EXPECT_TRUE(open_db_callbacks->forced_close_called()); |
222 EXPECT_FALSE(closed_db_callbacks->forced_close_called()); | 223 EXPECT_FALSE(closed_db_callbacks->forced_close_called()); |
223 EXPECT_FALSE(base::DirectoryExists(test_path)); | 224 EXPECT_FALSE(base::DirectoryExists(test_path)); |
(...skipping 12 matching lines...) Expand all Loading... |
236 ASSERT_TRUE(base::CreateDirectory(test_path)); | 237 ASSERT_TRUE(base::CreateDirectory(test_path)); |
237 | 238 |
238 std::unique_ptr<LevelDBLock> lock = | 239 std::unique_ptr<LevelDBLock> lock = |
239 LevelDBDatabase::LockForTesting(test_path); | 240 LevelDBDatabase::LockForTesting(test_path); |
240 ASSERT_TRUE(lock); | 241 ASSERT_TRUE(lock); |
241 | 242 |
242 // TODO(jsbell): Remove static_cast<> when overloads are eliminated. | 243 // TODO(jsbell): Remove static_cast<> when overloads are eliminated. |
243 void (IndexedDBContextImpl::* delete_for_origin)(const Origin&) = | 244 void (IndexedDBContextImpl::* delete_for_origin)(const Origin&) = |
244 &IndexedDBContextImpl::DeleteForOrigin; | 245 &IndexedDBContextImpl::DeleteForOrigin; |
245 idb_context->TaskRunner()->PostTask( | 246 idb_context->TaskRunner()->PostTask( |
246 FROM_HERE, | 247 FROM_HERE, base::BindOnce(delete_for_origin, idb_context, kTestOrigin)); |
247 base::Bind(delete_for_origin, idb_context, kTestOrigin)); | |
248 FlushIndexedDBTaskRunner(); | 248 FlushIndexedDBTaskRunner(); |
249 | 249 |
250 EXPECT_TRUE(base::DirectoryExists(test_path)); | 250 EXPECT_TRUE(base::DirectoryExists(test_path)); |
251 } | 251 } |
252 | 252 |
253 TEST_F(IndexedDBTest, ForceCloseOpenDatabasesOnCommitFailure) { | 253 TEST_F(IndexedDBTest, ForceCloseOpenDatabasesOnCommitFailure) { |
254 const Origin kTestOrigin(GURL("http://test/")); | 254 const Origin kTestOrigin(GURL("http://test/")); |
255 | 255 |
256 base::ScopedTempDir temp_dir; | 256 base::ScopedTempDir temp_dir; |
257 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 257 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
(...skipping 26 matching lines...) Expand all Loading... |
284 | 284 |
285 // Simulate the write failure. | 285 // Simulate the write failure. |
286 leveldb::Status status = leveldb::Status::IOError("Simulated failure"); | 286 leveldb::Status status = leveldb::Status::IOError("Simulated failure"); |
287 context->GetIDBFactory()->HandleBackingStoreFailure(kTestOrigin); | 287 context->GetIDBFactory()->HandleBackingStoreFailure(kTestOrigin); |
288 | 288 |
289 EXPECT_TRUE(db_callbacks->forced_close_called()); | 289 EXPECT_TRUE(db_callbacks->forced_close_called()); |
290 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin)); | 290 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin)); |
291 } | 291 } |
292 | 292 |
293 } // namespace content | 293 } // namespace content |
OLD | NEW |