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

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

Issue 1782473002: Check if stylesheet resource was cached before marking it as such. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix non-oilpan compilation Created 4 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/core/css/StyleSheetContents.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
6 Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. 6 Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
(...skipping 10 matching lines...) Expand all
21 Boston, MA 02110-1301, USA. 21 Boston, MA 02110-1301, USA.
22 22
23 This class provides all functionality needed for loading images, style sheet s and html 23 This class provides all functionality needed for loading images, style sheet s and html
24 pages from the web. It has a memory cache for these objects. 24 pages from the web. It has a memory cache for these objects.
25 */ 25 */
26 26
27 #include "core/fetch/CSSStyleSheetResource.h" 27 #include "core/fetch/CSSStyleSheetResource.h"
28 28
29 #include "core/css/StyleSheetContents.h" 29 #include "core/css/StyleSheetContents.h"
30 #include "core/fetch/FetchRequest.h" 30 #include "core/fetch/FetchRequest.h"
31 #include "core/fetch/MemoryCache.h"
31 #include "core/fetch/ResourceClientWalker.h" 32 #include "core/fetch/ResourceClientWalker.h"
32 #include "core/fetch/ResourceFetcher.h" 33 #include "core/fetch/ResourceFetcher.h"
33 #include "core/fetch/StyleSheetResourceClient.h" 34 #include "core/fetch/StyleSheetResourceClient.h"
34 #include "platform/SharedBuffer.h" 35 #include "platform/SharedBuffer.h"
35 #include "wtf/CurrentTime.h" 36 #include "wtf/CurrentTime.h"
36 37
37 namespace blink { 38 namespace blink {
38 39
39 PassRefPtrWillBeRawPtr<CSSStyleSheetResource> CSSStyleSheetResource::fetch(Fetch Request& request, ResourceFetcher* fetcher) 40 PassRefPtrWillBeRawPtr<CSSStyleSheetResource> CSSStyleSheetResource::fetch(Fetch Request& request, ResourceFetcher* fetcher)
40 { 41 {
(...skipping 12 matching lines...) Expand all
53 { 54 {
54 DEFINE_STATIC_LOCAL(const AtomicString, acceptCSS, ("text/css,*/*;q=0.1", At omicString::ConstructFromLiteral)); 55 DEFINE_STATIC_LOCAL(const AtomicString, acceptCSS, ("text/css,*/*;q=0.1", At omicString::ConstructFromLiteral));
55 56
56 // Prefer text/css but accept any type (dell.com serves a stylesheet 57 // Prefer text/css but accept any type (dell.com serves a stylesheet
57 // as text/html; see <http://bugs.webkit.org/show_bug.cgi?id=11451>). 58 // as text/html; see <http://bugs.webkit.org/show_bug.cgi?id=11451>).
58 setAccept(acceptCSS); 59 setAccept(acceptCSS);
59 } 60 }
60 61
61 CSSStyleSheetResource::~CSSStyleSheetResource() 62 CSSStyleSheetResource::~CSSStyleSheetResource()
62 { 63 {
63 // Make sure dispose() was cllaed before destruction.
64 ASSERT(!m_parsedStyleSheetCache);
65 } 64 }
66 65
67 void CSSStyleSheetResource::removedFromMemoryCache() 66 void CSSStyleSheetResource::removedFromMemoryCache()
68 { 67 {
69 if (m_parsedStyleSheetCache) 68 if (m_parsedStyleSheetCache)
70 m_parsedStyleSheetCache->removedFromMemoryCache(); 69 m_parsedStyleSheetCache->removedFromMemoryCache();
71 m_parsedStyleSheetCache.clear(); 70 m_parsedStyleSheetCache.clear();
72 Resource::removedFromMemoryCache(); 71 Resource::removedFromMemoryCache();
73 } 72 }
74 73
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 return m_parsedStyleSheetCache; 172 return m_parsedStyleSheetCache;
174 } 173 }
175 174
176 void CSSStyleSheetResource::saveParsedStyleSheet(PassRefPtrWillBeRawPtr<StyleShe etContents> sheet) 175 void CSSStyleSheetResource::saveParsedStyleSheet(PassRefPtrWillBeRawPtr<StyleShe etContents> sheet)
177 { 176 {
178 ASSERT(sheet && sheet->isCacheable()); 177 ASSERT(sheet && sheet->isCacheable());
179 178
180 if (m_parsedStyleSheetCache) 179 if (m_parsedStyleSheetCache)
181 m_parsedStyleSheetCache->removedFromMemoryCache(); 180 m_parsedStyleSheetCache->removedFromMemoryCache();
182 m_parsedStyleSheetCache = sheet; 181 m_parsedStyleSheetCache = sheet;
183 m_parsedStyleSheetCache->addedToMemoryCache();
184 182
185 setDecodedSize(m_parsedStyleSheetCache->estimatedSizeInBytes()); 183 setDecodedSize(m_parsedStyleSheetCache->estimatedSizeInBytes());
184
185 // Check if this stylesheet resource didn't conflict with
186 // another resource and has indeed been added to the cache.
187 if (memoryCache()->contains(this))
188 m_parsedStyleSheetCache->addedToMemoryCache();
186 } 189 }
187 190
188 } // namespace blink 191 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/StyleSheetContents.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698