OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <map> | 5 #include <map> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } | 131 } |
132 | 132 |
133 IndexedDBContextImpl* idb_context() { return idb_context_.get(); } | 133 IndexedDBContextImpl* idb_context() { return idb_context_.get(); } |
134 | 134 |
135 void SetFileSizeTo(const base::FilePath& path, int size) { | 135 void SetFileSizeTo(const base::FilePath& path, int size) { |
136 std::string junk(size, 'a'); | 136 std::string junk(size, 'a'); |
137 ASSERT_EQ(size, base::WriteFile(path, junk.c_str(), size)); | 137 ASSERT_EQ(size, base::WriteFile(path, junk.c_str(), size)); |
138 } | 138 } |
139 | 139 |
140 void AddFakeIndexedDB(const GURL& origin, int size) { | 140 void AddFakeIndexedDB(const GURL& origin, int size) { |
141 base::FilePath file_path_origin = idb_context()->GetFilePathForTesting( | 141 base::FilePath file_path_origin = idb_context()->GetFilePath(origin); |
142 storage::GetIdentifierFromOrigin(origin)); | |
143 if (!base::CreateDirectory(file_path_origin)) { | 142 if (!base::CreateDirectory(file_path_origin)) { |
144 LOG(ERROR) << "failed to base::CreateDirectory " | 143 LOG(ERROR) << "failed to base::CreateDirectory " |
145 << file_path_origin.value(); | 144 << file_path_origin.value(); |
146 } | 145 } |
147 file_path_origin = file_path_origin.Append(FILE_PATH_LITERAL("fake_file")); | 146 file_path_origin = file_path_origin.Append(FILE_PATH_LITERAL("fake_file")); |
148 SetFileSizeTo(file_path_origin, size); | 147 SetFileSizeTo(file_path_origin, size); |
149 idb_context()->ResetCaches(); | 148 idb_context()->ResetCaches(); |
150 } | 149 } |
151 | 150 |
152 private: | 151 private: |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp)); | 235 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp)); |
237 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); | 236 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); |
238 | 237 |
239 storage::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA); | 238 storage::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA); |
240 EXPECT_EQ(storage::kQuotaStatusOk, delete_status); | 239 EXPECT_EQ(storage::kQuotaStatusOk, delete_status); |
241 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp)); | 240 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp)); |
242 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); | 241 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); |
243 } | 242 } |
244 | 243 |
245 } // namespace content | 244 } // namespace content |
OLD | NEW |