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

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

Issue 1667843003: Make Resource RefCountedWillBeGarbageCollectedFinalized, attempt #2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + address review comments Created 4 years, 10 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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "core/fetch/MemoryCache.h" 31 #include "core/fetch/MemoryCache.h"
32 32
33 #include "core/fetch/MockImageResourceClient.h" 33 #include "core/fetch/MockImageResourceClient.h"
34 #include "core/fetch/RawResource.h" 34 #include "core/fetch/RawResource.h"
35 #include "core/fetch/ResourcePtr.h"
36 #include "platform/network/ResourceRequest.h" 35 #include "platform/network/ResourceRequest.h"
37 #include "platform/testing/UnitTestHelpers.h" 36 #include "platform/testing/UnitTestHelpers.h"
38 #include "public/platform/Platform.h" 37 #include "public/platform/Platform.h"
39 #include "testing/gtest/include/gtest/gtest.h" 38 #include "testing/gtest/include/gtest/gtest.h"
40 #include "wtf/OwnPtr.h" 39 #include "wtf/OwnPtr.h"
41 40
42 namespace blink { 41 namespace blink {
43 42
44 class MemoryCacheTest : public ::testing::Test { 43 class MemoryCacheTest : public ::testing::Test {
45 public: 44 public:
46 class FakeDecodedResource : public Resource { 45 class FakeDecodedResource : public Resource {
47 public: 46 public:
48 FakeDecodedResource(const ResourceRequest& request, Type type) 47 static RefPtrWillBeRawPtr<FakeDecodedResource> create(const ResourceRequ est& request, Type type)
49 : Resource(request, type)
50 { 48 {
49 return adoptRefWillBeNoop(new FakeDecodedResource(request, type));
51 } 50 }
52 51
53 virtual void appendData(const char* data, size_t len) 52 virtual void appendData(const char* data, size_t len)
54 { 53 {
55 Resource::appendData(data, len); 54 Resource::appendData(data, len);
56 setDecodedSize(this->size()); 55 setDecodedSize(this->size());
57 } 56 }
58 57
59 protected: 58 protected:
59 FakeDecodedResource(const ResourceRequest& request, Type type)
60 : Resource(request, type)
61 {
62 }
63
60 void destroyDecodedDataIfPossible() override 64 void destroyDecodedDataIfPossible() override
61 { 65 {
62 setDecodedSize(0); 66 setDecodedSize(0);
63 } 67 }
64 }; 68 };
65 69
66 class FakeResource : public Resource { 70 class FakeResource : public Resource {
67 public: 71 public:
68 FakeResource(const ResourceRequest& request, Type type) 72 static RefPtrWillBeRawPtr<FakeResource> create(const ResourceRequest& re quest, Type type)
69 : Resource(request, type)
70 { 73 {
74 return adoptRefWillBeNoop(new FakeResource(request, type));
71 } 75 }
72 76
73 void fakeEncodedSize(size_t size) 77 void fakeEncodedSize(size_t size)
74 { 78 {
75 setEncodedSize(size); 79 setEncodedSize(size);
76 } 80 }
81
82 private:
83 FakeResource(const ResourceRequest& request, Type type)
84 : Resource(request, type)
85 {
86 }
77 }; 87 };
78 88
79 protected: 89 protected:
80 virtual void SetUp() 90 virtual void SetUp()
81 { 91 {
82 // Save the global memory cache to restore it upon teardown. 92 // Save the global memory cache to restore it upon teardown.
83 m_globalMemoryCache = replaceMemoryCacheForTesting(MemoryCache::create() ); 93 m_globalMemoryCache = replaceMemoryCacheForTesting(MemoryCache::create() );
84 } 94 }
85 95
86 virtual void TearDown() 96 virtual void TearDown()
(...skipping 19 matching lines...) Expand all
106 116
107 TEST_F(MemoryCacheTest, VeryLargeResourceAccounting) 117 TEST_F(MemoryCacheTest, VeryLargeResourceAccounting)
108 { 118 {
109 const size_t sizeMax = ~static_cast<size_t>(0); 119 const size_t sizeMax = ~static_cast<size_t>(0);
110 const size_t totalCapacity = sizeMax / 4; 120 const size_t totalCapacity = sizeMax / 4;
111 const size_t minDeadCapacity = sizeMax / 16; 121 const size_t minDeadCapacity = sizeMax / 16;
112 const size_t maxDeadCapacity = sizeMax / 8; 122 const size_t maxDeadCapacity = sizeMax / 8;
113 const size_t resourceSize1 = sizeMax / 16; 123 const size_t resourceSize1 = sizeMax / 16;
114 const size_t resourceSize2 = sizeMax / 20; 124 const size_t resourceSize2 = sizeMax / 20;
115 memoryCache()->setCapacities(minDeadCapacity, maxDeadCapacity, totalCapacity ); 125 memoryCache()->setCapacities(minDeadCapacity, maxDeadCapacity, totalCapacity );
116 ResourcePtr<FakeResource> cachedResource = 126 RefPtrWillBeRawPtr<FakeResource> cachedResource =
117 new FakeResource(ResourceRequest("http://test/resource"), Resource::Raw) ; 127 FakeResource::create(ResourceRequest("http://test/resource"), Resource:: Raw);
118 cachedResource->fakeEncodedSize(resourceSize1); 128 cachedResource->fakeEncodedSize(resourceSize1);
119 129
120 ASSERT_EQ(0u, memoryCache()->deadSize()); 130 ASSERT_EQ(0u, memoryCache()->deadSize());
121 ASSERT_EQ(0u, memoryCache()->liveSize()); 131 ASSERT_EQ(0u, memoryCache()->liveSize());
122 memoryCache()->add(cachedResource.get()); 132 memoryCache()->add(cachedResource.get());
123 ASSERT_EQ(cachedResource->size(), memoryCache()->deadSize()); 133 ASSERT_EQ(cachedResource->size(), memoryCache()->deadSize());
124 ASSERT_EQ(0u, memoryCache()->liveSize()); 134 ASSERT_EQ(0u, memoryCache()->liveSize());
125 135
126 MockImageResourceClient client(cachedResource); 136 MockImageResourceClient client(cachedResource);
127 ASSERT_EQ(0u, memoryCache()->deadSize()); 137 ASSERT_EQ(0u, memoryCache()->deadSize());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 ASSERT_EQ(resource1->size() + resource2->size(), memoryCache()->deadSize()); 173 ASSERT_EQ(resource1->size() + resource2->size(), memoryCache()->deadSize());
164 ASSERT_EQ(0u, memoryCache()->liveSize()); 174 ASSERT_EQ(0u, memoryCache()->liveSize());
165 175
166 memoryCache()->prune(); 176 memoryCache()->prune();
167 ASSERT_EQ(0u, memoryCache()->deadSize()); 177 ASSERT_EQ(0u, memoryCache()->deadSize());
168 ASSERT_EQ(0u, memoryCache()->liveSize()); 178 ASSERT_EQ(0u, memoryCache()->liveSize());
169 } 179 }
170 180
171 TEST_F(MemoryCacheTest, DeadResourceEviction_Basic) 181 TEST_F(MemoryCacheTest, DeadResourceEviction_Basic)
172 { 182 {
173 Resource* resource1 = 183 RefPtrWillBeRawPtr<Resource> resource1 =
174 new Resource(ResourceRequest("http://test/resource1"), Resource::Raw); 184 Resource::create(ResourceRequest("http://test/resource1"), Resource::Raw );
175 Resource* resource2 = 185 RefPtrWillBeRawPtr<Resource> resource2 =
176 new Resource(ResourceRequest("http://test/resource2"), Resource::Raw); 186 Resource::create(ResourceRequest("http://test/resource2"), Resource::Raw );
177 TestDeadResourceEviction(resource1, resource2); 187 TestDeadResourceEviction(resource1.get(), resource2.get());
178 } 188 }
179 189
180 TEST_F(MemoryCacheTest, DeadResourceEviction_MultipleResourceMaps) 190 TEST_F(MemoryCacheTest, DeadResourceEviction_MultipleResourceMaps)
181 { 191 {
182 Resource* resource1 = 192 RefPtrWillBeRawPtr<Resource> resource1 =
183 new Resource(ResourceRequest("http://test/resource1"), Resource::Raw); 193 Resource::create(ResourceRequest("http://test/resource1"), Resource::Raw );
184 Resource* resource2 = 194 RefPtrWillBeRawPtr<Resource> resource2 =
185 new Resource(ResourceRequest("http://test/resource2"), Resource::Raw); 195 Resource::create(ResourceRequest("http://test/resource2"), Resource::Raw );
186 resource2->setCacheIdentifier("foo"); 196 resource2->setCacheIdentifier("foo");
187 TestDeadResourceEviction(resource1, resource2); 197 TestDeadResourceEviction(resource1.get(), resource2.get());
188 } 198 }
189 199
190 static void TestLiveResourceEvictionAtEndOfTask(Resource* cachedDeadResource, co nst ResourcePtr<Resource>& cachedLiveResource) 200 static void TestLiveResourceEvictionAtEndOfTask(Resource* cachedDeadResource, Re source* cachedLiveResource)
191 { 201 {
192 memoryCache()->setDelayBeforeLiveDecodedPrune(0); 202 memoryCache()->setDelayBeforeLiveDecodedPrune(0);
193 const unsigned totalCapacity = 1; 203 const unsigned totalCapacity = 1;
194 const unsigned minDeadCapacity = 0; 204 const unsigned minDeadCapacity = 0;
195 const unsigned maxDeadCapacity = 0; 205 const unsigned maxDeadCapacity = 0;
196 memoryCache()->setCapacities(minDeadCapacity, maxDeadCapacity, totalCapacity ); 206 memoryCache()->setCapacities(minDeadCapacity, maxDeadCapacity, totalCapacity );
197 const char data[6] = "abcde"; 207 const char data[6] = "abcde";
198 cachedDeadResource->appendData(data, 3u); 208 cachedDeadResource->appendData(data, 3u);
199 MockImageResourceClient client(cachedLiveResource); 209 MockImageResourceClient client(cachedLiveResource);
200 cachedLiveResource->appendData(data, 4u); 210 cachedLiveResource->appendData(data, 4u);
201 211
202 class Task1 : public WebTaskRunner::Task { 212 class Task1 : public WebTaskRunner::Task {
203 public: 213 public:
204 Task1(const ResourcePtr<Resource>& live, Resource* dead) 214 Task1(Resource* live, Resource* dead)
205 : m_live(live) 215 : m_live(live)
206 , m_dead(dead) 216 , m_dead(dead)
207 { } 217 { }
208 218
209 void run() override 219 void run() override
210 { 220 {
211 // The resource size has to be nonzero for this test to be meaningfu l, but 221 // The resource size has to be nonzero for this test to be meaningfu l, but
212 // we do not rely on it having any particular value. 222 // we do not rely on it having any particular value.
213 ASSERT_GT(m_live->size(), 0u); 223 ASSERT_GT(m_live->size(), 0u);
214 ASSERT_GT(m_dead->size(), 0u); 224 ASSERT_GT(m_dead->size(), 0u);
215 225
216 ASSERT_EQ(0u, memoryCache()->deadSize()); 226 ASSERT_EQ(0u, memoryCache()->deadSize());
217 ASSERT_EQ(0u, memoryCache()->liveSize()); 227 ASSERT_EQ(0u, memoryCache()->liveSize());
218 228
219 memoryCache()->add(m_dead); 229 memoryCache()->add(m_dead.get());
220 memoryCache()->add(m_live.get()); 230 memoryCache()->add(m_live.get());
221 memoryCache()->updateDecodedResource(m_live.get(), UpdateForProperty Change); 231 memoryCache()->updateDecodedResource(m_live.get(), UpdateForProperty Change);
222 ASSERT_EQ(m_dead->size(), memoryCache()->deadSize()); 232 ASSERT_EQ(m_dead->size(), memoryCache()->deadSize());
223 ASSERT_EQ(m_live->size(), memoryCache()->liveSize()); 233 ASSERT_EQ(m_live->size(), memoryCache()->liveSize());
224 ASSERT_GT(m_live->decodedSize(), 0u); 234 ASSERT_GT(m_live->decodedSize(), 0u);
225 235
226 memoryCache()->prune(); // Dead resources are pruned immediately 236 memoryCache()->prune(); // Dead resources are pruned immediately
227 ASSERT_EQ(m_dead->size(), memoryCache()->deadSize()); 237 ASSERT_EQ(m_dead->size(), memoryCache()->deadSize());
228 ASSERT_EQ(m_live->size(), memoryCache()->liveSize()); 238 ASSERT_EQ(m_live->size(), memoryCache()->liveSize());
229 ASSERT_GT(m_live->decodedSize(), 0u); 239 ASSERT_GT(m_live->decodedSize(), 0u);
230 } 240 }
231 241
232 private: 242 private:
233 ResourcePtr<Resource> m_live; 243 RefPtrWillBePersistent<Resource> m_live;
234 RawPtrWillBePersistent<Resource> m_dead; 244 RefPtrWillBePersistent<Resource> m_dead;
235 }; 245 };
236 246
237 class Task2 : public WebTaskRunner::Task { 247 class Task2 : public WebTaskRunner::Task {
238 public: 248 public:
239 Task2(unsigned liveSizeWithoutDecode) 249 Task2(unsigned liveSizeWithoutDecode)
240 : m_liveSizeWithoutDecode(liveSizeWithoutDecode) { } 250 : m_liveSizeWithoutDecode(liveSizeWithoutDecode) { }
241 251
242 void run() override 252 void run() override
243 { 253 {
244 // Next task: now, the live resource was evicted. 254 // Next task: now, the live resource was evicted.
245 ASSERT_EQ(0u, memoryCache()->deadSize()); 255 ASSERT_EQ(0u, memoryCache()->deadSize());
246 ASSERT_EQ(m_liveSizeWithoutDecode, memoryCache()->liveSize()); 256 ASSERT_EQ(m_liveSizeWithoutDecode, memoryCache()->liveSize());
247 } 257 }
248 258
249 private: 259 private:
250 unsigned m_liveSizeWithoutDecode; 260 unsigned m_liveSizeWithoutDecode;
251 }; 261 };
252 262
253 263
254 Platform::current()->currentThread()->taskRunner()->postTask(BLINK_FROM_HERE , new Task1(cachedLiveResource, cachedDeadResource)); 264 Platform::current()->currentThread()->taskRunner()->postTask(BLINK_FROM_HERE , new Task1(cachedLiveResource, cachedDeadResource));
255 Platform::current()->currentThread()->taskRunner()->postTask(BLINK_FROM_HERE , new Task2(cachedLiveResource->encodedSize() + cachedLiveResource->overheadSize ())); 265 Platform::current()->currentThread()->taskRunner()->postTask(BLINK_FROM_HERE , new Task2(cachedLiveResource->encodedSize() + cachedLiveResource->overheadSize ()));
256 testing::runPendingTasks(); 266 testing::runPendingTasks();
257 } 267 }
258 268
259 // Verified that when ordering a prune in a runLoop task, the prune 269 // Verified that when ordering a prune in a runLoop task, the prune
260 // is deferred to the end of the task. 270 // is deferred to the end of the task.
261 TEST_F(MemoryCacheTest, LiveResourceEvictionAtEndOfTask_Basic) 271 TEST_F(MemoryCacheTest, LiveResourceEvictionAtEndOfTask_Basic)
262 { 272 {
263 Resource* cachedDeadResource = 273 RefPtrWillBeRawPtr<Resource> cachedDeadResource =
264 new Resource(ResourceRequest("hhtp://foo"), Resource::Raw); 274 Resource::create(ResourceRequest("hhtp://foo"), Resource::Raw);
265 ResourcePtr<Resource> cachedLiveResource = 275 RefPtrWillBeRawPtr<Resource> cachedLiveResource =
266 new FakeDecodedResource(ResourceRequest("http://test/resource"), Resourc e::Raw); 276 FakeDecodedResource::create(ResourceRequest("http://test/resource"), Res ource::Raw);
267 TestLiveResourceEvictionAtEndOfTask(cachedDeadResource, cachedLiveResource); 277 TestLiveResourceEvictionAtEndOfTask(cachedDeadResource.get(), cachedLiveReso urce.get());
268 } 278 }
269 279
270 TEST_F(MemoryCacheTest, LiveResourceEvictionAtEndOfTask_MultipleResourceMaps) 280 TEST_F(MemoryCacheTest, LiveResourceEvictionAtEndOfTask_MultipleResourceMaps)
271 { 281 {
272 { 282 {
273 Resource* cachedDeadResource = 283 RefPtrWillBeRawPtr<Resource> cachedDeadResource =
274 new Resource(ResourceRequest("hhtp://foo"), Resource::Raw); 284 Resource::create(ResourceRequest("hhtp://foo"), Resource::Raw);
275 cachedDeadResource->setCacheIdentifier("foo"); 285 cachedDeadResource->setCacheIdentifier("foo");
276 ResourcePtr<Resource> cachedLiveResource = 286 RefPtrWillBeRawPtr<Resource> cachedLiveResource =
277 new FakeDecodedResource(ResourceRequest("http://test/resource"), Res ource::Raw); 287 FakeDecodedResource::create(ResourceRequest("http://test/resource"), Resource::Raw);
278 TestLiveResourceEvictionAtEndOfTask(cachedDeadResource, cachedLiveResour ce); 288 TestLiveResourceEvictionAtEndOfTask(cachedDeadResource.get(), cachedLive Resource.get());
279 memoryCache()->evictResources(); 289 memoryCache()->evictResources();
280 } 290 }
281 { 291 {
282 Resource* cachedDeadResource = 292 RefPtrWillBeRawPtr<Resource> cachedDeadResource =
283 new Resource(ResourceRequest("hhtp://foo"), Resource::Raw); 293 Resource::create(ResourceRequest("hhtp://foo"), Resource::Raw);
284 ResourcePtr<Resource> cachedLiveResource = 294 RefPtrWillBeRawPtr<Resource> cachedLiveResource =
285 new FakeDecodedResource(ResourceRequest("http://test/resource"), Res ource::Raw); 295 FakeDecodedResource::create(ResourceRequest("http://test/resource"), Resource::Raw);
286 cachedLiveResource->setCacheIdentifier("foo"); 296 cachedLiveResource->setCacheIdentifier("foo");
287 TestLiveResourceEvictionAtEndOfTask(cachedDeadResource, cachedLiveResour ce); 297 TestLiveResourceEvictionAtEndOfTask(cachedDeadResource.get(), cachedLive Resource.get());
288 memoryCache()->evictResources(); 298 memoryCache()->evictResources();
289 } 299 }
290 { 300 {
291 Resource* cachedDeadResource = 301 RefPtrWillBeRawPtr<Resource> cachedDeadResource =
292 new Resource(ResourceRequest("hhtp://test/resource"), Resource::Raw) ; 302 Resource::create(ResourceRequest("hhtp://test/resource"), Resource:: Raw);
293 cachedDeadResource->setCacheIdentifier("foo"); 303 cachedDeadResource->setCacheIdentifier("foo");
294 ResourcePtr<Resource> cachedLiveResource = 304 RefPtrWillBeRawPtr<Resource> cachedLiveResource =
295 new FakeDecodedResource(ResourceRequest("http://test/resource"), Res ource::Raw); 305 FakeDecodedResource::create(ResourceRequest("http://test/resource"), Resource::Raw);
296 cachedLiveResource->setCacheIdentifier("bar"); 306 cachedLiveResource->setCacheIdentifier("bar");
297 TestLiveResourceEvictionAtEndOfTask(cachedDeadResource, cachedLiveResour ce); 307 TestLiveResourceEvictionAtEndOfTask(cachedDeadResource.get(), cachedLive Resource.get());
298 memoryCache()->evictResources(); 308 memoryCache()->evictResources();
299 } 309 }
300 } 310 }
301 311
302 // Verifies that cached resources are evicted immediately after release when 312 // Verifies that cached resources are evicted immediately after release when
303 // the total dead resource size is more than double the dead resource capacity. 313 // the total dead resource size is more than double the dead resource capacity.
304 static void TestClientRemoval(const ResourcePtr<Resource>& resource1, const Reso urcePtr<Resource>& resource2) 314 static void TestClientRemoval(Resource* resource1, Resource* resource2)
305 { 315 {
306 const char data[6] = "abcde"; 316 const char data[6] = "abcde";
307 MockImageResourceClient client1(resource1); 317 MockImageResourceClient client1(resource1);
308 resource1->appendData(data, 4u); 318 resource1->appendData(data, 4u);
309 MockImageResourceClient client2(resource2); 319 MockImageResourceClient client2(resource2);
310 resource2->appendData(data, 4u); 320 resource2->appendData(data, 4u);
311 321
312 const unsigned minDeadCapacity = 0; 322 const unsigned minDeadCapacity = 0;
313 const unsigned maxDeadCapacity = ((resource1->size() + resource2->size()) / 2) - 1; 323 const unsigned maxDeadCapacity = ((resource1->size() + resource2->size()) / 2) - 1;
314 const unsigned totalCapacity = maxDeadCapacity; 324 const unsigned totalCapacity = maxDeadCapacity;
315 memoryCache()->setCapacities(minDeadCapacity, maxDeadCapacity, totalCapacity ); 325 memoryCache()->setCapacities(minDeadCapacity, maxDeadCapacity, totalCapacity );
316 memoryCache()->add(resource1.get()); 326 memoryCache()->add(resource1);
317 memoryCache()->add(resource2.get()); 327 memoryCache()->add(resource2);
318 // Call prune. There is nothing to prune, but this will initialize 328 // Call prune. There is nothing to prune, but this will initialize
319 // the prune timestamp, allowing future prunes to be deferred. 329 // the prune timestamp, allowing future prunes to be deferred.
320 memoryCache()->prune(); 330 memoryCache()->prune();
321 ASSERT_GT(resource1->decodedSize(), 0u); 331 ASSERT_GT(resource1->decodedSize(), 0u);
322 ASSERT_GT(resource2->decodedSize(), 0u); 332 ASSERT_GT(resource2->decodedSize(), 0u);
323 ASSERT_EQ(memoryCache()->deadSize(), 0u); 333 ASSERT_EQ(memoryCache()->deadSize(), 0u);
324 ASSERT_EQ(memoryCache()->liveSize(), resource1->size() + resource2->size()); 334 ASSERT_EQ(memoryCache()->liveSize(), resource1->size() + resource2->size());
325 335
326 // Removing the client from resource1 should result in all resources 336 // Removing the client from resource1 should result in all resources
327 // remaining in cache since the prune is deferred. 337 // remaining in cache since the prune is deferred.
328 client1.removeAsClient(); 338 client1.removeAsClient();
329 ASSERT_GT(resource1->decodedSize(), 0u); 339 ASSERT_GT(resource1->decodedSize(), 0u);
330 ASSERT_GT(resource2->decodedSize(), 0u); 340 ASSERT_GT(resource2->decodedSize(), 0u);
331 ASSERT_EQ(memoryCache()->deadSize(), resource1->size()); 341 ASSERT_EQ(memoryCache()->deadSize(), resource1->size());
332 ASSERT_EQ(memoryCache()->liveSize(), resource2->size()); 342 ASSERT_EQ(memoryCache()->liveSize(), resource2->size());
333 ASSERT_TRUE(memoryCache()->contains(resource1.get())); 343 ASSERT_TRUE(memoryCache()->contains(resource1));
334 ASSERT_TRUE(memoryCache()->contains(resource2.get())); 344 ASSERT_TRUE(memoryCache()->contains(resource2));
335 345
336 // Removing the client from resource2 should result in immediate 346 // Removing the client from resource2 should result in immediate
337 // eviction of resource2 because we are over the prune deferral limit. 347 // eviction of resource2 because we are over the prune deferral limit.
338 client2.removeAsClient(); 348 client2.removeAsClient();
339 ASSERT_GT(resource1->decodedSize(), 0u); 349 ASSERT_GT(resource1->decodedSize(), 0u);
340 ASSERT_GT(resource2->decodedSize(), 0u); 350 ASSERT_GT(resource2->decodedSize(), 0u);
341 ASSERT_EQ(memoryCache()->deadSize(), resource1->size()); 351 ASSERT_EQ(memoryCache()->deadSize(), resource1->size());
342 ASSERT_EQ(memoryCache()->liveSize(), 0u); 352 ASSERT_EQ(memoryCache()->liveSize(), 0u);
343 ASSERT_TRUE(memoryCache()->contains(resource1.get())); 353 ASSERT_TRUE(memoryCache()->contains(resource1));
344 ASSERT_FALSE(memoryCache()->contains(resource2.get())); 354 ASSERT_FALSE(memoryCache()->contains(resource2));
345 } 355 }
346 356
347 TEST_F(MemoryCacheTest, ClientRemoval_Basic) 357 TEST_F(MemoryCacheTest, ClientRemoval_Basic)
348 { 358 {
349 ResourcePtr<Resource> resource1 = 359 RefPtrWillBeRawPtr<Resource> resource1 =
350 new FakeDecodedResource(ResourceRequest("http://foo.com"), Resource::Raw ); 360 FakeDecodedResource::create(ResourceRequest("http://foo.com"), Resource: :Raw);
351 ResourcePtr<Resource> resource2 = 361 RefPtrWillBeRawPtr<Resource> resource2 =
352 new FakeDecodedResource(ResourceRequest("http://test/resource"), Resourc e::Raw); 362 FakeDecodedResource::create(ResourceRequest("http://test/resource"), Res ource::Raw);
353 TestClientRemoval(resource1, resource2); 363 TestClientRemoval(resource1.get(), resource2.get());
354 } 364 }
355 365
356 TEST_F(MemoryCacheTest, ClientRemoval_MultipleResourceMaps) 366 TEST_F(MemoryCacheTest, ClientRemoval_MultipleResourceMaps)
357 { 367 {
358 { 368 {
359 ResourcePtr<Resource> resource1 = 369 RefPtrWillBeRawPtr<Resource> resource1 =
360 new FakeDecodedResource(ResourceRequest("http://foo.com"), Resource: :Raw); 370 FakeDecodedResource::create(ResourceRequest("http://foo.com"), Resou rce::Raw);
361 resource1->setCacheIdentifier("foo"); 371 resource1->setCacheIdentifier("foo");
362 ResourcePtr<Resource> resource2 = 372 RefPtrWillBeRawPtr<Resource> resource2 =
363 new FakeDecodedResource(ResourceRequest("http://test/resource"), Res ource::Raw); 373 FakeDecodedResource::create(ResourceRequest("http://test/resource"), Resource::Raw);
364 TestClientRemoval(resource1, resource2); 374 TestClientRemoval(resource1.get(), resource2.get());
365 memoryCache()->evictResources(); 375 memoryCache()->evictResources();
366 } 376 }
367 { 377 {
368 ResourcePtr<Resource> resource1 = 378 RefPtrWillBeRawPtr<Resource> resource1 =
369 new FakeDecodedResource(ResourceRequest("http://foo.com"), Resource: :Raw); 379 FakeDecodedResource::create(ResourceRequest("http://foo.com"), Resou rce::Raw);
370 ResourcePtr<Resource> resource2 = 380 RefPtrWillBeRawPtr<Resource> resource2 =
371 new FakeDecodedResource(ResourceRequest("http://test/resource"), Res ource::Raw); 381 FakeDecodedResource::create(ResourceRequest("http://test/resource"), Resource::Raw);
372 resource2->setCacheIdentifier("foo"); 382 resource2->setCacheIdentifier("foo");
373 TestClientRemoval(resource1, resource2); 383 TestClientRemoval(resource1.get(), resource2.get());
374 memoryCache()->evictResources(); 384 memoryCache()->evictResources();
375 } 385 }
376 { 386 {
377 ResourcePtr<Resource> resource1 = 387 RefPtrWillBeRawPtr<Resource> resource1 =
378 new FakeDecodedResource(ResourceRequest("http://test/resource"), Res ource::Raw); 388 FakeDecodedResource::create(ResourceRequest("http://test/resource"), Resource::Raw);
379 resource1->setCacheIdentifier("foo"); 389 resource1->setCacheIdentifier("foo");
380 ResourcePtr<Resource> resource2 = 390 RefPtrWillBeRawPtr<Resource> resource2 =
381 new FakeDecodedResource(ResourceRequest("http://test/resource"), Res ource::Raw); 391 FakeDecodedResource::create(ResourceRequest("http://test/resource"), Resource::Raw);
382 resource2->setCacheIdentifier("bar"); 392 resource2->setCacheIdentifier("bar");
383 TestClientRemoval(resource1, resource2); 393 TestClientRemoval(resource1.get(), resource2.get());
384 memoryCache()->evictResources(); 394 memoryCache()->evictResources();
385 } 395 }
386 } 396 }
387 397
388 // Verifies that CachedResources are evicted from the decode cache 398 // Verifies that CachedResources are evicted from the decode cache
389 // according to their DecodeCachePriority. 399 // according to their DecodeCachePriority.
390 static void TestDecodeCacheOrder(const ResourcePtr<Resource>& cachedImageLowPrio rity, const ResourcePtr<Resource>& cachedImageHighPriority) 400 static void TestDecodeCacheOrder(Resource* cachedImageLowPriority, Resource* cac hedImageHighPriority)
391 { 401 {
392 memoryCache()->setDelayBeforeLiveDecodedPrune(0); 402 memoryCache()->setDelayBeforeLiveDecodedPrune(0);
393 memoryCache()->setMaxPruneDeferralDelay(0); 403 memoryCache()->setMaxPruneDeferralDelay(0);
394 404
395 MockImageResourceClient clientLowPriority(cachedImageLowPriority); 405 MockImageResourceClient clientLowPriority(cachedImageLowPriority);
396 MockImageResourceClient clientHighPriority(cachedImageHighPriority); 406 MockImageResourceClient clientHighPriority(cachedImageHighPriority);
397 407
398 const char data[5] = "abcd"; 408 const char data[5] = "abcd";
399 cachedImageLowPriority->appendData(data, 1u); 409 cachedImageLowPriority->appendData(data, 1u);
400 cachedImageHighPriority->appendData(data, 4u); 410 cachedImageHighPriority->appendData(data, 4u);
401 const unsigned lowPrioritySize = cachedImageLowPriority->size(); 411 const unsigned lowPrioritySize = cachedImageLowPriority->size();
402 const unsigned highPrioritySize = cachedImageHighPriority->size(); 412 const unsigned highPrioritySize = cachedImageHighPriority->size();
403 const unsigned lowPriorityMockDecodeSize = cachedImageLowPriority->decodedSi ze(); 413 const unsigned lowPriorityMockDecodeSize = cachedImageLowPriority->decodedSi ze();
404 const unsigned highPriorityMockDecodeSize = cachedImageHighPriority->decoded Size(); 414 const unsigned highPriorityMockDecodeSize = cachedImageHighPriority->decoded Size();
405 const unsigned totalSize = lowPrioritySize + highPrioritySize; 415 const unsigned totalSize = lowPrioritySize + highPrioritySize;
406 416
407 // Verify that the sizes are different to ensure that we can test eviction o rder. 417 // Verify that the sizes are different to ensure that we can test eviction o rder.
408 ASSERT_GT(lowPrioritySize, 0u); 418 ASSERT_GT(lowPrioritySize, 0u);
409 ASSERT_NE(lowPrioritySize, highPrioritySize); 419 ASSERT_NE(lowPrioritySize, highPrioritySize);
410 ASSERT_GT(lowPriorityMockDecodeSize, 0u); 420 ASSERT_GT(lowPriorityMockDecodeSize, 0u);
411 ASSERT_NE(lowPriorityMockDecodeSize, highPriorityMockDecodeSize); 421 ASSERT_NE(lowPriorityMockDecodeSize, highPriorityMockDecodeSize);
412 422
413 ASSERT_EQ(memoryCache()->deadSize(), 0u); 423 ASSERT_EQ(memoryCache()->deadSize(), 0u);
414 ASSERT_EQ(memoryCache()->liveSize(), 0u); 424 ASSERT_EQ(memoryCache()->liveSize(), 0u);
415 425
416 // Add the items. The item added first would normally be evicted first. 426 // Add the items. The item added first would normally be evicted first.
417 memoryCache()->add(cachedImageHighPriority.get()); 427 memoryCache()->add(cachedImageHighPriority);
418 ASSERT_EQ(memoryCache()->deadSize(), 0u); 428 ASSERT_EQ(memoryCache()->deadSize(), 0u);
419 ASSERT_EQ(memoryCache()->liveSize(), highPrioritySize); 429 ASSERT_EQ(memoryCache()->liveSize(), highPrioritySize);
420 430
421 memoryCache()->add(cachedImageLowPriority.get()); 431 memoryCache()->add(cachedImageLowPriority);
422 ASSERT_EQ(memoryCache()->deadSize(), 0u); 432 ASSERT_EQ(memoryCache()->deadSize(), 0u);
423 ASSERT_EQ(memoryCache()->liveSize(), highPrioritySize + lowPrioritySize); 433 ASSERT_EQ(memoryCache()->liveSize(), highPrioritySize + lowPrioritySize);
424 434
425 // Insert all items in the decoded items list with the same priority 435 // Insert all items in the decoded items list with the same priority
426 memoryCache()->updateDecodedResource(cachedImageHighPriority.get(), UpdateFo rPropertyChange); 436 memoryCache()->updateDecodedResource(cachedImageHighPriority, UpdateForPrope rtyChange);
427 memoryCache()->updateDecodedResource(cachedImageLowPriority.get(), UpdateFor PropertyChange); 437 memoryCache()->updateDecodedResource(cachedImageLowPriority, UpdateForProper tyChange);
428 ASSERT_EQ(memoryCache()->deadSize(), 0u); 438 ASSERT_EQ(memoryCache()->deadSize(), 0u);
429 ASSERT_EQ(memoryCache()->liveSize(), totalSize); 439 ASSERT_EQ(memoryCache()->liveSize(), totalSize);
430 440
431 // Now we will assign their priority and make sure they are moved to the cor rect buckets. 441 // Now we will assign their priority and make sure they are moved to the cor rect buckets.
432 memoryCache()->updateDecodedResource(cachedImageLowPriority.get(), UpdateFor PropertyChange, MemoryCacheLiveResourcePriorityLow); 442 memoryCache()->updateDecodedResource(cachedImageLowPriority, UpdateForProper tyChange, MemoryCacheLiveResourcePriorityLow);
433 memoryCache()->updateDecodedResource(cachedImageHighPriority.get(), UpdateFo rPropertyChange, MemoryCacheLiveResourcePriorityHigh); 443 memoryCache()->updateDecodedResource(cachedImageHighPriority, UpdateForPrope rtyChange, MemoryCacheLiveResourcePriorityHigh);
434 444
435 // Should first prune the LowPriority item. 445 // Should first prune the LowPriority item.
436 memoryCache()->setCapacities(memoryCache()->minDeadCapacity(), memoryCache() ->liveSize() - 10, memoryCache()->liveSize() - 10); 446 memoryCache()->setCapacities(memoryCache()->minDeadCapacity(), memoryCache() ->liveSize() - 10, memoryCache()->liveSize() - 10);
437 memoryCache()->prune(); 447 memoryCache()->prune();
438 ASSERT_EQ(memoryCache()->deadSize(), 0u); 448 ASSERT_EQ(memoryCache()->deadSize(), 0u);
439 ASSERT_EQ(memoryCache()->liveSize(), totalSize - lowPriorityMockDecodeSize); 449 ASSERT_EQ(memoryCache()->liveSize(), totalSize - lowPriorityMockDecodeSize);
440 450
441 // Should prune the HighPriority item. 451 // Should prune the HighPriority item.
442 memoryCache()->setCapacities(memoryCache()->minDeadCapacity(), memoryCache() ->liveSize() - 10, memoryCache()->liveSize() - 10); 452 memoryCache()->setCapacities(memoryCache()->minDeadCapacity(), memoryCache() ->liveSize() - 10, memoryCache()->liveSize() - 10);
443 memoryCache()->prune(); 453 memoryCache()->prune();
444 ASSERT_EQ(memoryCache()->deadSize(), 0u); 454 ASSERT_EQ(memoryCache()->deadSize(), 0u);
445 ASSERT_EQ(memoryCache()->liveSize(), totalSize - lowPriorityMockDecodeSize - highPriorityMockDecodeSize); 455 ASSERT_EQ(memoryCache()->liveSize(), totalSize - lowPriorityMockDecodeSize - highPriorityMockDecodeSize);
446 } 456 }
447 457
448 TEST_F(MemoryCacheTest, DecodeCacheOrder_Basic) 458 TEST_F(MemoryCacheTest, DecodeCacheOrder_Basic)
449 { 459 {
450 ResourcePtr<FakeDecodedResource> cachedImageLowPriority = 460 RefPtrWillBeRawPtr<FakeDecodedResource> cachedImageLowPriority =
451 new FakeDecodedResource(ResourceRequest("http://foo.com"), Resource::Raw ); 461 FakeDecodedResource::create(ResourceRequest("http://foo.com"), Resource: :Raw);
452 ResourcePtr<FakeDecodedResource> cachedImageHighPriority = 462 RefPtrWillBeRawPtr<FakeDecodedResource> cachedImageHighPriority =
453 new FakeDecodedResource(ResourceRequest("http://test/resource"), Resourc e::Raw); 463 FakeDecodedResource::create(ResourceRequest("http://test/resource"), Res ource::Raw);
454 TestDecodeCacheOrder(cachedImageLowPriority, cachedImageHighPriority); 464 TestDecodeCacheOrder(cachedImageLowPriority.get(), cachedImageHighPriority.g et());
455 } 465 }
456 466
457 TEST_F(MemoryCacheTest, DecodeCacheOrder_MultipleResourceMaps) 467 TEST_F(MemoryCacheTest, DecodeCacheOrder_MultipleResourceMaps)
458 { 468 {
459 { 469 {
460 ResourcePtr<FakeDecodedResource> cachedImageLowPriority = 470 RefPtrWillBeRawPtr<FakeDecodedResource> cachedImageLowPriority =
461 new FakeDecodedResource(ResourceRequest("http://foo.com"), Resource: :Raw); 471 FakeDecodedResource::create(ResourceRequest("http://foo.com"), Resou rce::Raw);
462 ResourcePtr<FakeDecodedResource> cachedImageHighPriority = 472 RefPtrWillBeRawPtr<FakeDecodedResource> cachedImageHighPriority =
463 new FakeDecodedResource(ResourceRequest("http://test/resource"), Res ource::Raw); 473 FakeDecodedResource::create(ResourceRequest("http://test/resource"), Resource::Raw);
464 cachedImageLowPriority->setCacheIdentifier("foo"); 474 cachedImageLowPriority->setCacheIdentifier("foo");
465 TestDecodeCacheOrder(cachedImageLowPriority, cachedImageHighPriority); 475 TestDecodeCacheOrder(cachedImageLowPriority.get(), cachedImageHighPriori ty.get());
466 memoryCache()->evictResources(); 476 memoryCache()->evictResources();
467 } 477 }
468 { 478 {
469 ResourcePtr<FakeDecodedResource> cachedImageLowPriority = 479 RefPtrWillBeRawPtr<FakeDecodedResource> cachedImageLowPriority =
470 new FakeDecodedResource(ResourceRequest("http://foo.com"), Resource: :Raw); 480 FakeDecodedResource::create(ResourceRequest("http://foo.com"), Resou rce::Raw);
471 ResourcePtr<FakeDecodedResource> cachedImageHighPriority = 481 RefPtrWillBeRawPtr<FakeDecodedResource> cachedImageHighPriority =
472 new FakeDecodedResource(ResourceRequest("http://test/resource"), Res ource::Raw); 482 FakeDecodedResource::create(ResourceRequest("http://test/resource"), Resource::Raw);
473 cachedImageHighPriority->setCacheIdentifier("foo"); 483 cachedImageHighPriority->setCacheIdentifier("foo");
474 TestDecodeCacheOrder(cachedImageLowPriority, cachedImageHighPriority); 484 TestDecodeCacheOrder(cachedImageLowPriority.get(), cachedImageHighPriori ty.get());
475 memoryCache()->evictResources(); 485 memoryCache()->evictResources();
476 } 486 }
477 { 487 {
478 ResourcePtr<FakeDecodedResource> cachedImageLowPriority = 488 RefPtrWillBeRawPtr<FakeDecodedResource> cachedImageLowPriority =
479 new FakeDecodedResource(ResourceRequest("http://test/resource"), Res ource::Raw); 489 FakeDecodedResource::create(ResourceRequest("http://test/resource"), Resource::Raw);
480 cachedImageLowPriority->setCacheIdentifier("foo"); 490 cachedImageLowPriority->setCacheIdentifier("foo");
481 ResourcePtr<FakeDecodedResource> cachedImageHighPriority = 491 RefPtrWillBeRawPtr<FakeDecodedResource> cachedImageHighPriority =
482 new FakeDecodedResource(ResourceRequest("http://test/resource"), Res ource::Raw); 492 FakeDecodedResource::create(ResourceRequest("http://test/resource"), Resource::Raw);
483 cachedImageHighPriority->setCacheIdentifier("bar"); 493 cachedImageHighPriority->setCacheIdentifier("bar");
484 TestDecodeCacheOrder(cachedImageLowPriority, cachedImageHighPriority); 494 TestDecodeCacheOrder(cachedImageLowPriority.get(), cachedImageHighPriori ty.get());
485 memoryCache()->evictResources(); 495 memoryCache()->evictResources();
486 } 496 }
487 } 497 }
488 498
489 TEST_F(MemoryCacheTest, RemoveDuringRevalidation) 499 TEST_F(MemoryCacheTest, RemoveDuringRevalidation)
490 { 500 {
491 ResourcePtr<FakeResource> resource1 = new FakeResource(ResourceRequest("http ://test/resource"), Resource::Raw); 501 RefPtrWillBeRawPtr<FakeResource> resource1 = FakeResource::create(ResourceRe quest("http://test/resource"), Resource::Raw);
492 memoryCache()->add(resource1.get()); 502 memoryCache()->add(resource1.get());
493 503
494 ResourcePtr<FakeResource> resource2 = new FakeResource(ResourceRequest("http ://test/resource"), Resource::Raw); 504 RefPtrWillBeRawPtr<FakeResource> resource2 = FakeResource::create(ResourceRe quest("http://test/resource"), Resource::Raw);
495 memoryCache()->remove(resource1.get()); 505 memoryCache()->remove(resource1.get());
496 memoryCache()->add(resource2.get()); 506 memoryCache()->add(resource2.get());
497 EXPECT_TRUE(memoryCache()->contains(resource2.get())); 507 EXPECT_TRUE(memoryCache()->contains(resource2.get()));
498 EXPECT_FALSE(memoryCache()->contains(resource1.get())); 508 EXPECT_FALSE(memoryCache()->contains(resource1.get()));
499 509
500 ResourcePtr<FakeResource> resource3 = new FakeResource(ResourceRequest("http ://test/resource"), Resource::Raw); 510 RefPtrWillBeRawPtr<FakeResource> resource3 = FakeResource::create(ResourceRe quest("http://test/resource"), Resource::Raw);
501 memoryCache()->remove(resource2.get()); 511 memoryCache()->remove(resource2.get());
502 memoryCache()->add(resource3.get()); 512 memoryCache()->add(resource3.get());
503 EXPECT_TRUE(memoryCache()->contains(resource3.get())); 513 EXPECT_TRUE(memoryCache()->contains(resource3.get()));
504 EXPECT_FALSE(memoryCache()->contains(resource2.get())); 514 EXPECT_FALSE(memoryCache()->contains(resource2.get()));
505 } 515 }
506 516
507 TEST_F(MemoryCacheTest, ResourceMapIsolation) 517 TEST_F(MemoryCacheTest, ResourceMapIsolation)
508 { 518 {
509 ResourcePtr<FakeResource> resource1 = new FakeResource(ResourceRequest("http ://test/resource"), Resource::Raw); 519 RefPtrWillBeRawPtr<FakeResource> resource1 = FakeResource::create(ResourceRe quest("http://test/resource"), Resource::Raw);
510 memoryCache()->add(resource1.get()); 520 memoryCache()->add(resource1.get());
511 521
512 ResourcePtr<FakeResource> resource2 = new FakeResource(ResourceRequest("http ://test/resource"), Resource::Raw); 522 RefPtrWillBeRawPtr<FakeResource> resource2 = FakeResource::create(ResourceRe quest("http://test/resource"), Resource::Raw);
513 resource2->setCacheIdentifier("foo"); 523 resource2->setCacheIdentifier("foo");
514 memoryCache()->add(resource2.get()); 524 memoryCache()->add(resource2.get());
515 EXPECT_TRUE(memoryCache()->contains(resource1.get())); 525 EXPECT_TRUE(memoryCache()->contains(resource1.get()));
516 EXPECT_TRUE(memoryCache()->contains(resource2.get())); 526 EXPECT_TRUE(memoryCache()->contains(resource2.get()));
517 527
518 const KURL url = KURL(ParsedURLString, "http://test/resource"); 528 const KURL url = KURL(ParsedURLString, "http://test/resource");
519 EXPECT_EQ(resource1.get(), memoryCache()->resourceForURL(url)); 529 EXPECT_EQ(resource1.get(), memoryCache()->resourceForURL(url));
520 EXPECT_EQ(resource1.get(), memoryCache()->resourceForURL(url, memoryCache()- >defaultCacheIdentifier())); 530 EXPECT_EQ(resource1.get(), memoryCache()->resourceForURL(url, memoryCache()- >defaultCacheIdentifier()));
521 EXPECT_EQ(resource2.get(), memoryCache()->resourceForURL(url, "foo")); 531 EXPECT_EQ(resource2.get(), memoryCache()->resourceForURL(url, "foo"));
522 EXPECT_EQ(0, memoryCache()->resourceForURL(KURL())); 532 EXPECT_EQ(0, memoryCache()->resourceForURL(KURL()));
523 533
524 ResourcePtr<FakeResource> resource3 = new FakeResource(ResourceRequest("http ://test/resource"), Resource::Raw); 534 RefPtrWillBeRawPtr<FakeResource> resource3 = FakeResource::create(ResourceRe quest("http://test/resource"), Resource::Raw);
525 resource3->setCacheIdentifier("foo"); 535 resource3->setCacheIdentifier("foo");
526 memoryCache()->remove(resource2.get()); 536 memoryCache()->remove(resource2.get());
527 memoryCache()->add(resource3.get()); 537 memoryCache()->add(resource3.get());
528 EXPECT_TRUE(memoryCache()->contains(resource1.get())); 538 EXPECT_TRUE(memoryCache()->contains(resource1.get()));
529 EXPECT_FALSE(memoryCache()->contains(resource2.get())); 539 EXPECT_FALSE(memoryCache()->contains(resource2.get()));
530 EXPECT_TRUE(memoryCache()->contains(resource3.get())); 540 EXPECT_TRUE(memoryCache()->contains(resource3.get()));
531 541
532 WillBeHeapVector<RawPtrWillBeMember<Resource>> resources = memoryCache()->re sourcesForURL(url); 542 WillBeHeapVector<RawPtrWillBeMember<Resource>> resources = memoryCache()->re sourcesForURL(url);
533 EXPECT_EQ(2u, resources.size()); 543 EXPECT_EQ(2u, resources.size());
534 544
535 memoryCache()->evictResources(); 545 memoryCache()->evictResources();
536 EXPECT_FALSE(memoryCache()->contains(resource1.get())); 546 EXPECT_FALSE(memoryCache()->contains(resource1.get()));
537 EXPECT_FALSE(memoryCache()->contains(resource3.get())); 547 EXPECT_FALSE(memoryCache()->contains(resource3.get()));
538 } 548 }
539 549
540 } // namespace blink 550 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/MemoryCache.cpp ('k') | third_party/WebKit/Source/core/fetch/MockImageResourceClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698