handleDataURL is only used by curl
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Jun 2016 22:26:34 +0000 (22:26 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Jun 2016 22:26:34 +0000 (22:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=158636

Reviewed by Tim Horton.

* CMakeLists.txt:
* platform/network/DataURL.cpp: Removed.
* platform/network/DataURL.h: Removed.
* platform/network/curl/ResourceHandleManager.cpp:
(WebCore::ResourceHandleManager::startScheduledJobs):
(WebCore::handleDataURL):
(WebCore::ResourceHandleManager::dispatchSynchronousJob):

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

Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/platform/network/DataURL.cpp [deleted file]
Source/WebCore/platform/network/DataURL.h [deleted file]
Source/WebCore/platform/network/curl/ResourceHandleManager.cpp

index 73e6255..3205d43 100644 (file)
@@ -2331,7 +2331,6 @@ set(WebCore_SOURCES
     platform/network/CredentialBase.cpp
     platform/network/CredentialStorage.cpp
     platform/network/DNSResolveQueue.cpp
     platform/network/CredentialBase.cpp
     platform/network/CredentialStorage.cpp
     platform/network/DNSResolveQueue.cpp
-    platform/network/DataURL.cpp
     platform/network/DataURLDecoder.cpp
     platform/network/FormData.cpp
     platform/network/FormDataBuilder.cpp
     platform/network/DataURLDecoder.cpp
     platform/network/FormData.cpp
     platform/network/FormDataBuilder.cpp
index 48608e7..d03267f 100644 (file)
@@ -1,5 +1,20 @@
 2016-06-10  Alex Christensen  <achristensen@webkit.org>
 
 2016-06-10  Alex Christensen  <achristensen@webkit.org>
 
+        handleDataURL is only used by curl
+        https://bugs.webkit.org/show_bug.cgi?id=158636
+
+        Reviewed by Tim Horton.
+
+        * CMakeLists.txt:
+        * platform/network/DataURL.cpp: Removed.
+        * platform/network/DataURL.h: Removed.
+        * platform/network/curl/ResourceHandleManager.cpp:
+        (WebCore::ResourceHandleManager::startScheduledJobs):
+        (WebCore::handleDataURL):
+        (WebCore::ResourceHandleManager::dispatchSynchronousJob):
+
+2016-06-10  Alex Christensen  <achristensen@webkit.org>
+
         Reduce ResourceResponse copying
         https://bugs.webkit.org/show_bug.cgi?id=158232
 
         Reduce ResourceResponse copying
         https://bugs.webkit.org/show_bug.cgi?id=158232
 
diff --git a/Source/WebCore/platform/network/DataURL.cpp b/Source/WebCore/platform/network/DataURL.cpp
deleted file mode 100644 (file)
index 4dc4832..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DataURL.h"
-
-#include "HTTPParsers.h"
-#include "ResourceHandle.h"
-#include "ResourceHandleClient.h"
-#include "ResourceRequest.h"
-#include "ResourceResponse.h"
-#include "TextEncoding.h"
-#include <wtf/text/Base64.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/StringView.h>
-
-namespace WebCore {
-
-void handleDataURL(ResourceHandle* handle)
-{
-    ASSERT(handle->firstRequest().url().protocolIsData());
-    String url = handle->firstRequest().url().string();
-
-    ASSERT(handle);
-    ASSERT(handle->client());
-
-    int index = url.find(',');
-    if (index == -1) {
-        handle->client()->cannotShowURL(handle);
-        return;
-    }
-
-    String mediaType = url.substring(5, index - 5);
-    String data = url.substring(index + 1);
-
-    bool base64 = mediaType.endsWith(";base64", false);
-    if (base64)
-        mediaType = mediaType.left(mediaType.length() - 7);
-
-    if (mediaType.isEmpty())
-        mediaType = "text/plain";
-
-    String mimeType = extractMIMETypeFromMediaType(mediaType);
-    String charset = extractCharsetFromMediaType(mediaType);
-
-    if (charset.isEmpty())
-        charset = "US-ASCII";
-
-    ResourceResponse response;
-    response.setMimeType(mimeType);
-    response.setTextEncodingName(charset);
-    response.setURL(handle->firstRequest().url());
-
-    if (base64) {
-        data = decodeURLEscapeSequences(data);
-        handle->client()->didReceiveResponse(handle, WTFMove(response));
-
-        // didReceiveResponse might cause the client to be deleted.
-        if (handle->client()) {
-            Vector<char> out;
-            if (base64Decode(data, out, Base64IgnoreSpacesAndNewLines) && out.size() > 0)
-                handle->client()->didReceiveData(handle, out.data(), out.size(), 0);
-        }
-    } else {
-        TextEncoding encoding(charset);
-        data = decodeURLEscapeSequences(data, encoding);
-        handle->client()->didReceiveResponse(handle, WTFMove(response));
-
-        // didReceiveResponse might cause the client to be deleted.
-        if (handle->client()) {
-            CString encodedData = encoding.encode(data, URLEncodedEntitiesForUnencodables);
-            if (encodedData.length())
-                handle->client()->didReceiveData(handle, encodedData.data(), encodedData.length(), 0);
-        }
-    }
-
-    if (handle->client())
-        handle->client()->didFinishLoading(handle, 0);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/network/DataURL.h b/Source/WebCore/platform/network/DataURL.h
deleted file mode 100644 (file)
index 706cf1f..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef DataURL_h
-#define DataURL_h
-
-namespace WebCore {
-
-class ResourceHandle;
-
-void handleDataURL(ResourceHandle*);
-
-}
-
-#endif // DataURL_h
index 7a06ce5..16d7db3 100644 (file)
@@ -7,6 +7,7 @@
  * Copyright (C) 2008 Nuanti Ltd.
  * Copyright (C) 2009 Appcelerator Inc.
  * Copyright (C) 2009 Brent Fulgham <bfulgham@webkit.org>
  * Copyright (C) 2008 Nuanti Ltd.
  * Copyright (C) 2009 Appcelerator Inc.
  * Copyright (C) 2009 Brent Fulgham <bfulgham@webkit.org>
+ * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
  * Copyright (C) 2013 Peter Gal <galpeter@inf.u-szeged.hu>, University of Szeged
  * Copyright (C) 2013 Alex Christensen <achristensen@webkit.org>
  * Copyright (C) 2013 University of Szeged
  * Copyright (C) 2013 Peter Gal <galpeter@inf.u-szeged.hu>, University of Szeged
  * Copyright (C) 2013 Alex Christensen <achristensen@webkit.org>
  * Copyright (C) 2013 University of Szeged
 #include "MultipartHandle.h"
 #include "ResourceError.h"
 #include "ResourceHandle.h"
 #include "MultipartHandle.h"
 #include "ResourceError.h"
 #include "ResourceHandle.h"
+#include "ResourceHandleClient.h"
 #include "ResourceHandleInternal.h"
 #include "ResourceHandleInternal.h"
+#include "ResourceRequest.h"
+#include "ResourceResponse.h"
 #include "SSLHandle.h"
 #include "SSLHandle.h"
+#include "TextEncoding.h"
+#include <wtf/text/Base64.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/StringView.h>
 
 #if OS(WINDOWS)
 #include "WebCoreBundleWin.h"
 
 #if OS(WINDOWS)
 #include "WebCoreBundleWin.h"
@@ -73,7 +81,6 @@
 #include <wtf/Vector.h>
 #include <wtf/text/CString.h>
 
 #include <wtf/Vector.h>
 #include <wtf/text/CString.h>
 
-
 namespace WebCore {
 
 const int selectTimeoutMS = 5;
 namespace WebCore {
 
 const int selectTimeoutMS = 5;
@@ -906,6 +913,68 @@ bool ResourceHandleManager::startScheduledJobs()
     return started;
 }
 
     return started;
 }
 
+static void handleDataURL(ResourceHandle* handle)
+{
+    ASSERT(handle->firstRequest().url().protocolIsData());
+    String url = handle->firstRequest().url().string();
+
+    ASSERT(handle);
+    ASSERT(handle->client());
+
+    int index = url.find(',');
+    if (index == -1) {
+        handle->client()->cannotShowURL(handle);
+        return;
+    }
+
+    String mediaType = url.substring(5, index - 5);
+    String data = url.substring(index + 1);
+
+    bool base64 = mediaType.endsWith(";base64", false);
+    if (base64)
+        mediaType = mediaType.left(mediaType.length() - 7);
+
+    if (mediaType.isEmpty())
+        mediaType = "text/plain";
+
+    String mimeType = extractMIMETypeFromMediaType(mediaType);
+    String charset = extractCharsetFromMediaType(mediaType);
+
+    if (charset.isEmpty())
+        charset = "US-ASCII";
+
+    ResourceResponse response;
+    response.setMimeType(mimeType);
+    response.setTextEncodingName(charset);
+    response.setURL(handle->firstRequest().url());
+
+    if (base64) {
+        data = decodeURLEscapeSequences(data);
+        handle->client()->didReceiveResponse(handle, WTFMove(response));
+
+        // didReceiveResponse might cause the client to be deleted.
+        if (handle->client()) {
+            Vector<char> out;
+            if (base64Decode(data, out, Base64IgnoreSpacesAndNewLines) && out.size() > 0)
+                handle->client()->didReceiveData(handle, out.data(), out.size(), 0);
+        }
+    } else {
+        TextEncoding encoding(charset);
+        data = decodeURLEscapeSequences(data, encoding);
+        handle->client()->didReceiveResponse(handle, WTFMove(response));
+
+        // didReceiveResponse might cause the client to be deleted.
+        if (handle->client()) {
+            CString encodedData = encoding.encode(data, URLEncodedEntitiesForUnencodables);
+            if (encodedData.length())
+                handle->client()->didReceiveData(handle, encodedData.data(), encodedData.length(), 0);
+        }
+    }
+
+    if (handle->client())
+        handle->client()->didFinishLoading(handle, 0);
+}
+
 void ResourceHandleManager::dispatchSynchronousJob(ResourceHandle* job)
 {
     URL kurl = job->firstRequest().url();
 void ResourceHandleManager::dispatchSynchronousJob(ResourceHandle* job)
 {
     URL kurl = job->firstRequest().url();