Source/WebCore: Change a bunch of nondescript bools to
authorjaphet@chromium.org <japhet@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Aug 2011 17:41:25 +0000 (17:41 +0000)
committerjaphet@chromium.org <japhet@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Aug 2011 17:41:25 +0000 (17:41 +0000)
descriptive enums in ResourceLoaderOptions and
ThreadableLoaderOptions.
https://bugs.webkit.org/show_bug.cgi?id=66984

Reviewed by David Levin.

No new tests, no functionality change intended.

* WebCore.exp.in:
* fileapi/FileReaderLoader.cpp:
* html/MediaDocument.cpp:
* html/PluginDocument.cpp:
* loader/CrossOriginAccessControl.cpp:
* loader/CrossOriginAccessControl.h:
* loader/CrossOriginPreflightResultCache.cpp:
* loader/CrossOriginPreflightResultCache.h:
* loader/DocumentThreadableLoader.cpp:
* loader/FrameLoader.h:
* loader/ImageLoader.cpp:
* loader/MainResourceLoader.cpp:
* loader/NetscapePlugInStreamLoader.cpp:
* loader/ResourceLoadScheduler.h:
* loader/ResourceLoader.cpp:
* loader/ResourceLoader.h:
* loader/ResourceLoaderOptions.h:
* loader/ThreadableLoader.h:
* loader/cache/CachedResource.cpp:
* loader/cache/CachedResourceRequest.cpp:
* loader/cf/ResourceLoaderCFNet.cpp:
* loader/mac/ResourceLoaderMac.mm:
* page/EventSource.cpp:
* platform/network/ResourceHandle.h:
* workers/WorkerScriptLoader.cpp:
* xml/XMLHttpRequest.cpp:

Source/WebKit/chromium: Use enums instead of bools for ThreadableLoaderOptions
variables.
https://bugs.webkit.org/show_bug.cgi?id=66984

Reviewed by David Levin.

* src/AssociatedURLLoader.cpp:
(WebKit::AssociatedURLLoader::loadAsynchronously):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@93886 268f45cc-cd09-0410-ab3c-d52691b4dbfc

32 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/bindings/v8/ScriptController.cpp
Source/WebCore/fileapi/FileReaderLoader.cpp
Source/WebCore/html/MediaDocument.cpp
Source/WebCore/html/PluginDocument.cpp
Source/WebCore/loader/CrossOriginAccessControl.cpp
Source/WebCore/loader/CrossOriginAccessControl.h
Source/WebCore/loader/CrossOriginPreflightResultCache.cpp
Source/WebCore/loader/CrossOriginPreflightResultCache.h
Source/WebCore/loader/DocumentThreadableLoader.cpp
Source/WebCore/loader/FrameLoader.h
Source/WebCore/loader/ImageLoader.cpp
Source/WebCore/loader/MainResourceLoader.cpp
Source/WebCore/loader/NetscapePlugInStreamLoader.cpp
Source/WebCore/loader/ResourceLoadScheduler.h
Source/WebCore/loader/ResourceLoader.cpp
Source/WebCore/loader/ResourceLoader.h
Source/WebCore/loader/ResourceLoaderOptions.h
Source/WebCore/loader/ThreadableLoader.h
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/loader/cache/CachedResourceRequest.cpp
Source/WebCore/loader/cf/ResourceLoaderCFNet.cpp
Source/WebCore/loader/mac/ResourceLoaderMac.mm
Source/WebCore/notifications/Notification.cpp
Source/WebCore/page/EventSource.cpp
Source/WebCore/platform/network/ResourceHandle.h
Source/WebCore/workers/WorkerScriptLoader.cpp
Source/WebCore/xml/XMLHttpRequest.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/AssociatedURLLoader.cpp
Source/WebKit/chromium/src/WebDocument.cpp

index 4592190..25151f9 100644 (file)
@@ -1,3 +1,41 @@
+2011-08-26  Nate Chapin  <japhet@chromium.org>
+
+        Change a bunch of nondescript bools to
+        descriptive enums in ResourceLoaderOptions and
+        ThreadableLoaderOptions.
+        https://bugs.webkit.org/show_bug.cgi?id=66984
+
+        Reviewed by David Levin.
+
+        No new tests, no functionality change intended.
+
+        * WebCore.exp.in:
+        * fileapi/FileReaderLoader.cpp:
+        * html/MediaDocument.cpp:
+        * html/PluginDocument.cpp:
+        * loader/CrossOriginAccessControl.cpp:
+        * loader/CrossOriginAccessControl.h:
+        * loader/CrossOriginPreflightResultCache.cpp:
+        * loader/CrossOriginPreflightResultCache.h:
+        * loader/DocumentThreadableLoader.cpp:
+        * loader/FrameLoader.h:
+        * loader/ImageLoader.cpp:
+        * loader/MainResourceLoader.cpp:
+        * loader/NetscapePlugInStreamLoader.cpp:
+        * loader/ResourceLoadScheduler.h:
+        * loader/ResourceLoader.cpp:
+        * loader/ResourceLoader.h:
+        * loader/ResourceLoaderOptions.h:
+        * loader/ThreadableLoader.h:
+        * loader/cache/CachedResource.cpp:
+        * loader/cache/CachedResourceRequest.cpp:
+        * loader/cf/ResourceLoaderCFNet.cpp:
+        * loader/mac/ResourceLoaderMac.mm:
+        * page/EventSource.cpp:
+        * platform/network/ResourceHandle.h:
+        * workers/WorkerScriptLoader.cpp:
+        * xml/XMLHttpRequest.cpp:
+
 2011-08-26  Andreas Kling  <kling@webkit.org>
 
         HTMLMetaElement: Don't cache "http-equiv" and "content" attributes.
index ee7ab88..91a1580 100644 (file)
@@ -364,7 +364,6 @@ __ZN7WebCore14FrameSelectionC1EPNS_5FrameE
 __ZN7WebCore14ResourceHandle20forceContentSniffingEv
 __ZN7WebCore14ResourceHandle26synchronousLoadRunLoopModeEv
 __ZN7WebCore14ResourceLoader14cancelledErrorEv
-__ZN7WebCore14ResourceLoader19setShouldBufferDataEb
 __ZN7WebCore14SVGSMILElement13isSMILElementEPNS_4NodeE
 __ZN7WebCore14SchemeRegistry24registerURLSchemeAsLocalERKN3WTF6StringE
 __ZN7WebCore14SchemeRegistry25registerURLSchemeAsSecureERKN3WTF6StringE
index c7febfb..51591b3 100644 (file)
@@ -49,6 +49,7 @@
 #include "npruntime_priv.h"
 #include "NPV8Object.h"
 #include "ScriptSourceCode.h"
+#include "SecurityOrigin.h"
 #include "Settings.h"
 #include "UserGestureIndicator.h"
 #include "V8Binding.h"
index 15137e7..1b54128 100644 (file)
@@ -86,10 +86,10 @@ void FileReaderLoader::start(ScriptExecutionContext* scriptExecutionContext, Blo
     request.setHTTPMethod("GET");
 
     ThreadableLoaderOptions options;
-    options.sendLoadCallbacks = true;
-    options.sniffContent = false;
+    options.sendLoadCallbacks = SendCallbacks;
+    options.sniffContent = DoNotSniffContent;
     options.preflightPolicy = ConsiderPreflight;
-    options.allowCredentials = true;
+    options.allowCredentials = AllowStoredCredentials;
     options.crossOriginRequestPolicy = DenyCrossOriginRequests;
 
     if (m_client)
index f27d21f..aed28db 100644 (file)
@@ -101,7 +101,7 @@ void MediaDocumentParser::createDocumentStructure()
     if (!frame)
         return;
 
-    frame->loader()->activeDocumentLoader()->mainResourceLoader()->setShouldBufferData(false);
+    frame->loader()->activeDocumentLoader()->mainResourceLoader()->setShouldBufferData(DoNotBufferData);
 }
 
 void MediaDocumentParser::appendBytes(DocumentWriter*, const char*, size_t)
index 7e5a0e6..908ba6c 100644 (file)
@@ -132,7 +132,7 @@ void PluginDocumentParser::appendBytes(DocumentWriter*, const char*, size_t)
             // In a plugin document, the main resource is the plugin. If we have a null widget, that means
             // the loading of the plugin was cancelled, which gives us a null mainResourceLoader(), so we
             // need to have this call in a null check of the widget or of mainResourceLoader().
-            frame->loader()->activeDocumentLoader()->mainResourceLoader()->setShouldBufferData(false);
+            frame->loader()->activeDocumentLoader()->mainResourceLoader()->setShouldBufferData(DoNotBufferData);
         }
     }
 
index 8d29b36..0fb3d3b 100644 (file)
@@ -97,14 +97,14 @@ bool isOnAccessControlResponseHeaderWhitelist(const String& name)
     return allowedCrossOriginResponseHeaders->contains(name);
 }
 
-void updateRequestForAccessControl(ResourceRequest& request, SecurityOrigin* securityOrigin, bool allowCredentials)
+void updateRequestForAccessControl(ResourceRequest& request, SecurityOrigin* securityOrigin, StoredCredentials allowCredentials)
 {
     request.removeCredentials();
-    request.setAllowCookies(allowCredentials);
+    request.setAllowCookies(allowCredentials == AllowStoredCredentials);
     request.setHTTPOrigin(securityOrigin->toString());
 }
 
-ResourceRequest createAccessControlPreflightRequest(const ResourceRequest& request, SecurityOrigin* securityOrigin, bool allowCredentials)
+ResourceRequest createAccessControlPreflightRequest(const ResourceRequest& request, SecurityOrigin* securityOrigin, StoredCredentials allowCredentials)
 {
     ResourceRequest preflightRequest(request.url());
     updateRequestForAccessControl(preflightRequest, securityOrigin, allowCredentials);
@@ -133,12 +133,12 @@ ResourceRequest createAccessControlPreflightRequest(const ResourceRequest& reque
     return preflightRequest;
 }
 
-bool passesAccessControlCheck(const ResourceResponse& response, bool includeCredentials, SecurityOrigin* securityOrigin, String& errorDescription)
+bool passesAccessControlCheck(const ResourceResponse& response, StoredCredentials includeCredentials, SecurityOrigin* securityOrigin, String& errorDescription)
 {
     // A wildcard Access-Control-Allow-Origin can not be used if credentials are to be sent,
     // even with Access-Control-Allow-Credentials set to true.
     const String& accessControlOriginString = response.httpHeaderField("Access-Control-Allow-Origin");
-    if (accessControlOriginString == "*" && !includeCredentials)
+    if (accessControlOriginString == "*" && includeCredentials == DoNotAllowStoredCredentials)
         return true;
 
     if (securityOrigin->isUnique()) {
@@ -156,7 +156,7 @@ bool passesAccessControlCheck(const ResourceResponse& response, bool includeCred
         return false;
     }
 
-    if (includeCredentials) {
+    if (includeCredentials == AllowStoredCredentials) {
         const String& accessControlCredentialsString = response.httpHeaderField("Access-Control-Allow-Credentials");
         if (accessControlCredentialsString != "true") {
             errorDescription = "Credentials flag is true, but Access-Control-Allow-Credentials is not \"true\".";
index 74b4d58..59e7c38 100644 (file)
@@ -27,6 +27,7 @@
 #ifndef CrossOriginAccessControl_h
 #define CrossOriginAccessControl_h
 
+#include "ResourceHandle.h"
 #include "ResourceRequest.h"
 #include <wtf/Forward.h>
 
@@ -41,10 +42,10 @@ bool isOnAccessControlSimpleRequestMethodWhitelist(const String&);
 bool isOnAccessControlSimpleRequestHeaderWhitelist(const String& name, const String& value);
 bool isOnAccessControlResponseHeaderWhitelist(const String&);
 
-void updateRequestForAccessControl(ResourceRequest&, SecurityOrigin*, bool allowCredentials);
-ResourceRequest createAccessControlPreflightRequest(const ResourceRequest&, SecurityOrigin*, bool allowCredentials);
+void updateRequestForAccessControl(ResourceRequest&, SecurityOrigin*, StoredCredentials);
+ResourceRequest createAccessControlPreflightRequest(const ResourceRequest&, SecurityOrigin*, StoredCredentials);
 
-bool passesAccessControlCheck(const ResourceResponse&, bool includeCredentials, SecurityOrigin*, String& errorDescription);
+bool passesAccessControlCheck(const ResourceResponse&, StoredCredentials, SecurityOrigin*, String& errorDescription);
 
 } // namespace WebCore
 
index 711adf4..1f0e712 100644 (file)
@@ -135,12 +135,12 @@ bool CrossOriginPreflightResultCacheItem::allowsCrossOriginHeaders(const HTTPHea
     return true;
 }
 
-bool CrossOriginPreflightResultCacheItem::allowsRequest(bool includeCredentials, const String& method, const HTTPHeaderMap& requestHeaders) const
+bool CrossOriginPreflightResultCacheItem::allowsRequest(StoredCredentials includeCredentials, const String& method, const HTTPHeaderMap& requestHeaders) const
 {
     String ignoredExplanation;
     if (m_absoluteExpiryTime < currentTime())
         return false;
-    if (includeCredentials && !m_credentials)
+    if (includeCredentials == AllowStoredCredentials && m_credentials == DoNotAllowStoredCredentials)
         return false;
     if (!allowsCrossOriginMethod(method, ignoredExplanation))
         return false;
@@ -167,7 +167,7 @@ void CrossOriginPreflightResultCache::appendEntry(const String& origin, const KU
     }
 }
 
-bool CrossOriginPreflightResultCache::canSkipPreflight(const String& origin, const KURL& url, bool includeCredentials, const String& method, const HTTPHeaderMap& requestHeaders)
+bool CrossOriginPreflightResultCache::canSkipPreflight(const String& origin, const KURL& url, StoredCredentials includeCredentials, const String& method, const HTTPHeaderMap& requestHeaders)
 {
     ASSERT(isMainThread());
     CrossOriginPreflightResultHashMap::iterator cacheIt = m_preflightHashMap.find(std::make_pair(origin, url));
index ddd5070..115d833 100644 (file)
@@ -28,6 +28,7 @@
 #define CrossOriginPreflightResultCache_h
 
 #include "KURLHash.h"
+#include "ResourceHandle.h"
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
 #include <wtf/PassOwnPtr.h>
@@ -41,7 +42,7 @@ namespace WebCore {
     class CrossOriginPreflightResultCacheItem {
         WTF_MAKE_NONCOPYABLE(CrossOriginPreflightResultCacheItem); WTF_MAKE_FAST_ALLOCATED;
     public:
-        CrossOriginPreflightResultCacheItem(bool credentials)
+        CrossOriginPreflightResultCacheItem(StoredCredentials credentials)
             : m_absoluteExpiryTime(0)
             , m_credentials(credentials)
         {
@@ -50,7 +51,7 @@ namespace WebCore {
         bool parse(const ResourceResponse&, String& errorDescription);
         bool allowsCrossOriginMethod(const String&, String& errorDescription) const;
         bool allowsCrossOriginHeaders(const HTTPHeaderMap&, String& errorDescription) const;
-        bool allowsRequest(bool includeCredentials, const String& method, const HTTPHeaderMap& requestHeaders) const;
+        bool allowsRequest(StoredCredentials, const String& method, const HTTPHeaderMap& requestHeaders) const;
 
     private:
         typedef HashSet<String, CaseFoldingHash> HeadersSet;
@@ -59,7 +60,7 @@ namespace WebCore {
         // to start a timer for the expiration delta that removes this from the cache when
         // it fires.
         double m_absoluteExpiryTime;
-        bool m_credentials;
+        StoredCredentials m_credentials;
         HashSet<String> m_methods;
         HeadersSet m_headers;
     };
@@ -70,7 +71,7 @@ namespace WebCore {
         static CrossOriginPreflightResultCache& shared();
 
         void appendEntry(const String& origin, const KURL&, PassOwnPtr<CrossOriginPreflightResultCacheItem>);
-        bool canSkipPreflight(const String& origin, const KURL&, bool includeCredentials, const String& method, const HTTPHeaderMap& requestHeaders);
+        bool canSkipPreflight(const String& origin, const KURL&, StoredCredentials, const String& method, const HTTPHeaderMap& requestHeaders);
 
         void empty();
 
index c300156..092b99b 100644 (file)
@@ -292,7 +292,7 @@ bool DocumentThreadableLoader::getShouldUseCredentialStorage(SubresourceLoader*
 {
     ASSERT_UNUSED(loader, loader == m_loader || !m_loader);
 
-    if (!m_options.allowCredentials) {
+    if (m_options.allowCredentials == DoNotAllowStoredCredentials) {
         shouldUseCredentialStorage = false;
         return true;
     }
@@ -345,10 +345,10 @@ void DocumentThreadableLoader::loadRequest(const ResourceRequest& request, Secur
         ThreadableLoaderOptions options = m_options;
         if (m_actualRequest) {
             // Don't sniff content or send load callbacks for the preflight request.
-            options.sendLoadCallbacks = false;
-            options.sniffContent = false;
+            options.sendLoadCallbacks = DoNotSendCallbacks;
+            options.sniffContent = DoNotSniffContent;
             // Keep buffering the data for the preflight request.
-            options.shouldBufferData = true;
+            options.shouldBufferData = BufferData;
         }
 
 #if ENABLE(INSPECTOR)
@@ -368,14 +368,12 @@ void DocumentThreadableLoader::loadRequest(const ResourceRequest& request, Secur
     }
     
     // FIXME: ThreadableLoaderOptions.sniffContent is not supported for synchronous requests.
-    StoredCredentials storedCredentials = m_options.allowCredentials ? AllowStoredCredentials : DoNotAllowStoredCredentials;
-
     Vector<char> data;
     ResourceError error;
     ResourceResponse response;
     unsigned long identifier = std::numeric_limits<unsigned long>::max();
     if (m_document->frame())
-        identifier = m_document->frame()->loader()->loadResourceSynchronously(request, storedCredentials, error, response, data);
+        identifier = m_document->frame()->loader()->loadResourceSynchronously(request, m_options.allowCredentials, error, response, data);
 
     // No exception for file:/// resources, see <rdar://problem/4962298>.
     // Also, if we have an HTTP response, then it wasn't a network error in fact.
index d6a2119..ec37816 100644 (file)
@@ -38,9 +38,9 @@
 #include "IconController.h"
 #include "IconURL.h"
 #include "PolicyChecker.h"
+#include "ResourceHandle.h"
 #include "ResourceLoadNotifier.h"
 #include "SubframeLoader.h"
-#include "ThreadableLoader.h"
 #include "Timer.h"
 #include <wtf/Forward.h>
 #include <wtf/HashSet.h>
index ac570aa..8392365 100644 (file)
@@ -168,7 +168,7 @@ void ImageLoader::updateFromElement()
 
         String crossOriginMode = m_element->fastGetAttribute(HTMLNames::crossoriginAttr);
         if (!crossOriginMode.isNull()) {
-            bool allowCredentials = equalIgnoringCase(crossOriginMode, "use-credentials");
+            StoredCredentials allowCredentials = equalIgnoringCase(crossOriginMode, "use-credentials") ? AllowStoredCredentials : DoNotAllowStoredCredentials;
             updateRequestForAccessControl(request, document->securityOrigin(), allowCredentials);
         }
 
index fae5b7f..17a6bc5 100644 (file)
@@ -60,7 +60,7 @@
 namespace WebCore {
 
 MainResourceLoader::MainResourceLoader(Frame* frame)
-    : ResourceLoader(frame, ResourceLoaderOptions(true, true, true))
+    : ResourceLoader(frame, ResourceLoaderOptions(SendCallbacks, SniffContent, BufferData))
     , m_dataLoadTimer(this, &MainResourceLoader::handleDataLoadNow)
     , m_loadingMultipartContent(false)
     , m_waitingForContentPolicy(false)
index 6d757f3..9541546 100644 (file)
@@ -36,7 +36,7 @@
 namespace WebCore {
 
 NetscapePlugInStreamLoader::NetscapePlugInStreamLoader(Frame* frame, NetscapePlugInStreamLoaderClient* client)
-    : ResourceLoader(frame, ResourceLoaderOptions(true, true, true))
+    : ResourceLoader(frame, ResourceLoaderOptions(SendCallbacks, SniffContent, DoNotBufferData))
     , m_client(client)
 {
 }
@@ -48,7 +48,6 @@ NetscapePlugInStreamLoader::~NetscapePlugInStreamLoader()
 PassRefPtr<NetscapePlugInStreamLoader> NetscapePlugInStreamLoader::create(Frame* frame, NetscapePlugInStreamLoaderClient* client, const ResourceRequest& request)
 {
     RefPtr<NetscapePlugInStreamLoader> loader(adoptRef(new NetscapePlugInStreamLoader(frame, client)));
-    loader->setShouldBufferData(false);
     loader->documentLoader()->addPlugInStreamLoader(loader.get());
     if (!loader->init(request))
         return 0;
index 9bc4b0d..d388b96 100644 (file)
@@ -51,7 +51,7 @@ class ResourceLoadScheduler {
 public:
     friend ResourceLoadScheduler* resourceLoadScheduler();
 
-    PassRefPtr<SubresourceLoader> scheduleSubresourceLoad(Frame*, SubresourceLoaderClient*, const ResourceRequest&, ResourceLoadPriority = ResourceLoadPriorityLow, SecurityCheckPolicy = DoSecurityCheck, const ResourceLoaderOptions& = ResourceLoaderOptions(true, true, true));
+    PassRefPtr<SubresourceLoader> scheduleSubresourceLoad(Frame*, SubresourceLoaderClient*, const ResourceRequest&, ResourceLoadPriority = ResourceLoadPriorityLow, SecurityCheckPolicy = DoSecurityCheck, const ResourceLoaderOptions& = ResourceLoaderOptions(SendCallbacks, SniffContent, BufferData));
     PassRefPtr<NetscapePlugInStreamLoader> schedulePluginStreamLoad(Frame*, NetscapePlugInStreamLoaderClient*, const ResourceRequest&);
     void addMainResourceLoad(ResourceLoader*);
     void remove(ResourceLoader*);
index 1a67c86..d623fcd 100644 (file)
@@ -160,7 +160,7 @@ void ResourceLoader::start()
     }
 
     if (!m_reachedTerminalState)
-        m_handle = ResourceHandle::create(m_frame->loader()->networkingContext(), m_request, this, m_defersLoading, m_options.sniffContent);
+        m_handle = ResourceHandle::create(m_frame->loader()->networkingContext(), m_request, this, m_defersLoading, m_options.sniffContent == SniffContent);
 }
 
 void ResourceLoader::setDefersLoading(bool defers)
@@ -182,7 +182,7 @@ FrameLoader* ResourceLoader::frameLoader() const
     return m_frame->loader();
 }
 
-void ResourceLoader::setShouldBufferData(bool shouldBufferData)
+void ResourceLoader::setShouldBufferData(DataBufferingPolicy shouldBufferData)
 { 
     m_options.shouldBufferData = shouldBufferData; 
 
@@ -194,7 +194,7 @@ void ResourceLoader::setShouldBufferData(bool shouldBufferData)
 
 void ResourceLoader::addData(const char* data, int length, bool allAtOnce)
 {
-    if (!m_options.shouldBufferData)
+    if (m_options.shouldBufferData == DoNotBufferData)
         return;
 
     if (allAtOnce) {
@@ -234,7 +234,7 @@ void ResourceLoader::willSendRequest(ResourceRequest& request, const ResourceRes
 
     ASSERT(!m_reachedTerminalState);
 
-    if (m_options.sendLoadCallbacks) {
+    if (m_options.sendLoadCallbacks == SendCallbacks) {
         if (!m_identifier) {
             m_identifier = m_frame->page()->progress()->createUniqueIdentifier();
             frameLoader()->notifier()->assignIdentifierToInitialRequest(m_identifier, documentLoader(), request);
@@ -277,7 +277,7 @@ void ResourceLoader::didReceiveResponse(const ResourceResponse& r)
     if (FormData* data = m_request.httpBody())
         data->removeGeneratedFilesIfNeeded();
         
-    if (m_options.sendLoadCallbacks)
+    if (m_options.sendLoadCallbacks == SendCallbacks)
         frameLoader()->notifier()->didReceiveResponse(this, m_response);
 }
 
@@ -303,13 +303,13 @@ void ResourceLoader::didReceiveData(const char* data, int length, long long enco
     // FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing.
     // However, with today's computers and networking speeds, this won't happen in practice.
     // Could be an issue with a giant local file.
-    if (m_options.sendLoadCallbacks && m_frame)
+    if (m_options.sendLoadCallbacks == SendCallbacks && m_frame)
         frameLoader()->notifier()->didReceiveData(this, data, length, static_cast<int>(encodedDataLength));
 }
 
 void ResourceLoader::willStopBufferingData(const char* data, int length)
 {
-    if (!m_options.shouldBufferData)
+    if (m_options.shouldBufferData == DoNotBufferData)
         return;
 
     ASSERT(!m_resourceData);
@@ -337,7 +337,7 @@ void ResourceLoader::didFinishLoadingOnePart(double finishTime)
     if (m_calledDidFinishLoad)
         return;
     m_calledDidFinishLoad = true;
-    if (m_options.sendLoadCallbacks)
+    if (m_options.sendLoadCallbacks == SendCallbacks)
         frameLoader()->notifier()->didFinishLoad(this, finishTime);
 }
 
@@ -354,7 +354,7 @@ void ResourceLoader::didFail(const ResourceError& error)
     if (FormData* data = m_request.httpBody())
         data->removeGeneratedFilesIfNeeded();
 
-    if (m_options.sendLoadCallbacks && !m_calledDidFinishLoad)
+    if (m_options.sendLoadCallbacks == SendCallbacks && !m_calledDidFinishLoad)
         frameLoader()->notifier()->didFailToLoad(this, error);
 
     releaseResources();
@@ -402,7 +402,7 @@ void ResourceLoader::cancel(const ResourceError& error)
             m_handle = 0;
         }
 
-        if (m_options.sendLoadCallbacks && m_identifier && !m_calledDidFinishLoad)
+        if (m_options.sendLoadCallbacks == SendCallbacks && m_identifier && !m_calledDidFinishLoad)
             frameLoader()->notifier()->didFailToLoad(this, nonNullError);
     }
 
index 05f26e7..56b6018 100644 (file)
@@ -139,7 +139,7 @@ namespace WebCore {
 
         bool reachedTerminalState() const { return m_reachedTerminalState; }
 
-        void setShouldBufferData(bool shouldBufferData);
+        void setShouldBufferData(DataBufferingPolicy);
 
     protected:
         ResourceLoader(Frame*, ResourceLoaderOptions);
index b74563e..a92fb22 100644 (file)
 
 namespace WebCore {
     
+enum SendCallbackPolicy {
+    SendCallbacks,
+    DoNotSendCallbacks
+};
+
+enum ContentSniffingPolicy {
+    SniffContent,
+    DoNotSniffContent
+};
+
+enum DataBufferingPolicy {
+    BufferData,
+    DoNotBufferData
+};
+
 struct ResourceLoaderOptions {
-    ResourceLoaderOptions() : sendLoadCallbacks(false), sniffContent(false), shouldBufferData(true) { }
-    ResourceLoaderOptions(bool sendLoadCallbacksArg, bool sniffContentArg, bool shouldBufferDataArg) : sendLoadCallbacks(sendLoadCallbacksArg), sniffContent(sniffContentArg), shouldBufferData(shouldBufferDataArg) { }
-    bool sendLoadCallbacks;
-    bool sniffContent;
-    bool shouldBufferData;
+    ResourceLoaderOptions() : sendLoadCallbacks(DoNotSendCallbacks), sniffContent(DoNotSniffContent), shouldBufferData(BufferData) { }
+    ResourceLoaderOptions(SendCallbackPolicy sendLoadCallbacksArg, ContentSniffingPolicy sniffContentArg, DataBufferingPolicy shouldBufferDataArg) : sendLoadCallbacks(sendLoadCallbacksArg), sniffContent(sniffContentArg), shouldBufferData(shouldBufferDataArg) { }
+    SendCallbackPolicy sendLoadCallbacks;
+    ContentSniffingPolicy sniffContent;
+    DataBufferingPolicy shouldBufferData;
 };
 
 } // namespace WebCore    
index f5ab9a5..9d35187 100644 (file)
@@ -31,6 +31,7 @@
 #ifndef ThreadableLoader_h
 #define ThreadableLoader_h
 
+#include "ResourceHandle.h"
 #include "ResourceLoaderOptions.h"
 #include "SecurityOrigin.h"
 #include <wtf/Noncopyable.h>
@@ -45,11 +46,6 @@ namespace WebCore {
     class ResourceResponse;
     class ScriptExecutionContext;
     class ThreadableLoaderClient;
-
-    enum StoredCredentials {
-        AllowStoredCredentials,
-        DoNotAllowStoredCredentials
-    };
     
     enum CrossOriginRequestPolicy {
         DenyCrossOriginRequests,
@@ -64,8 +60,8 @@ namespace WebCore {
     };
 
     struct ThreadableLoaderOptions : public ResourceLoaderOptions {
-        ThreadableLoaderOptions() : allowCredentials(false), preflightPolicy(ConsiderPreflight), crossOriginRequestPolicy(DenyCrossOriginRequests) { }
-        bool allowCredentials;  // Whether HTTP credentials and cookies are sent with the request.
+        ThreadableLoaderOptions() : allowCredentials(DoNotAllowStoredCredentials), preflightPolicy(ConsiderPreflight), crossOriginRequestPolicy(DenyCrossOriginRequests) { }
+        StoredCredentials allowCredentials; // Whether HTTP credentials and cookies are sent with the request.
         PreflightPolicy preflightPolicy; // If AccessControl is used, how to determine if a preflight is needed.
         CrossOriginRequestPolicy crossOriginRequestPolicy;
         RefPtr<SecurityOrigin> securityOrigin;
index e6c0d74..9803865 100644 (file)
@@ -179,7 +179,7 @@ void CachedResource::finish()
 bool CachedResource::passesAccessControlCheck(SecurityOrigin* securityOrigin)
 {
     String errorDescription;
-    return WebCore::passesAccessControlCheck(m_response, resourceRequest().allowCookies(), securityOrigin, errorDescription);
+    return WebCore::passesAccessControlCheck(m_response, resourceRequest().allowCookies() ? AllowStoredCredentials : DoNotAllowStoredCredentials, securityOrigin, errorDescription);
 }
 
 bool CachedResource::isExpired() const
index 1a351a0..ea56b92 100644 (file)
@@ -124,8 +124,8 @@ PassOwnPtr<CachedResourceRequest> CachedResourceRequest::load(CachedResourceLoad
     ResourceLoadPriority priority = resource->loadPriority();
     resourceRequest.setPriority(priority);
 
-    RefPtr<SubresourceLoader> loader = resourceLoadScheduler()->scheduleSubresourceLoad(cachedResourceLoader->document()->frame(),
-        request.get(), resourceRequest, priority, securityCheck, ResourceLoaderOptions(sendResourceLoadCallbacks, true, true));
+    RefPtr<SubresourceLoader> loader = resourceLoadScheduler()->scheduleSubresourceLoad(cachedResourceLoader->document()->frame(), request.get(), resourceRequest, priority, securityCheck,
+                                                                                        ResourceLoaderOptions(sendResourceLoadCallbacks ? SendCallbacks : DoNotSendCallbacks, SniffContent, BufferData));
     if (!loader || loader->reachedTerminalState()) {
         // FIXME: What if resources in other frames were waiting for this revalidation?
         LOG(ResourceLoading, "Cannot start loading '%s'", resource->url().string().latin1().data());
index 4b9dfa4..c745c17 100644 (file)
@@ -37,7 +37,7 @@ namespace WebCore {
 
 bool ResourceLoader::shouldCacheResponse(ResourceHandle*, CFCachedURLResponseRef cachedResponse)
 {
-    if (!m_options.sendLoadCallbacks)
+    if (m_options.sendLoadCallbacks == DoNotSendCallbacks)
         return 0;
 
     CFURLResponseRef response = CFCachedURLResponseGetWrappedResponse(cachedResponse);
index 8dbafa8..e54e2e2 100644 (file)
@@ -90,7 +90,7 @@ void ResourceLoader::didReceiveDataArray(CFArrayRef dataArray)
         // FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing.
         // However, with today's computers and networking speeds, this won't happen in practice.
         // Could be an issue with a giant local file.
-        if (m_sendResourceLoadCallbacks && m_frame)
+        if (m_options.sendLoadCallbacks == SendCallbacks && m_frame)
             frameLoader()->notifier()->didReceiveData(this, reinterpret_cast<const char*>(CFDataGetBytePtr(data)), dataLen, dataLen);
     }
 }
index 5bf7f95..c9f66a4 100644 (file)
@@ -166,8 +166,8 @@ void Notification::startLoading()
     setPendingActivity(this);
     m_state = Loading;
     ThreadableLoaderOptions options;
-    options.sendLoadCallbacks = false;
-    options.sniffContent = false;
+    options.sendLoadCallbacks = DoNotSendCallbacks;
+    options.sniffContent = DoNotSniffContent;
     options.preflightPolicy = ConsiderPreflight;
     options.allowCredentials = AllowStoredCredentials;
     options.crossOriginRequestPolicy = AllowCrossOriginRequests;
index 3b5bb25..ad76262 100644 (file)
@@ -113,10 +113,10 @@ void EventSource::connect()
         request.setHTTPHeaderField("Last-Event-ID", m_lastEventId);
 
     ThreadableLoaderOptions options;
-    options.sendLoadCallbacks = true;
-    options.sniffContent = false;
-    options.allowCredentials = true;
-    options.shouldBufferData = false;
+    options.sendLoadCallbacks = SendCallbacks;
+    options.sniffContent = DoNotSniffContent;
+    options.allowCredentials = AllowStoredCredentials;
+    options.shouldBufferData = DoNotBufferData;
 
     m_loader = ThreadableLoader::create(scriptExecutionContext(), this, request, options);
 
index eadd98d..a7b7658 100644 (file)
@@ -30,7 +30,6 @@
 #include "AuthenticationClient.h"
 #include "HTTPHeaderMap.h"
 #include "NetworkingContext.h"
-#include "ThreadableLoader.h"
 #include <wtf/OwnPtr.h>
 
 #if USE(SOUP)
@@ -91,6 +90,11 @@ class ResourceResponse;
 class SchedulePair;
 class SharedBuffer;
 
+enum StoredCredentials {
+    AllowStoredCredentials,
+    DoNotAllowStoredCredentials
+};
+
 template <typename T> class Timer;
 
 class ResourceHandle : public RefCounted<ResourceHandle>
index 244c2f9..95476f8 100644 (file)
@@ -72,9 +72,9 @@ void WorkerScriptLoader::loadSynchronously(ScriptExecutionContext* scriptExecuti
     ASSERT(scriptExecutionContext->isWorkerContext());
 
     ThreadableLoaderOptions options;
-    options.allowCredentials = true;
+    options.allowCredentials = AllowStoredCredentials;
     options.crossOriginRequestPolicy = crossOriginRequestPolicy;
-    options.sendLoadCallbacks = true;
+    options.sendLoadCallbacks = SendCallbacks;
 
     WorkerThreadableLoader::loadResourceSynchronously(static_cast<WorkerContext*>(scriptExecutionContext), *request, *this, options);
 }
@@ -90,9 +90,9 @@ void WorkerScriptLoader::loadAsynchronously(ScriptExecutionContext* scriptExecut
         return;
 
     ThreadableLoaderOptions options;
-    options.allowCredentials = true;
+    options.allowCredentials = AllowStoredCredentials;
     options.crossOriginRequestPolicy = crossOriginRequestPolicy;
-    options.sendLoadCallbacks = true;
+    options.sendLoadCallbacks = SendCallbacks;
 
     // During create, callbacks may happen which remove the last reference to this object.
     RefPtr<WorkerScriptLoader> protect(this);
index 7560088..42fe332 100644 (file)
@@ -650,10 +650,10 @@ void XMLHttpRequest::createRequest(ExceptionCode& ec)
         request.addHTTPHeaderFields(m_requestHeaders);
 
     ThreadableLoaderOptions options;
-    options.sendLoadCallbacks = true;
-    options.sniffContent = false;
+    options.sendLoadCallbacks = SendCallbacks;
+    options.sniffContent = DoNotSniffContent;
     options.preflightPolicy = uploadEvents ? ForcePreflight : ConsiderPreflight;
-    options.allowCredentials = m_sameOriginRequest || m_includeCredentials;
+    options.allowCredentials = (m_sameOriginRequest || m_includeCredentials) ? AllowStoredCredentials : DoNotAllowStoredCredentials;
     options.crossOriginRequestPolicy = UseAccessControl;
     options.securityOrigin = securityOrigin();
 
index a740ad0..3f08739 100644 (file)
@@ -1,3 +1,14 @@
+2011-08-26  Nate Chapin  <japhet@chromium.org>
+
+        Use enums instead of bools for ThreadableLoaderOptions
+        variables.
+        https://bugs.webkit.org/show_bug.cgi?id=66984
+
+        Reviewed by David Levin.
+
+        * src/AssociatedURLLoader.cpp:
+        (WebKit::AssociatedURLLoader::loadAsynchronously):
+
 2011-08-25  Jeremy Apthorp  <jeremya@google.com>
 
         Enable fullscreen API in Chromium by default.
index 789fe73..2ca687b 100644 (file)
@@ -226,12 +226,12 @@ void AssociatedURLLoader::loadAsynchronously(const WebURLRequest& request, WebUR
     ASSERT(m_client);
 
     ThreadableLoaderOptions options;
-    options.sendLoadCallbacks = true; // Always send callbacks.
-    options.sniffContent = m_options.sniffContent;
-    options.allowCredentials = m_options.allowCredentials;
+    options.sendLoadCallbacks = SendCallbacks; // Always send callbacks.
+    options.sniffContent = m_options.sniffContent ? SniffContent : DoNotSniffContent;
+    options.allowCredentials = m_options.allowCredentials ? AllowStoredCredentials : DoNotAllowStoredCredentials;
     options.preflightPolicy = m_options.forcePreflight ? ForcePreflight : ConsiderPreflight;
     options.crossOriginRequestPolicy = static_cast<WebCore::CrossOriginRequestPolicy>(m_options.crossOriginRequestPolicy);
-    options.shouldBufferData = false;
+    options.shouldBufferData = DoNotBufferData;
 
     const ResourceRequest& webcoreRequest = request.toResourceRequest();
     Document* webcoreDocument = m_frameImpl->frame()->document();
index ab058a6..a7766c4 100644 (file)
@@ -44,7 +44,7 @@
 #include "HTMLFormElement.h"
 #include "HTMLHeadElement.h"
 #include "NodeList.h"
-
+#include "SecurityOrigin.h"
 #include "WebAccessibilityObject.h"
 #include "WebDocumentType.h"
 #include "WebElement.h"