diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-30 22:42:58 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-30 22:42:58 +0000 |
commit | eed529ce5d09706bc2b9da5b96822eda2919a9ae (patch) | |
tree | f5afad43a1e8412ed9473fa9d7e418621373decd /webkit/api/src | |
parent | ee8f54a54cab5cc3eaf837622ec61b482fac8858 (diff) | |
download | chromium_src-eed529ce5d09706bc2b9da5b96822eda2919a9ae.zip chromium_src-eed529ce5d09706bc2b9da5b96822eda2919a9ae.tar.gz chromium_src-eed529ce5d09706bc2b9da5b96822eda2919a9ae.tar.bz2 |
Revert WebURLLoader landing. Too many layout test failures.
TBR=dglazkov
Review URL: http://codereview.chromium.org/115973
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17293 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/api/src')
-rw-r--r-- | webkit/api/src/ResourceHandle.cpp | 279 | ||||
-rw-r--r-- | webkit/api/src/WebDragData.cpp | 5 | ||||
-rw-r--r-- | webkit/api/src/WebHTTPBody.cpp | 124 | ||||
-rw-r--r-- | webkit/api/src/WebURLError.cpp | 69 | ||||
-rw-r--r-- | webkit/api/src/WebURLRequest.cpp | 246 | ||||
-rw-r--r-- | webkit/api/src/WebURLRequestPrivate.h | 53 | ||||
-rw-r--r-- | webkit/api/src/WebURLResponse.cpp | 259 | ||||
-rw-r--r-- | webkit/api/src/WebURLResponsePrivate.h | 50 | ||||
-rw-r--r-- | webkit/api/src/WrappedResourceRequest.h | 67 | ||||
-rw-r--r-- | webkit/api/src/WrappedResourceResponse.h | 68 |
10 files changed, 4 insertions, 1216 deletions
diff --git a/webkit/api/src/ResourceHandle.cpp b/webkit/api/src/ResourceHandle.cpp deleted file mode 100644 index b7def8d..0000000 --- a/webkit/api/src/ResourceHandle.cpp +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * 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. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT - * OWNER 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 "ResourceHandle.h" - -#include "WebKit.h" -#include "WebKitClient.h" -#include "WebURLError.h" -#include "WebURLLoader.h" -#include "WebURLLoaderClient.h" -#include "WebURLRequest.h" -#include "WebURLResponse.h" -#include "WrappedResourceRequest.h" -#include "WrappedResourceResponse.h" - -#include "ResourceHandleClient.h" -#include "ResourceRequest.h" - -using namespace WebKit; - -namespace WebCore { - -// ResourceHandleInternal ----------------------------------------------------- - -class ResourceHandleInternal : public WebURLLoaderClient { -public: - ResourceHandleInternal(const ResourceRequest& request, ResourceHandleClient* client) - : m_request(request) - , m_owner(0) - , m_client(client) - { - } - - void start(); - void cancel(); - void setDefersLoading(bool); - - // WebURLLoaderClient methods: - virtual void willSendRequest(WebURLLoader*, WebURLRequest&, const WebURLResponse&); - virtual void didSendData( - WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent); - virtual void didReceiveResponse(WebURLLoader*, const WebURLResponse&); - virtual void didReceiveData( - WebURLLoader*, const char* data, int dataLength, long long totalDataLength); - virtual void didFinishLoading(WebURLLoader*); - virtual void didFail(WebURLLoader*, const WebURLError&); - - ResourceRequest m_request; - ResourceHandle* m_owner; - ResourceHandleClient* m_client; - OwnPtr<WebURLLoader> m_loader; -}; - -void ResourceHandleInternal::start() -{ - m_loader.set(webKitClient()->createURLLoader()); - ASSERT(m_loader.get()); - - WrappedResourceRequest wrappedRequest(m_request); - m_loader->loadAsynchronously(wrappedRequest, this); -} - -void ResourceHandleInternal::cancel() -{ - m_loader->cancel(); - - // Do not make any further calls to the client. - m_client = 0; -} - -void ResourceHandleInternal::setDefersLoading(bool value) -{ - m_loader->setDefersLoading(value); -} - -void ResourceHandleInternal::willSendRequest( - WebURLLoader*, WebURLRequest& request, const WebURLResponse& response) -{ - ASSERT(m_client); - ASSERT(!request.isNull()); - ASSERT(!response.isNull()); - m_client->willSendRequest(m_owner, request.toMutableResourceRequest(), response.toResourceResponse()); -} - -void ResourceHandleInternal::didSendData( - WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) -{ - ASSERT(m_client); - m_client->didSendData(m_owner, bytesSent, totalBytesToBeSent); -} - -void ResourceHandleInternal::didReceiveResponse(WebURLLoader*, const WebURLResponse& response) -{ - ASSERT(m_client); - ASSERT(!response.isNull()); - m_client->didReceiveResponse(m_owner, response.toResourceResponse()); -} - -void ResourceHandleInternal::didReceiveData( - WebURLLoader*, const char* data, int dataLength, long long totalDataLength) -{ - ASSERT(m_client); - - // FIXME: ResourceHandleClient::didReceiveData should take a 'long long' - int lengthReceived = static_cast<int>(totalDataLength); - if (lengthReceived != totalDataLength) // overflow occurred - lengthReceived = -1; - - m_client->didReceiveData(m_owner, data, dataLength, lengthReceived); -} - -void ResourceHandleInternal::didFinishLoading(WebURLLoader*) -{ - ASSERT(m_client); - m_client->didFinishLoading(m_owner); -} - -void ResourceHandleInternal::didFail(WebURLLoader*, const WebURLError& error) -{ - ASSERT(m_client); - m_client->didFail(m_owner, error); -} - -// ResourceHandle ------------------------------------------------------------- - -ResourceHandle::ResourceHandle(const ResourceRequest& request, - ResourceHandleClient* client, - bool defersLoading, - bool shouldContentSniff, - bool mightDownloadFromHandle) - : d(new ResourceHandleInternal(request, client)) -{ - d->m_owner = this; - - // FIXME: Figure out what to do with the bool params. -} - -PassRefPtr<ResourceHandle> ResourceHandle::create(const ResourceRequest& request, - ResourceHandleClient* client, - Frame* deprecated, - bool defersLoading, - bool shouldContentSniff, - bool mightDownloadFromHandle) -{ - RefPtr<ResourceHandle> newHandle = adoptRef(new ResourceHandle( - request, client, defersLoading, shouldContentSniff, mightDownloadFromHandle)); - - if (newHandle->start(deprecated)) - return newHandle.release(); - - return 0; -} - -const ResourceRequest& ResourceHandle::request() const -{ - return d->m_request; -} - -ResourceHandleClient* ResourceHandle::client() const -{ - return d->m_client; -} - -void ResourceHandle::setClient(ResourceHandleClient* client) -{ - d->m_client = client; -} - -void ResourceHandle::setDefersLoading(bool value) -{ - d->setDefersLoading(value); -} - -bool ResourceHandle::start(Frame* deprecated) -{ - d->start(); - return true; -} - -void ResourceHandle::clearAuthentication() -{ -} - -void ResourceHandle::cancel() -{ - d->cancel(); -} - -ResourceHandle::~ResourceHandle() -{ - d->m_owner = 0; -} - -PassRefPtr<SharedBuffer> ResourceHandle::bufferedData() -{ - return 0; -} - -bool ResourceHandle::loadsBlocked() -{ - return false; // This seems to be related to sync XMLHttpRequest... -} - -// static -bool ResourceHandle::supportsBufferedData() -{ - return false; // The loader will buffer manually if it needs to. -} - -// static -void ResourceHandle::loadResourceSynchronously(const ResourceRequest& request, - StoredCredentials unused, - ResourceError& error, - ResourceResponse& response, - Vector<char>& data, - Frame* deprecated) -{ - OwnPtr<WebURLLoader> loader(webKitClient()->createURLLoader()); - ASSERT(loader.get()); - - WrappedResourceRequest requestIn(request); - WrappedResourceResponse responseOut(response); - WebURLError errorOut; - WebData dataOut; - - loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut); - - error = errorOut; - data.clear(); - data.append(dataOut.data(), dataOut.size()); -} - -// static -bool ResourceHandle::willLoadFromCache(ResourceRequest& request) -{ - // This method is used to determine if a POST request can be repeated from - // cache, but you cannot really know until you actually try to read from the - // cache. Even if we checked now, something else could come along and wipe - // out the cache entry by the time we fetch it. - // - // So, we always say yes here, which allows us to generate an ERR_CACHE_MISS - // if the request cannot be serviced from cache. We force the 'DontLoad' - // cache policy at this point to ensure that we never hit the network for - // this request. - // - ASSERT(request.httpMethod() == "POST"); - request.setCachePolicy(ReturnCacheDataDontLoad); - return true; -} - -} // namespace WebCore diff --git a/webkit/api/src/WebDragData.cpp b/webkit/api/src/WebDragData.cpp index a8210ac..426ceea 100644 --- a/webkit/api/src/WebDragData.cpp +++ b/webkit/api/src/WebDragData.cpp @@ -53,7 +53,10 @@ void WebDragData::initialize() void WebDragData::reset() { - assign(0); + if (m_private) { + m_private->deref(); + m_private = 0; + } } void WebDragData::assign(const WebDragData& other) diff --git a/webkit/api/src/WebHTTPBody.cpp b/webkit/api/src/WebHTTPBody.cpp deleted file mode 100644 index 69875e7..0000000 --- a/webkit/api/src/WebHTTPBody.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * 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. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT - * OWNER 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 "WebHTTPBody.h" - -#include "FormData.h" - -using namespace WebCore; - -namespace WebKit { - -class WebHTTPBodyPrivate : public FormData { -}; - -void WebHTTPBody::initialize() -{ - assign(static_cast<WebHTTPBodyPrivate*>(FormData::create().releaseRef())); -} - -void WebHTTPBody::reset() -{ - assign(0); -} - -size_t WebHTTPBody::elementCount() const -{ - return m_private->elements().size(); -} - -bool WebHTTPBody::elementAt(size_t index, Element& result) const -{ - if (index >= m_private->elements().size()) - return false; - - const FormDataElement& element = m_private->elements()[index]; - - switch (element.m_type) { - case FormDataElement::data: - result.type = Element::TypeData; - result.data.assign(element.m_data.data(), element.m_data.size()); - result.filePath.reset(); - break; - case FormDataElement::encodedFile: - result.type = Element::TypeFile; - result.data.reset(); - result.filePath = element.m_filename; - break; - default: - ASSERT_NOT_REACHED(); - return false; - } - - return true; -} - -void WebHTTPBody::appendData(const WebData& data) -{ - // FIXME: FormDataElement::m_data should be a SharedBuffer<char>. Then we - // could avoid this buffer copy. - m_private->appendData(data.data(), data.size()); -} - -void WebHTTPBody::appendFile(const WebString& filePath) -{ - m_private->appendFile(filePath); -} - -long long WebHTTPBody::identifier() const -{ - return m_private->identifier(); -} - -void WebHTTPBody::setIdentifier(long long identifier) -{ - return m_private->setIdentifier(identifier); -} - -void WebHTTPBody::rebind(PassRefPtr<FormData> formData) -{ - assign(static_cast<WebHTTPBodyPrivate*>(formData.releaseRef())); -} - -WebHTTPBody::operator PassRefPtr<FormData>() const -{ - return m_private; -} - -void WebHTTPBody::assign(WebHTTPBodyPrivate* p) -{ - // p is already ref'd for us by the caller - if (m_private) - m_private->deref(); - m_private = p; -} - -} // namespace WebKit diff --git a/webkit/api/src/WebURLError.cpp b/webkit/api/src/WebURLError.cpp deleted file mode 100644 index cd7d72d..0000000 --- a/webkit/api/src/WebURLError.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * 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. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT - * OWNER 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 "WebURLError.h" - -#include "CString.h" -#include "KURL.h" -#include "ResourceError.h" - -using namespace WebCore; - -namespace WebKit { - -WebURLError::WebURLError(const ResourceError& error) -{ - *this = error; -} - -WebURLError& WebURLError::operator=(const ResourceError& error) -{ - if (error.isNull()) - *this = WebURLError(); - else { - domain = error.domain(); - reason = error.errorCode(); - unreachableURL = KURL(error.failingURL()); - } - return *this; -} - -WebURLError::operator ResourceError() const -{ - if (reason == 0) - return ResourceError(); - CString spec = unreachableURL.spec(); - return ResourceError(domain, reason, - String::fromUTF8(spec.data(), spec.length()), - String()); -} - -} // namespace WebKit diff --git a/webkit/api/src/WebURLRequest.cpp b/webkit/api/src/WebURLRequest.cpp deleted file mode 100644 index 66483f9..0000000 --- a/webkit/api/src/WebURLRequest.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * 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. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT - * OWNER 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 "WebURLRequest.h" - -#include "WebHTTPHeaderVisitor.h" -#include "WebURL.h" -#include "WebURLRequestPrivate.h" - -#include "ResourceRequest.h" - -using namespace WebCore; - -namespace WebKit { - -// The standard implementation of WebURLRequestPrivate, which maintains -// ownership of a ResourceRequest instance. -class WebURLRequestPrivateImpl : public WebURLRequestPrivate { -public: - WebURLRequestPrivateImpl() - { - m_resourceRequest = &m_resourceRequestAllocation; - } - - WebURLRequestPrivateImpl(const WebURLRequestPrivate* p) - : m_resourceRequestAllocation(*p->m_resourceRequest) - { - m_resourceRequest = &m_resourceRequestAllocation; - } - - virtual void dispose() { delete this; } - - ResourceRequest m_resourceRequestAllocation; -}; - -void WebURLRequest::initialize() -{ - assign(new WebURLRequestPrivateImpl()); -} - -void WebURLRequest::reset() -{ - assign(0); -} - -void WebURLRequest::assign(const WebURLRequest& r) -{ - assign(r.m_private ? new WebURLRequestPrivateImpl(r.m_private) : 0); -} - -WebURL WebURLRequest::url() const -{ - return m_private->m_resourceRequest->url(); -} - -void WebURLRequest::setURL(const WebURL& url) -{ - m_private->m_resourceRequest->setURL(url); -} - -WebURL WebURLRequest::firstPartyForCookies() const -{ - return m_private->m_resourceRequest->firstPartyForCookies(); -} - -void WebURLRequest::setFirstPartyForCookies(const WebURL& firstPartyForCookies) -{ - m_private->m_resourceRequest->setFirstPartyForCookies(firstPartyForCookies); -} - -WebURLRequest::CachePolicy WebURLRequest::cachePolicy() const -{ - return static_cast<WebURLRequest::CachePolicy>( - m_private->m_resourceRequest->cachePolicy()); -} - -void WebURLRequest::setCachePolicy(CachePolicy cachePolicy) -{ - m_private->m_resourceRequest->setCachePolicy( - static_cast<ResourceRequestCachePolicy>(cachePolicy)); -} - -WebString WebURLRequest::httpMethod() const -{ - return m_private->m_resourceRequest->httpMethod(); -} - -void WebURLRequest::setHTTPMethod(const WebString& httpMethod) -{ - m_private->m_resourceRequest->setHTTPMethod(httpMethod); -} - -WebString WebURLRequest::httpHeaderField(const WebString& name) const -{ - return m_private->m_resourceRequest->httpHeaderField(String(name)); -} - -void WebURLRequest::setHTTPHeaderField(const WebString& name, const WebString& value) -{ - m_private->m_resourceRequest->setHTTPHeaderField(String(name), value); -} - -void WebURLRequest::addHTTPHeaderField(const WebString& name, const WebString& value) -{ - m_private->m_resourceRequest->addHTTPHeaderField(String(name), value); -} - -void WebURLRequest::clearHTTPHeaderField(const WebString& name) -{ - // FIXME: Add a clearHTTPHeaderField method to ResourceRequest. - const HTTPHeaderMap& map = m_private->m_resourceRequest->httpHeaderFields(); - const_cast<HTTPHeaderMap*>(&map)->remove(String(name)); -} - -void WebURLRequest::visitHTTPHeaderFields(WebHTTPHeaderVisitor* visitor) const -{ - const HTTPHeaderMap& map = m_private->m_resourceRequest->httpHeaderFields(); - for (HTTPHeaderMap::const_iterator it = map.begin(); it != map.end(); ++it) - visitor->visitHeader(String(it->first), it->second); -} - -const WebHTTPBody& WebURLRequest::httpBody() const -{ - m_private->m_httpBody.rebind(m_private->m_resourceRequest->httpBody()); - return m_private->m_httpBody; -} - -void WebURLRequest::setHTTPBody(const WebHTTPBody& httpBody) -{ - m_private->m_resourceRequest->setHTTPBody(httpBody); - m_private->m_httpBody.rebind(0); // Free memory of the old body -} - -bool WebURLRequest::reportUploadProgress() const -{ - return m_private->m_resourceRequest->reportUploadProgress(); -} - -void WebURLRequest::setReportUploadProgress(bool reportUploadProgress) -{ - m_private->m_resourceRequest->setReportUploadProgress(reportUploadProgress); -} - -WebURLRequest::TargetType WebURLRequest::targetType() const -{ - return static_cast<TargetType>(m_private->m_resourceRequest->targetType()); -} - -void WebURLRequest::setTargetType(TargetType targetType) -{ - m_private->m_resourceRequest->setTargetType( - static_cast<ResourceRequest::TargetType>(targetType)); -} - -int WebURLRequest::requestorID() const -{ - return m_private->m_resourceRequest->requestorID(); -} - -void WebURLRequest::setRequestorID(int requestorID) -{ - m_private->m_resourceRequest->setRequestorID(requestorID); -} - -int WebURLRequest::requestorProcessID() const -{ - return m_private->m_resourceRequest->requestorProcessID(); -} - -void WebURLRequest::setRequestorProcessID(int requestorProcessID) -{ - m_private->m_resourceRequest->setRequestorProcessID(requestorProcessID); -} - -int WebURLRequest::appCacheContextID() const -{ - return m_private->m_resourceRequest->appCacheContextID(); -} - -void WebURLRequest::setAppCacheContextID(int appCacheContextID) -{ - m_private->m_resourceRequest->setAppCacheContextID(appCacheContextID); -} - -WebCString WebURLRequest::securityInfo() const -{ - return m_private->m_resourceRequest->securityInfo(); -} - -void WebURLRequest::setSecurityInfo(const WebCString& securityInfo) -{ - m_private->m_resourceRequest->setSecurityInfo(securityInfo); -} - -ResourceRequest& WebURLRequest::toMutableResourceRequest() -{ - ASSERT(m_private); - ASSERT(m_private->m_resourceRequest); - - return *m_private->m_resourceRequest; -} - -const ResourceRequest& WebURLRequest::toResourceRequest() const -{ - ASSERT(m_private); - ASSERT(m_private->m_resourceRequest); - - return *m_private->m_resourceRequest; -} - -void WebURLRequest::assign(WebURLRequestPrivate* p) -{ - if (m_private) - m_private->dispose(); - m_private = p; -} - -} // namespace WebKit diff --git a/webkit/api/src/WebURLRequestPrivate.h b/webkit/api/src/WebURLRequestPrivate.h deleted file mode 100644 index 57ef3d1..0000000 --- a/webkit/api/src/WebURLRequestPrivate.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * 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. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT - * OWNER 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 WebURLRequestPrivate_h -#define WebURLRequestPrivate_h - -#include "WebHTTPBody.h" - -namespace WebCore { struct ResourceRequest; } - -namespace WebKit { - - class WebURLRequestPrivate { - public: - WebURLRequestPrivate() : m_resourceRequest(0) { } - - // Called by WebURLRequest when it no longer needs this object. - virtual void dispose() = 0; - - WebCore::ResourceRequest* m_resourceRequest; - WebHTTPBody m_httpBody; - }; - -} // namespace WebKit - -#endif diff --git a/webkit/api/src/WebURLResponse.cpp b/webkit/api/src/WebURLResponse.cpp deleted file mode 100644 index 52e193f..0000000 --- a/webkit/api/src/WebURLResponse.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * 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. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT - * OWNER 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 "WebURLResponse.h" - -#include "WebHTTPHeaderVisitor.h" -#include "WebString.h" -#include "WebURL.h" -#include "WebURLResponsePrivate.h" - -#include "ResourceResponse.h" - -using namespace WebCore; - -namespace WebKit { - -// The standard implementation of WebURLResponsePrivate, which maintains -// ownership of a ResourceResponse instance. -class WebURLResponsePrivateImpl : public WebURLResponsePrivate { -public: - WebURLResponsePrivateImpl() - { - m_resourceResponse = &m_resourceResponseAllocation; - } - - WebURLResponsePrivateImpl(const WebURLResponsePrivate* p) - : m_resourceResponseAllocation(*p->m_resourceResponse) - { - m_resourceResponse = &m_resourceResponseAllocation; - } - - virtual void dispose() { delete this; } - - ResourceResponse m_resourceResponseAllocation; -}; - -void WebURLResponse::initialize() -{ - assign(new WebURLResponsePrivateImpl()); -} - -void WebURLResponse::reset() -{ - assign(0); -} - -void WebURLResponse::assign(const WebURLResponse& r) -{ - assign(r.m_private ? new WebURLResponsePrivateImpl(r.m_private) : 0); -} - -WebURL WebURLResponse::url() const -{ - return m_private->m_resourceResponse->url(); -} - -void WebURLResponse::setURL(const WebURL& url) -{ - m_private->m_resourceResponse->setURL(url); -} - -WebString WebURLResponse::mimeType() const -{ - return m_private->m_resourceResponse->mimeType(); -} - -void WebURLResponse::setMIMEType(const WebString& mimeType) -{ - m_private->m_resourceResponse->setMimeType(mimeType); -} - -long long WebURLResponse::expectedContentLength() const -{ - return m_private->m_resourceResponse->expectedContentLength(); -} - -void WebURLResponse::setExpectedContentLength(long long expectedContentLength) -{ - m_private->m_resourceResponse->setExpectedContentLength(expectedContentLength); -} - -WebString WebURLResponse::textEncodingName() const -{ - return m_private->m_resourceResponse->textEncodingName(); -} - -void WebURLResponse::setTextEncodingName(const WebString& textEncodingName) -{ - m_private->m_resourceResponse->setTextEncodingName(textEncodingName); -} - -WebString WebURLResponse::suggestedFileName() const -{ - return m_private->m_resourceResponse->suggestedFilename(); -} - -void WebURLResponse::setSuggestedFileName(const WebString& suggestedFileName) -{ - m_private->m_resourceResponse->setSuggestedFilename(suggestedFileName); -} - -int WebURLResponse::httpStatusCode() const -{ - return m_private->m_resourceResponse->httpStatusCode(); -} - -void WebURLResponse::setHTTPStatusCode(int httpStatusCode) -{ - m_private->m_resourceResponse->setHTTPStatusCode(httpStatusCode); -} - -WebString WebURLResponse::httpStatusText() const -{ - return m_private->m_resourceResponse->httpStatusText(); -} - -void WebURLResponse::setHTTPStatusText(const WebString& httpStatusText) -{ - m_private->m_resourceResponse->setHTTPStatusText(httpStatusText); -} - -WebString WebURLResponse::httpHeaderField(const WebString& name) const -{ - return m_private->m_resourceResponse->httpHeaderField(String(name)); -} - -void WebURLResponse::setHTTPHeaderField(const WebString& name, const WebString& value) -{ - m_private->m_resourceResponse->setHTTPHeaderField(String(name), value); -} - -void WebURLResponse::addHTTPHeaderField(const WebString& name, const WebString& value) -{ - // FIXME: Add an addHTTPHeaderField method to ResourceResponse. - const HTTPHeaderMap& map = m_private->m_resourceResponse->httpHeaderFields(); - String valueStr(value); - pair<HTTPHeaderMap::iterator, bool> result = - const_cast<HTTPHeaderMap*>(&map)->add(String(name), valueStr); - if (!result.second) - result.first->second += "," + valueStr; -} - -void WebURLResponse::clearHTTPHeaderField(const WebString& name) -{ - // FIXME: Add a clearHTTPHeaderField method to ResourceResponse. - const HTTPHeaderMap& map = m_private->m_resourceResponse->httpHeaderFields(); - const_cast<HTTPHeaderMap*>(&map)->remove(String(name)); -} - -void WebURLResponse::visitHTTPHeaderFields(WebHTTPHeaderVisitor* visitor) const -{ - const HTTPHeaderMap& map = m_private->m_resourceResponse->httpHeaderFields(); - for (HTTPHeaderMap::const_iterator it = map.begin(); it != map.end(); ++it) - visitor->visitHeader(String(it->first), it->second); -} - -double WebURLResponse::expirationDate() const -{ - return static_cast<double>(m_private->m_resourceResponse->expirationDate()); -} - -void WebURLResponse::setExpirationDate(double expirationDate) -{ - m_private->m_resourceResponse->setExpirationDate(static_cast<time_t>(expirationDate)); -} - -double WebURLResponse::lastModifiedDate() const -{ - return static_cast<double>(m_private->m_resourceResponse->lastModifiedDate()); -} - -void WebURLResponse::setLastModifiedDate(double lastModifiedDate) -{ - m_private->m_resourceResponse->setLastModifiedDate(static_cast<time_t>(lastModifiedDate)); -} - -bool WebURLResponse::isContentFiltered() const -{ - return m_private->m_resourceResponse->isContentFiltered(); -} - -void WebURLResponse::setIsContentFiltered(bool isContentFiltered) -{ - m_private->m_resourceResponse->setIsContentFiltered(isContentFiltered); -} - -long long WebURLResponse::appCacheID() const -{ - return m_private->m_resourceResponse->getAppCacheID(); -} - -void WebURLResponse::setAppCacheID(long long appCacheID) -{ - m_private->m_resourceResponse->setAppCacheID(appCacheID); -} - -WebCString WebURLResponse::securityInfo() const -{ - // FIXME: getSecurityInfo is misnamed. - return m_private->m_resourceResponse->getSecurityInfo(); -} - -void WebURLResponse::setSecurityInfo(const WebCString& securityInfo) -{ - m_private->m_resourceResponse->setSecurityInfo(securityInfo); -} - -ResourceResponse& WebURLResponse::toMutableResourceResponse() -{ - ASSERT(m_private); - ASSERT(m_private->m_resourceResponse); - - return *m_private->m_resourceResponse; -} - -const ResourceResponse& WebURLResponse::toResourceResponse() const -{ - ASSERT(m_private); - ASSERT(m_private->m_resourceResponse); - - return *m_private->m_resourceResponse; -} - -void WebURLResponse::assign(WebURLResponsePrivate* p) -{ - if (m_private) - m_private->dispose(); - m_private = p; -} - -} // namespace WebKit diff --git a/webkit/api/src/WebURLResponsePrivate.h b/webkit/api/src/WebURLResponsePrivate.h deleted file mode 100644 index d421c1a..0000000 --- a/webkit/api/src/WebURLResponsePrivate.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * 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. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT - * OWNER 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 WebURLResponsePrivate_h -#define WebURLResponsePrivate_h - -namespace WebCore { class ResourceResponse; } - -namespace WebKit { - - class WebURLResponsePrivate { - public: - WebURLResponsePrivate() : m_resourceResponse(0) { } - - // Called by WebURLResponse when it no longer needs this object. - virtual void dispose() = 0; - - WebCore::ResourceResponse* m_resourceResponse; - }; - -} // namespace WebKit - -#endif diff --git a/webkit/api/src/WrappedResourceRequest.h b/webkit/api/src/WrappedResourceRequest.h deleted file mode 100644 index 58188c1..0000000 --- a/webkit/api/src/WrappedResourceRequest.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * 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. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT - * OWNER 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 "WebURLRequestPrivate.h" - -namespace WebKit { - - class WrappedResourceRequest : public WebURLRequest { - public: - ~WrappedResourceRequest() - { - reset(); // Need to drop reference to m_handle - } - - WrappedResourceRequest(WebCore::ResourceRequest& resourceRequest) - { - bind(&resourceRequest); - } - - WrappedResourceRequest(const WebCore::ResourceRequest& resourceRequest) - { - bind(const_cast<WebCore::ResourceRequest*>(&resourceRequest)); - } - - private: - void bind(WebCore::ResourceRequest* resourceRequest) - { - m_handle.m_resourceRequest = resourceRequest; - assign(&m_handle); - } - - class Handle : public WebURLRequestPrivate { - public: - virtual void dispose() { m_resourceRequest = 0; } - }; - - Handle m_handle; - }; - -} // namespace WebKit diff --git a/webkit/api/src/WrappedResourceResponse.h b/webkit/api/src/WrappedResourceResponse.h deleted file mode 100644 index fe7bb99..0000000 --- a/webkit/api/src/WrappedResourceResponse.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * 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. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT - * OWNER 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 "WebURLResponse.h" -#include "WebURLResponsePrivate.h" - -namespace WebKit { - - class WrappedResourceResponse : public WebURLResponse { - public: - ~WrappedResourceResponse() - { - reset(); // Need to drop reference to m_handle - } - - WrappedResourceResponse(WebCore::ResourceResponse& resourceResponse) - { - bind(&resourceResponse); - } - - WrappedResourceResponse(const WebCore::ResourceResponse& resourceResponse) - { - bind(const_cast<WebCore::ResourceResponse*>(&resourceResponse)); - } - - private: - void bind(WebCore::ResourceResponse* resourceResponse) - { - m_handle.m_resourceResponse = resourceResponse; - assign(&m_handle); - } - - class Handle : public WebURLResponsePrivate { - public: - virtual void dispose() { m_resourceResponse = 0; } - }; - - Handle m_handle; - }; - -} // namespace WebKit |