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

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: Don't dump in background mode 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 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 // Data should have been preserved now. 1054 // Data should have been preserved now.
1056 context = new LocalStorageContextMojo(base::ThreadTaskRunnerHandle::Get(), 1055 context = new LocalStorageContextMojo(base::ThreadTaskRunnerHandle::Get(),
1057 connector(), nullptr, base::FilePath(), 1056 connector(), nullptr, base::FilePath(),
1058 test_path, nullptr); 1057 test_path, nullptr);
1059 EXPECT_TRUE(DoTestGet(context, key, &result)); 1058 EXPECT_TRUE(DoTestGet(context, key, &result));
1060 EXPECT_EQ(value, result); 1059 EXPECT_EQ(value, result);
1061 context->ShutdownAndDelete(); 1060 context->ShutdownAndDelete();
1062 } 1061 }
1063 1062
1064 } // namespace content 1063 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698