| 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/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 base::MessageLoop::current()->RunUntilIdle(); | 59 base::MessageLoop::current()->RunUntilIdle(); |
| 60 setup_temp_dir(); | 60 setup_temp_dir(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void FlushIndexedDBTaskRunner() { task_runner_->RunUntilIdle(); } | 63 void FlushIndexedDBTaskRunner() { task_runner_->RunUntilIdle(); } |
| 64 | 64 |
| 65 void setup_temp_dir() { | 65 void setup_temp_dir() { |
| 66 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 66 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 67 base::FilePath indexeddb_dir = | 67 base::FilePath indexeddb_dir = |
| 68 temp_dir_.path().Append(IndexedDBContextImpl::kIndexedDBDirectory); | 68 temp_dir_.path().Append(IndexedDBContextImpl::kIndexedDBDirectory); |
| 69 ASSERT_TRUE(file_util::CreateDirectory(indexeddb_dir)); | 69 ASSERT_TRUE(base::CreateDirectory(indexeddb_dir)); |
| 70 idb_context()->set_data_path_for_testing(indexeddb_dir); | 70 idb_context()->set_data_path_for_testing(indexeddb_dir); |
| 71 } | 71 } |
| 72 | 72 |
| 73 virtual ~IndexedDBQuotaClientTest() { | 73 virtual ~IndexedDBQuotaClientTest() { |
| 74 FlushIndexedDBTaskRunner(); | 74 FlushIndexedDBTaskRunner(); |
| 75 idb_context_ = NULL; | 75 idb_context_ = NULL; |
| 76 browser_context_.reset(); | 76 browser_context_.reset(); |
| 77 base::MessageLoop::current()->RunUntilIdle(); | 77 base::MessageLoop::current()->RunUntilIdle(); |
| 78 } | 78 } |
| 79 | 79 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 IndexedDBContextImpl* idb_context() { return idb_context_; } | 134 IndexedDBContextImpl* idb_context() { return idb_context_; } |
| 135 | 135 |
| 136 void SetFileSizeTo(const base::FilePath& path, int size) { | 136 void SetFileSizeTo(const base::FilePath& path, int size) { |
| 137 std::string junk(size, 'a'); | 137 std::string junk(size, 'a'); |
| 138 ASSERT_EQ(size, file_util::WriteFile(path, junk.c_str(), size)); | 138 ASSERT_EQ(size, file_util::WriteFile(path, junk.c_str(), size)); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void AddFakeIndexedDB(const GURL& origin, int size) { | 141 void AddFakeIndexedDB(const GURL& origin, int size) { |
| 142 base::FilePath file_path_origin = idb_context()->GetFilePathForTesting( | 142 base::FilePath file_path_origin = idb_context()->GetFilePathForTesting( |
| 143 webkit_database::GetIdentifierFromOrigin(origin)); | 143 webkit_database::GetIdentifierFromOrigin(origin)); |
| 144 if (!file_util::CreateDirectory(file_path_origin)) { | 144 if (!base::CreateDirectory(file_path_origin)) { |
| 145 LOG(ERROR) << "failed to file_util::CreateDirectory " | 145 LOG(ERROR) << "failed to base::CreateDirectory " |
| 146 << file_path_origin.value(); | 146 << file_path_origin.value(); |
| 147 } | 147 } |
| 148 file_path_origin = file_path_origin.Append(FILE_PATH_LITERAL("fake_file")); | 148 file_path_origin = file_path_origin.Append(FILE_PATH_LITERAL("fake_file")); |
| 149 SetFileSizeTo(file_path_origin, size); | 149 SetFileSizeTo(file_path_origin, size); |
| 150 idb_context()->ResetCaches(); | 150 idb_context()->ResetCaches(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 private: | 153 private: |
| 154 void OnGetOriginUsageComplete(int64 usage) { usage_ = usage; } | 154 void OnGetOriginUsageComplete(int64 usage) { usage_ = usage; } |
| 155 | 155 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp)); | 237 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp)); |
| 238 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); | 238 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); |
| 239 | 239 |
| 240 quota::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA); | 240 quota::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA); |
| 241 EXPECT_EQ(quota::kQuotaStatusOk, delete_status); | 241 EXPECT_EQ(quota::kQuotaStatusOk, delete_status); |
| 242 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp)); | 242 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp)); |
| 243 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); | 243 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); |
| 244 } | 244 } |
| 245 | 245 |
| 246 } // namespace content | 246 } // namespace content |
| OLD | NEW |