| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/fetch/Resource.h" | 5 #include "core/fetch/Resource.h" |
| 6 | 6 |
| 7 #include "core/fetch/MemoryCache.h" | 7 #include "core/fetch/MemoryCache.h" |
| 8 #include "platform/SharedBuffer.h" | 8 #include "platform/SharedBuffer.h" |
| 9 #include "platform/network/ResourceRequest.h" | 9 #include "platform/network/ResourceRequest.h" |
| 10 #include "platform/network/ResourceResponse.h" | 10 #include "platform/network/ResourceResponse.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 UnlockableResource* resource = UnlockableResource::create(response.url()); | 96 UnlockableResource* resource = UnlockableResource::create(response.url()); |
| 97 memoryCache()->add(resource); | 97 memoryCache()->add(resource); |
| 98 resource->setResponse(response); | 98 resource->setResponse(response); |
| 99 | 99 |
| 100 // A Resource won't be put in DiscardableMemory unless it is at least 16KiB. | 100 // A Resource won't be put in DiscardableMemory unless it is at least 16KiB. |
| 101 Vector<char> dataVector(4*4096); | 101 Vector<char> dataVector(4*4096); |
| 102 for (int i = 0; i < 4096; i++) | 102 for (int i = 0; i < 4096; i++) |
| 103 dataVector.append("test", 4); | 103 dataVector.append("test", 4); |
| 104 resource->setResourceBuffer(SharedBuffer::adoptVector(dataVector)); | 104 resource->setResourceBuffer(SharedBuffer::adoptVector(dataVector)); |
| 105 | 105 |
| 106 resource->setLoadFinishTime(currentTime()); | 106 resource->finish(currentTime()); |
| 107 resource->finish(); | |
| 108 resource->prune(); | 107 resource->prune(); |
| 109 ASSERT_TRUE(resource->isPurgeable()); | 108 ASSERT_TRUE(resource->isPurgeable()); |
| 110 bool didLock = resource->lock(); | 109 bool didLock = resource->lock(); |
| 111 ASSERT_FALSE(didLock); | 110 ASSERT_FALSE(didLock); |
| 112 EXPECT_EQ(nullptr, resource->resourceBuffer()); | 111 EXPECT_EQ(nullptr, resource->resourceBuffer()); |
| 113 EXPECT_EQ(size_t(0), resource->encodedSize()); | 112 EXPECT_EQ(size_t(0), resource->encodedSize()); |
| 114 } | 113 } |
| 115 | 114 |
| 116 } // namespace blink | 115 } // namespace blink |
| OLD | NEW |