Get rid of ResourceRequestBase::m_targetType. Move it to chromium's ResourceRequest.
authorjochen@chromium.org <jochen@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Aug 2011 19:23:27 +0000 (19:23 +0000)
committerjochen@chromium.org <jochen@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Aug 2011 19:23:27 +0000 (19:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=48483

Reviewed by Alexey Proskuryakov.

Source/WebCore:

* loader/PingLoader.cpp:
(WebCore::PingLoader::loadImage):
(WebCore::PingLoader::sendPing):
(WebCore::PingLoader::reportContentSecurityPolicyViolation):
* loader/cache/CachedResourceRequest.cpp:
(WebCore::CachedResourceRequest::load):
* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(webKitWebSrcStart):
* platform/network/ResourceRequestBase.cpp:
(WebCore::ResourceRequestBase::adopt):
(WebCore::ResourceRequestBase::copyData):
* platform/network/ResourceRequestBase.h:
(WebCore::ResourceRequestBase::ResourceRequestBase):
* platform/network/chromium/ResourceRequest.cpp:
(WebCore::ResourceRequest::doPlatformCopyData):
(WebCore::ResourceRequest::doPlatformAdopt):
* platform/network/chromium/ResourceRequest.h:
(WebCore::ResourceRequest::ResourceRequest):
(WebCore::ResourceRequest::targetType):
(WebCore::ResourceRequest::setTargetType):
* workers/DefaultSharedWorkerRepository.cpp:
(WebCore::SharedWorkerScriptLoader::load):
* workers/Worker.cpp:
(WebCore::Worker::create):
* workers/WorkerContext.cpp:
(WebCore::WorkerContext::importScripts):
* workers/WorkerScriptLoader.cpp:
(WebCore::WorkerScriptLoader::WorkerScriptLoader):
(WebCore::WorkerScriptLoader::createResourceRequest):
* workers/WorkerScriptLoader.h:
(WebCore::WorkerScriptLoader::create):
(WebCore::WorkerScriptLoader::setTargetType):

Source/WebKit/chromium:

* src/SharedWorkerRepository.cpp:
(WebCore::SharedWorkerScriptLoader::SharedWorkerScriptLoader):

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

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/loader/PingLoader.cpp
Source/WebCore/loader/cache/CachedResourceRequest.cpp
Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
Source/WebCore/platform/network/ResourceRequestBase.cpp
Source/WebCore/platform/network/ResourceRequestBase.h
Source/WebCore/platform/network/chromium/ResourceRequest.cpp
Source/WebCore/platform/network/chromium/ResourceRequest.h
Source/WebCore/workers/DefaultSharedWorkerRepository.cpp
Source/WebCore/workers/Worker.cpp
Source/WebCore/workers/WorkerContext.cpp
Source/WebCore/workers/WorkerScriptLoader.cpp
Source/WebCore/workers/WorkerScriptLoader.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/SharedWorkerRepository.cpp

index 6d4042d..59b803b 100644 (file)
@@ -1,3 +1,43 @@
+2011-08-04  Jochen Eisinger  <jochen@chromium.org>
+
+        Get rid of ResourceRequestBase::m_targetType. Move it to chromium's ResourceRequest.
+        https://bugs.webkit.org/show_bug.cgi?id=48483
+
+        Reviewed by Alexey Proskuryakov.
+
+        * loader/PingLoader.cpp:
+        (WebCore::PingLoader::loadImage):
+        (WebCore::PingLoader::sendPing):
+        (WebCore::PingLoader::reportContentSecurityPolicyViolation):
+        * loader/cache/CachedResourceRequest.cpp:
+        (WebCore::CachedResourceRequest::load):
+        * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
+        (webKitWebSrcStart):
+        * platform/network/ResourceRequestBase.cpp:
+        (WebCore::ResourceRequestBase::adopt):
+        (WebCore::ResourceRequestBase::copyData):
+        * platform/network/ResourceRequestBase.h:
+        (WebCore::ResourceRequestBase::ResourceRequestBase):
+        * platform/network/chromium/ResourceRequest.cpp:
+        (WebCore::ResourceRequest::doPlatformCopyData):
+        (WebCore::ResourceRequest::doPlatformAdopt):
+        * platform/network/chromium/ResourceRequest.h:
+        (WebCore::ResourceRequest::ResourceRequest):
+        (WebCore::ResourceRequest::targetType):
+        (WebCore::ResourceRequest::setTargetType):
+        * workers/DefaultSharedWorkerRepository.cpp:
+        (WebCore::SharedWorkerScriptLoader::load):
+        * workers/Worker.cpp:
+        (WebCore::Worker::create):
+        * workers/WorkerContext.cpp:
+        (WebCore::WorkerContext::importScripts):
+        * workers/WorkerScriptLoader.cpp:
+        (WebCore::WorkerScriptLoader::WorkerScriptLoader):
+        (WebCore::WorkerScriptLoader::createResourceRequest):
+        * workers/WorkerScriptLoader.h:
+        (WebCore::WorkerScriptLoader::create):
+        (WebCore::WorkerScriptLoader::setTargetType):
+
 2011-08-04  Jeff Miller  <jeffm@apple.com>
 
         Fix WinCE build after r92308.
index e5cdb01..0e53784 100644 (file)
@@ -55,7 +55,9 @@ void PingLoader::loadImage(Frame* frame, const KURL& url)
     }
 
     ResourceRequest request(url);
+#if PLATFORM(CHROMIUM)
     request.setTargetType(ResourceRequest::TargetIsImage);
+#endif
     request.setHTTPHeaderField("Cache-Control", "max-age=0");
     if (!SecurityOrigin::shouldHideReferrer(request.url(), frame->loader()->outgoingReferrer()))
         request.setHTTPReferrer(frame->loader()->outgoingReferrer());
@@ -71,7 +73,9 @@ void PingLoader::loadImage(Frame* frame, const KURL& url)
 void PingLoader::sendPing(Frame* frame, const KURL& pingURL, const KURL& destinationURL)
 {
     ResourceRequest request(pingURL);
+#if PLATFORM(CHROMIUM)
     request.setTargetType(ResourceRequest::TargetIsSubresource);
+#endif
     request.setHTTPMethod("POST");
     request.setHTTPContentType("text/ping");
     request.setHTTPBody(FormData::create("PING"));
@@ -97,7 +101,9 @@ void PingLoader::sendPing(Frame* frame, const KURL& pingURL, const KURL& destina
 void PingLoader::reportContentSecurityPolicyViolation(Frame* frame, const KURL& reportURL, PassRefPtr<FormData> report)
 {
     ResourceRequest request(reportURL);
+#if PLATFORM(CHROMIUM)
     request.setTargetType(ResourceRequest::TargetIsSubresource);
+#endif
     request.setHTTPMethod("POST");
     request.setHTTPContentType("application/x-www-form-urlencoded");
     request.setHTTPBody(report);
index 2387728..42d7700 100644 (file)
@@ -44,7 +44,8 @@
 #include <wtf/text/CString.h>
 
 namespace WebCore {
-    
+
+#if PLATFORM(CHROMIUM)
 static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource::Type type)
 {
     switch (type) {
@@ -71,6 +72,7 @@ static ResourceRequest::TargetType cachedResourceTypeToTargetType(CachedResource
     ASSERT_NOT_REACHED();
     return ResourceRequest::TargetIsSubresource;
 }
+#endif
 
 CachedResourceRequest::CachedResourceRequest(CachedResourceLoader* cachedResourceLoader, CachedResource* resource, bool incremental)
     : m_cachedResourceLoader(cachedResourceLoader)
@@ -90,7 +92,9 @@ PassOwnPtr<CachedResourceRequest> CachedResourceRequest::load(CachedResourceLoad
     OwnPtr<CachedResourceRequest> request = adoptPtr(new CachedResourceRequest(cachedResourceLoader, resource, incremental));
 
     ResourceRequest resourceRequest = resource->resourceRequest();
+#if PLATFORM(CHROMIUM)
     resourceRequest.setTargetType(cachedResourceTypeToTargetType(resource->type()));
+#endif
 
     if (!resource->accept().isEmpty())
         resourceRequest.setHTTPAccept(resource->accept());
index e48998f..8f3fd6d 100644 (file)
@@ -412,7 +412,6 @@ static bool webKitWebSrcStart(WebKitWebSrc* src)
     KURL url = KURL(KURL(), priv->uri);
 
     ResourceRequest request(url);
-    request.setTargetType(ResourceRequestBase::TargetIsMedia);
     request.setAllowCookies(true);
 
     NetworkingContext* context = 0;
index fe86993..01d92c0 100644 (file)
@@ -53,7 +53,6 @@ PassOwnPtr<ResourceRequest> ResourceRequestBase::adopt(PassOwnPtr<CrossThreadRes
     request->setFirstPartyForCookies(data->m_firstPartyForCookies);
     request->setHTTPMethod(data->m_httpMethod);
     request->setPriority(data->m_priority);
-    request->setTargetType(data->m_targetType);
 
     request->updateResourceRequest();
     request->m_httpHeaderFields.adopt(data->m_httpHeaders.release());
@@ -87,7 +86,6 @@ PassOwnPtr<CrossThreadResourceRequestData> ResourceRequestBase::copyData() const
     data->m_httpMethod = httpMethod().crossThreadString();
     data->m_httpHeaders = httpHeaderFields().copyData();
     data->m_priority = priority();
-    data->m_targetType = m_targetType;
 
     data->m_responseContentDispositionEncodingFallbackArray.reserveInitialCapacity(m_responseContentDispositionEncodingFallbackArray.size());
     size_t encodingArraySize = m_responseContentDispositionEncodingFallbackArray.size();
index 4c7abcb..4b24dc3 100644 (file)
@@ -51,24 +51,6 @@ namespace WebCore {
     class ResourceRequestBase {
         WTF_MAKE_FAST_ALLOCATED;
     public:
-        // The type of this ResourceRequest, based on how the resource will be used.
-        enum TargetType {
-            TargetIsMainFrame,
-            TargetIsSubframe,
-            TargetIsSubresource,  // Resource is a generic subresource.  (Generally a specific type should be specified)
-            TargetIsStyleSheet,
-            TargetIsScript,
-            TargetIsFontResource,
-            TargetIsImage,
-            TargetIsObject,
-            TargetIsMedia,
-            TargetIsWorker,
-            TargetIsSharedWorker,
-            TargetIsPrefetch,
-            TargetIsPrerender,
-            TargetIsFavicon,
-        };
-
         static PassOwnPtr<ResourceRequest> adopt(PassOwnPtr<CrossThreadResourceRequestData>);
 
         // Gets a copy of the data suitable for passing to another thread.
@@ -147,11 +129,6 @@ namespace WebCore {
         bool reportRawHeaders() const { return m_reportRawHeaders; }
         void setReportRawHeaders(bool reportRawHeaders) { m_reportRawHeaders = reportRawHeaders; }
 
-        // What this request is for.
-        // FIXME: This should be moved out of ResourceRequestBase, <https://bugs.webkit.org/show_bug.cgi?id=48483>.
-        TargetType targetType() const { return m_targetType; }
-        void setTargetType(TargetType type) { m_targetType = type; }
-
         static double defaultTimeoutInterval(); // May return 0 when using platform default.
         static void setDefaultTimeoutInterval(double);
 
@@ -166,7 +143,6 @@ namespace WebCore {
             , m_reportLoadTiming(false)
             , m_reportRawHeaders(false)
             , m_priority(ResourceLoadPriorityLow)
-            , m_targetType(TargetIsSubresource)
         {
         }
 
@@ -182,7 +158,6 @@ namespace WebCore {
             , m_reportLoadTiming(false)
             , m_reportRawHeaders(false)
             , m_priority(ResourceLoadPriorityLow)
-            , m_targetType(TargetIsSubresource)
         {
         }
 
@@ -208,7 +183,6 @@ namespace WebCore {
         bool m_reportLoadTiming;
         bool m_reportRawHeaders;
         ResourceLoadPriority m_priority;
-        TargetType m_targetType;
 
     private:
         const ResourceRequest& asResourceRequest() const;
@@ -237,7 +211,6 @@ namespace WebCore {
         RefPtr<FormData> m_httpBody;
         bool m_allowCookies;
         ResourceLoadPriority m_priority;
-        ResourceRequestBase::TargetType m_targetType;
     };
     
     unsigned initializeMaximumHTTPConnectionCountPerHost();
index 519c63f..2541de7 100644 (file)
@@ -44,6 +44,7 @@ PassOwnPtr<CrossThreadResourceRequestData> ResourceRequest::doPlatformCopyData(P
     data->m_appCacheHostID = m_appCacheHostID;
     data->m_hasUserGesture = m_hasUserGesture;
     data->m_downloadToFile = m_downloadToFile;
+    data->m_targetType = m_targetType;
     return data;
 }
 
@@ -54,6 +55,7 @@ void ResourceRequest::doPlatformAdopt(PassOwnPtr<CrossThreadResourceRequestData>
     m_appCacheHostID = data->m_appCacheHostID;
     m_hasUserGesture = data->m_hasUserGesture;
     m_downloadToFile = data->m_downloadToFile;
+    m_targetType = data->m_targetType;
 }
 
 } // namespace WebCore
index c97e54b..6b578b0 100644 (file)
@@ -39,6 +39,24 @@ namespace WebCore {
 
     class ResourceRequest : public ResourceRequestBase {
     public:
+        // The type of this ResourceRequest, based on how the resource will be used.
+        enum TargetType {
+            TargetIsMainFrame,
+            TargetIsSubframe,
+            TargetIsSubresource, // Resource is a generic subresource. (Generally a specific type should be specified)
+            TargetIsStyleSheet,
+            TargetIsScript,
+            TargetIsFontResource,
+            TargetIsImage,
+            TargetIsObject,
+            TargetIsMedia,
+            TargetIsWorker,
+            TargetIsSharedWorker,
+            TargetIsPrefetch,
+            TargetIsPrerender,
+            TargetIsFavicon,
+        };
+
         class ExtraData : public RefCounted<ExtraData> {
         public:
             virtual ~ExtraData() { }
@@ -51,6 +69,7 @@ namespace WebCore {
             , m_appCacheHostID(0)
             , m_hasUserGesture(false)
             , m_downloadToFile(false)
+            , m_targetType(TargetIsSubresource)
         {
         }
 
@@ -61,6 +80,7 @@ namespace WebCore {
             , m_appCacheHostID(0)
             , m_hasUserGesture(false)
             , m_downloadToFile(false)
+            , m_targetType(TargetIsSubresource)
         {
         }
 
@@ -71,6 +91,7 @@ namespace WebCore {
             , m_appCacheHostID(0)
             , m_hasUserGesture(false)
             , m_downloadToFile(false)
+            , m_targetType(TargetIsSubresource)
         {
             setHTTPReferrer(referrer);
         }
@@ -82,6 +103,7 @@ namespace WebCore {
             , m_appCacheHostID(0)
             , m_hasUserGesture(false)
             , m_downloadToFile(false)
+            , m_targetType(TargetIsSubresource)
         {
         }
 
@@ -112,6 +134,10 @@ namespace WebCore {
         ExtraData* extraData() const { return m_extraData.get(); }
         void setExtraData(PassRefPtr<ExtraData> extraData) { m_extraData = extraData; }
 
+        // What this request is for.
+        TargetType targetType() const { return m_targetType; }
+        void setTargetType(TargetType type) { m_targetType = type; }
+
     private:
         friend class ResourceRequestBase;
 
@@ -127,6 +153,7 @@ namespace WebCore {
         bool m_hasUserGesture;
         bool m_downloadToFile;
         RefPtr<ExtraData> m_extraData;
+        TargetType m_targetType;
     };
 
     struct CrossThreadResourceRequestData : public CrossThreadResourceRequestDataBase {
@@ -135,6 +162,7 @@ namespace WebCore {
         int m_appCacheHostID;
         bool m_hasUserGesture;
         bool m_downloadToFile;
+        ResourceRequest::TargetType m_targetType;
     };
 
 } // namespace WebCore
index 5f6cebe..23da9ff 100644 (file)
@@ -288,7 +288,10 @@ void SharedWorkerScriptLoader::load(const KURL& url)
     m_worker->setPendingActivity(m_worker.get());
 
     // Mark this object as active for the duration of the load.
-    m_scriptLoader = WorkerScriptLoader::create(ResourceRequestBase::TargetIsSharedWorker);
+    m_scriptLoader = WorkerScriptLoader::create();
+#if PLATFORM(CHROMIUM)
+    m_scriptLoader->setTargetType(ResourceRequest::TargetIsSharedWorker);
+#endif
     m_scriptLoader->loadAsynchronously(m_worker->scriptExecutionContext(), url, DenyCrossOriginRequests, this);
 }
 
index 724f641..237b610 100644 (file)
@@ -67,7 +67,10 @@ PassRefPtr<Worker> Worker::create(const String& url, ScriptExecutionContext* con
     // The worker context does not exist while loading, so we must ensure that the worker object is not collected, nor are its event listeners.
     worker->setPendingActivity(worker.get());
 
-    worker->m_scriptLoader = WorkerScriptLoader::create(ResourceRequestBase::TargetIsWorker);
+    worker->m_scriptLoader = WorkerScriptLoader::create();
+#if PLATFORM(CHROMIUM)
+    worker->m_scriptLoader->setTargetType(ResourceRequest::TargetIsWorker);
+#endif
     worker->m_scriptLoader->loadAsynchronously(context, scriptURL, DenyCrossOriginRequests, worker.get());
 
     InspectorInstrumentation::didCreateWorker(context, worker->asID(), scriptURL.string(), false);
index 58eb854..930c360 100644 (file)
@@ -245,7 +245,10 @@ void WorkerContext::importScripts(const Vector<String>& urls, ExceptionCode& ec)
     Vector<KURL>::const_iterator end = completedURLs.end();
 
     for (Vector<KURL>::const_iterator it = completedURLs.begin(); it != end; ++it) {
-        RefPtr<WorkerScriptLoader> scriptLoader(WorkerScriptLoader::create(ResourceRequestBase::TargetIsScript));
+        RefPtr<WorkerScriptLoader> scriptLoader(WorkerScriptLoader::create());
+#if PLATFORM(CHROMIUM)
+        scriptLoader->setTargetType(ResourceRequest::TargetIsScript);
+#endif
         scriptLoader->loadSynchronously(scriptExecutionContext(), *it, AllowCrossOriginRequests);
 
         // If the fetching attempt failed, throw a NETWORK_ERR exception and abort all these steps.
index 13bf427..88b4c3d 100644 (file)
@@ -32,7 +32,6 @@
 #include "WorkerScriptLoader.h"
 
 #include "CrossThreadTask.h"
-#include "ResourceRequest.h"
 #include "ResourceResponse.h"
 #include "ScriptExecutionContext.h"
 #include "SecurityOrigin.h"
 
 namespace WebCore {
 
-WorkerScriptLoader::WorkerScriptLoader(ResourceRequestBase::TargetType targetType)
+WorkerScriptLoader::WorkerScriptLoader()
     : m_client(0)
     , m_failed(false)
     , m_identifier(0)
-    , m_targetType(targetType)
     , m_finishing(false)
+#if PLATFORM(CHROMIUM)
+    , m_targetType(ResourceRequest::TargetIsWorker)
+#endif
 {
 }
 
@@ -108,7 +109,9 @@ PassOwnPtr<ResourceRequest> WorkerScriptLoader::createResourceRequest()
 {
     OwnPtr<ResourceRequest> request = adoptPtr(new ResourceRequest(m_url));
     request->setHTTPMethod("GET");
+#if PLATFORM(CHROMIUM)
     request->setTargetType(m_targetType);
+#endif
     return request.release();
 }
     
index bec8a6a..95a1897 100644 (file)
@@ -31,7 +31,7 @@
 #if ENABLE(WORKERS)
 
 #include "KURL.h"
-#include "ResourceRequestBase.h"
+#include "ResourceRequest.h"
 #include "ThreadableLoader.h"
 #include "ThreadableLoaderClient.h"
 
@@ -50,9 +50,9 @@ namespace WebCore {
     class WorkerScriptLoader : public RefCounted<WorkerScriptLoader>, public ThreadableLoaderClient {
         WTF_MAKE_FAST_ALLOCATED;
     public:
-        static PassRefPtr<WorkerScriptLoader> create(ResourceRequestBase::TargetType targetType)
+        static PassRefPtr<WorkerScriptLoader> create()
         {
-            return adoptRef(new WorkerScriptLoader(targetType));
+            return adoptRef(new WorkerScriptLoader());
         }
 
         void loadSynchronously(ScriptExecutionContext*, const KURL&, CrossOriginRequestPolicy);
@@ -73,10 +73,14 @@ namespace WebCore {
         virtual void didFailRedirectCheck();
         virtual void didReceiveAuthenticationCancellation(unsigned long /*identifier*/, const ResourceResponse&);
 
+#if PLATFORM(CHROMIUM)
+        void setTargetType(ResourceRequest::TargetType targetType) { m_targetType = targetType; }
+#endif
+
     private:
         friend class WTF::RefCounted<WorkerScriptLoader>;
 
-        explicit WorkerScriptLoader(ResourceRequestBase::TargetType);
+        WorkerScriptLoader();
         ~WorkerScriptLoader();
 
         PassOwnPtr<ResourceRequest> createResourceRequest();
@@ -91,8 +95,10 @@ namespace WebCore {
         KURL m_responseURL;
         bool m_failed;
         unsigned long m_identifier;
-        ResourceRequestBase::TargetType m_targetType;
         bool m_finishing;
+#if PLATFORM(CHROMIUM)
+        ResourceRequest::TargetType m_targetType;
+#endif
     };
 
 } // namespace WebCore
index d28646d..3a9ecab 100644 (file)
@@ -1,3 +1,13 @@
+2011-08-04  Jochen Eisinger  <jochen@chromium.org>
+
+        Get rid of ResourceRequestBase::m_targetType. Move it to chromium's ResourceRequest.
+        https://bugs.webkit.org/show_bug.cgi?id=48483
+
+        Reviewed by Alexey Proskuryakov.
+
+        * src/SharedWorkerRepository.cpp:
+        (WebCore::SharedWorkerScriptLoader::SharedWorkerScriptLoader):
+
 2011-08-04  Brian Weinstein  <bweinstein@apple.com>
 
         WebKit2: Web Inspector always starts in undocked mode
index e2421ae..52c22be 100644 (file)
@@ -70,10 +70,11 @@ public:
         , m_name(name)
         , m_webWorker(webWorker)
         , m_port(port)
-        , m_scriptLoader(WorkerScriptLoader::create(ResourceRequestBase::TargetIsSharedWorker))
+        , m_scriptLoader(WorkerScriptLoader::create())
         , m_loading(false)
         , m_responseAppCacheID(0)
     {
+        m_scriptLoader->setTargetType(ResourceRequest::TargetIsSharedWorker);
     }
 
     ~SharedWorkerScriptLoader();