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

Side by Side Diff: content/browser/dom_storage/local_storage_context_mojo_unittest.cc

Issue 2953473002: Use leveldb_env::OpenDB() to open leveldb databases. (Closed)
Patch Set: Rebase; address comments Created 3 years, 5 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 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 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 EXPECT_TRUE(DoTestGet(context, key, &result)); 971 EXPECT_TRUE(DoTestGet(context, key, &result));
972 EXPECT_EQ(value, result); 972 EXPECT_EQ(value, result);
973 973
974 context->ShutdownAndDelete(); 974 context->ShutdownAndDelete();
975 context = nullptr; 975 context = nullptr;
976 base::RunLoop().RunUntilIdle(); 976 base::RunLoop().RunUntilIdle();
977 977
978 { 978 {
979 // Mess up version number in database. 979 // Mess up version number in database.
980 leveldb_env::ChromiumEnv env; 980 leveldb_env::ChromiumEnv env;
981 leveldb::DB* db = nullptr; 981 std::unique_ptr<leveldb::DB> db;
982 leveldb::Options options; 982 leveldb::Options options;
983 options.env = &env; 983 options.env = &env;
984 base::FilePath db_path = 984 base::FilePath db_path =
985 temp_path().Append(test_path).Append(FILE_PATH_LITERAL("leveldb")); 985 temp_path().Append(test_path).Append(FILE_PATH_LITERAL("leveldb"));
986 ASSERT_TRUE(leveldb::DB::Open(options, db_path.AsUTF8Unsafe(), &db).ok()); 986 ASSERT_TRUE(leveldb_env::OpenDB(options, db_path.AsUTF8Unsafe(), &db).ok());
987 std::unique_ptr<leveldb::DB> db_owner(db);
988 ASSERT_TRUE(db->Put(leveldb::WriteOptions(), "VERSION", "argh").ok()); 987 ASSERT_TRUE(db->Put(leveldb::WriteOptions(), "VERSION", "argh").ok());
989 } 988 }
990 989
991 // Make sure data is gone. 990 // Make sure data is gone.
992 context = new LocalStorageContextMojo(base::ThreadTaskRunnerHandle::Get(), 991 context = new LocalStorageContextMojo(base::ThreadTaskRunnerHandle::Get(),
993 connector(), nullptr, base::FilePath(), 992 connector(), nullptr, base::FilePath(),
994 test_path, nullptr); 993 test_path, nullptr);
995 EXPECT_FALSE(DoTestGet(context, key, &result)); 994 EXPECT_FALSE(DoTestGet(context, key, &result));
996 995
997 // Write data again. 996 // Write data again.
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 // Make sure all messages to the DB have been processed (Flush above merely 1407 // Make sure all messages to the DB have been processed (Flush above merely
1409 // schedules a commit, but there is no guarantee about those having been 1408 // schedules a commit, but there is no guarantee about those having been
1410 // processed yet). 1409 // processed yet).
1411 if (mock_db) 1410 if (mock_db)
1412 mock_db->FlushForTesting(); 1411 mock_db->FlushForTesting();
1413 EXPECT_TRUE(mock_db); 1412 EXPECT_TRUE(mock_db);
1414 EXPECT_FALSE(wrapper.encountered_error()); 1413 EXPECT_FALSE(wrapper.encountered_error());
1415 } 1414 }
1416 1415
1417 } // namespace content 1416 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698