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

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

Issue 1889973002: Refactoring starting a resource load (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 28 matching lines...) Expand all
39 #include "wtf/HashSet.h" 39 #include "wtf/HashSet.h"
40 #include "wtf/OwnPtr.h" 40 #include "wtf/OwnPtr.h"
41 #include "wtf/text/WTFString.h" 41 #include "wtf/text/WTFString.h"
42 42
43 namespace blink { 43 namespace blink {
44 44
45 struct FetchInitiatorInfo; 45 struct FetchInitiatorInfo;
46 class CachedMetadata; 46 class CachedMetadata;
47 class FetchRequest; 47 class FetchRequest;
48 class ResourceClient; 48 class ResourceClient;
49 class ResourceFetcher;
50 class ResourceTimingInfo; 49 class ResourceTimingInfo;
51 class ResourceLoader; 50 class ResourceLoader;
52 class SecurityOrigin; 51 class SecurityOrigin;
53 class SharedBuffer; 52 class SharedBuffer;
54 53
55 // A resource that is held in the cache. Classes who want to use this object sho uld derive 54 // A resource that is held in the cache. Classes who want to use this object sho uld derive
56 // from ResourceClient, to get the function calls in case the requested data has arrived. 55 // from ResourceClient, to get the function calls in case the requested data has arrived.
57 // This class also does the actual communication with the loader to obtain the r esource from the network. 56 // This class also does the actual communication with the loader to obtain the r esource from the network.
58 class CORE_EXPORT Resource : public GarbageCollectedFinalized<Resource> { 57 class CORE_EXPORT Resource : public GarbageCollectedFinalized<Resource> {
59 WTF_MAKE_NONCOPYABLE(Resource); 58 WTF_MAKE_NONCOPYABLE(Resource);
(...skipping 26 matching lines...) Expand all
86 // Exposed for testing. 85 // Exposed for testing.
87 static Resource* create(const ResourceRequest& request, Type type, const Res ourceLoaderOptions& options = ResourceLoaderOptions()) 86 static Resource* create(const ResourceRequest& request, Type type, const Res ourceLoaderOptions& options = ResourceLoaderOptions())
88 { 87 {
89 return new Resource(request, type, options); 88 return new Resource(request, type, options);
90 } 89 }
91 virtual ~Resource(); 90 virtual ~Resource();
92 91
93 virtual void removedFromMemoryCache(); 92 virtual void removedFromMemoryCache();
94 DECLARE_VIRTUAL_TRACE(); 93 DECLARE_VIRTUAL_TRACE();
95 94
96 void load(ResourceFetcher*);
97
98 virtual void setEncoding(const String&) { } 95 virtual void setEncoding(const String&) { }
99 virtual String encoding() const { return String(); } 96 virtual String encoding() const { return String(); }
100 virtual void appendData(const char*, size_t); 97 virtual void appendData(const char*, size_t);
101 virtual void error(Resource::Status); 98 virtual void error(Resource::Status);
102 virtual void setCORSFailed() { } 99 virtual void setCORSFailed() { }
103 100
104 void setNeedsSynchronousCacheHit(bool needsSynchronousCacheHit) { m_needsSyn chronousCacheHit = needsSynchronousCacheHit; } 101 void setNeedsSynchronousCacheHit(bool needsSynchronousCacheHit) { m_needsSyn chronousCacheHit = needsSynchronousCacheHit; }
105 102
106 void setLinkPreload(bool isLinkPreload) { m_linkPreload = isLinkPreload; } 103 void setLinkPreload(bool isLinkPreload) { m_linkPreload = isLinkPreload; }
107 bool isLinkPreload() const { return m_linkPreload; } 104 bool isLinkPreload() const { return m_linkPreload; }
108 105
109 void setResourceError(const ResourceError& error) { m_error = error; } 106 void setResourceError(const ResourceError& error) { m_error = error; }
110 const ResourceError& resourceError() const { return m_error; } 107 const ResourceError& resourceError() const { return m_error; }
111 108
112 void setIdentifier(unsigned long identifier) { m_identifier = identifier; } 109 void setIdentifier(unsigned long identifier) { m_identifier = identifier; }
113 unsigned long identifier() const { return m_identifier; } 110 unsigned long identifier() const { return m_identifier; }
114 111
115 virtual bool shouldIgnoreHTTPStatusCodeErrors() const { return false; } 112 virtual bool shouldIgnoreHTTPStatusCodeErrors() const { return false; }
116 113
114 ResourceRequest& prepareRequestForLoadStart();
117 const ResourceRequest& resourceRequest() const { return m_resourceRequest; } 115 const ResourceRequest& resourceRequest() const { return m_resourceRequest; }
118 const ResourceRequest& lastResourceRequest() const; 116 const ResourceRequest& lastResourceRequest() const;
119 117
120 void setRevalidatingRequest(const ResourceRequest&); 118 void setRevalidatingRequest(const ResourceRequest&);
121 119
122 // This url can have a fragment, but it can match resources that differ by t he fragment only. 120 // This url can have a fragment, but it can match resources that differ by t he fragment only.
123 const KURL& url() const { return m_resourceRequest.url();} 121 const KURL& url() const { return m_resourceRequest.url();}
124 Type getType() const { return static_cast<Type>(m_type); } 122 Type getType() const { return static_cast<Type>(m_type); }
125 const ResourceLoaderOptions& options() const { return m_options; } 123 const ResourceLoaderOptions& options() const { return m_options; }
126 ResourceLoaderOptions& mutableOptions() { return m_options; } 124 ResourceLoaderOptions& mutableOptions() { return m_options; }
(...skipping 21 matching lines...) Expand all
148 size_t size() const { return encodedSize() + decodedSize() + overheadSize(); } 146 size_t size() const { return encodedSize() + decodedSize() + overheadSize(); }
149 size_t encodedSize() const { return m_encodedSize; } 147 size_t encodedSize() const { return m_encodedSize; }
150 size_t decodedSize() const { return m_decodedSize; } 148 size_t decodedSize() const { return m_decodedSize; }
151 size_t overheadSize() const { return m_overheadSize; } 149 size_t overheadSize() const { return m_overheadSize; }
152 150
153 bool isLoaded() const { return m_status > Pending; } 151 bool isLoaded() const { return m_status > Pending; }
154 152
155 bool isLoading() const { return m_status == Pending; } 153 bool isLoading() const { return m_status == Pending; }
156 bool stillNeedsLoad() const { return m_status < Pending; } 154 bool stillNeedsLoad() const { return m_status < Pending; }
157 155
156 void setLoader(ResourceLoader* loader) { m_loader = loader; }
158 ResourceLoader* loader() const { return m_loader.get(); } 157 ResourceLoader* loader() const { return m_loader.get(); }
159 158
160 virtual bool isImage() const { return false; } 159 virtual bool isImage() const { return false; }
161 bool shouldBlockLoadEvent() const; 160 bool shouldBlockLoadEvent() const;
162 bool isLoadEventBlockingResourceType() const; 161 bool isLoadEventBlockingResourceType() const;
163 162
164 // Computes the status of an object after loading. 163 // Computes the status of an object after loading.
165 // Updates the expire date on the cache entry file 164 // Updates the expire date on the cache entry file
166 void setLoadFinishTime(double finishTime) { m_loadFinishTime = finishTime; } 165 void setLoadFinishTime(double finishTime) { m_loadFinishTime = finishTime; }
167 virtual void finish(); 166 virtual void finish();
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 363
365 Resource::Type m_type; 364 Resource::Type m_type;
366 }; 365 };
367 366
368 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ 367 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \
369 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType( ) == Resource::typeName, resource.getType() == Resource::typeName); 368 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType( ) == Resource::typeName, resource.getType() == Resource::typeName);
370 369
371 } // namespace blink 370 } // namespace blink
372 371
373 #endif 372 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698