Changeset 173272 in webkit
- Timestamp:
- Sep 4, 2014, 1:00:11 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r173268 r173272 1 2014-09-04 Antti Koivisto <antti@apple.com> 2 3 Remove ResourceResponse::m_suggestedFilename 4 https://bugs.webkit.org/show_bug.cgi?id=136534 5 6 Reviewed by Alexey Proskuryakov. 7 8 This will simplify things. 9 10 * WebCore.exp.in: 11 * loader/DocumentLoader.cpp: 12 (WebCore::DocumentLoader::handleSubstituteDataLoadNow): 13 (WebCore::DocumentLoader::maybeLoadEmpty): 14 * loader/FrameLoader.cpp: 15 (WebCore::FrameLoader::willLoadMediaElementURL): 16 * loader/appcache/ApplicationCacheStorage.cpp: 17 (WebCore::ApplicationCacheStorage::loadCache): 18 * loader/archive/ArchiveResource.cpp: 19 (WebCore::ArchiveResource::create): 20 * platform/network/BlobResourceHandle.cpp: 21 (WebCore::BlobResourceHandle::notifyResponseOnSuccess): 22 (WebCore::BlobResourceHandle::notifyResponseOnError): 23 * platform/network/ResourceResponseBase.cpp: 24 (WebCore::ResourceResponseBase::ResourceResponseBase): 25 (WebCore::ResourceResponseBase::adopt): 26 (WebCore::ResourceResponseBase::copyData): 27 (WebCore::ResourceResponseBase::suggestedFilename): 28 (WebCore::ResourceResponseBase::httpStatusText): 29 (WebCore::ResourceResponseBase::setHTTPStatusText): 30 (WebCore::ResourceResponseBase::httpHeaderField): 31 (WebCore::ResourceResponseBase::setHTTPHeaderField): 32 (WebCore::ResourceResponseBase::addHTTPHeaderField): 33 (WebCore::ResourceResponseBase::httpHeaderFields): 34 (WebCore::ResourceResponseBase::isAttachment): 35 (WebCore::ResourceResponseBase::wasCached): 36 (WebCore::ResourceResponseBase::connectionReused): 37 (WebCore::ResourceResponseBase::setConnectionReused): 38 (WebCore::ResourceResponseBase::connectionID): 39 (WebCore::ResourceResponseBase::setConnectionID): 40 41 Remove AllFields initialization. It was only used to get m_suggestedFilename. 42 Rename CommonAndUncommonFields to AllFields 43 44 (WebCore::ResourceResponseBase::setSuggestedFilename): Deleted. 45 46 No more setter. 47 48 * platform/network/ResourceResponseBase.h: 49 (WebCore::ResourceResponseBase::platformSuggestedFileName): 50 51 Get the suggested filename from the platform class on-demand. 52 53 * platform/network/cf/ResourceResponse.h: 54 (WebCore::ResourceResponse::ResourceResponse): 55 56 Remove never-used file name constructor parameter. 57 58 * platform/network/cf/ResourceResponseCFNet.cpp: 59 (WebCore::ResourceResponse::platformLazyInit): 60 * platform/network/mac/ResourceResponseMac.mm: 61 (WebCore::ResourceResponse::initNSURLResponse): 62 63 Synthesize HTTP response properly so it can hold Content-Disposition for file name (and other headers). 64 65 (WebCore::ResourceResponse::platformLazyInit): 66 67 Don't pull the suggested filename anymore. 68 69 (WebCore::ResourceResponse::platformSuggestedFilename): 70 71 Get the suggested name from the (possibly synthetic) NSURLRequest. 72 1 73 2014-09-04 Eva Balazsfalvi <evab.u-szeged@partner.samsung.com> 2 74 -
trunk/Source/WebCore/WebCore.exp.in
r173268 r173272 879 879 __ZN7WebCore20ResourceResponseBase18setHTTPHeaderFieldERKN3WTF6StringES4_ 880 880 __ZN7WebCore20ResourceResponseBase19setTextEncodingNameERKN3WTF6StringE 881 __ZN7WebCore20ResourceResponseBase20setSuggestedFilenameERKN3WTF6StringE882 881 __ZN7WebCore20ResourceResponseBase24setExpectedContentLengthEx 883 882 __ZN7WebCore20ResourceResponseBase6setURLERKNS_3URLE -
trunk/Source/WebCore/loader/DocumentLoader.cpp
r172790 r173272 473 473 if (url.isEmpty()) 474 474 url = m_request.url(); 475 ResourceResponse response(url, m_substituteData.mimeType(), m_substituteData.content()->size(), m_substituteData.textEncoding() , "");475 ResourceResponse response(url, m_substituteData.mimeType(), m_substituteData.content()->size(), m_substituteData.textEncoding()); 476 476 responseReceived(0, response); 477 477 } … … 1386 1386 m_request.setURL(blankURL()); 1387 1387 String mimeType = shouldLoadEmpty ? "text/html" : frameLoader()->client().generatedMIMETypeForURLScheme(m_request.url().protocol()); 1388 m_response = ResourceResponse(m_request.url(), mimeType, 0, String() , String());1388 m_response = ResourceResponse(m_request.url(), mimeType, 0, String()); 1389 1389 finishedLoading(monotonicallyIncreasingTime()); 1390 1390 return true; -
trunk/Source/WebCore/loader/FrameLoader.cpp
r173142 r173272 1514 1514 ResourceError error; 1515 1515 requestFromDelegate(request, identifier, error); 1516 notifier().sendRemainingDelegateMessages(m_documentLoader.get(), identifier, request, ResourceResponse(url, String(), -1, String() , String()), 0, -1, -1, error);1516 notifier().sendRemainingDelegateMessages(m_documentLoader.get(), identifier, request, ResourceResponse(url, String(), -1, String()), 0, -1, -1, error); 1517 1517 1518 1518 url = request.url(); -
trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp
r170113 r173272 1160 1160 String textEncodingName = cacheStatement.getColumnText(4); 1161 1161 1162 ResourceResponse response(url, mimeType, size, textEncodingName , "");1162 ResourceResponse response(url, mimeType, size, textEncodingName); 1163 1163 response.setHTTPStatusCode(httpStatusCode); 1164 1164 -
trunk/Source/WebCore/loader/archive/ArchiveResource.cpp
r171708 r173272 50 50 unsigned dataSize = data->size(); 51 51 return adoptRef(new ArchiveResource(data, url, mimeType, textEncoding, frameName, 52 ResourceResponse(url, mimeType, dataSize, textEncoding , String())));52 ResourceResponse(url, mimeType, dataSize, textEncoding))); 53 53 } 54 54 return adoptRef(new ArchiveResource(data, url, mimeType, textEncoding, frameName, response)); -
trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp
r169974 r173272 597 597 598 598 bool isRangeRequest = m_rangeOffset != positionNotSpecified; 599 ResourceResponse response(firstRequest().url(), m_blobData->contentType(), m_totalRemainingSize, String() , String());599 ResourceResponse response(firstRequest().url(), m_blobData->contentType(), m_totalRemainingSize, String()); 600 600 response.setExpectedContentLength(m_totalRemainingSize); 601 601 response.setHTTPStatusCode(isRangeRequest ? httpPartialContent : httpOK); … … 618 618 ASSERT(m_errorCode); 619 619 620 ResourceResponse response(firstRequest().url(), "text/plain", 0, String() , String());620 ResourceResponse response(firstRequest().url(), "text/plain", 0, String()); 621 621 switch (m_errorCode) { 622 622 case rangeError: -
trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp
r170774 r173272 68 68 } 69 69 70 ResourceResponseBase::ResourceResponseBase(const URL& url, const String& mimeType, long long expectedLength, const String& textEncodingName , const String& filename)70 ResourceResponseBase::ResourceResponseBase(const URL& url, const String& mimeType, long long expectedLength, const String& textEncodingName) 71 71 : m_url(url) 72 72 , m_mimeType(mimeType) 73 73 , m_expectedContentLength(expectedLength) 74 74 , m_textEncodingName(textEncodingName) 75 , m_suggestedFilename(filename)76 75 , m_httpStatusCode(0) 77 76 , m_connectionID(0) … … 102 101 response->setExpectedContentLength(data->m_expectedContentLength); 103 102 response->setTextEncodingName(data->m_textEncodingName); 104 response->setSuggestedFilename(data->m_suggestedFilename);105 103 106 104 response->setHTTPStatusCode(data->m_httpStatusCode); 107 105 response->setHTTPStatusText(data->m_httpStatusText); 108 106 109 response->lazyInit( CommonAndUncommonFields);107 response->lazyInit(AllFields); 110 108 response->m_httpHeaderFields.adopt(WTF::move(data->m_httpHeaders)); 111 109 response->m_resourceLoadTiming = data->m_resourceLoadTiming; … … 121 119 data->m_expectedContentLength = expectedContentLength(); 122 120 data->m_textEncodingName = textEncodingName().isolatedCopy(); 123 data->m_suggestedFilename = suggestedFilename().isolatedCopy();124 121 data->m_httpStatusCode = httpStatusCode(); 125 122 data->m_httpStatusText = httpStatusText().isolatedCopy(); … … 210 207 211 208 // FIXME should compute this on the fly 212 const String& ResourceResponseBase::suggestedFilename() const 213 { 214 lazyInit(AllFields); 215 216 return m_suggestedFilename; 217 } 218 219 void ResourceResponseBase::setSuggestedFilename(const String& suggestedName) 220 { 221 lazyInit(AllFields); 222 m_isNull = false; 223 224 // FIXME: Suggested file name is calculated based on other headers. There should not be a setter for it. 225 m_suggestedFilename = suggestedName; 226 227 // FIXME: Should invalidate or update platform response if present. 209 String ResourceResponseBase::suggestedFilename() const 210 { 211 return static_cast<const ResourceResponse*>(this)->platformSuggestedFilename(); 228 212 } 229 213 … … 246 230 const String& ResourceResponseBase::httpStatusText() const 247 231 { 248 lazyInit( CommonAndUncommonFields);232 lazyInit(AllFields); 249 233 250 234 return m_httpStatusText; … … 253 237 void ResourceResponseBase::setHTTPStatusText(const String& statusText) 254 238 { 255 lazyInit( CommonAndUncommonFields);239 lazyInit(AllFields); 256 240 257 241 m_httpStatusText = statusText; … … 269 253 return value; 270 254 271 lazyInit( CommonAndUncommonFields);255 lazyInit(AllFields); 272 256 273 257 return m_httpHeaderFields.get(name); … … 283 267 return value; 284 268 285 lazyInit( CommonAndUncommonFields);269 lazyInit(AllFields); 286 270 287 271 return m_httpHeaderFields.get(name); … … 319 303 void ResourceResponseBase::setHTTPHeaderField(const String& name, const String& value) 320 304 { 321 lazyInit( CommonAndUncommonFields);305 lazyInit(AllFields); 322 306 323 307 HTTPHeaderName headerName; … … 332 316 void ResourceResponseBase::setHTTPHeaderField(HTTPHeaderName name, const String& value) 333 317 { 334 lazyInit( CommonAndUncommonFields);318 lazyInit(AllFields); 335 319 336 320 updateHeaderParsedState(name); … … 343 327 void ResourceResponseBase::addHTTPHeaderField(const String& name, const String& value) 344 328 { 345 lazyInit( CommonAndUncommonFields);329 lazyInit(AllFields); 346 330 347 331 HTTPHeaderName headerName; … … 354 338 const HTTPHeaderMap& ResourceResponseBase::httpHeaderFields() const 355 339 { 356 lazyInit( CommonAndUncommonFields);340 lazyInit(AllFields); 357 341 358 342 return m_httpHeaderFields; … … 509 493 bool ResourceResponseBase::isAttachment() const 510 494 { 511 lazyInit( CommonAndUncommonFields);495 lazyInit(AllFields); 512 496 513 497 String value = m_httpHeaderFields.get(HTTPHeaderName::ContentDisposition); … … 522 506 bool ResourceResponseBase::wasCached() const 523 507 { 524 lazyInit( CommonAndUncommonFields);508 lazyInit(AllFields); 525 509 526 510 return m_wasCached; … … 534 518 bool ResourceResponseBase::connectionReused() const 535 519 { 536 lazyInit( CommonAndUncommonFields);520 lazyInit(AllFields); 537 521 538 522 return m_connectionReused; … … 541 525 void ResourceResponseBase::setConnectionReused(bool connectionReused) 542 526 { 543 lazyInit( CommonAndUncommonFields);527 lazyInit(AllFields); 544 528 545 529 m_connectionReused = connectionReused; … … 548 532 unsigned ResourceResponseBase::connectionID() const 549 533 { 550 lazyInit( CommonAndUncommonFields);534 lazyInit(AllFields); 551 535 552 536 return m_connectionID; … … 555 539 void ResourceResponseBase::setConnectionID(unsigned connectionID) 556 540 { 557 lazyInit( CommonAndUncommonFields);541 lazyInit(AllFields); 558 542 559 543 m_connectionID = connectionID; -
trunk/Source/WebCore/platform/network/ResourceResponseBase.h
r172849 r173272 68 68 WEBCORE_EXPORT void setTextEncodingName(const String& name); 69 69 70 // FIXME: Should compute this on the fly.71 // There should not be a setter exposed, as suggested file name is determined based on other headers in a manner that WebCore does not necessarily know about.72 WEBCORE_EXPORT const String& suggestedFilename() const;73 WEBCORE_EXPORT void setSuggestedFilename(const String&);74 75 70 WEBCORE_EXPORT int httpStatusCode() const; 76 71 WEBCORE_EXPORT void setHTTPStatusCode(int); … … 96 91 97 92 WEBCORE_EXPORT bool isAttachment() const; 93 WEBCORE_EXPORT String suggestedFilename() const; 98 94 99 95 // These functions return parsed values of the corresponding response headers. … … 133 129 Uninitialized, 134 130 CommonFieldsOnly, 135 CommonAndUncommonFields,136 131 AllFields 137 132 }; 138 133 139 134 WEBCORE_EXPORT ResourceResponseBase(); 140 ResourceResponseBase(const URL& url, const String& mimeType, long long expectedLength, const String& textEncodingName, const String& filename);135 ResourceResponseBase(const URL&, const String& mimeType, long long expectedLength, const String& textEncodingName); 141 136 142 137 void lazyInit(InitLevel) const; … … 144 139 // The ResourceResponse subclass may "shadow" this method to lazily initialize platform specific fields 145 140 void platformLazyInit(InitLevel) { } 141 String platformSuggestedFileName() { return String(); } 146 142 147 143 // The ResourceResponse subclass may "shadow" this method to compare platform specific fields … … 152 148 long long m_expectedContentLength; 153 149 AtomicString m_textEncodingName; 154 String m_suggestedFilename;155 150 AtomicString m_httpStatusText; 156 151 HTTPHeaderMap m_httpHeaderFields; … … 200 195 long long m_expectedContentLength; 201 196 String m_textEncodingName; 202 String m_suggestedFilename;203 197 int m_httpStatusCode; 204 198 String m_httpStatusText; -
trunk/Source/WebCore/platform/network/cf/ResourceResponse.h
r172849 r173272 41 41 public: 42 42 ResourceResponse() 43 : m_initLevel( CommonAndUncommonFields)43 : m_initLevel(AllFields) 44 44 , m_platformResponseIsUpToDate(true) 45 45 { … … 67 67 #endif 68 68 69 ResourceResponse(const URL& url, const String& mimeType, long long expectedLength, const String& textEncodingName , const String& filename)70 : ResourceResponseBase(url, mimeType, expectedLength, textEncodingName , filename)71 , m_initLevel( CommonAndUncommonFields)69 ResourceResponse(const URL& url, const String& mimeType, long long expectedLength, const String& textEncodingName) 70 : ResourceResponseBase(url, mimeType, expectedLength, textEncodingName) 71 , m_initLevel(AllFields) 72 72 , m_platformResponseIsUpToDate(false) 73 73 { … … 104 104 105 105 void platformLazyInit(InitLevel); 106 String platformSuggestedFilename() const; 106 107 PassOwnPtr<CrossThreadResourceResponseData> doPlatformCopyData(PassOwnPtr<CrossThreadResourceResponseData> data) const { return data; } 107 108 void doPlatformAdopt(PassOwnPtr<CrossThreadResourceResponseData>) { } -
trunk/Source/WebCore/platform/network/cf/ResourceResponseCFNet.cpp
r165676 r173272 93 93 } 94 94 95 if (m_initLevel < CommonAndUncommonFields && initLevel >= CommonAndUncommonFields) {95 if (m_initLevel < AllFields) { 96 96 CFHTTPMessageRef httpResponse = CFURLResponseGetHTTPResponse(m_cfResponse.get()); 97 97 if (httpResponse) { … … 108 108 } 109 109 } 110 111 if (m_initLevel < AllFields && initLevel >= AllFields) {112 RetainPtr<CFStringRef> suggestedFilename = adoptCF(CFURLResponseCopySuggestedFilename(m_cfResponse.get()));113 m_suggestedFilename = suggestedFilename.get();114 }115 110 116 111 m_initLevel = initLevel; 117 112 } 118 113 114 String ResourceResponse::platformSuggestedFilename() const 115 { 116 RetainPtr<CFStringRef> suggestedFilename = adoptCF(CFURLResponseCopySuggestedFilename(m_cfResponse.get())); 117 return suggestedFilename.get(); 118 } 119 119 120 bool ResourceResponse::platformCompare(const ResourceResponse& a, const ResourceResponse& b) 120 121 { -
trunk/Source/WebCore/platform/network/mac/ResourceResponseMac.mm
r170029 r173272 46 46 void ResourceResponse::initNSURLResponse() const 47 47 { 48 // Work around a mistake in the NSURLResponse class - <rdar://problem/6875219>. 49 // The init function takes an NSInteger, even though the accessor returns a long long. 50 // For values that won't fit in an NSInteger, pass -1 instead. 51 NSInteger expectedContentLength; 52 if (m_expectedContentLength < 0 || m_expectedContentLength > std::numeric_limits<NSInteger>::max()) 53 expectedContentLength = -1; 54 else 55 expectedContentLength = static_cast<NSInteger>(m_expectedContentLength); 56 57 // FIXME: This creates a very incomplete NSURLResponse, which does not even have a status code. 58 59 m_nsResponse = adoptNS([[NSURLResponse alloc] initWithURL:m_url MIMEType:m_mimeType expectedContentLength:expectedContentLength textEncodingName:m_textEncodingName]); 48 if (!m_httpStatusCode) { 49 // Work around a mistake in the NSURLResponse class - <rdar://problem/6875219>. 50 // The init function takes an NSInteger, even though the accessor returns a long long. 51 // For values that won't fit in an NSInteger, pass -1 instead. 52 NSInteger expectedContentLength; 53 if (m_expectedContentLength < 0 || m_expectedContentLength > std::numeric_limits<NSInteger>::max()) 54 expectedContentLength = -1; 55 else 56 expectedContentLength = static_cast<NSInteger>(m_expectedContentLength); 57 58 m_nsResponse = adoptNS([[NSURLResponse alloc] initWithURL:m_url MIMEType:m_mimeType expectedContentLength:-1 textEncodingName:m_textEncodingName]); 59 return; 60 } 61 NSMutableDictionary* headerDictionary = [NSMutableDictionary dictionary]; 62 for (auto& header : m_httpHeaderFields) 63 [headerDictionary setObject:(NSString *)header.value forKey:(NSString *)header.key]; 64 65 m_nsResponse = adoptNS([[NSHTTPURLResponse alloc] initWithURL:m_url statusCode:m_httpStatusCode HTTPVersion:(NSString*)kCFHTTPVersion1_1 headerFields:headerDictionary]); 60 66 } 61 67 … … 140 146 } 141 147 142 if (m_initLevel < CommonAndUncommonFields && initLevel >= CommonAndUncommonFields) {148 if (m_initLevel < AllFields) { 143 149 if ([m_nsResponse.get() isKindOfClass:[NSHTTPURLResponse class]]) { 144 150 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; … … 160 166 } 161 167 } 162 163 if (m_initLevel < AllFields && initLevel >= AllFields)164 m_suggestedFilename = [m_nsResponse.get() suggestedFilename];165 168 166 169 m_initLevel = initLevel; 167 170 } 168 171 169 172 String ResourceResponse::platformSuggestedFilename() const 173 { 174 return [nsURLResponse() suggestedFilename]; 175 } 176 170 177 bool ResourceResponse::platformCompare(const ResourceResponse& a, const ResourceResponse& b) 171 178 { -
trunk/Source/WebCore/plugins/PluginStream.cpp
r170021 r173272 390 390 void PluginStream::sendJavaScriptStream(const URL& requestURL, const CString& resultString) 391 391 { 392 didReceiveResponse(0, ResourceResponse(requestURL, "text/plain", resultString.length(), "" , ""));392 didReceiveResponse(0, ResourceResponse(requestURL, "text/plain", resultString.length(), "")); 393 393 394 394 if (m_streamState == StreamStopped) -
trunk/Source/WebKit2/ChangeLog
r173268 r173272 1 2014-09-04 Antti Koivisto <antti@apple.com> 2 3 Remove ResourceResponse::m_suggestedFilename 4 https://bugs.webkit.org/show_bug.cgi?id=136534 5 6 Reviewed by Alexey Proskuryakov. 7 8 * Shared/WebCoreArgumentCoders.cpp: 9 (IPC::ArgumentCoder<ResourceResponse>::encode): 10 (IPC::ArgumentCoder<ResourceResponse>::decode): 11 12 No more m_suggestedFilename. 13 14 * WebProcess/Plugins/PDF/PDFPlugin.mm: 15 (WebKit::PDFPlugin::addArchiveResource): 16 17 Fake the suggested filename by using the Content-Disposition header. 18 1 19 2014-09-04 Eva Balazsfalvi <evab.u-szeged@partner.samsung.com> 2 20 -
trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
r173268 r173272 700 700 encoder << static_cast<int64_t>(resourceResponse.expectedContentLength()); 701 701 encoder << resourceResponse.httpStatusText(); 702 encoder << resourceResponse.suggestedFilename();703 702 } 704 703 … … 774 773 return false; 775 774 response.setHTTPStatusText(httpStatusText); 776 777 String suggestedFilename;778 if (!decoder.decode(suggestedFilename))779 return false;780 response.setSuggestedFilename(suggestedFilename);781 775 } 782 776 -
trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm
r171891 r173272 810 810 811 811 // Add just enough data for context menu handling and web archives to work. 812 ResourceResponse synthesizedResponse; 813 synthesizedResponse.setSuggestedFilename(m_suggestedFilename); 814 synthesizedResponse.setURL(m_sourceURL); // Needs to match the HitTestResult::absolutePDFURL. 815 synthesizedResponse.setMimeType("application/pdf"); 812 NSDictionary* headers = @{ @"Content-Disposition": (NSString *)m_suggestedFilename, @"Content-Type" : @"application/pdf" }; 813 RetainPtr<NSURLResponse> response = adoptNS([[NSHTTPURLResponse alloc] initWithURL:m_sourceURL statusCode:200 HTTPVersion:(NSString*)kCFHTTPVersion1_1 headerFields:headers]); 814 ResourceResponse synthesizedResponse(response.get()); 816 815 817 816 RefPtr<ArchiveResource> resource = ArchiveResource::create(SharedBuffer::wrapCFData(m_data.get()), m_sourceURL, "application/pdf", String(), String(), synthesizedResponse);
Note:
See TracChangeset
for help on using the changeset viewer.