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

Side by Side Diff: third_party/WebKit/Source/core/css/CSSStyleSheetResourceTest.cpp

Issue 2307003002: Move collectGarbage* methods to ThreadState (Closed)
Patch Set: fix Created 4 years, 3 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/CSSStyleSheetResource.h" 5 #include "core/fetch/CSSStyleSheetResource.h"
6 6
7 #include "core/css/CSSCrossfadeValue.h" 7 #include "core/css/CSSCrossfadeValue.h"
8 #include "core/css/CSSImageValue.h" 8 #include "core/css/CSSImageValue.h"
9 #include "core/css/CSSPrimitiveValue.h" 9 #include "core/css/CSSPrimitiveValue.h"
10 #include "core/css/CSSProperty.h" 10 #include "core/css/CSSProperty.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 memoryCache()->update(imageResource, imageResource->size(), imageResourc e->size(), false); 108 memoryCache()->update(imageResource, imageResource->size(), imageResourc e->size(), false);
109 if (!memoryCache()->isInSameLRUListForTest(cssResource, imageResource)) { 109 if (!memoryCache()->isInSameLRUListForTest(cssResource, imageResource)) {
110 // We assume that the LRU list is determined by |size / accessCount| . 110 // We assume that the LRU list is determined by |size / accessCount| .
111 for (size_t i = 0; i < cssResource->size() + 1; ++i) 111 for (size_t i = 0; i < cssResource->size() + 1; ++i)
112 memoryCache()->update(cssResource, cssResource->size(), cssResou rce->size(), true); 112 memoryCache()->update(cssResource, cssResource->size(), cssResou rce->size(), true);
113 for (size_t i = 0; i < imageResource->size() + 1; ++i) 113 for (size_t i = 0; i < imageResource->size() + 1; ++i)
114 memoryCache()->update(imageResource, imageResource->size(), imag eResource->size(), true); 114 memoryCache()->update(imageResource, imageResource->size(), imag eResource->size(), true);
115 } 115 }
116 ASSERT_TRUE(memoryCache()->isInSameLRUListForTest(cssResource, imageReso urce)); 116 ASSERT_TRUE(memoryCache()->isInSameLRUListForTest(cssResource, imageReso urce));
117 } 117 }
118 ThreadHeap::collectAllGarbage(); 118 ThreadState::current()-> collectAllGarbage();
119 // This operation should not lead to crash! 119 // This operation should not lead to crash!
120 memoryCache()->pruneAll(); 120 memoryCache()->pruneAll();
121 } 121 }
122 122
123 TEST_F(CSSStyleSheetResourceTest, DuplicateResourceNotCached) 123 TEST_F(CSSStyleSheetResourceTest, DuplicateResourceNotCached)
124 { 124 {
125 const char url[] = "https://localhost/style.css"; 125 const char url[] = "https://localhost/style.css";
126 KURL imageURL(KURL(), url); 126 KURL imageURL(KURL(), url);
127 KURL cssURL(KURL(), url); 127 KURL cssURL(KURL(), url);
128 128
(...skipping 20 matching lines...) Expand all
149 // The underlying |contents| for the stylesheet resource must have a 149 // The underlying |contents| for the stylesheet resource must have a
150 // matching reference status. 150 // matching reference status.
151 EXPECT_TRUE(memoryCache()->contains(imageResource)); 151 EXPECT_TRUE(memoryCache()->contains(imageResource));
152 EXPECT_FALSE(memoryCache()->contains(cssResource)); 152 EXPECT_FALSE(memoryCache()->contains(cssResource));
153 EXPECT_FALSE(contents->isReferencedFromResource()); 153 EXPECT_FALSE(contents->isReferencedFromResource());
154 EXPECT_FALSE(cssResource->restoreParsedStyleSheet(parserContext)); 154 EXPECT_FALSE(cssResource->restoreParsedStyleSheet(parserContext));
155 } 155 }
156 156
157 } // namespace 157 } // namespace
158 } // namespace blink 158 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698