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

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

Issue 1738553002: [ABANDONED] Move multipart/x-mixed-replace related code to ImageResource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@multipart-cleanup-2
Patch Set: Created 4 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 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.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. 20 Boston, MA 02110-1301, USA.
21 */ 21 */
22 22
23 #ifndef Resource_h 23 #ifndef Resource_h
24 #define Resource_h 24 #define Resource_h
25 25
26 #include "core/CoreExport.h" 26 #include "core/CoreExport.h"
27 #include "core/fetch/CachedMetadataHandler.h" 27 #include "core/fetch/CachedMetadataHandler.h"
28 #include "core/fetch/MultipartImageResourceParser.h"
29 #include "core/fetch/ResourceLoaderOptions.h" 28 #include "core/fetch/ResourceLoaderOptions.h"
30 #include "platform/Timer.h" 29 #include "platform/Timer.h"
31 #include "platform/network/ResourceError.h" 30 #include "platform/network/ResourceError.h"
32 #include "platform/network/ResourceLoadPriority.h" 31 #include "platform/network/ResourceLoadPriority.h"
33 #include "platform/network/ResourceRequest.h" 32 #include "platform/network/ResourceRequest.h"
34 #include "platform/network/ResourceResponse.h" 33 #include "platform/network/ResourceResponse.h"
35 #include "platform/scheduler/CancellableTaskFactory.h" 34 #include "platform/scheduler/CancellableTaskFactory.h"
36 #include "public/platform/WebDataConsumerHandle.h" 35 #include "public/platform/WebDataConsumerHandle.h"
37 #include "public/platform/WebMemoryDumpProvider.h" 36 #include "public/platform/WebMemoryDumpProvider.h"
38 #include "wtf/Allocator.h" 37 #include "wtf/Allocator.h"
(...skipping 14 matching lines...) Expand all
53 class ResourceFetcher; 52 class ResourceFetcher;
54 class ResourceTimingInfo; 53 class ResourceTimingInfo;
55 class InspectorResource; 54 class InspectorResource;
56 class ResourceLoader; 55 class ResourceLoader;
57 class SecurityOrigin; 56 class SecurityOrigin;
58 class SharedBuffer; 57 class SharedBuffer;
59 58
60 // A resource that is held in the cache. Classes who want to use this object sho uld derive 59 // A resource that is held in the cache. Classes who want to use this object sho uld derive
61 // from ResourceClient, to get the function calls in case the requested data has arrived. 60 // from ResourceClient, to get the function calls in case the requested data has arrived.
62 // This class also does the actual communication with the loader to obtain the r esource from the network. 61 // This class also does the actual communication with the loader to obtain the r esource from the network.
63 class CORE_EXPORT Resource : public RefCountedWillBeGarbageCollectedFinalized<Re source>, public MultipartImageResourceParser::Client { 62 class CORE_EXPORT Resource : public RefCountedWillBeGarbageCollectedFinalized<Re source> {
64 WTF_MAKE_NONCOPYABLE(Resource); 63 WTF_MAKE_NONCOPYABLE(Resource);
65 USING_FAST_MALLOC_WITH_TYPE_NAME_WILL_BE_REMOVED(blink::Resource); 64 USING_FAST_MALLOC_WITH_TYPE_NAME_WILL_BE_REMOVED(blink::Resource);
66 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Resource);
67 friend class InspectorResource; 65 friend class InspectorResource;
68 66
69 public: 67 public:
70 enum Type { 68 enum Type {
71 MainResource, 69 MainResource,
72 Image, 70 Image,
73 CSSStyleSheet, 71 CSSStyleSheet,
74 Script, 72 Script,
75 Font, 73 Font,
76 Raw, 74 Raw,
(...skipping 22 matching lines...) Expand all
99 } 97 }
100 virtual ~Resource(); 98 virtual ~Resource();
101 99
102 virtual void removedFromMemoryCache(); 100 virtual void removedFromMemoryCache();
103 DECLARE_VIRTUAL_TRACE(); 101 DECLARE_VIRTUAL_TRACE();
104 102
105 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&); 103 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&);
106 104
107 virtual void setEncoding(const String&) { } 105 virtual void setEncoding(const String&) { }
108 virtual String encoding() const { return String(); } 106 virtual String encoding() const { return String(); }
109 void appendData(const char*, size_t); 107 virtual void appendData(const char*, size_t);
110 virtual void error(Resource::Status); 108 virtual void error(Resource::Status);
111 virtual void setCORSFailed() { } 109 virtual void setCORSFailed() { }
112 110
113 void setNeedsSynchronousCacheHit(bool needsSynchronousCacheHit) { m_needsSyn chronousCacheHit = needsSynchronousCacheHit; } 111 void setNeedsSynchronousCacheHit(bool needsSynchronousCacheHit) { m_needsSyn chronousCacheHit = needsSynchronousCacheHit; }
114 112
115 void setLinkPreload(bool isLinkPreload) { m_linkPreload = isLinkPreload; } 113 void setLinkPreload(bool isLinkPreload) { m_linkPreload = isLinkPreload; }
116 bool isLinkPreload() const { return m_linkPreload; } 114 bool isLinkPreload() const { return m_linkPreload; }
117 115
118 void setResourceError(const ResourceError& error) { m_error = error; } 116 void setResourceError(const ResourceError& error) { m_error = error; }
119 const ResourceError& resourceError() const { return m_error; } 117 const ResourceError& resourceError() const { return m_error; }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 168
171 ResourceLoader* loader() const { return m_loader.get(); } 169 ResourceLoader* loader() const { return m_loader.get(); }
172 170
173 virtual bool isImage() const { return false; } 171 virtual bool isImage() const { return false; }
174 bool shouldBlockLoadEvent() const; 172 bool shouldBlockLoadEvent() const;
175 bool isLoadEventBlockingResourceType() const; 173 bool isLoadEventBlockingResourceType() const;
176 174
177 // Computes the status of an object after loading. 175 // Computes the status of an object after loading.
178 // Updates the expire date on the cache entry file 176 // Updates the expire date on the cache entry file
179 void setLoadFinishTime(double finishTime) { m_loadFinishTime = finishTime; } 177 void setLoadFinishTime(double finishTime) { m_loadFinishTime = finishTime; }
180 void finish(); 178 virtual void finish();
181 179
182 // FIXME: Remove the stringless variant once all the callsites' error messag es are updated. 180 // FIXME: Remove the stringless variant once all the callsites' error messag es are updated.
183 bool passesAccessControlCheck(SecurityOrigin*) const; 181 bool passesAccessControlCheck(SecurityOrigin*) const;
184 bool passesAccessControlCheck(SecurityOrigin*, String& errorDescription) con st; 182 bool passesAccessControlCheck(SecurityOrigin*, String& errorDescription) con st;
185 183
186 bool isEligibleForIntegrityCheck(SecurityOrigin*) const; 184 bool isEligibleForIntegrityCheck(SecurityOrigin*) const;
187 185
188 void clearLoader(); 186 void clearLoader();
189 187
190 SharedBuffer* resourceBuffer() const { return m_data.get(); } 188 SharedBuffer* resourceBuffer() const { return m_data.get(); }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 void prune(); 251 void prune();
254 252
255 virtual void onMemoryDump(WebMemoryDumpLevelOfDetail, WebProcessMemoryDump*) const; 253 virtual void onMemoryDump(WebMemoryDumpLevelOfDetail, WebProcessMemoryDump*) const;
256 254
257 static const char* resourceTypeToString(Type, const FetchInitiatorInfo&); 255 static const char* resourceTypeToString(Type, const FetchInitiatorInfo&);
258 static const char* resourceTypeName(Type); 256 static const char* resourceTypeName(Type);
259 257
260 // TODO(japhet): Remove once oilpan ships, it doesn't need the WeakPtr. 258 // TODO(japhet): Remove once oilpan ships, it doesn't need the WeakPtr.
261 WeakPtrWillBeRawPtr<Resource> asWeakPtr(); 259 WeakPtrWillBeRawPtr<Resource> asWeakPtr();
262 260
263 bool isMultipartImage() const;
264
265 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK 261 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK
266 void assertAlive() const { RELEASE_ASSERT(!m_deleted); } 262 void assertAlive() const { RELEASE_ASSERT(!m_deleted); }
267 #else 263 #else
268 void assertAlive() const { } 264 void assertAlive() const { }
269 #endif 265 #endif
270 266
271 // MultipartImageResourceParser::Client
272 void didReceiveResponse(const ResourceResponse&) final;
273 void didReceiveData(const char*, size_t) final;
274
275 protected: 267 protected:
276 Resource(const ResourceRequest&, Type); 268 Resource(const ResourceRequest&, Type);
277 269
278 virtual void checkNotify(); 270 virtual void checkNotify();
279 virtual void finishOnePart();
280 271
281 virtual void destroyDecodedDataForFailedRevalidation() { } 272 virtual void destroyDecodedDataForFailedRevalidation() { }
282 virtual void appendDataInternal(const char*, size_t);
283 273
284 void setEncodedSize(size_t); 274 void setEncodedSize(size_t);
285 void setDecodedSize(size_t); 275 void setDecodedSize(size_t);
286 void didAccessDecodedData(); 276 void didAccessDecodedData();
287 277
288 void finishPendingClients(); 278 void finishPendingClients();
289 279
290 HashCountedSet<ResourceClient*> m_clients; 280 HashCountedSet<ResourceClient*> m_clients;
291 HashCountedSet<ResourceClient*> m_clientsAwaitingCallback; 281 HashCountedSet<ResourceClient*> m_clientsAwaitingCallback;
292 HashCountedSet<ResourceClient*> m_finishedClients; 282 HashCountedSet<ResourceClient*> m_finishedClients;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 CachedMetadata* cachedMetadata(unsigned dataTypeID) const; 345 CachedMetadata* cachedMetadata(unsigned dataTypeID) const;
356 346
357 String m_fragmentIdentifierForRequest; 347 String m_fragmentIdentifierForRequest;
358 348
359 #if !ENABLE(OILPAN) 349 #if !ENABLE(OILPAN)
360 WeakPtrFactory<Resource> m_weakPtrFactory; 350 WeakPtrFactory<Resource> m_weakPtrFactory;
361 #endif 351 #endif
362 352
363 RefPtr<CachedMetadata> m_cachedMetadata; 353 RefPtr<CachedMetadata> m_cachedMetadata;
364 OwnPtrWillBeMember<CacheHandler> m_cacheHandler; 354 OwnPtrWillBeMember<CacheHandler> m_cacheHandler;
365 PersistentWillBeMember<MultipartImageResourceParser> m_multipartParser;
366 355
367 ResourceError m_error; 356 ResourceError m_error;
368 357
369 double m_loadFinishTime; 358 double m_loadFinishTime;
370 359
371 unsigned long m_identifier; 360 unsigned long m_identifier;
372 361
373 size_t m_encodedSize; 362 size_t m_encodedSize;
374 size_t m_decodedSize; 363 size_t m_decodedSize;
375 unsigned m_preloadCount; 364 unsigned m_preloadCount;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 Resource::Type m_type; 396 Resource::Type m_type;
408 }; 397 };
409 398
410 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ 399 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \
411 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->type() = = Resource::typeName, resource.type() == Resource::typeName); \ 400 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->type() = = Resource::typeName, resource.type() == Resource::typeName); \
412 inline typeName##Resource* to##typeName##Resource(const RefPtrWillBeRawPtr<R esource>& ptr) { return to##typeName##Resource(ptr.get()); } 401 inline typeName##Resource* to##typeName##Resource(const RefPtrWillBeRawPtr<R esource>& ptr) { return to##typeName##Resource(ptr.get()); }
413 402
414 } // namespace blink 403 } // namespace blink
415 404
416 #endif 405 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698