| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/dom_storage/local_storage_context_mojo.h" | 5 #include "content/browser/dom_storage/local_storage_context_mojo.h" |
| 6 | 6 |
| 7 #include "base/files/file_enumerator.h" | 7 #include "base/files/file_enumerator.h" |
| 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/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 EXPECT_TRUE(DoTestGet(context, key, &result)); | 969 EXPECT_TRUE(DoTestGet(context, key, &result)); |
| 970 EXPECT_EQ(value, result); | 970 EXPECT_EQ(value, result); |
| 971 | 971 |
| 972 context->ShutdownAndDelete(); | 972 context->ShutdownAndDelete(); |
| 973 context = nullptr; | 973 context = nullptr; |
| 974 base::RunLoop().RunUntilIdle(); | 974 base::RunLoop().RunUntilIdle(); |
| 975 | 975 |
| 976 { | 976 { |
| 977 // Mess up version number in database. | 977 // Mess up version number in database. |
| 978 leveldb_env::ChromiumEnv env; | 978 leveldb_env::ChromiumEnv env; |
| 979 leveldb::DB* db = nullptr; | 979 std::unique_ptr<leveldb::DB> db; |
| 980 leveldb::Options options; | 980 leveldb::Options options; |
| 981 options.env = &env; | 981 options.env = &env; |
| 982 base::FilePath db_path = | 982 base::FilePath db_path = |
| 983 temp_path().Append(test_path).Append(FILE_PATH_LITERAL("leveldb")); | 983 temp_path().Append(test_path).Append(FILE_PATH_LITERAL("leveldb")); |
| 984 ASSERT_TRUE(leveldb::DB::Open(options, db_path.AsUTF8Unsafe(), &db).ok()); | 984 ASSERT_TRUE(leveldb_env::OpenDB(options, db_path.AsUTF8Unsafe(), &db).ok()); |
| 985 std::unique_ptr<leveldb::DB> db_owner(db); | |
| 986 ASSERT_TRUE(db->Put(leveldb::WriteOptions(), "VERSION", "argh").ok()); | 985 ASSERT_TRUE(db->Put(leveldb::WriteOptions(), "VERSION", "argh").ok()); |
| 987 } | 986 } |
| 988 | 987 |
| 989 // Make sure data is gone. | 988 // Make sure data is gone. |
| 990 context = new LocalStorageContextMojo(base::ThreadTaskRunnerHandle::Get(), | 989 context = new LocalStorageContextMojo(base::ThreadTaskRunnerHandle::Get(), |
| 991 connector(), nullptr, base::FilePath(), | 990 connector(), nullptr, base::FilePath(), |
| 992 test_path, nullptr); | 991 test_path, nullptr); |
| 993 EXPECT_FALSE(DoTestGet(context, key, &result)); | 992 EXPECT_FALSE(DoTestGet(context, key, &result)); |
| 994 | 993 |
| 995 // Write data again. | 994 // Write data again. |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1406 // Make sure all messages to the DB have been processed (Flush above merely | 1405 // Make sure all messages to the DB have been processed (Flush above merely |
| 1407 // schedules a commit, but there is no guarantee about those having been | 1406 // schedules a commit, but there is no guarantee about those having been |
| 1408 // processed yet). | 1407 // processed yet). |
| 1409 if (mock_db) | 1408 if (mock_db) |
| 1410 mock_db->FlushForTesting(); | 1409 mock_db->FlushForTesting(); |
| 1411 EXPECT_TRUE(mock_db); | 1410 EXPECT_TRUE(mock_db); |
| 1412 EXPECT_FALSE(wrapper.encountered_error()); | 1411 EXPECT_FALSE(wrapper.encountered_error()); |
| 1413 } | 1412 } |
| 1414 | 1413 |
| 1415 } // namespace content | 1414 } // namespace content |
| OLD | NEW |