Changeset 87460 in webkit
- Timestamp:
- May 26, 2011, 6:36:54 PM (14 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r87459 r87460 1 2011-05-26 Stephanie Lewis <slewis@apple.com> 2 3 Reviewed by Geoff Garen. 4 5 https://bugs.webkit.org/show_bug.cgi?id=61345 6 part of <rdar://problem/8675177> 7 Roll back in now that the Crashes are fixed. ResourceResponseBase and ResourceResponse had two different definitions 8 for m_isNull. ResourceResponse treats m_isNull as meaning there isn't any platform ResourceResponse. 9 ResourceResponseBase treats m_isNull as meaning no fields have been initialized. Consolidate calls into ResourceResponseBase meaning. 10 11 Don't initialize ResourceResponse.m_suggestedFilename until we want to use it. Initializing it requires reading in and parsing a plist. 12 Add new initialization state CommonAndUncommonFields to ResourceResponse. This will be for all the header fields. 13 Move suggestedFilename initialization to AllFields so it is never initialized unless we ask for it. 14 Add "Content-Type" to common headers since it is looked for by every CSS sheet load. 15 16 No new functionality so no new tests. 17 18 * platform/network/ResourceResponseBase.cpp: 19 (WebCore::ResourceResponseBase::adopt): 20 (WebCore::ResourceResponseBase::suggestedFilename): 21 (WebCore::ResourceResponseBase::setSuggestedFilename): 22 (WebCore::ResourceResponseBase::httpStatusText): 23 (WebCore::ResourceResponseBase::setHTTPStatusText): 24 (WebCore::ResourceResponseBase::httpHeaderField): 25 (WebCore::ResourceResponseBase::setHTTPHeaderField): 26 (WebCore::ResourceResponseBase::httpHeaderFields): 27 (WebCore::ResourceResponseBase::isAttachment): 28 (WebCore::ResourceResponseBase::setLastModifiedDate): 29 (WebCore::ResourceResponseBase::lastModifiedDate): 30 (WebCore::ResourceResponseBase::wasCached): 31 (WebCore::ResourceResponseBase::connectionReused): 32 (WebCore::ResourceResponseBase::setConnectionReused): 33 (WebCore::ResourceResponseBase::connectionID): 34 (WebCore::ResourceResponseBase::setConnectionID): 35 (WebCore::ResourceResponseBase::resourceLoadTiming): 36 (WebCore::ResourceResponseBase::setResourceLoadTiming): 37 (WebCore::ResourceResponseBase::resourceLoadInfo): 38 (WebCore::ResourceResponseBase::setResourceLoadInfo): 39 * platform/network/ResourceResponseBase.h: 40 * platform/network/cf/ResourceResponse.h: 41 (WebCore::ResourceResponse::ResourceResponse): 42 * platform/network/cf/ResourceResponseCFNet.cpp: 43 (WebCore::ResourceResponse::platformLazyInit): 44 * platform/network/mac/ResourceResponseMac.mm: 45 1 46 2011-05-26 James Kozianski <koz@chromium.org> 2 47 -
trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp
r87301 r87460 109 109 response->setHTTPStatusText(data->m_httpStatusText); 110 110 111 response->lazyInit( AllFields);111 response->lazyInit(CommonAndUncommonFields); 112 112 response->m_httpHeaderFields.adopt(data->m_httpHeaders.release()); 113 113 response->setLastModifiedDate(data->m_lastModifiedDate); … … 206 206 const String& ResourceResponseBase::suggestedFilename() const 207 207 { 208 lazyInit( CommonFieldsOnly);208 lazyInit(AllFields); 209 209 210 210 return m_suggestedFilename; … … 213 213 void ResourceResponseBase::setSuggestedFilename(const String& suggestedName) 214 214 { 215 lazyInit( CommonFieldsOnly);215 lazyInit(AllFields); 216 216 m_isNull = false; 217 217 … … 235 235 const String& ResourceResponseBase::httpStatusText() const 236 236 { 237 lazyInit( AllFields);237 lazyInit(CommonAndUncommonFields); 238 238 239 239 return m_httpStatusText; … … 242 242 void ResourceResponseBase::setHTTPStatusText(const String& statusText) 243 243 { 244 lazyInit( AllFields);244 lazyInit(CommonAndUncommonFields); 245 245 246 246 m_httpStatusText = statusText; … … 256 256 return value; 257 257 258 lazyInit( AllFields);258 lazyInit(CommonAndUncommonFields); 259 259 260 260 return m_httpHeaderFields.get(name); … … 270 270 return value; 271 271 272 lazyInit( AllFields);272 lazyInit(CommonAndUncommonFields); 273 273 274 274 return m_httpHeaderFields.get(name); … … 277 277 void ResourceResponseBase::setHTTPHeaderField(const AtomicString& name, const String& value) 278 278 { 279 lazyInit( AllFields);279 lazyInit(CommonAndUncommonFields); 280 280 281 281 DEFINE_STATIC_LOCAL(const AtomicString, ageHeader, ("age")); … … 301 301 const HTTPHeaderMap& ResourceResponseBase::httpHeaderFields() const 302 302 { 303 lazyInit( AllFields);303 lazyInit(CommonAndUncommonFields); 304 304 305 305 return m_httpHeaderFields; … … 465 465 bool ResourceResponseBase::isAttachment() const 466 466 { 467 lazyInit( AllFields);467 lazyInit(CommonAndUncommonFields); 468 468 469 469 DEFINE_STATIC_LOCAL(const AtomicString, headerName, ("content-disposition")); … … 479 479 void ResourceResponseBase::setLastModifiedDate(time_t lastModifiedDate) 480 480 { 481 lazyInit( AllFields);481 lazyInit(CommonAndUncommonFields); 482 482 483 483 m_lastModifiedDate = lastModifiedDate; … … 486 486 time_t ResourceResponseBase::lastModifiedDate() const 487 487 { 488 lazyInit( AllFields);488 lazyInit(CommonAndUncommonFields); 489 489 490 490 return m_lastModifiedDate; … … 493 493 bool ResourceResponseBase::wasCached() const 494 494 { 495 lazyInit( AllFields);495 lazyInit(CommonAndUncommonFields); 496 496 497 497 return m_wasCached; … … 505 505 bool ResourceResponseBase::connectionReused() const 506 506 { 507 lazyInit( AllFields);507 lazyInit(CommonAndUncommonFields); 508 508 509 509 return m_connectionReused; … … 512 512 void ResourceResponseBase::setConnectionReused(bool connectionReused) 513 513 { 514 lazyInit( AllFields);514 lazyInit(CommonAndUncommonFields); 515 515 516 516 m_connectionReused = connectionReused; … … 519 519 unsigned ResourceResponseBase::connectionID() const 520 520 { 521 lazyInit( AllFields);521 lazyInit(CommonAndUncommonFields); 522 522 523 523 return m_connectionID; … … 526 526 void ResourceResponseBase::setConnectionID(unsigned connectionID) 527 527 { 528 lazyInit( AllFields);528 lazyInit(CommonAndUncommonFields); 529 529 530 530 m_connectionID = connectionID; … … 533 533 ResourceLoadTiming* ResourceResponseBase::resourceLoadTiming() const 534 534 { 535 lazyInit( AllFields);535 lazyInit(CommonAndUncommonFields); 536 536 537 537 return m_resourceLoadTiming.get(); … … 540 540 void ResourceResponseBase::setResourceLoadTiming(PassRefPtr<ResourceLoadTiming> resourceLoadTiming) 541 541 { 542 lazyInit( AllFields);542 lazyInit(CommonAndUncommonFields); 543 543 544 544 m_resourceLoadTiming = resourceLoadTiming; … … 547 547 PassRefPtr<ResourceLoadInfo> ResourceResponseBase::resourceLoadInfo() const 548 548 { 549 lazyInit( AllFields);549 lazyInit(CommonAndUncommonFields); 550 550 551 551 return m_resourceLoadInfo.get(); … … 554 554 void ResourceResponseBase::setResourceLoadInfo(PassRefPtr<ResourceLoadInfo> loadInfo) 555 555 { 556 lazyInit( AllFields);556 lazyInit(CommonAndUncommonFields); 557 557 558 558 m_resourceLoadInfo = loadInfo; -
trunk/Source/WebCore/platform/network/ResourceResponseBase.h
r87301 r87460 133 133 Uninitialized, 134 134 CommonFieldsOnly, 135 CommonAndUncommonFields, 135 136 AllFields 136 137 }; -
trunk/Source/WebCore/platform/network/cf/ResourceResponse.h
r87301 r87460 45 45 public: 46 46 ResourceResponse() 47 : m_initLevel( AllFields)47 : m_initLevel(CommonAndUncommonFields) 48 48 { 49 49 } … … 67 67 ResourceResponse(const KURL& url, const String& mimeType, long long expectedLength, const String& textEncodingName, const String& filename) 68 68 : ResourceResponseBase(url, mimeType, expectedLength, textEncodingName, filename) 69 , m_initLevel( AllFields)69 , m_initLevel(CommonAndUncommonFields) 70 70 { 71 71 } -
trunk/Source/WebCore/platform/network/cf/ResourceResponseCFNet.cpp
r87301 r87460 44 44 45 45 static CFStringRef const commonHeaderFields[] = { 46 CFSTR("Age"), CFSTR("Cache-Control"), CFSTR(" Date"), CFSTR("Etag"), CFSTR("Expires"), CFSTR("Last-Modified"), CFSTR("Pragma")46 CFSTR("Age"), CFSTR("Cache-Control"), CFSTR("Content-Type"), CFSTR("Date"), CFSTR("Etag"), CFSTR("Expires"), CFSTR("Last-Modified"), CFSTR("Pragma") 47 47 }; 48 48 static const int numCommonHeaderFields = sizeof(commonHeaderFields) / sizeof(CFStringRef); … … 81 81 return; 82 82 83 if (m_isNull) { 84 ASSERT(!m_cfResponse.get()); 83 if (m_isNull || !m_cfResponse.get()) 85 84 return; 86 }87 85 88 86 if (m_initLevel < CommonFieldsOnly && initLevel >= CommonFieldsOnly) { … … 98 96 99 97 m_lastModifiedDate = toTimeT(CFURLResponseGetLastModifiedDate(m_cfResponse.get())); 100 101 RetainPtr<CFStringRef> suggestedFilename(AdoptCF, CFURLResponseCopySuggestedFilename(m_cfResponse.get()));102 m_suggestedFilename = suggestedFilename.get();103 98 104 99 CFHTTPMessageRef httpResponse = CFURLResponseGetHTTPResponse(m_cfResponse.get()); … … 117 112 } 118 113 119 if (m_initLevel < AllFields && initLevel >= AllFields) {114 if (m_initLevel < CommonAndUncommonFields && initLevel >= CommonAndUncommonFields) { 120 115 CFHTTPMessageRef httpResponse = CFURLResponseGetHTTPResponse(m_cfResponse.get()); 121 116 if (httpResponse) { … … 132 127 } 133 128 } 129 130 if (m_initLevel < AllFields && initLevel >= AllFields) { 131 RetainPtr<CFStringRef> suggestedFilename(AdoptCF, CFURLResponseCopySuggestedFilename(m_cfResponse.get())); 132 m_suggestedFilename = suggestedFilename.get(); 133 } 134 134 135 135 m_initLevel = initLevel; -
trunk/Source/WebCore/platform/network/mac/ResourceResponseMac.mm
r87301 r87460 45 45 46 46 static NSString* const commonHeaderFields[] = { 47 @"Age", @"Cache-Control", @" Date", @"Etag", @"Expires", @"Last-Modified", @"Pragma"47 @"Age", @"Cache-Control", @"Content-Type", @"Date", @"Etag", @"Expires", @"Last-Modified", @"Pragma" 48 48 }; 49 49 static const int numCommonHeaderFields = sizeof(commonHeaderFields) / sizeof(AtomicString*); … … 70 70 return; 71 71 72 if (m_isNull) { 73 ASSERT(!m_nsResponse); 72 if (m_isNull || !m_nsResponse) 74 73 return; 75 } 76 74 77 75 if (m_initLevel < CommonFieldsOnly && initLevel >= CommonFieldsOnly) { 78 76 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; … … 88 86 if (textEncodingNameLength >= 2 && m_textEncodingName[0U] == '"' && m_textEncodingName[textEncodingNameLength - 1] == '"') 89 87 m_textEncodingName = m_textEncodingName.substring(1, textEncodingNameLength - 2); 90 91 m_suggestedFilename = [m_nsResponse.get() suggestedFilename];92 88 93 89 if ([m_nsResponse.get() isKindOfClass:[NSHTTPURLResponse class]]) { … … 108 104 } 109 105 110 if (m_initLevel < AllFields && initLevel >= AllFields && [m_nsResponse.get() isKindOfClass:[NSHTTPURLResponse class]]) { 111 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; 106 if (m_initLevel < CommonAndUncommonFields && initLevel >= CommonAndUncommonFields) { 107 if ([m_nsResponse.get() isKindOfClass:[NSHTTPURLResponse class]]) { 108 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; 112 109 113 NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)m_nsResponse.get();110 NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)m_nsResponse.get(); 114 111 115 RetainPtr<NSString> httpStatusLine(AdoptNS, wkCopyNSURLResponseStatusLine(m_nsResponse.get()));116 if (httpStatusLine)117 m_httpStatusText = extractReasonPhraseFromHTTPStatusLine(httpStatusLine.get());118 else119 m_httpStatusText = "OK";112 RetainPtr<NSString> httpStatusLine(AdoptNS, wkCopyNSURLResponseStatusLine(m_nsResponse.get())); 113 if (httpStatusLine) 114 m_httpStatusText = extractReasonPhraseFromHTTPStatusLine(httpStatusLine.get()); 115 else 116 m_httpStatusText = "OK"; 120 117 121 NSDictionary *headers = [httpResponse allHeaderFields]; 122 NSEnumerator *e = [headers keyEnumerator]; 123 while (NSString *name = [e nextObject]) 124 m_httpHeaderFields.set(name, [headers objectForKey:name]); 125 126 [pool drain]; 118 NSDictionary *headers = [httpResponse allHeaderFields]; 119 NSEnumerator *e = [headers keyEnumerator]; 120 while (NSString *name = [e nextObject]) 121 m_httpHeaderFields.set(name, [headers objectForKey:name]); 122 123 [pool drain]; 124 } 127 125 } 126 127 if (m_initLevel < AllFields && initLevel >= AllFields) 128 m_suggestedFilename = [m_nsResponse.get() suggestedFilename]; 128 129 129 130 m_initLevel = initLevel;
Note:
See TracChangeset
for help on using the changeset viewer.