OLD | NEW |
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 memoryCache()->update(imageResource, imageResource->size(), imageResourc
e->size(), false); | 105 memoryCache()->update(imageResource, imageResource->size(), imageResourc
e->size(), false); |
106 if (!memoryCache()->isInSameLRUListForTest(cssResource, imageResource))
{ | 106 if (!memoryCache()->isInSameLRUListForTest(cssResource, imageResource))
{ |
107 // We assume that the LRU list is determined by |size / accessCount|
. | 107 // We assume that the LRU list is determined by |size / accessCount|
. |
108 for (size_t i = 0; i < cssResource->size() + 1; ++i) | 108 for (size_t i = 0; i < cssResource->size() + 1; ++i) |
109 memoryCache()->update(cssResource, cssResource->size(), cssResou
rce->size(), true); | 109 memoryCache()->update(cssResource, cssResource->size(), cssResou
rce->size(), true); |
110 for (size_t i = 0; i < imageResource->size() + 1; ++i) | 110 for (size_t i = 0; i < imageResource->size() + 1; ++i) |
111 memoryCache()->update(imageResource, imageResource->size(), imag
eResource->size(), true); | 111 memoryCache()->update(imageResource, imageResource->size(), imag
eResource->size(), true); |
112 } | 112 } |
113 ASSERT_TRUE(memoryCache()->isInSameLRUListForTest(cssResource, imageReso
urce)); | 113 ASSERT_TRUE(memoryCache()->isInSameLRUListForTest(cssResource, imageReso
urce)); |
114 } | 114 } |
115 ThreadHeap::collectAllGarbage(); | 115 Heap::collectAllGarbage(); |
116 // This operation should not lead to crash! | 116 // This operation should not lead to crash! |
117 memoryCache()->pruneAll(); | 117 memoryCache()->pruneAll(); |
118 } | 118 } |
119 | 119 |
120 TEST_F(CSSStyleSheetResourceTest, DuplicateResourceNotCached) | 120 TEST_F(CSSStyleSheetResourceTest, DuplicateResourceNotCached) |
121 { | 121 { |
122 const char url[] = "https://localhost/style.css"; | 122 const char url[] = "https://localhost/style.css"; |
123 KURL imageURL(KURL(), url); | 123 KURL imageURL(KURL(), url); |
124 KURL cssURL(KURL(), url); | 124 KURL cssURL(KURL(), url); |
125 | 125 |
(...skipping 18 matching lines...) Expand all Loading... |
144 // Verify that the cache will have a mapping for |imageResource| at |url|. | 144 // Verify that the cache will have a mapping for |imageResource| at |url|. |
145 // The underlying |contents| for the stylesheet resource must have a | 145 // The underlying |contents| for the stylesheet resource must have a |
146 // matching cache status. | 146 // matching cache status. |
147 ASSERT_TRUE(memoryCache()->contains(imageResource)); | 147 ASSERT_TRUE(memoryCache()->contains(imageResource)); |
148 ASSERT_FALSE(memoryCache()->contains(cssResource)); | 148 ASSERT_FALSE(memoryCache()->contains(cssResource)); |
149 ASSERT_FALSE(contents->isInMemoryCache()); | 149 ASSERT_FALSE(contents->isInMemoryCache()); |
150 } | 150 } |
151 | 151 |
152 } // namespace | 152 } // namespace |
153 } // namespace blink | 153 } // namespace blink |
OLD | NEW |