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

Side by Side Diff: third_party/WebKit/Source/core/fetch/MemoryCacheTest.cpp

Issue 1802123002: Unify Resource loading status tracking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months 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 /* 1 /*
2 * Copyright (c) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 229
230 static void TestLiveResourceEvictionAtEndOfTask(Resource* cachedDeadResource, Re source* cachedLiveResource) 230 static void TestLiveResourceEvictionAtEndOfTask(Resource* cachedDeadResource, Re source* cachedLiveResource)
231 { 231 {
232 memoryCache()->setDelayBeforeLiveDecodedPrune(0); 232 memoryCache()->setDelayBeforeLiveDecodedPrune(0);
233 const unsigned totalCapacity = 1; 233 const unsigned totalCapacity = 1;
234 const unsigned minDeadCapacity = 0; 234 const unsigned minDeadCapacity = 0;
235 const unsigned maxDeadCapacity = 0; 235 const unsigned maxDeadCapacity = 0;
236 memoryCache()->setCapacities(minDeadCapacity, maxDeadCapacity, totalCapacity ); 236 memoryCache()->setCapacities(minDeadCapacity, maxDeadCapacity, totalCapacity );
237 const char data[6] = "abcde"; 237 const char data[6] = "abcde";
238 cachedDeadResource->appendData(data, 3u); 238 cachedDeadResource->appendData(data, 3u);
239 cachedDeadResource->finish();
239 MockImageResourceClient client(cachedLiveResource); 240 MockImageResourceClient client(cachedLiveResource);
240 cachedLiveResource->appendData(data, 4u); 241 cachedLiveResource->appendData(data, 4u);
242 cachedLiveResource->finish();
241 243
242 Platform::current()->currentThread()->getWebTaskRunner()->postTask(BLINK_FRO M_HERE, bind(&runTask1, PassRefPtrWillBeRawPtr<Resource>(cachedLiveResource), Pa ssRefPtrWillBeRawPtr<Resource>(cachedDeadResource))); 244 Platform::current()->currentThread()->getWebTaskRunner()->postTask(BLINK_FRO M_HERE, bind(&runTask1, PassRefPtrWillBeRawPtr<Resource>(cachedLiveResource), Pa ssRefPtrWillBeRawPtr<Resource>(cachedDeadResource)));
243 Platform::current()->currentThread()->getWebTaskRunner()->postTask(BLINK_FRO M_HERE, bind(&runTask2, cachedLiveResource->encodedSize() + cachedLiveResource-> overheadSize())); 245 Platform::current()->currentThread()->getWebTaskRunner()->postTask(BLINK_FRO M_HERE, bind(&runTask2, cachedLiveResource->encodedSize() + cachedLiveResource-> overheadSize()));
244 testing::runPendingTasks(); 246 testing::runPendingTasks();
245 } 247 }
246 248
247 // Verified that when ordering a prune in a runLoop task, the prune 249 // Verified that when ordering a prune in a runLoop task, the prune
248 // is deferred to the end of the task. 250 // is deferred to the end of the task.
249 TEST_F(MemoryCacheTest, LiveResourceEvictionAtEndOfTask_Basic) 251 TEST_F(MemoryCacheTest, LiveResourceEvictionAtEndOfTask_Basic)
250 { 252 {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 420
419 WillBeHeapVector<RawPtrWillBeMember<Resource>> resources = memoryCache()->re sourcesForURL(url); 421 WillBeHeapVector<RawPtrWillBeMember<Resource>> resources = memoryCache()->re sourcesForURL(url);
420 EXPECT_EQ(2u, resources.size()); 422 EXPECT_EQ(2u, resources.size());
421 423
422 memoryCache()->evictResources(); 424 memoryCache()->evictResources();
423 EXPECT_FALSE(memoryCache()->contains(resource1.get())); 425 EXPECT_FALSE(memoryCache()->contains(resource1.get()));
424 EXPECT_FALSE(memoryCache()->contains(resource3.get())); 426 EXPECT_FALSE(memoryCache()->contains(resource3.get()));
425 } 427 }
426 428
427 } // namespace blink 429 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698