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

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

Issue 2642383003: Replace Resource::Status with ResourceStatus (Closed)
Patch Set: Rebase. Created 3 years, 10 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 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
6 rights reserved. 6 rights reserved.
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 XSLStyleSheet, 79 XSLStyleSheet,
80 LinkPrefetch, 80 LinkPrefetch,
81 TextTrack, 81 TextTrack,
82 ImportResource, 82 ImportResource,
83 Media, // Audio or video file requested by a HTML5 media element 83 Media, // Audio or video file requested by a HTML5 media element
84 Manifest, 84 Manifest,
85 Mock // Only for testing 85 Mock // Only for testing
86 }; 86 };
87 static const int kLastResourceType = Mock + 1; 87 static const int kLastResourceType = Mock + 1;
88 88
89 using Status = ResourceStatus;
90
91 // TODO(hiroshige): Remove the following declarations.
92 static constexpr Status NotStarted = ResourceStatus::NotStarted;
93 static constexpr Status Pending = ResourceStatus::Pending;
94 static constexpr Status Cached = ResourceStatus::Cached;
95 static constexpr Status LoadError = ResourceStatus::LoadError;
96 static constexpr Status DecodeError = ResourceStatus::DecodeError;
97
98 // Whether a resource client for a preload should mark the preload as 89 // Whether a resource client for a preload should mark the preload as
99 // referenced. 90 // referenced.
100 enum PreloadReferencePolicy { 91 enum PreloadReferencePolicy {
101 MarkAsReferenced, 92 MarkAsReferenced,
102 DontMarkAsReferenced, 93 DontMarkAsReferenced,
103 }; 94 };
104 95
105 // Used by reloadIfLoFiOrPlaceholderImage(). 96 // Used by reloadIfLoFiOrPlaceholderImage().
106 enum ReloadLoFiOrPlaceholderPolicy { 97 enum ReloadLoFiOrPlaceholderPolicy {
107 kReloadIfNeeded, 98 kReloadIfNeeded,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 void removeClient(ResourceClient*); 156 void removeClient(ResourceClient*);
166 157
167 enum PreloadResult { 158 enum PreloadResult {
168 PreloadNotReferenced, 159 PreloadNotReferenced,
169 PreloadReferenced, 160 PreloadReferenced,
170 PreloadReferencedWhileLoading, 161 PreloadReferencedWhileLoading,
171 PreloadReferencedWhileComplete 162 PreloadReferencedWhileComplete
172 }; 163 };
173 PreloadResult getPreloadResult() const { return m_preloadResult; } 164 PreloadResult getPreloadResult() const { return m_preloadResult; }
174 165
175 Status getStatus() const { return m_status; } 166 ResourceStatus getStatus() const { return m_status; }
176 void setStatus(Status status) { m_status = status; } 167 void setStatus(ResourceStatus status) { m_status = status; }
177 168
178 size_t size() const { return encodedSize() + decodedSize() + overheadSize(); } 169 size_t size() const { return encodedSize() + decodedSize() + overheadSize(); }
179 170
180 // Returns the size of content (response body) before decoding. Adding a new 171 // Returns the size of content (response body) before decoding. Adding a new
181 // usage of this function is not recommended (See the TODO below). 172 // usage of this function is not recommended (See the TODO below).
182 // 173 //
183 // TODO(hiroshige): Now encodedSize/decodedSize states are inconsistent and 174 // TODO(hiroshige): Now encodedSize/decodedSize states are inconsistent and
184 // need to be refactored (crbug/643135). 175 // need to be refactored (crbug/643135).
185 size_t encodedSize() const { return m_encodedSize; } 176 size_t encodedSize() const { return m_encodedSize; }
186 177
187 // Returns the current memory usage for the encoded data. Adding a new usage 178 // Returns the current memory usage for the encoded data. Adding a new usage
188 // of this function is not recommended as the same reason as |encodedSize()|. 179 // of this function is not recommended as the same reason as |encodedSize()|.
189 // 180 //
190 // |encodedSize()| and |encodedSizeMemoryUsageForTesting()| can return 181 // |encodedSize()| and |encodedSizeMemoryUsageForTesting()| can return
191 // different values, e.g., when ImageResource purges encoded image data after 182 // different values, e.g., when ImageResource purges encoded image data after
192 // finishing loading. 183 // finishing loading.
193 size_t encodedSizeMemoryUsageForTesting() const { 184 size_t encodedSizeMemoryUsageForTesting() const {
194 return m_encodedSizeMemoryUsage; 185 return m_encodedSizeMemoryUsage;
195 } 186 }
196 187
197 size_t decodedSize() const { return m_decodedSize; } 188 size_t decodedSize() const { return m_decodedSize; }
198 size_t overheadSize() const { return m_overheadSize; } 189 size_t overheadSize() const { return m_overheadSize; }
199 190
200 bool isLoaded() const { return m_status > Pending; } 191 bool isLoaded() const { return m_status > ResourceStatus::Pending; }
201 192
202 bool isLoading() const { return m_status == Pending; } 193 bool isLoading() const { return m_status == ResourceStatus::Pending; }
203 bool stillNeedsLoad() const { return m_status < Pending; } 194 bool stillNeedsLoad() const { return m_status < ResourceStatus::Pending; }
204 195
205 void setLoader(ResourceLoader*); 196 void setLoader(ResourceLoader*);
206 ResourceLoader* loader() const { return m_loader.get(); } 197 ResourceLoader* loader() const { return m_loader.get(); }
207 198
208 virtual bool isImage() const { return false; } 199 virtual bool isImage() const { return false; }
209 bool shouldBlockLoadEvent() const; 200 bool shouldBlockLoadEvent() const;
210 bool isLoadEventBlockingResourceType() const; 201 bool isLoadEventBlockingResourceType() const;
211 202
212 // Computes the status of an object after loading. Updates the expire date on 203 // Computes the status of an object after loading. Updates the expire date on
213 // the cache entry file 204 // the cache entry file
(...skipping 24 matching lines...) Expand all
238 // Sets the serialized metadata retrieved from the platform's cache. 229 // Sets the serialized metadata retrieved from the platform's cache.
239 virtual void setSerializedCachedMetadata(const char*, size_t); 230 virtual void setSerializedCachedMetadata(const char*, size_t);
240 231
241 // This may return nullptr when the resource isn't cacheable. 232 // This may return nullptr when the resource isn't cacheable.
242 CachedMetadataHandler* cacheHandler(); 233 CachedMetadataHandler* cacheHandler();
243 234
244 AtomicString httpContentType() const; 235 AtomicString httpContentType() const;
245 236
246 bool wasCanceled() const { return m_error.isCancellation(); } 237 bool wasCanceled() const { return m_error.isCancellation(); }
247 bool errorOccurred() const { 238 bool errorOccurred() const {
248 return m_status == LoadError || m_status == DecodeError; 239 return m_status == ResourceStatus::LoadError ||
240 m_status == ResourceStatus::DecodeError;
249 } 241 }
250 bool loadFailedOrCanceled() const { return !m_error.isNull(); } 242 bool loadFailedOrCanceled() const { return !m_error.isNull(); }
251 243
252 DataBufferingPolicy getDataBufferingPolicy() const { 244 DataBufferingPolicy getDataBufferingPolicy() const {
253 return m_options.dataBufferingPolicy; 245 return m_options.dataBufferingPolicy;
254 } 246 }
255 void setDataBufferingPolicy(DataBufferingPolicy); 247 void setDataBufferingPolicy(DataBufferingPolicy);
256 248
257 // The isPreloaded() flag is using a counter in order to make sure that even 249 // The isPreloaded() flag is using a counter in order to make sure that even
258 // when multiple ResourceFetchers are preloading the resource, it will remain 250 // when multiple ResourceFetchers are preloading the resource, it will remain
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 const size_t m_overheadSize; 447 const size_t m_overheadSize;
456 448
457 unsigned m_preloadCount; 449 unsigned m_preloadCount;
458 450
459 double m_preloadDiscoveryTime; 451 double m_preloadDiscoveryTime;
460 452
461 String m_cacheIdentifier; 453 String m_cacheIdentifier;
462 454
463 PreloadResult m_preloadResult; 455 PreloadResult m_preloadResult;
464 Type m_type; 456 Type m_type;
465 Status m_status; 457 ResourceStatus m_status;
466 458
467 bool m_needsSynchronousCacheHit; 459 bool m_needsSynchronousCacheHit;
468 bool m_linkPreload; 460 bool m_linkPreload;
469 bool m_isRevalidating; 461 bool m_isRevalidating;
470 bool m_isAlive; 462 bool m_isAlive;
471 bool m_isAddRemoveClientProhibited; 463 bool m_isAddRemoveClientProhibited;
472 bool m_isRevalidationStartForbidden = false; 464 bool m_isRevalidationStartForbidden = false;
473 465
474 ResourceIntegrityDisposition m_integrityDisposition; 466 ResourceIntegrityDisposition m_integrityDisposition;
475 IntegrityMetadataSet m_integrityMetadata; 467 IntegrityMetadataSet m_integrityMetadata;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 }; 502 };
511 503
512 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ 504 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \
513 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, \ 505 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, \
514 resource->getType() == Resource::typeName, \ 506 resource->getType() == Resource::typeName, \
515 resource.getType() == Resource::typeName); 507 resource.getType() == Resource::typeName);
516 508
517 } // namespace blink 509 } // namespace blink
518 510
519 #endif 511 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698