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

Side by Side Diff: content/browser/appcache/appcache_storage_impl_unittest.cc

Issue 1498003003: Remove kint64max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: INT64_MAX Created 5 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stack> 5 #include <stack>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 class AppCacheStorageImplTest : public testing::Test { 188 class AppCacheStorageImplTest : public testing::Test {
189 public: 189 public:
190 class MockStorageDelegate : public AppCacheStorage::Delegate { 190 class MockStorageDelegate : public AppCacheStorage::Delegate {
191 public: 191 public:
192 explicit MockStorageDelegate(AppCacheStorageImplTest* test) 192 explicit MockStorageDelegate(AppCacheStorageImplTest* test)
193 : loaded_cache_id_(0), stored_group_success_(false), 193 : loaded_cache_id_(0), stored_group_success_(false),
194 would_exceed_quota_(false), obsoleted_success_(false), 194 would_exceed_quota_(false), obsoleted_success_(false),
195 found_cache_id_(kAppCacheNoCacheId), test_(test) { 195 found_cache_id_(kAppCacheNoCacheId), test_(test) {
196 } 196 }
197 197
198 void OnCacheLoaded(AppCache* cache, int64 cache_id) override { 198 void OnCacheLoaded(AppCache* cache, int64_t cache_id) override {
199 loaded_cache_ = cache; 199 loaded_cache_ = cache;
200 loaded_cache_id_ = cache_id; 200 loaded_cache_id_ = cache_id;
201 test_->ScheduleNextTask(); 201 test_->ScheduleNextTask();
202 } 202 }
203 203
204 void OnGroupLoaded(AppCacheGroup* group, 204 void OnGroupLoaded(AppCacheGroup* group,
205 const GURL& manifest_url) override { 205 const GURL& manifest_url) override {
206 loaded_group_ = group; 206 loaded_group_ = group;
207 loaded_manifest_url_ = manifest_url; 207 loaded_manifest_url_ = manifest_url;
208 loaded_groups_newest_cache_ = group ? group->newest_complete_cache() 208 loaded_groups_newest_cache_ = group ? group->newest_complete_cache()
(...skipping 16 matching lines...) Expand all
225 int response_code) override { 225 int response_code) override {
226 obsoleted_group_ = group; 226 obsoleted_group_ = group;
227 obsoleted_success_ = success; 227 obsoleted_success_ = success;
228 test_->ScheduleNextTask(); 228 test_->ScheduleNextTask();
229 } 229 }
230 230
231 void OnMainResponseFound(const GURL& url, 231 void OnMainResponseFound(const GURL& url,
232 const AppCacheEntry& entry, 232 const AppCacheEntry& entry,
233 const GURL& namespace_entry_url, 233 const GURL& namespace_entry_url,
234 const AppCacheEntry& fallback_entry, 234 const AppCacheEntry& fallback_entry,
235 int64 cache_id, 235 int64_t cache_id,
236 int64 group_id, 236 int64_t group_id,
237 const GURL& manifest_url) override { 237 const GURL& manifest_url) override {
238 found_url_ = url; 238 found_url_ = url;
239 found_entry_ = entry; 239 found_entry_ = entry;
240 found_namespace_entry_url_ = namespace_entry_url; 240 found_namespace_entry_url_ = namespace_entry_url;
241 found_fallback_entry_ = fallback_entry; 241 found_fallback_entry_ = fallback_entry;
242 found_cache_id_ = cache_id; 242 found_cache_id_ = cache_id;
243 found_group_id_ = group_id; 243 found_group_id_ = group_id;
244 found_manifest_url_ = manifest_url; 244 found_manifest_url_ = manifest_url;
245 test_->ScheduleNextTask(); 245 test_->ScheduleNextTask();
246 } 246 }
247 247
248 scoped_refptr<AppCache> loaded_cache_; 248 scoped_refptr<AppCache> loaded_cache_;
249 int64 loaded_cache_id_; 249 int64_t loaded_cache_id_;
250 scoped_refptr<AppCacheGroup> loaded_group_; 250 scoped_refptr<AppCacheGroup> loaded_group_;
251 GURL loaded_manifest_url_; 251 GURL loaded_manifest_url_;
252 scoped_refptr<AppCache> loaded_groups_newest_cache_; 252 scoped_refptr<AppCache> loaded_groups_newest_cache_;
253 scoped_refptr<AppCacheGroup> stored_group_; 253 scoped_refptr<AppCacheGroup> stored_group_;
254 bool stored_group_success_; 254 bool stored_group_success_;
255 bool would_exceed_quota_; 255 bool would_exceed_quota_;
256 scoped_refptr<AppCacheGroup> obsoleted_group_; 256 scoped_refptr<AppCacheGroup> obsoleted_group_;
257 bool obsoleted_success_; 257 bool obsoleted_success_;
258 GURL found_url_; 258 GURL found_url_;
259 AppCacheEntry found_entry_; 259 AppCacheEntry found_entry_;
260 GURL found_namespace_entry_url_; 260 GURL found_namespace_entry_url_;
261 AppCacheEntry found_fallback_entry_; 261 AppCacheEntry found_fallback_entry_;
262 int64 found_cache_id_; 262 int64_t found_cache_id_;
263 int64 found_group_id_; 263 int64_t found_group_id_;
264 GURL found_manifest_url_; 264 GURL found_manifest_url_;
265 AppCacheStorageImplTest* test_; 265 AppCacheStorageImplTest* test_;
266 }; 266 };
267 267
268 class MockQuotaManager : public storage::QuotaManager { 268 class MockQuotaManager : public storage::QuotaManager {
269 public: 269 public:
270 MockQuotaManager() 270 MockQuotaManager()
271 : QuotaManager(true /* is_incognito */, 271 : QuotaManager(true /* is_incognito */,
272 base::FilePath(), 272 base::FilePath(),
273 io_thread->task_runner().get(), 273 io_thread->task_runner().get(),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 storage::StorageType type) override { 314 storage::StorageType type) override {
315 EXPECT_EQ(storage::QuotaClient::kAppcache, client_id); 315 EXPECT_EQ(storage::QuotaClient::kAppcache, client_id);
316 EXPECT_EQ(storage::kStorageTypeTemporary, type); 316 EXPECT_EQ(storage::kStorageTypeTemporary, type);
317 ++notify_storage_accessed_count_; 317 ++notify_storage_accessed_count_;
318 last_origin_ = origin; 318 last_origin_ = origin;
319 } 319 }
320 320
321 void NotifyStorageModified(storage::QuotaClient::ID client_id, 321 void NotifyStorageModified(storage::QuotaClient::ID client_id,
322 const GURL& origin, 322 const GURL& origin,
323 storage::StorageType type, 323 storage::StorageType type,
324 int64 delta) override { 324 int64_t delta) override {
325 EXPECT_EQ(storage::QuotaClient::kAppcache, client_id); 325 EXPECT_EQ(storage::QuotaClient::kAppcache, client_id);
326 EXPECT_EQ(storage::kStorageTypeTemporary, type); 326 EXPECT_EQ(storage::kStorageTypeTemporary, type);
327 ++notify_storage_modified_count_; 327 ++notify_storage_modified_count_;
328 last_origin_ = origin; 328 last_origin_ = origin;
329 last_delta_ = delta; 329 last_delta_ = delta;
330 } 330 }
331 331
332 // Not needed for our tests. 332 // Not needed for our tests.
333 void RegisterClient(storage::QuotaClient* client) override {} 333 void RegisterClient(storage::QuotaClient* client) override {}
334 void NotifyOriginInUse(const GURL& origin) override {} 334 void NotifyOriginInUse(const GURL& origin) override {}
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 486
487 // LoadCache_NearHit ------------------------------------------------- 487 // LoadCache_NearHit -------------------------------------------------
488 488
489 void LoadCache_NearHit() { 489 void LoadCache_NearHit() {
490 // Attempt to load a cache that is currently in use 490 // Attempt to load a cache that is currently in use
491 // and does not require loading from storage. This 491 // and does not require loading from storage. This
492 // load should complete syncly. 492 // load should complete syncly.
493 493
494 // Setup some preconditions. Make an 'unstored' cache for 494 // Setup some preconditions. Make an 'unstored' cache for
495 // us to load. The ctor should put it in the working set. 495 // us to load. The ctor should put it in the working set.
496 int64 cache_id = storage()->NewCacheId(); 496 int64_t cache_id = storage()->NewCacheId();
497 scoped_refptr<AppCache> cache(new AppCache(storage(), cache_id)); 497 scoped_refptr<AppCache> cache(new AppCache(storage(), cache_id));
498 498
499 // Conduct the test. 499 // Conduct the test.
500 storage()->LoadCache(cache_id, delegate()); 500 storage()->LoadCache(cache_id, delegate());
501 EXPECT_EQ(cache_id, delegate()->loaded_cache_id_); 501 EXPECT_EQ(cache_id, delegate()->loaded_cache_id_);
502 EXPECT_EQ(cache.get(), delegate()->loaded_cache_.get()); 502 EXPECT_EQ(cache.get(), delegate()->loaded_cache_.get());
503 EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_accessed_count_); 503 EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_accessed_count_);
504 EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_modified_count_); 504 EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_modified_count_);
505 TestFinished(); 505 TestFinished();
506 } 506 }
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 757
758 // FailStoreGroup -------------------------------------- 758 // FailStoreGroup --------------------------------------
759 759
760 void FailStoreGroup() { 760 void FailStoreGroup() {
761 // Store a group and its newest cache. Should complete asynchronously. 761 // Store a group and its newest cache. Should complete asynchronously.
762 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_FailStoreGroup, 762 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_FailStoreGroup,
763 base::Unretained(this))); 763 base::Unretained(this)));
764 764
765 // Setup some preconditions. Create a group and newest cache that 765 // Setup some preconditions. Create a group and newest cache that
766 // appear to be "unstored" and big enough to exceed the 5M limit. 766 // appear to be "unstored" and big enough to exceed the 5M limit.
767 const int64 kTooBig = 10 * 1024 * 1024; // 10M 767 const int64_t kTooBig = 10 * 1024 * 1024; // 10M
768 group_ = new AppCacheGroup( 768 group_ = new AppCacheGroup(
769 storage(), kManifestUrl, storage()->NewGroupId()); 769 storage(), kManifestUrl, storage()->NewGroupId());
770 cache_ = new AppCache(storage(), storage()->NewCacheId()); 770 cache_ = new AppCache(storage(), storage()->NewCacheId());
771 cache_->AddEntry(kManifestUrl, 771 cache_->AddEntry(kManifestUrl,
772 AppCacheEntry(AppCacheEntry::MANIFEST, 1, kTooBig)); 772 AppCacheEntry(AppCacheEntry::MANIFEST, 1, kTooBig));
773 // Hold a ref to the cache simulate the UpdateJob holding that ref, 773 // Hold a ref to the cache simulate the UpdateJob holding that ref,
774 // and hold a ref to the group to simulate the CacheHost holding that ref. 774 // and hold a ref to the group to simulate the CacheHost holding that ref.
775 775
776 // Conduct the store test. 776 // Conduct the store test.
777 storage()->StoreGroupAndNewestCache(group_.get(), cache_.get(), delegate()); 777 storage()->StoreGroupAndNewestCache(group_.get(), cache_.get(), delegate());
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
1830 } 1830 }
1831 1831
1832 AppCacheDatabase* database() { 1832 AppCacheDatabase* database() {
1833 return storage()->database_; 1833 return storage()->database_;
1834 } 1834 }
1835 1835
1836 MockStorageDelegate* delegate() { 1836 MockStorageDelegate* delegate() {
1837 return delegate_.get(); 1837 return delegate_.get();
1838 } 1838 }
1839 1839
1840 void MakeCacheAndGroup( 1840 void MakeCacheAndGroup(const GURL& manifest_url,
1841 const GURL& manifest_url, int64 group_id, int64 cache_id, 1841 int64_t group_id,
1842 bool add_to_database) { 1842 int64_t cache_id,
1843 bool add_to_database) {
1843 AppCacheEntry default_entry( 1844 AppCacheEntry default_entry(
1844 AppCacheEntry::EXPLICIT, cache_id + kDefaultEntryIdOffset, 1845 AppCacheEntry::EXPLICIT, cache_id + kDefaultEntryIdOffset,
1845 kDefaultEntrySize); 1846 kDefaultEntrySize);
1846 group_ = new AppCacheGroup(storage(), manifest_url, group_id); 1847 group_ = new AppCacheGroup(storage(), manifest_url, group_id);
1847 cache_ = new AppCache(storage(), cache_id); 1848 cache_ = new AppCache(storage(), cache_id);
1848 cache_->AddEntry(kDefaultEntryUrl, default_entry); 1849 cache_->AddEntry(kDefaultEntryUrl, default_entry);
1849 cache_->set_complete(true); 1850 cache_->set_complete(true);
1850 group_->AddCache(cache_.get()); 1851 group_->AddCache(cache_.get());
1851 if (add_to_database) { 1852 if (add_to_database) {
1852 AppCacheDatabase::GroupRecord group_record; 1853 AppCacheDatabase::GroupRecord group_record;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
2020 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2); 2021 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2);
2021 } 2022 }
2022 2023
2023 TEST_F(AppCacheStorageImplTest, Reinitialize3) { 2024 TEST_F(AppCacheStorageImplTest, Reinitialize3) {
2024 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3); 2025 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3);
2025 } 2026 }
2026 2027
2027 // That's all folks! 2028 // That's all folks!
2028 2029
2029 } // namespace content 2030 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_storage_impl.cc ('k') | content/browser/fileapi/blob_url_request_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698