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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 // Next task: now, the live resource was evicted. | 246 // Next task: now, the live resource was evicted. |
247 ASSERT_EQ(0u, memoryCache()->deadSize()); | 247 ASSERT_EQ(0u, memoryCache()->deadSize()); |
248 ASSERT_EQ(m_liveSizeWithoutDecode, memoryCache()->liveSize()); | 248 ASSERT_EQ(m_liveSizeWithoutDecode, memoryCache()->liveSize()); |
249 } | 249 } |
250 | 250 |
251 private: | 251 private: |
252 unsigned m_liveSizeWithoutDecode; | 252 unsigned m_liveSizeWithoutDecode; |
253 }; | 253 }; |
254 | 254 |
255 | 255 |
256 Platform::current()->currentThread()->taskRunner()->postTask(FROM_HERE, new
Task1(cachedLiveResource, cachedDeadResource)); | 256 Platform::current()->currentThread()->taskRunner()->postTask(BLINK_FROM_HERE
, new Task1(cachedLiveResource, cachedDeadResource)); |
257 Platform::current()->currentThread()->taskRunner()->postTask(FROM_HERE, new
Task2(cachedLiveResource->encodedSize() + cachedLiveResource->overheadSize())); | 257 Platform::current()->currentThread()->taskRunner()->postTask(BLINK_FROM_HERE
, new Task2(cachedLiveResource->encodedSize() + cachedLiveResource->overheadSize
())); |
258 testing::runPendingTasks(); | 258 testing::runPendingTasks(); |
259 } | 259 } |
260 | 260 |
261 // Verified that when ordering a prune in a runLoop task, the prune | 261 // Verified that when ordering a prune in a runLoop task, the prune |
262 // is deferred to the end of the task. | 262 // is deferred to the end of the task. |
263 TEST_F(MemoryCacheTest, LiveResourceEvictionAtEndOfTask_Basic) | 263 TEST_F(MemoryCacheTest, LiveResourceEvictionAtEndOfTask_Basic) |
264 { | 264 { |
265 Resource* cachedDeadResource = | 265 Resource* cachedDeadResource = |
266 new Resource(ResourceRequest("hhtp://foo"), Resource::Raw); | 266 new Resource(ResourceRequest("hhtp://foo"), Resource::Raw); |
267 ResourcePtr<Resource> cachedLiveResource = | 267 ResourcePtr<Resource> cachedLiveResource = |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 | 561 |
562 WillBeHeapVector<RawPtrWillBeMember<Resource>> resources = memoryCache()->re
sourcesForURL(url); | 562 WillBeHeapVector<RawPtrWillBeMember<Resource>> resources = memoryCache()->re
sourcesForURL(url); |
563 EXPECT_EQ(2u, resources.size()); | 563 EXPECT_EQ(2u, resources.size()); |
564 | 564 |
565 memoryCache()->evictResources(); | 565 memoryCache()->evictResources(); |
566 EXPECT_FALSE(memoryCache()->contains(resource1.get())); | 566 EXPECT_FALSE(memoryCache()->contains(resource1.get())); |
567 EXPECT_FALSE(memoryCache()->contains(resource3.get())); | 567 EXPECT_FALSE(memoryCache()->contains(resource3.get())); |
568 } | 568 } |
569 | 569 |
570 } // namespace | 570 } // namespace |
OLD | NEW |