OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/indexed_db/indexed_db_backing_store.h" | 5 #include "content/browser/indexed_db/indexed_db_backing_store.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 void SetUp() override { | 235 void SetUp() override { |
236 const Origin origin(GURL("http://localhost:81")); | 236 const Origin origin(GURL("http://localhost:81")); |
237 task_runner_ = new base::TestSimpleTaskRunner(); | 237 task_runner_ = new base::TestSimpleTaskRunner(); |
238 url_request_context_getter_ = | 238 url_request_context_getter_ = |
239 new net::TestURLRequestContextGetter(task_runner_); | 239 new net::TestURLRequestContextGetter(task_runner_); |
240 special_storage_policy_ = new MockSpecialStoragePolicy(); | 240 special_storage_policy_ = new MockSpecialStoragePolicy(); |
241 quota_manager_proxy_ = new MockQuotaManagerProxy(nullptr, nullptr); | 241 quota_manager_proxy_ = new MockQuotaManagerProxy(nullptr, nullptr); |
242 special_storage_policy_->SetAllUnlimited(true); | 242 special_storage_policy_->SetAllUnlimited(true); |
243 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 243 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
244 idb_context_ = new IndexedDBContextImpl( | 244 idb_context_ = new IndexedDBContextImpl( |
245 temp_dir_.path(), special_storage_policy_.get(), | 245 temp_dir_.GetPath(), special_storage_policy_.get(), |
246 quota_manager_proxy_.get(), task_runner_.get()); | 246 quota_manager_proxy_.get(), task_runner_.get()); |
247 idb_factory_ = new TestIDBFactory(idb_context_.get()); | 247 idb_factory_ = new TestIDBFactory(idb_context_.get()); |
248 backing_store_ = idb_factory_->OpenBackingStoreForTest( | 248 backing_store_ = idb_factory_->OpenBackingStoreForTest( |
249 origin, url_request_context_getter_); | 249 origin, url_request_context_getter_); |
250 | 250 |
251 // useful keys and values during tests | 251 // useful keys and values during tests |
252 m_value1 = IndexedDBValue("value1", std::vector<IndexedDBBlobInfo>()); | 252 m_value1 = IndexedDBValue("value1", std::vector<IndexedDBBlobInfo>()); |
253 m_value2 = IndexedDBValue("value2", std::vector<IndexedDBBlobInfo>()); | 253 m_value2 = IndexedDBValue("value2", std::vector<IndexedDBBlobInfo>()); |
254 | 254 |
255 m_blob_info.push_back( | 255 m_blob_info.push_back( |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 | 1066 |
1067 // Not in the anonymous namespace to friend IndexedDBBackingStore. | 1067 // Not in the anonymous namespace to friend IndexedDBBackingStore. |
1068 TEST_F(IndexedDBBackingStoreTest, ReadCorruptionInfo) { | 1068 TEST_F(IndexedDBBackingStoreTest, ReadCorruptionInfo) { |
1069 // No |path_base|. | 1069 // No |path_base|. |
1070 std::string message; | 1070 std::string message; |
1071 EXPECT_FALSE(IndexedDBBackingStore::ReadCorruptionInfo(base::FilePath(), | 1071 EXPECT_FALSE(IndexedDBBackingStore::ReadCorruptionInfo(base::FilePath(), |
1072 Origin(), &message)); | 1072 Origin(), &message)); |
1073 EXPECT_TRUE(message.empty()); | 1073 EXPECT_TRUE(message.empty()); |
1074 message.clear(); | 1074 message.clear(); |
1075 | 1075 |
1076 const base::FilePath path_base = temp_dir_.path(); | 1076 const base::FilePath path_base = temp_dir_.GetPath(); |
1077 const Origin origin(GURL("http://www.google.com/")); | 1077 const Origin origin(GURL("http://www.google.com/")); |
1078 ASSERT_FALSE(path_base.empty()); | 1078 ASSERT_FALSE(path_base.empty()); |
1079 ASSERT_TRUE(PathIsWritable(path_base)); | 1079 ASSERT_TRUE(PathIsWritable(path_base)); |
1080 | 1080 |
1081 // File not found. | 1081 // File not found. |
1082 EXPECT_FALSE( | 1082 EXPECT_FALSE( |
1083 IndexedDBBackingStore::ReadCorruptionInfo(path_base, origin, &message)); | 1083 IndexedDBBackingStore::ReadCorruptionInfo(path_base, origin, &message)); |
1084 EXPECT_TRUE(message.empty()); | 1084 EXPECT_TRUE(message.empty()); |
1085 message.clear(); | 1085 message.clear(); |
1086 | 1086 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 | 1149 |
1150 // Dictionary, message key and more. | 1150 // Dictionary, message key and more. |
1151 ASSERT_TRUE(WriteFile(info_path, "{\"message\":\"foo\",\"bar\":5}")); | 1151 ASSERT_TRUE(WriteFile(info_path, "{\"message\":\"foo\",\"bar\":5}")); |
1152 EXPECT_TRUE( | 1152 EXPECT_TRUE( |
1153 IndexedDBBackingStore::ReadCorruptionInfo(path_base, origin, &message)); | 1153 IndexedDBBackingStore::ReadCorruptionInfo(path_base, origin, &message)); |
1154 EXPECT_FALSE(PathExists(info_path)); | 1154 EXPECT_FALSE(PathExists(info_path)); |
1155 EXPECT_EQ("foo", message); | 1155 EXPECT_EQ("foo", message); |
1156 } | 1156 } |
1157 | 1157 |
1158 } // namespace content | 1158 } // namespace content |
OLD | NEW |