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

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

Issue 1710733002: Move multipart resource handling to core/fetch (2/2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@multipart-cleanup
Patch Set: rebase 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
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"
28 #include "core/fetch/ResourceLoaderOptions.h" 29 #include "core/fetch/ResourceLoaderOptions.h"
29 #include "platform/Timer.h" 30 #include "platform/Timer.h"
30 #include "platform/network/ResourceError.h" 31 #include "platform/network/ResourceError.h"
31 #include "platform/network/ResourceLoadPriority.h" 32 #include "platform/network/ResourceLoadPriority.h"
32 #include "platform/network/ResourceRequest.h" 33 #include "platform/network/ResourceRequest.h"
33 #include "platform/network/ResourceResponse.h" 34 #include "platform/network/ResourceResponse.h"
34 #include "platform/scheduler/CancellableTaskFactory.h" 35 #include "platform/scheduler/CancellableTaskFactory.h"
35 #include "public/platform/WebDataConsumerHandle.h" 36 #include "public/platform/WebDataConsumerHandle.h"
36 #include "public/platform/WebMemoryDumpProvider.h" 37 #include "public/platform/WebMemoryDumpProvider.h"
37 #include "wtf/Allocator.h" 38 #include "wtf/Allocator.h"
(...skipping 14 matching lines...) Expand all
52 class ResourceFetcher; 53 class ResourceFetcher;
53 class ResourceTimingInfo; 54 class ResourceTimingInfo;
54 class InspectorResource; 55 class InspectorResource;
55 class ResourceLoader; 56 class ResourceLoader;
56 class SecurityOrigin; 57 class SecurityOrigin;
57 class SharedBuffer; 58 class SharedBuffer;
58 59
59 // A resource that is held in the cache. Classes who want to use this object sho uld derive 60 // A resource that is held in the cache. Classes who want to use this object sho uld derive
60 // from ResourceClient, to get the function calls in case the requested data has arrived. 61 // from ResourceClient, to get the function calls in case the requested data has arrived.
61 // This class also does the actual communication with the loader to obtain the r esource from the network. 62 // This class also does the actual communication with the loader to obtain the r esource from the network.
62 class CORE_EXPORT Resource : public RefCountedWillBeGarbageCollectedFinalized<Re source> { 63 class CORE_EXPORT Resource : public RefCountedWillBeGarbageCollectedFinalized<Re source>, public MultipartImageResourceParser::Client {
Nate Chapin 2016/02/25 22:07:53 We should at least take a look at weather we can m
yhirano 2016/02/27 01:27:45 It's not possible at this moment because ImageDocu
63 WTF_MAKE_NONCOPYABLE(Resource); 64 WTF_MAKE_NONCOPYABLE(Resource);
64 USING_FAST_MALLOC_WITH_TYPE_NAME_WILL_BE_REMOVED(blink::Resource); 65 USING_FAST_MALLOC_WITH_TYPE_NAME_WILL_BE_REMOVED(blink::Resource);
66 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Resource);
65 friend class InspectorResource; 67 friend class InspectorResource;
66 68
67 public: 69 public:
68 enum Type { 70 enum Type {
69 MainResource, 71 MainResource,
70 Image, 72 Image,
71 CSSStyleSheet, 73 CSSStyleSheet,
72 Script, 74 Script,
73 Font, 75 Font,
74 Raw, 76 Raw,
(...skipping 22 matching lines...) Expand all
97 } 99 }
98 virtual ~Resource(); 100 virtual ~Resource();
99 101
100 virtual void removedFromMemoryCache(); 102 virtual void removedFromMemoryCache();
101 DECLARE_VIRTUAL_TRACE(); 103 DECLARE_VIRTUAL_TRACE();
102 104
103 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&); 105 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&);
104 106
105 virtual void setEncoding(const String&) { } 107 virtual void setEncoding(const String&) { }
106 virtual String encoding() const { return String(); } 108 virtual String encoding() const { return String(); }
107 virtual void appendData(const char*, size_t); 109 void appendData(const char*, size_t);
108 virtual void error(Resource::Status); 110 virtual void error(Resource::Status);
109 virtual void setCORSFailed() { } 111 virtual void setCORSFailed() { }
110 112
111 void setNeedsSynchronousCacheHit(bool needsSynchronousCacheHit) { m_needsSyn chronousCacheHit = needsSynchronousCacheHit; } 113 void setNeedsSynchronousCacheHit(bool needsSynchronousCacheHit) { m_needsSyn chronousCacheHit = needsSynchronousCacheHit; }
112 114
113 void setLinkPreload(bool isLinkPreload) { m_linkPreload = isLinkPreload; } 115 void setLinkPreload(bool isLinkPreload) { m_linkPreload = isLinkPreload; }
114 bool isLinkPreload() const { return m_linkPreload; } 116 bool isLinkPreload() const { return m_linkPreload; }
115 117
116 void setResourceError(const ResourceError& error) { m_error = error; } 118 void setResourceError(const ResourceError& error) { m_error = error; }
117 const ResourceError& resourceError() const { return m_error; } 119 const ResourceError& resourceError() const { return m_error; }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 void prune(); 253 void prune();
252 254
253 virtual void onMemoryDump(WebMemoryDumpLevelOfDetail, WebProcessMemoryDump*) const; 255 virtual void onMemoryDump(WebMemoryDumpLevelOfDetail, WebProcessMemoryDump*) const;
254 256
255 static const char* resourceTypeToString(Type, const FetchInitiatorInfo&); 257 static const char* resourceTypeToString(Type, const FetchInitiatorInfo&);
256 static const char* resourceTypeName(Type); 258 static const char* resourceTypeName(Type);
257 259
258 // TODO(japhet): Remove once oilpan ships, it doesn't need the WeakPtr. 260 // TODO(japhet): Remove once oilpan ships, it doesn't need the WeakPtr.
259 WeakPtrWillBeRawPtr<Resource> asWeakPtr(); 261 WeakPtrWillBeRawPtr<Resource> asWeakPtr();
260 262
263 bool isMultipartImage() const;
264
261 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK 265 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK
262 void assertAlive() const { RELEASE_ASSERT(!m_deleted); } 266 void assertAlive() const { RELEASE_ASSERT(!m_deleted); }
263 #else 267 #else
264 void assertAlive() const { } 268 void assertAlive() const { }
265 #endif 269 #endif
266 270
271 // MultipartImageResourceParser::Client
272 void didReceiveResponse(const ResourceResponse&) final;
273 void didReceiveData(const char*, size_t) final;
274
267 protected: 275 protected:
268 Resource(const ResourceRequest&, Type); 276 Resource(const ResourceRequest&, Type);
269 277
270 virtual void checkNotify(); 278 virtual void checkNotify();
271 virtual void finishOnePart(); 279 virtual void finishOnePart();
272 280
273 virtual void destroyDecodedDataForFailedRevalidation() { } 281 virtual void destroyDecodedDataForFailedRevalidation() { }
282 virtual void appendDataInternal(const char*, size_t);
274 283
275 void setEncodedSize(size_t); 284 void setEncodedSize(size_t);
276 void setDecodedSize(size_t); 285 void setDecodedSize(size_t);
277 void didAccessDecodedData(); 286 void didAccessDecodedData();
278 287
279 void finishPendingClients(); 288 void finishPendingClients();
280 289
281 HashCountedSet<ResourceClient*> m_clients; 290 HashCountedSet<ResourceClient*> m_clients;
282 HashCountedSet<ResourceClient*> m_clientsAwaitingCallback; 291 HashCountedSet<ResourceClient*> m_clientsAwaitingCallback;
283 HashCountedSet<ResourceClient*> m_finishedClients; 292 HashCountedSet<ResourceClient*> m_finishedClients;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 CachedMetadata* cachedMetadata(unsigned dataTypeID) const; 355 CachedMetadata* cachedMetadata(unsigned dataTypeID) const;
347 356
348 String m_fragmentIdentifierForRequest; 357 String m_fragmentIdentifierForRequest;
349 358
350 #if !ENABLE(OILPAN) 359 #if !ENABLE(OILPAN)
351 WeakPtrFactory<Resource> m_weakPtrFactory; 360 WeakPtrFactory<Resource> m_weakPtrFactory;
352 #endif 361 #endif
353 362
354 RefPtr<CachedMetadata> m_cachedMetadata; 363 RefPtr<CachedMetadata> m_cachedMetadata;
355 OwnPtrWillBeMember<CacheHandler> m_cacheHandler; 364 OwnPtrWillBeMember<CacheHandler> m_cacheHandler;
365 PersistentWillBeMember<MultipartImageResourceParser> m_multipartParser;
356 366
357 ResourceError m_error; 367 ResourceError m_error;
358 368
359 double m_loadFinishTime; 369 double m_loadFinishTime;
360 370
361 unsigned long m_identifier; 371 unsigned long m_identifier;
362 372
363 size_t m_encodedSize; 373 size_t m_encodedSize;
364 size_t m_decodedSize; 374 size_t m_decodedSize;
365 unsigned m_preloadCount; 375 unsigned m_preloadCount;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 Resource::Type m_type; 407 Resource::Type m_type;
398 }; 408 };
399 409
400 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ 410 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \
401 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->type() = = Resource::typeName, resource.type() == Resource::typeName); \ 411 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->type() = = Resource::typeName, resource.type() == Resource::typeName); \
402 inline typeName##Resource* to##typeName##Resource(const RefPtrWillBeRawPtr<R esource>& ptr) { return to##typeName##Resource(ptr.get()); } 412 inline typeName##Resource* to##typeName##Resource(const RefPtrWillBeRawPtr<R esource>& ptr) { return to##typeName##Resource(ptr.get()); }
403 413
404 } // namespace blink 414 } // namespace blink
405 415
406 #endif 416 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698