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

Side by Side Diff: third_party/WebKit/Source/core/fetch/Resource.h

Issue 1976463003: Preload scan external CSS for @import (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase + minor style tweaks 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 /* 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) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 static const int kLastResourceType = Manifest + 1; 80 static const int kLastResourceType = Manifest + 1;
81 81
82 enum Status { 82 enum Status {
83 NotStarted, 83 NotStarted,
84 Pending, // load in progress 84 Pending, // load in progress
85 Cached, // load completed successfully 85 Cached, // load completed successfully
86 LoadError, 86 LoadError,
87 DecodeError 87 DecodeError
88 }; 88 };
89 89
90 // Whether a resource client for a preload should mark the preload as
91 // referenced.
92 enum PreloadReferencePolicy {
93 MarkAsReferenced,
94 DontMarkAsReferenced,
95 };
96
90 // Exposed for testing. 97 // Exposed for testing.
91 static Resource* create(const ResourceRequest& request, Type type, const Res ourceLoaderOptions& options = ResourceLoaderOptions()) 98 static Resource* create(const ResourceRequest& request, Type type, const Res ourceLoaderOptions& options = ResourceLoaderOptions())
92 { 99 {
93 return new Resource(request, type, options); 100 return new Resource(request, type, options);
94 } 101 }
95 virtual ~Resource(); 102 virtual ~Resource();
96 103
97 DECLARE_VIRTUAL_TRACE(); 104 DECLARE_VIRTUAL_TRACE();
98 105
99 virtual void setEncoding(const String&) { } 106 virtual void setEncoding(const String&) { }
(...skipping 25 matching lines...) Expand all
125 132
126 // This url can have a fragment, but it can match resources that differ by t he fragment only. 133 // This url can have a fragment, but it can match resources that differ by t he fragment only.
127 const KURL& url() const { return m_resourceRequest.url();} 134 const KURL& url() const { return m_resourceRequest.url();}
128 Type getType() const { return static_cast<Type>(m_type); } 135 Type getType() const { return static_cast<Type>(m_type); }
129 const ResourceLoaderOptions& options() const { return m_options; } 136 const ResourceLoaderOptions& options() const { return m_options; }
130 ResourceLoaderOptions& mutableOptions() { return m_options; } 137 ResourceLoaderOptions& mutableOptions() { return m_options; }
131 138
132 void didChangePriority(ResourceLoadPriority, int intraPriorityValue); 139 void didChangePriority(ResourceLoadPriority, int intraPriorityValue);
133 virtual ResourcePriority priorityFromObservers() { return ResourcePriority() ; } 140 virtual ResourcePriority priorityFromObservers() { return ResourcePriority() ; }
134 141
135 void addClient(ResourceClient*); 142 // The reference policy indicates that the client should not affect whether
143 // a preload is considered referenced or not. This allows for "passive"
144 // resource clients that simply observe the resource.
145 void addClient(ResourceClient*, PreloadReferencePolicy = MarkAsReferenced);
136 void removeClient(ResourceClient*); 146 void removeClient(ResourceClient*);
137 virtual bool hasClientsOrObservers() const { return !m_clients.isEmpty() || !m_clientsAwaitingCallback.isEmpty() || !m_finishedClients.isEmpty(); } 147 virtual bool hasClientsOrObservers() const { return !m_clients.isEmpty() || !m_clientsAwaitingCallback.isEmpty() || !m_finishedClients.isEmpty(); }
138 148
139 enum PreloadResult { 149 enum PreloadResult {
140 PreloadNotReferenced, 150 PreloadNotReferenced,
141 PreloadReferenced, 151 PreloadReferenced,
142 PreloadReferencedWhileLoading, 152 PreloadReferencedWhileLoading,
143 PreloadReferencedWhileComplete 153 PreloadReferencedWhileComplete
144 }; 154 };
145 PreloadResult getPreloadResult() const { return static_cast<PreloadResult>(m _preloadResult); } 155 PreloadResult getPreloadResult() const { return static_cast<PreloadResult>(m _preloadResult); }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 266
257 virtual void destroyDecodedDataForFailedRevalidation() { } 267 virtual void destroyDecodedDataForFailedRevalidation() { }
258 268
259 void setEncodedSize(size_t); 269 void setEncodedSize(size_t);
260 void setDecodedSize(size_t); 270 void setDecodedSize(size_t);
261 void didAccessDecodedData(); 271 void didAccessDecodedData();
262 272
263 void finishPendingClients(); 273 void finishPendingClients();
264 274
265 virtual void didAddClient(ResourceClient*); 275 virtual void didAddClient(ResourceClient*);
266 void willAddClientOrObserver(); 276 void willAddClientOrObserver(PreloadReferencePolicy);
267 277
268 // |this| object may be dead after didRemoveClientOrObserver(). 278 // |this| object may be dead after didRemoveClientOrObserver().
269 void didRemoveClientOrObserver(); 279 void didRemoveClientOrObserver();
270 virtual void allClientsAndObserversRemoved(); 280 virtual void allClientsAndObserversRemoved();
271 281
272 bool hasClient(ResourceClient* client) { return m_clients.contains(client) | | m_clientsAwaitingCallback.contains(client) || m_finishedClients.contains(clien t); } 282 bool hasClient(ResourceClient* client) { return m_clients.contains(client) | | m_clientsAwaitingCallback.contains(client) || m_finishedClients.contains(clien t); }
273 283
274 struct RedirectPair { 284 struct RedirectPair {
275 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 285 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
276 public: 286 public:
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 389
380 Resource::Type m_type; 390 Resource::Type m_type;
381 }; 391 };
382 392
383 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ 393 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \
384 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType( ) == Resource::typeName, resource.getType() == Resource::typeName); 394 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType( ) == Resource::typeName, resource.getType() == Resource::typeName);
385 395
386 } // namespace blink 396 } // namespace blink
387 397
388 #endif 398 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ImageResource.cpp ('k') | third_party/WebKit/Source/core/fetch/Resource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698