Diff
Modified: trunk/Source/WebCore/ChangeLog (222186 => 222187)
--- trunk/Source/WebCore/ChangeLog 2017-09-18 22:41:04 UTC (rev 222186)
+++ trunk/Source/WebCore/ChangeLog 2017-09-18 23:02:23 UTC (rev 222187)
@@ -1,3 +1,30 @@
+2017-09-18 Basuke Suzuki <[email protected]>
+
+ [Curl] Move error generation task into ResourceError
+ https://bugs.webkit.org/show_bug.cgi?id=176963
+
+ Reviewed by Alex Christensen.
+
+ * platform/Curl.cmake:
+ * platform/network/curl/CurlContext.cpp:
+ (WebCore::CurlHandle::errorDescription):
+ (WebCore::CurlHandle::errorDescription const):
+ * platform/network/curl/CurlContext.h:
+ * platform/network/curl/ResourceError.h:
+ (WebCore::ResourceError::setSslErrors):
+ (WebCore::ResourceError::hasSSLConnectError const): Deleted.
+ (WebCore::ResourceError::doPlatformIsolatedCopy): Deleted.
+ * platform/network/curl/ResourceErrorCurl.cpp: Added.
+ (WebCore::ResourceError::httpError):
+ (WebCore::ResourceError::sslError):
+ (WebCore::ResourceError::hasSSLConnectError const):
+ (WebCore::ResourceError::doPlatformIsolatedCopy):
+ (WebCore::ResourceError::platformCompare):
+ * platform/network/curl/ResourceHandleCurlDelegate.cpp:
+ (WebCore::ResourceHandleCurlDelegate::notifyFail):
+ (WebCore::ResourceHandleCurlDelegate::didFail):
+ * platform/network/curl/ResourceHandleCurlDelegate.h:
+
2017-09-18 Ryan Haddad <[email protected]>
Unreviewed, rolling out r222170.
Modified: trunk/Source/WebCore/platform/Curl.cmake (222186 => 222187)
--- trunk/Source/WebCore/platform/Curl.cmake 2017-09-18 22:41:04 UTC (rev 222186)
+++ trunk/Source/WebCore/platform/Curl.cmake 2017-09-18 23:02:23 UTC (rev 222187)
@@ -16,6 +16,7 @@
platform/network/curl/FormDataStreamCurl.cpp
platform/network/curl/MultipartHandle.cpp
platform/network/curl/ProxyServerCurl.cpp
+ platform/network/curl/ResourceErrorCurl.cpp
platform/network/curl/ResourceHandleCurl.cpp
platform/network/curl/ResourceHandleCurlDelegate.cpp
platform/network/curl/ResourceResponseCurl.cpp
Modified: trunk/Source/WebCore/platform/network/curl/CurlContext.cpp (222186 => 222187)
--- trunk/Source/WebCore/platform/network/curl/CurlContext.cpp 2017-09-18 22:41:04 UTC (rev 222186)
+++ trunk/Source/WebCore/platform/network/curl/CurlContext.cpp 2017-09-18 23:02:23 UTC (rev 222187)
@@ -77,8 +77,6 @@
// CurlContext -------------------------------------------------------------------
-const char* const CurlContext::errorDomain = "CurlErrorDomain";
-
CurlContext::CurlContext()
: m_cookieJarFileName { cookieJarPath() }
, m_cookieJar { std::make_unique<CookieJarCurlFileSystem>() }
@@ -265,9 +263,14 @@
curl_easy_cleanup(m_handle);
}
+const String CurlHandle::errorDescription(CURLcode errorCode)
+{
+ return String(curl_easy_strerror(errorCode));
+}
+
const String CurlHandle::errorDescription() const
{
- return String(curl_easy_strerror(m_errorCode));
+ return errorDescription(m_errorCode);
}
void CurlHandle::initialize()
Modified: trunk/Source/WebCore/platform/network/curl/CurlContext.h (222186 => 222187)
--- trunk/Source/WebCore/platform/network/curl/CurlContext.h 2017-09-18 22:41:04 UTC (rev 222186)
+++ trunk/Source/WebCore/platform/network/curl/CurlContext.h 2017-09-18 23:02:23 UTC (rev 222187)
@@ -104,8 +104,6 @@
const String url() const;
};
- static const char* const errorDomain;
-
static CurlContext& singleton()
{
static CurlContext shared;
@@ -229,6 +227,7 @@
CURLcode errorCode() const { return m_errorCode; }
void setErrorCode(CURLcode errorCode) { m_errorCode = errorCode; }
+ static const String errorDescription(CURLcode);
const String errorDescription() const;
void enableShareHandle();
Modified: trunk/Source/WebCore/platform/network/curl/ResourceError.h (222186 => 222187)
--- trunk/Source/WebCore/platform/network/curl/ResourceError.h 2017-09-18 22:41:04 UTC (rev 222186)
+++ trunk/Source/WebCore/platform/network/curl/ResourceError.h 2017-09-18 23:02:23 UTC (rev 222187)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006 Apple Inc. All rights reserved.
+ * Copyright (C) 2017 Sony Interactive Entertainment Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -25,7 +26,6 @@
#pragma once
-#include "CurlContext.h"
#include "ResourceErrorBase.h"
namespace WebCore {
@@ -32,6 +32,7 @@
class ResourceError : public ResourceErrorBase {
friend class ResourceErrorBase;
+
public:
ResourceError(Type type = Type::Null)
: ResourceErrorBase(type)
@@ -43,18 +44,20 @@
{
}
- ResourceError(const String& domain, int errorCode, const URL& failingURL, const String& localizedDescription, unsigned sslErrors, Type type = Type::General)
- : ResourceErrorBase(domain, errorCode, failingURL, localizedDescription, type)
- , m_sslErrors(sslErrors)
- {
- }
+ static ResourceError httpError(int errorCode, const URL& failingURL);
+ static ResourceError sslError(int errorCode, unsigned sslErrors, const URL& failingURL);
unsigned sslErrors() const { return m_sslErrors; }
- bool hasSSLConnectError() const { return errorCode() == CURLE_SSL_CONNECT_ERROR; }
+ void setSslErrors(unsigned sslErrors) { m_sslErrors = sslErrors; }
+ bool hasSSLConnectError() const;
+ static bool platformCompare(const ResourceError& a, const ResourceError& b);
+
private:
- void doPlatformIsolatedCopy(const ResourceError&) { }
+ void doPlatformIsolatedCopy(const ResourceError&);
+ static const char* const curlErrorDomain;
+
unsigned m_sslErrors { 0 };
};
Added: trunk/Source/WebCore/platform/network/curl/ResourceErrorCurl.cpp (0 => 222187)
--- trunk/Source/WebCore/platform/network/curl/ResourceErrorCurl.cpp (rev 0)
+++ trunk/Source/WebCore/platform/network/curl/ResourceErrorCurl.cpp 2017-09-18 23:02:23 UTC (rev 222187)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2017 Sony Interactive Entertainment Inc.
+ *
+ * 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 INC. 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 ITS 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 "ResourceError.h"
+
+#if USE(CURL)
+
+#include "CurlContext.h"
+
+namespace WebCore {
+
+const char* const ResourceError::curlErrorDomain = "CurlErrorDomain";
+
+ResourceError ResourceError::httpError(int errorCode, const URL& failingURL)
+{
+ return ResourceError(curlErrorDomain, errorCode, failingURL, CurlHandle::errorDescription(static_cast<CURLcode>(errorCode)));
+}
+
+ResourceError ResourceError::sslError(int errorCode, unsigned sslErrors, const URL& failingURL)
+{
+ ResourceError resourceError = ResourceError::httpError(errorCode, failingURL);
+ resourceError.setSslErrors(sslErrors);
+ return resourceError;
+}
+
+bool ResourceError::hasSSLConnectError() const
+{
+ return errorCode() == CURLE_SSL_CONNECT_ERROR;
+}
+
+void ResourceError::doPlatformIsolatedCopy(const ResourceError& other)
+{
+ m_sslErrors = other.m_sslErrors;
+}
+
+bool ResourceError::platformCompare(const ResourceError& a, const ResourceError& b)
+{
+ return a.sslErrors() == b.sslErrors();
+}
+
+} // namespace WebCore
+
+#endif
Modified: trunk/Source/WebCore/platform/network/curl/ResourceHandleCurlDelegate.cpp (222186 => 222187)
--- trunk/Source/WebCore/platform/network/curl/ResourceHandleCurlDelegate.cpp 2017-09-18 22:41:04 UTC (rev 222186)
+++ trunk/Source/WebCore/platform/network/curl/ResourceHandleCurlDelegate.cpp 2017-09-18 23:02:23 UTC (rev 222187)
@@ -284,19 +284,17 @@
void ResourceHandleCurlDelegate::notifyFail()
{
- String domain = CurlContext::errorDomain;
- int errorCode = m_curlHandle.errorCode();
- URL failingURL = m_curlHandle.getEffectiveURL();
- String errorDescription = m_curlHandle.errorDescription();
- unsigned sslErrors = m_sslVerifier.sslErrors();
+ ResourceError resourceError = ResourceError::httpError(m_curlHandle.errorCode(), m_firstRequest.url());
+ if (m_sslVerifier.sslErrors())
+ resourceError.setSslErrors(m_sslVerifier.sslErrors());
if (isMainThread())
- didFail(domain, errorCode, failingURL, errorDescription, sslErrors);
+ didFail(resourceError);
else {
- callOnMainThread([protectedThis = makeRef(*this), domain = domain.isolatedCopy(), errorCode, failingURL = failingURL.isolatedCopy(), errorDescription = errorDescription.isolatedCopy(), sslErrors] {
+ callOnMainThread([protectedThis = makeRef(*this), error = resourceError.isolatedCopy()] {
if (!protectedThis->m_handle)
return;
- protectedThis->didFail(domain, errorCode, failingURL, errorDescription, sslErrors);
+ protectedThis->didFail(error);
});
}
}
@@ -525,7 +523,7 @@
}
}
-void ResourceHandleCurlDelegate::didFail(const String& domain, int errorCode, const URL& failingURL, const String& localizedDescription, unsigned sslErrors)
+void ResourceHandleCurlDelegate::didFail(const ResourceError& resourceError)
{
if (!m_handle)
return;
@@ -532,7 +530,7 @@
if (m_handle->client()) {
CurlCacheManager::getInstance().didFail(*m_handle);
- m_handle->client()->didFail(m_handle, ResourceError(domain, errorCode, failingURL, localizedDescription, sslErrors));
+ m_handle->client()->didFail(m_handle, resourceError);
}
}
Modified: trunk/Source/WebCore/platform/network/curl/ResourceHandleCurlDelegate.h (222186 => 222187)
--- trunk/Source/WebCore/platform/network/curl/ResourceHandleCurlDelegate.h 2017-09-18 22:41:04 UTC (rev 222186)
+++ trunk/Source/WebCore/platform/network/curl/ResourceHandleCurlDelegate.h 2017-09-18 23:02:23 UTC (rev 222187)
@@ -81,7 +81,7 @@
void prepareSendData(char*, size_t blockSize, size_t numberOfBlocks);
void didFinish(NetworkLoadMetrics);
- void didFail(const String& domain, int errorCode, const URL& failingURL, const String& localizedDescription, unsigned sslErrors);
+ void didFail(const ResourceError&);
void handleDataURL();