| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 { | 51 { |
| 52 } | 52 } |
| 53 | 53 |
| 54 virtual void appendData(const char* data, unsigned len) | 54 virtual void appendData(const char* data, unsigned len) |
| 55 { | 55 { |
| 56 Resource::appendData(data, len); | 56 Resource::appendData(data, len); |
| 57 setDecodedSize(this->size()); | 57 setDecodedSize(this->size()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 protected: | 60 protected: |
| 61 virtual void destroyDecodedDataIfPossible() OVERRIDE | 61 virtual void destroyDecodedDataIfPossible() override |
| 62 { | 62 { |
| 63 setDecodedSize(0); | 63 setDecodedSize(0); |
| 64 } | 64 } |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 class FakeResource : public blink::Resource { | 67 class FakeResource : public blink::Resource { |
| 68 public: | 68 public: |
| 69 FakeResource(const ResourceRequest& request, Type type) | 69 FakeResource(const ResourceRequest& request, Type type) |
| 70 : Resource(request, type) | 70 : Resource(request, type) |
| 71 { | 71 { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 cachedLiveResource->addClient(&client); | 186 cachedLiveResource->addClient(&client); |
| 187 cachedLiveResource->appendData(data, 4u); | 187 cachedLiveResource->appendData(data, 4u); |
| 188 | 188 |
| 189 class Task1 : public blink::WebThread::Task { | 189 class Task1 : public blink::WebThread::Task { |
| 190 public: | 190 public: |
| 191 Task1(const ResourcePtr<Resource>& live, Resource* dead) | 191 Task1(const ResourcePtr<Resource>& live, Resource* dead) |
| 192 : m_live(live) | 192 : m_live(live) |
| 193 , m_dead(dead) | 193 , m_dead(dead) |
| 194 { } | 194 { } |
| 195 | 195 |
| 196 virtual void run() OVERRIDE | 196 virtual void run() override |
| 197 { | 197 { |
| 198 // The resource size has to be nonzero for this test to be meaningfu
l, but | 198 // The resource size has to be nonzero for this test to be meaningfu
l, but |
| 199 // we do not rely on it having any particular value. | 199 // we do not rely on it having any particular value. |
| 200 ASSERT_GT(m_live->size(), 0u); | 200 ASSERT_GT(m_live->size(), 0u); |
| 201 ASSERT_GT(m_dead->size(), 0u); | 201 ASSERT_GT(m_dead->size(), 0u); |
| 202 | 202 |
| 203 ASSERT_EQ(0u, memoryCache()->deadSize()); | 203 ASSERT_EQ(0u, memoryCache()->deadSize()); |
| 204 ASSERT_EQ(0u, memoryCache()->liveSize()); | 204 ASSERT_EQ(0u, memoryCache()->liveSize()); |
| 205 | 205 |
| 206 memoryCache()->add(m_dead); | 206 memoryCache()->add(m_dead); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 219 private: | 219 private: |
| 220 ResourcePtr<Resource> m_live; | 220 ResourcePtr<Resource> m_live; |
| 221 Resource* m_dead; | 221 Resource* m_dead; |
| 222 }; | 222 }; |
| 223 | 223 |
| 224 class Task2 : public blink::WebThread::Task { | 224 class Task2 : public blink::WebThread::Task { |
| 225 public: | 225 public: |
| 226 Task2(unsigned liveSizeWithoutDecode) | 226 Task2(unsigned liveSizeWithoutDecode) |
| 227 : m_liveSizeWithoutDecode(liveSizeWithoutDecode) { } | 227 : m_liveSizeWithoutDecode(liveSizeWithoutDecode) { } |
| 228 | 228 |
| 229 virtual void run() OVERRIDE | 229 virtual void run() override |
| 230 { | 230 { |
| 231 // Next task: now, the live resource was evicted. | 231 // Next task: now, the live resource was evicted. |
| 232 ASSERT_EQ(0u, memoryCache()->deadSize()); | 232 ASSERT_EQ(0u, memoryCache()->deadSize()); |
| 233 ASSERT_EQ(m_liveSizeWithoutDecode, memoryCache()->liveSize()); | 233 ASSERT_EQ(m_liveSizeWithoutDecode, memoryCache()->liveSize()); |
| 234 blink::Platform::current()->currentThread()->exitRunLoop(); | 234 blink::Platform::current()->currentThread()->exitRunLoop(); |
| 235 } | 235 } |
| 236 | 236 |
| 237 private: | 237 private: |
| 238 unsigned m_liveSizeWithoutDecode; | 238 unsigned m_liveSizeWithoutDecode; |
| 239 }; | 239 }; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 EXPECT_TRUE(memoryCache()->contains(resource3.get())); | 398 EXPECT_TRUE(memoryCache()->contains(resource3.get())); |
| 399 EXPECT_FALSE(memoryCache()->contains(resource2.get())); | 399 EXPECT_FALSE(memoryCache()->contains(resource2.get())); |
| 400 | 400 |
| 401 memoryCache()->replace(resource1.get(), resource2.get()); | 401 memoryCache()->replace(resource1.get(), resource2.get()); |
| 402 EXPECT_TRUE(memoryCache()->contains(resource1.get())); | 402 EXPECT_TRUE(memoryCache()->contains(resource1.get())); |
| 403 EXPECT_FALSE(memoryCache()->contains(resource2.get())); | 403 EXPECT_FALSE(memoryCache()->contains(resource2.get())); |
| 404 EXPECT_FALSE(memoryCache()->contains(resource3.get())); | 404 EXPECT_FALSE(memoryCache()->contains(resource3.get())); |
| 405 } | 405 } |
| 406 | 406 |
| 407 } // namespace | 407 } // namespace |
| OLD | NEW |