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

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

Issue 1229743005: Fix virtual/override/final usage in Source/core/{fetch,loader,streams,xmlhttprequest}/. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 5 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/fetch/MemoryCache.h ('k') | Source/core/fetch/MockImageResourceClient.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 { 52 {
53 } 53 }
54 54
55 virtual void appendData(const char* data, unsigned len) 55 virtual void appendData(const char* data, unsigned len)
56 { 56 {
57 Resource::appendData(data, len); 57 Resource::appendData(data, len);
58 setDecodedSize(this->size()); 58 setDecodedSize(this->size());
59 } 59 }
60 60
61 protected: 61 protected:
62 virtual void destroyDecodedDataIfPossible() override 62 void destroyDecodedDataIfPossible() override
63 { 63 {
64 setDecodedSize(0); 64 setDecodedSize(0);
65 } 65 }
66 }; 66 };
67 67
68 class FakeResource : public Resource { 68 class FakeResource : public Resource {
69 public: 69 public:
70 FakeResource(const ResourceRequest& request, Type type) 70 FakeResource(const ResourceRequest& request, Type type)
71 : Resource(request, type) 71 : Resource(request, type)
72 { 72 {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 cachedLiveResource->addClient(&client); 205 cachedLiveResource->addClient(&client);
206 cachedLiveResource->appendData(data, 4u); 206 cachedLiveResource->appendData(data, 4u);
207 207
208 class Task1 : public WebThread::Task { 208 class Task1 : public WebThread::Task {
209 public: 209 public:
210 Task1(const ResourcePtr<Resource>& live, Resource* dead) 210 Task1(const ResourcePtr<Resource>& live, Resource* dead)
211 : m_live(live) 211 : m_live(live)
212 , m_dead(dead) 212 , m_dead(dead)
213 { } 213 { }
214 214
215 virtual void run() override 215 void run() override
216 { 216 {
217 // The resource size has to be nonzero for this test to be meaningfu l, but 217 // The resource size has to be nonzero for this test to be meaningfu l, but
218 // we do not rely on it having any particular value. 218 // we do not rely on it having any particular value.
219 ASSERT_GT(m_live->size(), 0u); 219 ASSERT_GT(m_live->size(), 0u);
220 ASSERT_GT(m_dead->size(), 0u); 220 ASSERT_GT(m_dead->size(), 0u);
221 221
222 ASSERT_EQ(0u, memoryCache()->deadSize()); 222 ASSERT_EQ(0u, memoryCache()->deadSize());
223 ASSERT_EQ(0u, memoryCache()->liveSize()); 223 ASSERT_EQ(0u, memoryCache()->liveSize());
224 224
225 memoryCache()->add(m_dead); 225 memoryCache()->add(m_dead);
(...skipping 12 matching lines...) Expand all
238 private: 238 private:
239 ResourcePtr<Resource> m_live; 239 ResourcePtr<Resource> m_live;
240 Resource* m_dead; 240 Resource* m_dead;
241 }; 241 };
242 242
243 class Task2 : public WebThread::Task { 243 class Task2 : public WebThread::Task {
244 public: 244 public:
245 Task2(unsigned liveSizeWithoutDecode) 245 Task2(unsigned liveSizeWithoutDecode)
246 : m_liveSizeWithoutDecode(liveSizeWithoutDecode) { } 246 : m_liveSizeWithoutDecode(liveSizeWithoutDecode) { }
247 247
248 virtual void run() override 248 void run() override
249 { 249 {
250 // Next task: now, the live resource was evicted. 250 // Next task: now, the live resource was evicted.
251 ASSERT_EQ(0u, memoryCache()->deadSize()); 251 ASSERT_EQ(0u, memoryCache()->deadSize());
252 ASSERT_EQ(m_liveSizeWithoutDecode, memoryCache()->liveSize()); 252 ASSERT_EQ(m_liveSizeWithoutDecode, memoryCache()->liveSize());
253 } 253 }
254 254
255 private: 255 private:
256 unsigned m_liveSizeWithoutDecode; 256 unsigned m_liveSizeWithoutDecode;
257 }; 257 };
258 258
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 573
574 WillBeHeapVector<RawPtrWillBeMember<Resource>> resources = memoryCache()->re sourcesForURL(url); 574 WillBeHeapVector<RawPtrWillBeMember<Resource>> resources = memoryCache()->re sourcesForURL(url);
575 EXPECT_EQ(2u, resources.size()); 575 EXPECT_EQ(2u, resources.size());
576 576
577 memoryCache()->evictResources(); 577 memoryCache()->evictResources();
578 EXPECT_FALSE(memoryCache()->contains(resource1.get())); 578 EXPECT_FALSE(memoryCache()->contains(resource1.get()));
579 EXPECT_FALSE(memoryCache()->contains(resource3.get())); 579 EXPECT_FALSE(memoryCache()->contains(resource3.get()));
580 } 580 }
581 581
582 } // namespace 582 } // namespace
OLDNEW
« no previous file with comments | « Source/core/fetch/MemoryCache.h ('k') | Source/core/fetch/MockImageResourceClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698