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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/memory/scoped_callback_factory.h" | 8 #include "base/memory/scoped_callback_factory.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/scoped_temp_dir.h" | 10 #include "base/memory/scoped_temp_dir.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 | 133 |
134 void DeleteOriginData(QuotaClient* client, | 134 void DeleteOriginData(QuotaClient* client, |
135 const GURL& origin, | 135 const GURL& origin, |
136 StorageType type) { | 136 StorageType type) { |
137 quota_status_ = kQuotaStatusUnknown; | 137 quota_status_ = kQuotaStatusUnknown; |
138 client->DeleteOriginData(origin, type, | 138 client->DeleteOriginData(origin, type, |
139 callback_factory_.NewCallback( | 139 callback_factory_.NewCallback( |
140 &QuotaManagerTest::DidDelete)); | 140 &QuotaManagerTest::DidDelete)); |
141 } | 141 } |
142 | 142 |
143 void EvictOriginData(const GURL& origin, | |
144 StorageType type) { | |
145 quota_status_ = kQuotaStatusUnknown; | |
146 quota_manager_->EvictOriginData(origin, type, | |
147 callback_factory_.NewCallback( | |
148 &QuotaManagerTest::DidDelete)); | |
michaeln
2011/05/17 19:30:01
DidEvict?
Dai Mikurube (NOT FULLTIME)
2011/05/18 04:34:48
Exactly. Done.
| |
149 } | |
150 | |
143 void DidGetUsageAndQuota(QuotaStatusCode status, int64 usage, int64 quota) { | 151 void DidGetUsageAndQuota(QuotaStatusCode status, int64 usage, int64 quota) { |
144 quota_status_ = status; | 152 quota_status_ = status; |
145 usage_ = usage; | 153 usage_ = usage; |
146 quota_ = quota; | 154 quota_ = quota; |
147 } | 155 } |
148 | 156 |
149 void DidGetQuota(QuotaStatusCode status, int64 quota) { | 157 void DidGetQuota(QuotaStatusCode status, int64 quota) { |
150 quota_status_ = status; | 158 quota_status_ = status; |
151 quota_ = quota; | 159 quota_ = quota; |
152 } | 160 } |
(...skipping 10 matching lines...) Expand all Loading... | |
163 } | 171 } |
164 | 172 |
165 void DidGetHostUsage(const std::string&, int64 usage) { | 173 void DidGetHostUsage(const std::string&, int64 usage) { |
166 usage_ = usage; | 174 usage_ = usage; |
167 } | 175 } |
168 | 176 |
169 void DidDelete(QuotaStatusCode status) { | 177 void DidDelete(QuotaStatusCode status) { |
170 quota_status_ = status; | 178 quota_status_ = status; |
171 } | 179 } |
172 | 180 |
181 void DidEvictOriginData(QuotaStatusCode status) { | |
182 quota_status_ = status; | |
183 } | |
184 | |
173 void set_additional_callback_count(int c) { additional_callback_count_ = c; } | 185 void set_additional_callback_count(int c) { additional_callback_count_ = c; } |
174 int additional_callback_count() const { return additional_callback_count_; } | 186 int additional_callback_count() const { return additional_callback_count_; } |
175 void DidGetUsageAndQuotaAdditional( | 187 void DidGetUsageAndQuotaAdditional( |
176 QuotaStatusCode status, int64 usage, int64 quota) { | 188 QuotaStatusCode status, int64 usage, int64 quota) { |
177 ++additional_callback_count_; | 189 ++additional_callback_count_; |
178 } | 190 } |
179 | 191 |
180 QuotaManager* quota_manager() const { return quota_manager_.get(); } | 192 QuotaManager* quota_manager() const { return quota_manager_.get(); } |
181 void set_quota_manager(QuotaManager* quota_manager) { | 193 void set_quota_manager(QuotaManager* quota_manager) { |
182 quota_manager_ = quota_manager; | 194 quota_manager_ = quota_manager; |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
711 | 723 |
712 GetHostUsage("foo.com", kStorageTypeTemporary); | 724 GetHostUsage("foo.com", kStorageTypeTemporary); |
713 MessageLoop::current()->RunAllPending(); | 725 MessageLoop::current()->RunAllPending(); |
714 EXPECT_EQ(predelete_host_tmp - 1, usage()); | 726 EXPECT_EQ(predelete_host_tmp - 1, usage()); |
715 | 727 |
716 GetHostUsage("foo.com", kStorageTypePersistent); | 728 GetHostUsage("foo.com", kStorageTypePersistent); |
717 MessageLoop::current()->RunAllPending(); | 729 MessageLoop::current()->RunAllPending(); |
718 EXPECT_EQ(predelete_host_pers, usage()); | 730 EXPECT_EQ(predelete_host_pers, usage()); |
719 } | 731 } |
720 | 732 |
733 TEST_F(QuotaManagerTest, EvictOriginData) { | |
734 static const MockOriginData kData[] = { | |
735 { "http://foo.com/", kStorageTypeTemporary, 1 }, | |
736 { "http://foo.com:1/", kStorageTypeTemporary, 20 }, | |
737 { "http://foo.com/", kStorageTypePersistent, 300 }, | |
738 { "http://bar.com/", kStorageTypeTemporary, 4000 }, | |
739 }; | |
740 MockStorageClient* client = CreateClient(kData, ARRAYSIZE_UNSAFE(kData)); | |
741 RegisterClient(client); | |
742 | |
743 GetGlobalUsage(kStorageTypeTemporary); | |
744 MessageLoop::current()->RunAllPending(); | |
745 LOG(ERROR) << usage(); | |
746 | |
747 EvictOriginData(GURL("http://bar.com/"), kStorageTypeTemporary); | |
748 MessageLoop::current()->RunAllPending(); | |
749 | |
750 GetGlobalUsage(kStorageTypeTemporary); | |
751 MessageLoop::current()->RunAllPending(); | |
752 LOG(ERROR) << usage(); | |
753 } | |
754 | |
721 } // namespace quota | 755 } // namespace quota |
OLD | NEW |