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