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

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

Issue 1928823002: Simplifying finishing a load on Resource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 7 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 // 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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceLoader.cpp ('k') | third_party/WebKit/Source/core/html/ImageDocument.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698