| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |