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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 temp_dir.path(), special_storage_policy_.get(), | 239 temp_dir.path(), special_storage_policy_.get(), |
240 quota_manager_proxy_.get(), task_runner_.get()); | 240 quota_manager_proxy_.get(), task_runner_.get()); |
241 | 241 |
242 base::FilePath test_path = idb_context->GetFilePathForTesting(kTestOrigin); | 242 base::FilePath test_path = idb_context->GetFilePathForTesting(kTestOrigin); |
243 ASSERT_TRUE(base::CreateDirectory(test_path)); | 243 ASSERT_TRUE(base::CreateDirectory(test_path)); |
244 | 244 |
245 std::unique_ptr<LevelDBLock> lock = | 245 std::unique_ptr<LevelDBLock> lock = |
246 LevelDBDatabase::LockForTesting(test_path); | 246 LevelDBDatabase::LockForTesting(test_path); |
247 ASSERT_TRUE(lock); | 247 ASSERT_TRUE(lock); |
248 | 248 |
249 // TODO(jsbell): Remove static_cast<> when overloads are eliminated. | 249 // TODO(jsbell): Remove static_cast<> when overloads are eliminated. |
jsbell
2016/07/07 16:49:05
Would have been nice to eliminate the comment too.
| |
250 void (IndexedDBContextImpl::* delete_for_origin)(const Origin&) = | |
251 &IndexedDBContextImpl::DeleteForOrigin; | |
250 idb_context->TaskRunner()->PostTask( | 252 idb_context->TaskRunner()->PostTask( |
251 FROM_HERE, | 253 FROM_HERE, |
252 base::Bind(static_cast<void (IndexedDBContextImpl::*)(const Origin&)>( | 254 base::Bind(delete_for_origin, idb_context, kTestOrigin)); |
253 &IndexedDBContextImpl::DeleteForOrigin), | |
254 idb_context, kTestOrigin)); | |
255 FlushIndexedDBTaskRunner(); | 255 FlushIndexedDBTaskRunner(); |
256 | 256 |
257 EXPECT_TRUE(base::DirectoryExists(test_path)); | 257 EXPECT_TRUE(base::DirectoryExists(test_path)); |
258 } | 258 } |
259 | 259 |
260 TEST_F(IndexedDBTest, ForceCloseOpenDatabasesOnCommitFailure) { | 260 TEST_F(IndexedDBTest, ForceCloseOpenDatabasesOnCommitFailure) { |
261 const Origin kTestOrigin(GURL("http://test/")); | 261 const Origin kTestOrigin(GURL("http://test/")); |
262 | 262 |
263 base::ScopedTempDir temp_dir; | 263 base::ScopedTempDir temp_dir; |
264 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 264 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
(...skipping 25 matching lines...) Expand all Loading... | |
290 | 290 |
291 // Simulate the write failure. | 291 // Simulate the write failure. |
292 leveldb::Status status = leveldb::Status::IOError("Simulated failure"); | 292 leveldb::Status status = leveldb::Status::IOError("Simulated failure"); |
293 callbacks->connection()->database()->TransactionCommitFailed(status); | 293 callbacks->connection()->database()->TransactionCommitFailed(status); |
294 | 294 |
295 EXPECT_TRUE(db_callbacks->forced_close_called()); | 295 EXPECT_TRUE(db_callbacks->forced_close_called()); |
296 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin)); | 296 EXPECT_FALSE(factory->IsBackingStoreOpen(kTestOrigin)); |
297 } | 297 } |
298 | 298 |
299 } // namespace content | 299 } // namespace content |
OLD | NEW |