| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 cachedDeadResource->finish(); |
| 240 MockResourceClient client(cachedLiveResource); | 240 MockResourceClient client(cachedLiveResource); |
| 241 cachedLiveResource->appendData(data, 4u); | 241 cachedLiveResource->appendData(data, 4u); |
| 242 cachedLiveResource->finish(); | 242 cachedLiveResource->finish(); |
| 243 | 243 |
| 244 Platform::current()->currentThread()->getWebTaskRunner()->postTask(BLINK_FRO
M_HERE, bind(&runTask1, cachedLiveResource, cachedDeadResource)); | 244 Platform::current()->currentThread()->getWebTaskRunner()->postTask(BLINK_FRO
M_HERE, bind(&runTask1, retainedRef(cachedLiveResource), retainedRef(cachedDeadR
esource))); |
| 245 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())); |
| 246 testing::runPendingTasks(); | 246 testing::runPendingTasks(); |
| 247 } | 247 } |
| 248 | 248 |
| 249 // 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 |
| 250 // is deferred to the end of the task. | 250 // is deferred to the end of the task. |
| 251 TEST_F(MemoryCacheTest, LiveResourceEvictionAtEndOfTask_Basic) | 251 TEST_F(MemoryCacheTest, LiveResourceEvictionAtEndOfTask_Basic) |
| 252 { | 252 { |
| 253 Resource* cachedDeadResource = | 253 Resource* cachedDeadResource = |
| 254 Resource::create(ResourceRequest("hhtp://foo"), Resource::Raw); | 254 Resource::create(ResourceRequest("hhtp://foo"), Resource::Raw); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 | 420 |
| 421 HeapVector<Member<Resource>> resources = memoryCache()->resourcesForURL(url)
; | 421 HeapVector<Member<Resource>> resources = memoryCache()->resourcesForURL(url)
; |
| 422 EXPECT_EQ(2u, resources.size()); | 422 EXPECT_EQ(2u, resources.size()); |
| 423 | 423 |
| 424 memoryCache()->evictResources(); | 424 memoryCache()->evictResources(); |
| 425 EXPECT_FALSE(memoryCache()->contains(resource1)); | 425 EXPECT_FALSE(memoryCache()->contains(resource1)); |
| 426 EXPECT_FALSE(memoryCache()->contains(resource3)); | 426 EXPECT_FALSE(memoryCache()->contains(resource3)); |
| 427 } | 427 } |
| 428 | 428 |
| 429 } // namespace blink | 429 } // namespace blink |
| OLD | NEW |