Changeset 167183 in webkit
- Timestamp:
- Apr 12, 2014 12:10:56 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r167181 r167183 1 2014-04-11 Darin Adler <darin@apple.com> 2 3 Some small loader refinements and refactoring 4 https://bugs.webkit.org/show_bug.cgi?id=131541 5 6 Reviewed by Alexey Proskuryakov. 7 8 Cut down on use of ResourceLoader::handle, which always returns null when 9 using a network process. Also streamlined conditionals and did some other 10 small refactoring. 11 12 * loader/DocumentLoader.h: Use references rather than pointers for SchedulePair. 13 14 * loader/ResourceLoader.cpp: 15 (WebCore::ResourceLoader::didChangePriority): Use m_handle instead of handle(), 16 since we'd like to delete handle() entirely soon. 17 (WebCore::ResourceLoader::didReceiveAuthenticationChallenge): Ditto. 18 (WebCore::ResourceLoader::schedule): Added. 19 (WebCore::ResourceLoader::unschedule): Ditto. 20 * loader/ResourceLoader.h: Rearranged header to eliminate nested conditionals. 21 Added schedule and unschedule functions for Mac. 22 23 * loader/mac/DocumentLoaderMac.cpp: 24 (WebCore::scheduleAll): Changed to take a reference and call ResourceLoader::schedule. 25 (WebCore::unscheduleAll): Ditto. 26 (WebCore::DocumentLoader::schedule): Ditto. 27 (WebCore::DocumentLoader::unschedule): Ditto. 28 29 * page/mac/PageMac.cpp: 30 (WebCore::Page::addSchedulePair): Pass a reference rather than a pointer to schedule. 31 (WebCore::Page::removeSchedulePair): Ditto. 32 33 * platform/network/ResourceHandle.h: Did a bit of reformatting and reorganizing of 34 conditionals. 35 36 * platform/network/ResourceHandleInternal.h: Removed a tiny bit of unneeded declaration. 37 38 * platform/network/mac/ResourceHandleMac.mm: 39 (WebCore::ResourceHandle::schedule): Updated to take a reference rather than a pointer. 40 (WebCore::ResourceHandle::unschedule): Ditto. 41 1 42 2014-04-11 Andreas Kling <akling@apple.com> 2 43 -
trunk/Source/WebCore/loader/DocumentLoader.h
r165676 r167183 52 52 #endif 53 53 54 namespace WTF {55 class SchedulePair;56 }57 58 54 namespace WebCore { 55 59 56 class ApplicationCacheHost; 60 #if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)61 57 class Archive; 62 #endif63 58 class ArchiveResource; 64 59 class ArchiveResourceCollection; … … 145 140 const String& overrideEncoding() const { return m_overrideEncoding; } 146 141 147 #if PLATFORM( COCOA)148 void schedule( WTF::SchedulePair*);149 void unschedule( WTF::SchedulePair*);142 #if PLATFORM(MAC) 143 void schedule(SchedulePair&); 144 void unschedule(SchedulePair&); 150 145 #endif 151 146 … … 158 153 159 154 bool scheduleArchiveLoad(ResourceLoader*, const ResourceRequest&); 160 #endif // ENABLE(WEB_ARCHIVE) || ENABLE(MHTML)155 #endif 161 156 162 157 // Return the ArchiveResource for the URL only when loading an Archive -
trunk/Source/WebCore/loader/ResourceLoader.cpp
r165676 r167183 397 397 void ResourceLoader::didChangePriority(ResourceLoadPriority loadPriority) 398 398 { 399 if ( handle())400 handle()->didChangePriority(loadPriority);399 if (m_handle) 400 m_handle->didChangePriority(loadPriority); 401 401 } 402 402 … … 537 537 void ResourceLoader::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge) 538 538 { 539 ASSERT( handle()->hasAuthenticationChallenge());539 ASSERT(m_handle->hasAuthenticationChallenge()); 540 540 541 541 // Protect this in this delegate method since the additional processing can do … … 553 553 #if PLATFORM(COCOA) || USE(CFNETWORK) || USE(CURL) || PLATFORM(GTK) || PLATFORM(EFL) 554 554 challenge.authenticationClient()->receivedRequestToContinueWithoutCredential(challenge); 555 ASSERT(! handle() || !handle()->hasAuthenticationChallenge());555 ASSERT(!m_handle || !m_handle->hasAuthenticationChallenge()); 556 556 #else 557 557 didFail(blockedError()); … … 568 568 569 569 #if USE(PROTECTION_SPACE_AUTH_CALLBACK) 570 570 571 bool ResourceLoader::canAuthenticateAgainstProtectionSpace(const ProtectionSpace& protectionSpace) 571 572 { … … 573 574 return frameLoader()->client().canAuthenticateAgainstProtectionSpace(documentLoader(), identifier(), protectionSpace); 574 575 } 576 575 577 #endif 576 578 577 579 #if PLATFORM(IOS) 580 578 581 RetainPtr<CFDictionaryRef> ResourceLoader::connectionProperties(ResourceHandle*) 579 582 { 580 583 return frameLoader()->connectionProperties(this); 581 584 } 585 582 586 #endif 583 587 … … 587 591 } 588 592 589 } 593 #if PLATFORM(MAC) 594 595 void ResourceLoader::schedule(SchedulePair& pair) 596 { 597 if (m_handle) 598 m_handle->schedule(pair); 599 } 600 601 void ResourceLoader::unschedule(SchedulePair& pair) 602 { 603 if (m_handle) 604 m_handle->unschedule(pair); 605 } 606 607 #endif 608 609 } -
trunk/Source/WebCore/loader/ResourceLoader.h
r165908 r167183 35 35 #include "ResourceRequest.h" 36 36 #include "ResourceResponse.h" 37 38 37 #include <wtf/Forward.h> 39 #include <wtf/RefCounted.h>40 38 41 39 #if USE(QUICK_LOOK) 42 40 #include "QuickLook.h" 43 41 #endif 42 43 namespace WTF { 44 class SchedulePair; 45 } 44 46 45 47 namespace WebCore { … … 51 53 class URL; 52 54 class ResourceBuffer; 53 class ResourceHandle;54 55 55 56 class ResourceLoader : public RefCounted<ResourceLoader>, protected ResourceHandleClient { … … 127 128 virtual void didReceiveAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge& challenge) override { didReceiveAuthenticationChallenge(challenge); } 128 129 virtual void didCancelAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge& challenge) override { didCancelAuthenticationChallenge(challenge); } 130 virtual void receivedCancellation(ResourceHandle*, const AuthenticationChallenge& challenge) override { receivedCancellation(challenge); } 131 129 132 #if USE(NETWORK_CFDATA_ARRAY_CALLBACK) 130 133 virtual void didReceiveDataArray(ResourceHandle*, CFArrayRef dataArray) override; 131 134 #endif 135 132 136 #if USE(PROTECTION_SPACE_AUTH_CALLBACK) 133 137 virtual bool canAuthenticateAgainstProtectionSpace(ResourceHandle*, const ProtectionSpace& protectionSpace) override { return canAuthenticateAgainstProtectionSpace(protectionSpace); } 134 138 #endif 135 virtual void receivedCancellation(ResourceHandle*, const AuthenticationChallenge& challenge) override { receivedCancellation(challenge); } 136 #if PLATFORM(COCOA) 137 #if USE(CFNETWORK) 139 140 #if PLATFORM(COCOA) && USE(CFNETWORK) 138 141 virtual CFCachedURLResponseRef willCacheResponse(ResourceHandle*, CFCachedURLResponseRef) override; 139 #else 140 virtual NSCachedURLResponse* willCacheResponse(ResourceHandle*, NSCachedURLResponse*) override; 141 #endif 142 #endif // PLATFORM(COCOA) 142 #endif 143 143 144 #if PLATFORM(WIN) && USE(CFNETWORK) 144 145 // FIXME: Windows should use willCacheResponse - <https://bugs.webkit.org/show_bug.cgi?id=57257>. … … 146 147 #endif 147 148 148 const URL& url() const { return m_request.url(); } 149 #if PLATFORM(COCOA) && !USE(CFNETWORK) 150 virtual NSCachedURLResponse* willCacheResponse(ResourceHandle*, NSCachedURLResponse*) override; 151 #endif 152 153 const URL& url() const { return m_request.url(); } 149 154 ResourceHandle* handle() const { return m_handle.get(); } 150 155 bool shouldSendResourceLoadCallbacks() const { return m_options.sendLoadCallbacks == SendCallbacks; } … … 162 167 QuickLookHandle* quickLookHandle() const { return m_quickLookHandle.get(); } 163 168 void setQuickLookHandle(PassOwnPtr<QuickLookHandle> handle) { m_quickLookHandle = handle; } 169 #endif 170 171 #if PLATFORM(MAC) 172 void schedule(WTF::SchedulePair&); 173 void unschedule(WTF::SchedulePair&); 164 174 #endif 165 175 -
trunk/Source/WebCore/loader/mac/DocumentLoaderMac.cpp
r165676 r167183 29 29 #include "config.h" 30 30 #include "DocumentLoader.h" 31 #include "ResourceHandle.h" 31 32 32 #include "ResourceLoader.h" 33 #include <wtf/SchedulePair.h>34 33 35 34 namespace WebCore { 36 35 37 #if !PLATFORM(IOS) 38 static void scheduleAll(const ResourceLoaderMap& loaders, SchedulePair* pair) 36 #if PLATFORM(MAC) 37 38 static void scheduleAll(const ResourceLoaderMap& loaders, SchedulePair& pair) 39 39 { 40 40 Vector<RefPtr<ResourceLoader>> loadersCopy; 41 41 copyValuesToVector(loaders, loadersCopy); 42 for (auto& loader : loadersCopy) { 43 if (ResourceHandle* handle = loader->handle()) 44 handle->schedule(pair); 45 } 42 for (auto& loader : loadersCopy) 43 loader->schedule(pair); 46 44 } 47 45 48 static void unscheduleAll(const ResourceLoaderMap& loaders, SchedulePair *pair)46 static void unscheduleAll(const ResourceLoaderMap& loaders, SchedulePair& pair) 49 47 { 50 48 Vector<RefPtr<ResourceLoader>> loadersCopy; 51 49 copyValuesToVector(loaders, loadersCopy); 52 for (auto& loader : loadersCopy) { 53 if (ResourceHandle* handle = loader->handle()) 54 handle->unschedule(pair); 55 } 50 for (auto& loader : loadersCopy) 51 loader->unschedule(pair); 56 52 } 57 #endif58 53 59 void DocumentLoader::schedule(SchedulePair *pair)54 void DocumentLoader::schedule(SchedulePair& pair) 60 55 { 61 #if !PLATFORM(IOS) 62 if (mainResourceLoader() && mainResourceLoader()->handle()) 63 mainResourceLoader()->handle()->schedule(pair); 56 if (mainResourceLoader()) 57 mainResourceLoader()->schedule(pair); 64 58 scheduleAll(m_subresourceLoaders, pair); 65 59 scheduleAll(m_plugInStreamLoaders, pair); 66 60 scheduleAll(m_multipartSubresourceLoaders, pair); 67 #else68 UNUSED_PARAM(pair);69 #endif70 61 } 71 62 72 void DocumentLoader::unschedule(SchedulePair *pair)63 void DocumentLoader::unschedule(SchedulePair& pair) 73 64 { 74 #if !PLATFORM(IOS) 75 if (mainResourceLoader() && mainResourceLoader()->handle()) 76 mainResourceLoader()->handle()->unschedule(pair); 65 if (mainResourceLoader()) 66 mainResourceLoader()->unschedule(pair); 77 67 unscheduleAll(m_subresourceLoaders, pair); 78 68 unscheduleAll(m_plugInStreamLoaders, pair); 79 69 unscheduleAll(m_multipartSubresourceLoaders, pair); 80 #else81 UNUSED_PARAM(pair);82 #endif83 70 } 84 71 72 #endif 73 85 74 } // namespace -
trunk/Source/WebCore/page/mac/PageMac.cpp
r165676 r167183 48 48 for (Frame* frame = m_mainFrame.get(); frame; frame = frame->tree().traverseNext()) { 49 49 if (DocumentLoader* documentLoader = frame->loader().documentLoader()) 50 documentLoader->schedule( pair.get());50 documentLoader->schedule(*pair); 51 51 if (DocumentLoader* documentLoader = frame->loader().provisionalDocumentLoader()) 52 documentLoader->schedule( pair.get());52 documentLoader->schedule(*pair); 53 53 } 54 54 #endif … … 69 69 for (Frame* frame = m_mainFrame.get(); frame; frame = frame->tree().traverseNext()) { 70 70 if (DocumentLoader* documentLoader = frame->loader().documentLoader()) 71 documentLoader->unschedule( pair.get());71 documentLoader->unschedule(*pair); 72 72 if (DocumentLoader* documentLoader = frame->loader().provisionalDocumentLoader()) 73 documentLoader->unschedule( pair.get());73 documentLoader->unschedule(*pair); 74 74 } 75 75 #endif -
trunk/Source/WebCore/platform/network/ResourceHandle.h
r166186 r167183 34 34 #include <wtf/RefCounted.h> 35 35 36 #if PLATFORM(COCOA) || USE(CFNETWORK) 37 #include <wtf/RetainPtr.h> 38 #endif 39 36 40 #if USE(QUICK_LOOK) 37 41 #include "QuickLook.h" 38 #endif // USE(QUICK_LOOK)42 #endif 39 43 40 44 #if USE(SOUP) … … 53 57 typedef void* LPVOID; 54 58 typedef LPVOID HINTERNET; 55 #endif56 57 #if PLATFORM(COCOA) || USE(CFNETWORK)58 #include <wtf/RetainPtr.h>59 59 #endif 60 60 … … 85 85 86 86 namespace WebCore { 87 87 88 class AuthenticationChallenge; 88 89 class Credential; … … 114 115 void willSendRequest(ResourceRequest&, const ResourceResponse& redirectResponse); 115 116 #endif 117 116 118 #if PLATFORM(COCOA) || USE(CFNETWORK) || USE(CURL) || USE(SOUP) 117 119 bool shouldUseCredentialStorage(); … … 122 124 #endif 123 125 124 #if PLATFORM(COCOA) 125 #if USE(PROTECTION_SPACE_AUTH_CALLBACK) 126 #if PLATFORM(COCOA) && USE(PROTECTION_SPACE_AUTH_CALLBACK) 126 127 bool canAuthenticateAgainstProtectionSpace(const ProtectionSpace&); 127 128 #endif 128 #if !USE(CFNETWORK) 129 130 #if PLATFORM(COCOA) && !USE(CFNETWORK) 129 131 void didCancelAuthenticationChallenge(const AuthenticationChallenge&); 130 132 NSURLConnection *connection() const; … … 133 135 #endif 134 136 135 void schedule(WTF::SchedulePair*); 136 void unschedule(WTF::SchedulePair*); 137 #endif 137 #if PLATFORM(MAC) 138 void schedule(WTF::SchedulePair&); 139 void unschedule(WTF::SchedulePair&); 140 #endif 141 138 142 #if USE(CFNETWORK) 139 143 CFURLStorageSessionRef storageSession() const; … … 143 147 static void setHostAllowsAnyHTTPSCertificate(const String&); 144 148 static void setClientCertificate(const String& host, CFDataRef); 149 #endif 145 150 146 151 #if USE(QUICK_LOOK) 147 152 QuickLookHandle* quickLookHandle() { return m_quickLook.get(); } 148 153 void setQuickLookHandle(PassOwnPtr<QuickLookHandle> handle) { m_quickLook = handle; } 149 #endif // USE(QUICK_LOOK) 150 151 #endif // USE(CFNETWORK) 154 #endif 152 155 153 156 #if PLATFORM(WIN) && USE(CURL) … … 155 158 static void setClientCertificateInfo(const String&, const String&, const String&); 156 159 #endif 160 157 161 #if PLATFORM(WIN) && USE(CURL) && USE(CF) 158 162 static void setClientCertificate(const String& host, CFDataRef); … … 216 220 #if USE(CFNETWORK) 217 221 void continueWillCacheResponse(CFCachedURLResponseRef); 218 #elif PLATFORM(COCOA) 222 #endif 223 #if PLATFORM(COCOA) && !USE(CFNETWORK) 219 224 void continueWillCacheResponse(NSCachedURLResponse *); 220 225 #endif … … 237 242 static CFStringRef synchronousLoadRunLoopMode(); 238 243 #endif 244 239 245 #if PLATFORM(IOS) && USE(CFNETWORK) 240 246 static CFMutableDictionaryRef createSSLPropertiesFromNSURLRequest(const ResourceRequest&); … … 272 278 273 279 #if PLATFORM(COCOA) || USE(CFNETWORK) 274 enum class SchedulingBehavior { 275 Asynchronous, 276 Synchronous 277 }; 280 enum class SchedulingBehavior { Asynchronous, Synchronous }; 281 #endif 278 282 279 283 #if USE(CFNETWORK) 280 284 void createCFURLConnection(bool shouldUseCredentialStorage, bool shouldContentSniff, SchedulingBehavior, CFDictionaryRef clientProperties); 281 #else 285 #endif 286 287 #if PLATFORM(COCOA) && !USE(CFNETWORK) 282 288 void createNSURLConnection(id delegate, bool shouldUseCredentialStorage, bool shouldContentSniff, SchedulingBehavior); 283 #endif284 289 #endif 285 290 … … 289 294 #if USE(QUICK_LOOK) 290 295 OwnPtr<QuickLookHandle> m_quickLook; 291 #endif // USE(QUICK_LOOK)296 #endif 292 297 }; 293 298 -
trunk/Source/WebCore/platform/network/ResourceHandleInternal.h
r165676 r167183 53 53 #include <libsoup/soup.h> 54 54 #include <wtf/gobject/GRefPtr.h> 55 class Frame;56 55 #endif 57 56 … … 70 69 71 70 namespace WebCore { 71 72 72 class ResourceHandleClient; 73 73 … … 84 84 , m_shouldContentSniff(shouldContentSniff) 85 85 #if USE(CFNETWORK) 86 , m_connection(0)87 86 , m_currentRequest(request) 88 87 #endif … … 217 216 NSURLAuthenticationChallenge *m_currentMacChallenge; 218 217 #endif 218 219 219 AuthenticationChallenge m_currentWebChallenge; 220 220 ResourceHandle::FailureType m_scheduledFailureType; -
trunk/Source/WebCore/platform/network/mac/ResourceHandleMac.mm
r166791 r167183 298 298 } 299 299 300 void ResourceHandle::schedule(SchedulePair* pair) 301 { 302 #if !PLATFORM(IOS) 303 NSRunLoop *runLoop = pair->nsRunLoop(); 300 #if PLATFORM(MAC) 301 302 void ResourceHandle::schedule(SchedulePair& pair) 303 { 304 NSRunLoop *runLoop = pair.nsRunLoop(); 304 305 if (!runLoop) 305 306 return; 306 [d->m_connection.get() scheduleInRunLoop:runLoop forMode:(NSString *)pair ->mode()];307 [d->m_connection.get() scheduleInRunLoop:runLoop forMode:(NSString *)pair.mode()]; 307 308 if (d->m_startWhenScheduled) { 308 309 [d->m_connection.get() start]; 309 310 d->m_startWhenScheduled = false; 310 311 } 311 #else 312 UNUSED_PARAM(pair); 313 #endif 314 } 315 316 void ResourceHandle::unschedule(SchedulePair* pair) 317 { 318 #if !PLATFORM(IOS) 319 if (NSRunLoop *runLoop = pair->nsRunLoop()) 320 [d->m_connection.get() unscheduleFromRunLoop:runLoop forMode:(NSString *)pair->mode()]; 321 #else 322 UNUSED_PARAM(pair); 323 #endif 324 } 312 } 313 314 void ResourceHandle::unschedule(SchedulePair& pair) 315 { 316 if (NSRunLoop *runLoop = pair.nsRunLoop()) 317 [d->m_connection.get() unscheduleFromRunLoop:runLoop forMode:(NSString *)pair.mode()]; 318 } 319 320 #endif 325 321 326 322 id ResourceHandle::delegate()
Note: See TracChangeset
for help on using the changeset viewer.