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

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: Use OpenDB in unittests; add allocation edges 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 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 EXPECT_TRUE(DoTestGet(context, key, &result)); 973 EXPECT_TRUE(DoTestGet(context, key, &result));
974 EXPECT_EQ(value, result); 974 EXPECT_EQ(value, result);
975 975
976 context->ShutdownAndDelete(); 976 context->ShutdownAndDelete();
977 context = nullptr; 977 context = nullptr;
978 base::RunLoop().RunUntilIdle(); 978 base::RunLoop().RunUntilIdle();
979 979
980 { 980 {
981 // Mess up version number in database. 981 // Mess up version number in database.
982 leveldb_env::ChromiumEnv env; 982 leveldb_env::ChromiumEnv env;
983 leveldb::DB* db = nullptr; 983 std::unique_ptr<leveldb::DB> db;
984 leveldb::Options options; 984 leveldb::Options options;
985 options.env = &env; 985 options.env = &env;
986 base::FilePath db_path = 986 base::FilePath db_path =
987 temp_path().Append(test_path).Append(FILE_PATH_LITERAL("leveldb")); 987 temp_path().Append(test_path).Append(FILE_PATH_LITERAL("leveldb"));
988 ASSERT_TRUE(leveldb::DB::Open(options, db_path.AsUTF8Unsafe(), &db).ok()); 988 ASSERT_TRUE(leveldb_env::OpenDB(options, db_path.AsUTF8Unsafe(), &db).ok());
989 std::unique_ptr<leveldb::DB> db_owner(db);
990 ASSERT_TRUE(db->Put(leveldb::WriteOptions(), "VERSION", "argh").ok()); 989 ASSERT_TRUE(db->Put(leveldb::WriteOptions(), "VERSION", "argh").ok());
991 } 990 }
992 991
993 // Make sure data is gone. 992 // Make sure data is gone.
994 context = new LocalStorageContextMojo(base::ThreadTaskRunnerHandle::Get(), 993 context = new LocalStorageContextMojo(base::ThreadTaskRunnerHandle::Get(),
995 connector(), nullptr, base::FilePath(), 994 connector(), nullptr, base::FilePath(),
996 test_path, nullptr); 995 test_path, nullptr);
997 EXPECT_FALSE(DoTestGet(context, key, &result)); 996 EXPECT_FALSE(DoTestGet(context, key, &result));
998 997
999 // Write data again. 998 // Write data again.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 // Data should have been preserved now. 1056 // Data should have been preserved now.
1058 context = new LocalStorageContextMojo(base::ThreadTaskRunnerHandle::Get(), 1057 context = new LocalStorageContextMojo(base::ThreadTaskRunnerHandle::Get(),
1059 connector(), nullptr, base::FilePath(), 1058 connector(), nullptr, base::FilePath(),
1060 test_path, nullptr); 1059 test_path, nullptr);
1061 EXPECT_TRUE(DoTestGet(context, key, &result)); 1060 EXPECT_TRUE(DoTestGet(context, key, &result));
1062 EXPECT_EQ(value, result); 1061 EXPECT_EQ(value, result);
1063 context->ShutdownAndDelete(); 1062 context->ShutdownAndDelete();
1064 } 1063 }
1065 1064
1066 } // namespace content 1065 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698