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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 const unsigned minDeadCapacity = 0; | 233 const unsigned minDeadCapacity = 0; |
234 const unsigned maxDeadCapacity = 0; | 234 const unsigned maxDeadCapacity = 0; |
235 memoryCache()->setCapacities(minDeadCapacity, maxDeadCapacity, totalCapacity
); | 235 memoryCache()->setCapacities(minDeadCapacity, maxDeadCapacity, totalCapacity
); |
236 const char data[6] = "abcde"; | 236 const char data[6] = "abcde"; |
237 cachedDeadResource->appendData(data, 3u); | 237 cachedDeadResource->appendData(data, 3u); |
238 cachedDeadResource->finish(); | 238 cachedDeadResource->finish(); |
239 Persistent<MockResourceClient> client = new MockResourceClient(cachedLiveRes
ource); | 239 Persistent<MockResourceClient> client = new MockResourceClient(cachedLiveRes
ource); |
240 cachedLiveResource->appendData(data, 4u); | 240 cachedLiveResource->appendData(data, 4u); |
241 cachedLiveResource->finish(); | 241 cachedLiveResource->finish(); |
242 | 242 |
243 Platform::current()->currentThread()->getWebTaskRunner()->postTask(BLINK_FRO
M_HERE, bind(&runTask1, wrapPersistent(cachedLiveResource), wrapPersistent(cache
dDeadResource))); | 243 Platform::current()->currentThread()->getWebTaskRunner()->postTask(BLINK_FRO
M_HERE, WTF::bind(&runTask1, wrapPersistent(cachedLiveResource), wrapPersistent(
cachedDeadResource))); |
244 Platform::current()->currentThread()->getWebTaskRunner()->postTask(BLINK_FRO
M_HERE, bind(&runTask2, cachedLiveResource->encodedSize() + cachedLiveResource->
overheadSize())); | 244 Platform::current()->currentThread()->getWebTaskRunner()->postTask(BLINK_FRO
M_HERE, WTF::bind(&runTask2, cachedLiveResource->encodedSize() + cachedLiveResou
rce->overheadSize())); |
245 testing::runPendingTasks(); | 245 testing::runPendingTasks(); |
246 } | 246 } |
247 | 247 |
248 // Verified that when ordering a prune in a runLoop task, the prune | 248 // Verified that when ordering a prune in a runLoop task, the prune |
249 // is deferred to the end of the task. | 249 // is deferred to the end of the task. |
250 TEST_F(MemoryCacheTest, LiveResourceEvictionAtEndOfTask_Basic) | 250 TEST_F(MemoryCacheTest, LiveResourceEvictionAtEndOfTask_Basic) |
251 { | 251 { |
252 Resource* cachedDeadResource = | 252 Resource* cachedDeadResource = |
253 Resource::create(ResourceRequest("hhtp://foo"), Resource::Raw); | 253 Resource::create(ResourceRequest("hhtp://foo"), Resource::Raw); |
254 Resource* cachedLiveResource = | 254 Resource* cachedLiveResource = |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 | 419 |
420 HeapVector<Member<Resource>> resources = memoryCache()->resourcesForURL(url)
; | 420 HeapVector<Member<Resource>> resources = memoryCache()->resourcesForURL(url)
; |
421 EXPECT_EQ(2u, resources.size()); | 421 EXPECT_EQ(2u, resources.size()); |
422 | 422 |
423 memoryCache()->evictResources(); | 423 memoryCache()->evictResources(); |
424 EXPECT_FALSE(memoryCache()->contains(resource1)); | 424 EXPECT_FALSE(memoryCache()->contains(resource1)); |
425 EXPECT_FALSE(memoryCache()->contains(resource3)); | 425 EXPECT_FALSE(memoryCache()->contains(resource3)); |
426 } | 426 } |
427 | 427 |
428 } // namespace blink | 428 } // namespace blink |
OLD | NEW |