diff options
author | Iain Merrick <husky@google.com> | 2010-08-19 17:55:56 +0100 |
---|---|---|
committer | Iain Merrick <husky@google.com> | 2010-08-23 11:05:40 +0100 |
commit | f486d19d62f1bc33246748b14b14a9dfa617b57f (patch) | |
tree | 195485454c93125455a30e553a73981c3816144d /WebCore/platform/network | |
parent | 6ba0b43722d16bc295606bec39f396f596e4fef1 (diff) | |
download | external_webkit-f486d19d62f1bc33246748b14b14a9dfa617b57f.zip external_webkit-f486d19d62f1bc33246748b14b14a9dfa617b57f.tar.gz external_webkit-f486d19d62f1bc33246748b14b14a9dfa617b57f.tar.bz2 |
Merge WebKit at r65615 : Initial merge by git.
Change-Id: Ifbf384f4531e3b58475a662e38195c2d9152ae79
Diffstat (limited to 'WebCore/platform/network')
-rw-r--r-- | WebCore/platform/network/BlobData.cpp | 87 | ||||
-rw-r--r-- | WebCore/platform/network/BlobData.h | 152 | ||||
-rw-r--r-- | WebCore/platform/network/BlobRegistry.h | 64 | ||||
-rw-r--r-- | WebCore/platform/network/BlobRegistryImpl.cpp | 177 | ||||
-rw-r--r-- | WebCore/platform/network/BlobRegistryImpl.h | 74 | ||||
-rw-r--r-- | WebCore/platform/network/BlobStorageData.h | 108 | ||||
-rw-r--r-- | WebCore/platform/network/CredentialStorage.cpp | 14 | ||||
-rw-r--r-- | WebCore/platform/network/HTTPHeaderMap.h | 6 | ||||
-rw-r--r-- | WebCore/platform/network/HTTPParsers.cpp | 34 | ||||
-rw-r--r-- | WebCore/platform/network/NetworkingContext.h | 68 | ||||
-rw-r--r-- | WebCore/platform/network/ResourceResponseBase.cpp | 24 | ||||
-rw-r--r-- | WebCore/platform/network/cf/DNSCFNet.cpp | 2 | ||||
-rw-r--r-- | WebCore/platform/network/curl/CookieJarCurl.cpp | 3 |
13 files changed, 771 insertions, 42 deletions
diff --git a/WebCore/platform/network/BlobData.cpp b/WebCore/platform/network/BlobData.cpp new file mode 100644 index 0000000..bb256d0 --- /dev/null +++ b/WebCore/platform/network/BlobData.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2010 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 "BlobData.h" + +namespace WebCore { + +const long long BlobDataItem::toEndOfFile = -1; +const double BlobDataItem::doNotCheckFileChange = 0; + +void BlobDataItem::copy(const BlobDataItem& item) +{ + type = item.type; + data = item.data; // This is OK because the underlying storage is Vector<char>. + path = item.path.crossThreadString(); + url = item.url.copy(); + offset = item.offset; + length = item.length; + expectedModificationTime = item.expectedModificationTime; +} + +PassOwnPtr<BlobData> BlobData::copy() const +{ + OwnPtr<BlobData> blobData = adoptPtr(new BlobData()); + blobData->m_contentType = m_contentType.crossThreadString(); + blobData->m_contentDisposition = m_contentDisposition.crossThreadString(); + blobData->m_items.resize(m_items.size()); + for (size_t i = 0; i < m_items.size(); ++i) + blobData->m_items.at(i).copy(m_items.at(i)); + + return blobData.release(); +} + +void BlobData::appendData(const CString& data) +{ + m_items.append(BlobDataItem(data)); +} + +void BlobData::appendFile(const String& path) +{ + m_items.append(BlobDataItem(path)); +} + +void BlobData::appendFile(const String& path, long long offset, long long length, double expectedModificationTime) +{ + m_items.append(BlobDataItem(path, offset, length, expectedModificationTime)); +} + +void BlobData::appendBlob(const KURL& url, long long offset, long long length) +{ + m_items.append(BlobDataItem(url, offset, length)); +} + +void BlobData::swapItems(BlobDataItemList& items) +{ + m_items.swap(items); +} + +} // namespace WebCore diff --git a/WebCore/platform/network/BlobData.h b/WebCore/platform/network/BlobData.h new file mode 100644 index 0000000..17cdfdd --- /dev/null +++ b/WebCore/platform/network/BlobData.h @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2010 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 BlobData_h +#define BlobData_h + +#include "KURL.h" +#include "PlatformString.h" +#include <wtf/PassOwnPtr.h> +#include <wtf/Vector.h> +#include <wtf/text/CString.h> + +namespace WebCore { + +struct BlobDataItem { + static const long long toEndOfFile; + static const double doNotCheckFileChange; + + // Default constructor. + BlobDataItem() + : offset(0) + , length(toEndOfFile) + , expectedModificationTime(doNotCheckFileChange) + { + } + + // Constructor for String type. + BlobDataItem(const CString& data) + : type(Data) + , data(data) + , offset(0) + , length(toEndOfFile) + , expectedModificationTime(doNotCheckFileChange) + { + } + + // Constructor for File type (complete file). + BlobDataItem(const String& path) + : type(File) + , path(path) + , offset(0) + , length(toEndOfFile) + , expectedModificationTime(doNotCheckFileChange) + { + } + + // Constructor for File type (partial file). + BlobDataItem(const String& path, long long offset, long long length, double expectedModificationTime) + : type(File) + , path(path) + , offset(offset) + , length(length) + , expectedModificationTime(expectedModificationTime) + { + } + + // Constructor for Blob type. + BlobDataItem(const KURL& url, long long offset, long long length) + : type(Blob) + , url(url) + , offset(offset) + , length(length) + , expectedModificationTime(doNotCheckFileChange) + { + } + + // Gets a copy of the data suitable for passing to another thread. + void copy(const BlobDataItem&); + + enum { Data, File, Blob } type; + + // For Data type. + CString data; + + // For File type. + String path; + + // For Blob type. + KURL url; + + // For File and Blob type. + long long offset; + long long length; + + // For File type only. + double expectedModificationTime; +}; + +typedef Vector<BlobDataItem> BlobDataItemList; + +class BlobData { +public: + static PassOwnPtr<BlobData> create() + { + return adoptPtr(new BlobData()); + } + + // Gets a copy of the data suitable for passing to another thread. + PassOwnPtr<BlobData> copy() const; + + const String& contentType() const { return m_contentType; } + void setContentType(const String& contentType) { m_contentType = contentType; } + + const String& contentDisposition() const { return m_contentDisposition; } + void setContentDisposition(const String& contentDisposition) { m_contentDisposition = contentDisposition; } + + const BlobDataItemList& items() const { return m_items; } + void swapItems(BlobDataItemList&); + + void appendData(const CString&); + void appendFile(const String& path); + void appendFile(const String& path, long long offset, long long length, double expectedModificationTime); + void appendBlob(const KURL&, long long offset, long long length); + +private: + BlobData() { } + + String m_contentType; + String m_contentDisposition; + BlobDataItemList m_items; +}; + +} // namespace WebCore + +#endif // BlobData_h diff --git a/WebCore/platform/network/BlobRegistry.h b/WebCore/platform/network/BlobRegistry.h new file mode 100644 index 0000000..fcd7b1c --- /dev/null +++ b/WebCore/platform/network/BlobRegistry.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2010 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 BlobRegistry_h +#define BlobRegistry_h + +#include <wtf/PassOwnPtr.h> +#include <wtf/PassRefPtr.h> +#include <wtf/Vector.h> + +namespace WebCore { + +class BlobData; +class KURL; +class ResourceError; +class ResourceHandle; +class ResourceHandleClient; +class ResourceRequest; +class ResourceResponse; + +// BlobRegistry is not thread-safe. It should only be called from main thread. +class BlobRegistry { +public: + static BlobRegistry& instance(); + + virtual void registerBlobURL(const KURL&, PassOwnPtr<BlobData>) = 0; + virtual void registerBlobURL(const KURL&, const KURL& srcURL) = 0; + virtual void unregisterBlobURL(const KURL&) = 0; + virtual PassRefPtr<ResourceHandle> createResourceHandle(const ResourceRequest&, ResourceHandleClient*) = 0; + virtual bool loadResourceSynchronously(const ResourceRequest&, ResourceError&, ResourceResponse&, Vector<char>& data) = 0; + + virtual ~BlobRegistry() { } +}; + +} // namespace WebCore + +#endif // BlobRegistry_h diff --git a/WebCore/platform/network/BlobRegistryImpl.cpp b/WebCore/platform/network/BlobRegistryImpl.cpp new file mode 100644 index 0000000..bbbb8f0 --- /dev/null +++ b/WebCore/platform/network/BlobRegistryImpl.cpp @@ -0,0 +1,177 @@ +/* + * Copyright (C) 2010 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 "BlobRegistryImpl.h" + +#include "FileStream.h" +#include "FileStreamProxy.h" +#include "FileSystem.h" +#include "ResourceError.h" +#include "ResourceHandle.h" +#include "ResourceLoader.h" +#include "ResourceRequest.h" +#include "ResourceResponse.h" +#include <wtf/MainThread.h> +#include <wtf/StdLibExtras.h> + +namespace WebCore { + +bool BlobRegistryImpl::shouldLoadResource(const ResourceRequest& request) const +{ + // If the resource is not fetched using the GET method, bail out. + if (!equalIgnoringCase(request.httpMethod(), "GET")) + return false; + + return true; +} + +PassRefPtr<ResourceHandle> BlobRegistryImpl::createResourceHandle(const ResourceRequest& request, ResourceHandleClient*) +{ + if (!shouldLoadResource(request)) + return 0; + + // FIXME: To be implemented. + return 0; +} + +bool BlobRegistryImpl::loadResourceSynchronously(const ResourceRequest& request, ResourceError&, ResourceResponse&, Vector<char>&) +{ + if (!shouldLoadResource(request)) + return false; + + // FIXME: To be implemented. + return false; +} + +BlobRegistry& BlobRegistry::instance() +{ + ASSERT(isMainThread()); + DEFINE_STATIC_LOCAL(BlobRegistryImpl, instance, ()); + return instance; +} + +void BlobRegistryImpl::appendStorageItems(BlobStorageData* blobStorageData, const BlobStorageDataItemList& items) +{ + for (BlobStorageDataItemList::const_iterator iter = items.begin(); iter != items.end(); ++iter) { + if (iter->type == BlobStorageDataItem::Data) + blobStorageData->appendData(iter->data, iter->offset, iter->length); + else { + ASSERT(iter->type == BlobStorageDataItem::File); + blobStorageData->appendFile(iter->path, iter->offset, iter->length, iter->expectedModificationTime); + } + } +} + +void BlobRegistryImpl::appendStorageItems(BlobStorageData* blobStorageData, const BlobStorageDataItemList& items, long long offset, long long length) +{ + ASSERT(length != BlobDataItem::toEndOfFile); + + BlobStorageDataItemList::const_iterator iter = items.begin(); + if (offset) { + for (; iter != items.end(); ++iter) { + if (offset >= iter->length) + offset -= iter->length; + else + break; + } + } + + for (; iter != items.end() && length > 0; ++iter) { + long long currentLength = iter->length - offset; + long long newLength = currentLength > length ? length : currentLength; + if (iter->type == BlobStorageDataItem::Data) + blobStorageData->appendData(iter->data, iter->offset + offset, newLength); + else { + ASSERT(iter->type == BlobStorageDataItem::File); + blobStorageData->appendFile(iter->path, iter->offset + offset, newLength, iter->expectedModificationTime); + } + offset = 0; + } +} + +void BlobRegistryImpl::registerBlobURL(const KURL& url, PassOwnPtr<BlobData> blobData) +{ + ASSERT(isMainThread()); + + RefPtr<BlobStorageData> blobStorageData = BlobStorageData::create(); + blobStorageData->setContentType(blobData->contentType()); + blobStorageData->setContentDisposition(blobData->contentDisposition()); + + for (BlobDataItemList::const_iterator iter = blobData->items().begin(); iter != blobData->items().end(); ++iter) { + switch (iter->type) { + case BlobDataItem::Data: + blobStorageData->appendData(iter->data, 0, iter->data.length()); + break; + case BlobDataItem::File: + blobStorageData->appendFile(iter->path, iter->offset, iter->length, iter->expectedModificationTime); + break; + case BlobDataItem::Blob: + if (m_blobs.contains(iter->url.string())) + appendStorageItems(blobStorageData.get(), m_blobs.get(iter->url.string())->items(), iter->offset, iter->length); + break; + } + } + + + m_blobs.set(url.string(), blobStorageData); +} + +void BlobRegistryImpl::registerBlobURL(const KURL& url, const KURL& srcURL) +{ + ASSERT(isMainThread()); + + RefPtr<BlobStorageData> src = m_blobs.get(srcURL.string()); + ASSERT(src); + if (!src) + return; + + RefPtr<BlobStorageData> blobStorageData = BlobStorageData::create(); + blobStorageData->setContentType(src->contentType()); + blobStorageData->setContentDisposition(src->contentDisposition()); + appendStorageItems(blobStorageData.get(), src->items()); + + m_blobs.set(url.string(), blobStorageData); +} + +void BlobRegistryImpl::unregisterBlobURL(const KURL& url) +{ + ASSERT(isMainThread()); + m_blobs.remove(url.string()); +} + +PassRefPtr<BlobStorageData> BlobRegistryImpl::getBlobDataFromURL(const KURL& url) const +{ + ASSERT(isMainThread()); + return m_blobs.get(url.string()); +} + +} // namespace WebCore diff --git a/WebCore/platform/network/BlobRegistryImpl.h b/WebCore/platform/network/BlobRegistryImpl.h new file mode 100644 index 0000000..42693bc --- /dev/null +++ b/WebCore/platform/network/BlobRegistryImpl.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2010 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 BlobRegistryImpl_h +#define BlobRegistryImpl_h + +#include "BlobData.h" +#include "BlobRegistry.h" +#include "BlobStorageData.h" +#include "PlatformString.h" +#include <wtf/HashMap.h> +#include <wtf/text/CString.h> +#include <wtf/text/StringHash.h> + +namespace WebCore { + +class KURL; +class ResourceError; +class ResourceHandle; +class ResourceHandleClient; +class ResourceRequest; +class ResourceResponse; + +// BlobRegistryImpl is not thread-safe. It should only be called from main thread. +class BlobRegistryImpl : public BlobRegistry { +public: + virtual ~BlobRegistryImpl() { } + + virtual void registerBlobURL(const KURL&, PassOwnPtr<BlobData>); + virtual void registerBlobURL(const KURL&, const KURL& srcURL); + virtual void unregisterBlobURL(const KURL&); + virtual PassRefPtr<ResourceHandle> createResourceHandle(const ResourceRequest&, ResourceHandleClient*); + virtual bool loadResourceSynchronously(const ResourceRequest&, ResourceError&, ResourceResponse&, Vector<char>& data); + + PassRefPtr<BlobStorageData> getBlobDataFromURL(const KURL&) const; + +private: + bool shouldLoadResource(const ResourceRequest& request) const; + void appendStorageItems(BlobStorageData*, const BlobStorageDataItemList&); + void appendStorageItems(BlobStorageData*, const BlobStorageDataItemList&, long long offset, long long length); + + HashMap<String, RefPtr<BlobStorageData> > m_blobs; +}; + +} // namespace WebCore + +#endif // BlobRegistryImpl_h diff --git a/WebCore/platform/network/BlobStorageData.h b/WebCore/platform/network/BlobStorageData.h new file mode 100644 index 0000000..f4125a4 --- /dev/null +++ b/WebCore/platform/network/BlobStorageData.h @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2010 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 BlobStorageData_h +#define BlobStorageData_h + +#include "PlatformString.h" +#include <wtf/PassRefPtr.h> +#include <wtf/Vector.h> +#include <wtf/text/CString.h> + +namespace WebCore { + +struct BlobStorageDataItem { + enum BlobStoreDataItemType { Data, File }; + BlobStoreDataItemType type; + long long offset; + long long length; + + // For string data. + CString data; + + // For file data. + String path; + double expectedModificationTime; + + BlobStorageDataItem(const CString& data, long long offset, long long length) + : type(Data) + , offset(offset) + , length(length) + , data(data) + , expectedModificationTime(0) + { + } + + BlobStorageDataItem(const String& path, long long offset, long long length, double expectedModificationTime) + : type(File) + , offset(offset) + , length(length) + , path(path) + , expectedModificationTime(expectedModificationTime) + { + } +}; + +typedef Vector<BlobStorageDataItem> BlobStorageDataItemList; + +class BlobStorageData : public RefCounted<BlobStorageData> { +public: + static PassRefPtr<BlobStorageData> create() + { + return adoptRef(new BlobStorageData()); + } + + const String& contentType() const { return m_contentType; } + void setContentType(const String& contentType) { m_contentType = contentType; } + + const String& contentDisposition() const { return m_contentDisposition; } + void setContentDisposition(const String& contentDisposition) { m_contentDisposition = contentDisposition; } + + const BlobStorageDataItemList& items() const { return m_items; } + + void appendData(const CString& data, long long offset, long long length) + { + m_items.append(BlobStorageDataItem(data, offset, length)); + } + + void appendFile(const String& path, long long offset, long long length, double expectedModificationTime) + { + m_items.append(BlobStorageDataItem(path, offset, length, expectedModificationTime)); + } + +private: + String m_contentType; + String m_contentDisposition; + BlobStorageDataItemList m_items; +}; + +} // namespace WebCore + +#endif // BlobStorageData_h diff --git a/WebCore/platform/network/CredentialStorage.cpp b/WebCore/platform/network/CredentialStorage.cpp index 14f4086..4fb7799 100644 --- a/WebCore/platform/network/CredentialStorage.cpp +++ b/WebCore/platform/network/CredentialStorage.cpp @@ -29,8 +29,8 @@ #include "Credential.h" #include "KURL.h" #include "ProtectionSpaceHash.h" -#include "StringHash.h" #include <wtf/text/CString.h> +#include <wtf/text/StringHash.h> #include <wtf/HashMap.h> #include <wtf/HashSet.h> #include <wtf/StdLibExtras.h> @@ -75,9 +75,9 @@ static String protectionSpaceMapKeyFromURL(const KURL& url) unsigned directoryURLPathStart = url.pathStart(); ASSERT(directoryURL[directoryURLPathStart] == '/'); if (directoryURL.length() > directoryURLPathStart + 1) { - int index = directoryURL.reverseFind('/'); - ASSERT(index > 0); - directoryURL = directoryURL.substring(0, (static_cast<unsigned>(index) != directoryURLPathStart) ? static_cast<unsigned>(index) : directoryURLPathStart + 1); + size_t index = directoryURL.reverseFind('/'); + ASSERT(index != notFound); + directoryURL = directoryURL.substring(0, (index != directoryURLPathStart) ? index : directoryURLPathStart + 1); } ASSERT(directoryURL.length() == directoryURLPathStart + 1 || directoryURL[directoryURL.length() - 1] != '/'); @@ -132,9 +132,9 @@ static PathToDefaultProtectionSpaceMap::iterator findDefaultProtectionSpaceForUR if (directoryURL.length() == directoryURLPathStart + 1) // path is "/" already, cannot shorten it any more return map.end(); - int index = directoryURL.reverseFind('/', -2); - ASSERT(index > 0); - directoryURL = directoryURL.substring(0, (static_cast<unsigned>(index) == directoryURLPathStart) ? index + 1 : index); + size_t index = directoryURL.reverseFind('/', directoryURL.length() - 2); + ASSERT(index != notFound); + directoryURL = directoryURL.substring(0, (index == directoryURLPathStart) ? index + 1 : index); ASSERT(directoryURL.length() > directoryURLPathStart); ASSERT(directoryURL.length() == directoryURLPathStart + 1 || directoryURL[directoryURL.length() - 1] != '/'); } diff --git a/WebCore/platform/network/HTTPHeaderMap.h b/WebCore/platform/network/HTTPHeaderMap.h index 557ddb3..c6145bd 100644 --- a/WebCore/platform/network/HTTPHeaderMap.h +++ b/WebCore/platform/network/HTTPHeaderMap.h @@ -27,13 +27,13 @@ #ifndef HTTPHeaderMap_h #define HTTPHeaderMap_h -#include "AtomicString.h" -#include "AtomicStringHash.h" -#include "StringHash.h" #include <utility> #include <wtf/HashMap.h> #include <wtf/PassOwnPtr.h> #include <wtf/Vector.h> +#include <wtf/text/AtomicString.h> +#include <wtf/text/AtomicStringHash.h> +#include <wtf/text/StringHash.h> namespace WebCore { diff --git a/WebCore/platform/network/HTTPParsers.cpp b/WebCore/platform/network/HTTPParsers.cpp index 6252bfc..b3f3d45 100644 --- a/WebCore/platform/network/HTTPParsers.cpp +++ b/WebCore/platform/network/HTTPParsers.cpp @@ -42,9 +42,9 @@ using namespace WTF; namespace WebCore { // true if there is more to parse -static inline bool skipWhiteSpace(const String& str, int& pos, bool fromHttpEquivMeta) +static inline bool skipWhiteSpace(const String& str, unsigned& pos, bool fromHttpEquivMeta) { - int len = str.length(); + unsigned len = str.length(); if (fromHttpEquivMeta) { while (pos != len && str[pos] <= ' ') @@ -59,9 +59,9 @@ static inline bool skipWhiteSpace(const String& str, int& pos, bool fromHttpEqui // Returns true if the function can match the whole token (case insensitive). // Note: Might return pos == str.length() -static inline bool skipToken(const String& str, int& pos, const char* token) +static inline bool skipToken(const String& str, unsigned& pos, const char* token) { - int len = str.length(); + unsigned len = str.length(); while (pos != len && *token) { if (toASCIILower(str[pos]) != *token++) @@ -104,8 +104,8 @@ ContentDispositionType contentDispositionType(const String& contentDisposition) bool parseHTTPRefresh(const String& refresh, bool fromHttpEquivMeta, double& delay, String& url) { - int len = refresh.length(); - int pos = 0; + unsigned len = refresh.length(); + unsigned pos = 0; if (!skipWhiteSpace(refresh, pos, fromHttpEquivMeta)) return false; @@ -126,7 +126,7 @@ bool parseHTTPRefresh(const String& refresh, bool fromHttpEquivMeta, double& del ++pos; skipWhiteSpace(refresh, pos, fromHttpEquivMeta); - int urlStartPos = pos; + unsigned urlStartPos = pos; if (refresh.find("url", urlStartPos, false) == urlStartPos) { urlStartPos += 3; skipWhiteSpace(refresh, urlStartPos, fromHttpEquivMeta); @@ -137,7 +137,7 @@ bool parseHTTPRefresh(const String& refresh, bool fromHttpEquivMeta, double& del urlStartPos = pos; // e.g. "Refresh: 0; url.html" } - int urlEndPos = len; + unsigned urlEndPos = len; if (refresh[urlStartPos] == '"' || refresh[urlStartPos] == '\'') { UChar quotationMark = refresh[urlStartPos]; @@ -173,8 +173,8 @@ String filenameFromHTTPContentDisposition(const String& value) unsigned length = keyValuePairs.size(); for (unsigned i = 0; i < length; i++) { - int valueStartPos = keyValuePairs[i].find('='); - if (valueStartPos < 0) + size_t valueStartPos = keyValuePairs[i].find('='); + if (valueStartPos == notFound) continue; String key = keyValuePairs[i].left(valueStartPos).stripWhiteSpace(); @@ -241,12 +241,12 @@ void findCharsetInMediaType(const String& mediaType, unsigned int& charsetPos, u charsetPos = start; charsetLen = 0; - int pos = start; - int length = (int)mediaType.length(); + size_t pos = start; + unsigned length = mediaType.length(); while (pos < length) { pos = mediaType.find("charset", pos, false); - if (pos <= 0) { + if (pos == notFound || pos == 0) { charsetLen = 0; return; } @@ -270,7 +270,7 @@ void findCharsetInMediaType(const String& mediaType, unsigned int& charsetPos, u ++pos; // we don't handle spaces within quoted parameter values, because charset names cannot have any - int endpos = pos; + unsigned endpos = pos; while (pos != length && mediaType[endpos] > ' ' && mediaType[endpos] != '"' && mediaType[endpos] != '\'' && mediaType[endpos] != ';') ++endpos; @@ -290,8 +290,8 @@ XSSProtectionDisposition parseXSSProtectionHeader(const String& header) if (stippedHeader[0] == '0') return XSSProtectionDisabled; - int length = (int)header.length(); - int pos = 0; + unsigned length = header.length(); + unsigned pos = 0; if (stippedHeader[pos++] == '1' && skipWhiteSpace(stippedHeader, pos, false) && stippedHeader[pos++] == ';' @@ -309,7 +309,7 @@ XSSProtectionDisposition parseXSSProtectionHeader(const String& header) String extractReasonPhraseFromHTTPStatusLine(const String& statusLine) { - int spacePos = statusLine.find(' '); + size_t spacePos = statusLine.find(' '); // Remove status code from the status line. spacePos = statusLine.find(' ', spacePos + 1); return statusLine.substring(spacePos + 1); diff --git a/WebCore/platform/network/NetworkingContext.h b/WebCore/platform/network/NetworkingContext.h new file mode 100644 index 0000000..31f3025 --- /dev/null +++ b/WebCore/platform/network/NetworkingContext.h @@ -0,0 +1,68 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef NetworkingContext_h +#define NetworkingContext_h + +#include <wtf/RefCounted.h> + +#if PLATFORM(MAC) +#include "SchedulePair.h" +#endif + +#if PLATFORM(QT) +class QObject; +class QNetworkAccessManager; +#endif + +namespace WebCore { + +class ResourceError; +class ResourceRequest; + +class NetworkingContext : public RefCounted<NetworkingContext> { +public: + virtual ~NetworkingContext() { } + + virtual bool isValid() const { return true; } + +#if PLATFORM(MAC) + virtual bool needsSiteSpecificQuirks() const = 0; + virtual bool localFileContentSniffingEnabled() const = 0; + virtual SchedulePairHashSet* scheduledRunLoopPairs() const = 0; + virtual ResourceError blockedError(const ResourceRequest&) const = 0; +#endif + +#if PLATFORM(QT) + virtual QObject* originatingObject() const = 0; + virtual QNetworkAccessManager* networkAccessManager() const = 0; +#endif + +#if PLATFORM(WIN) + virtual String userAgent() const = 0; + virtual String referrer() const = 0; +#endif + +protected: + NetworkingContext() { } +}; + +} + +#endif // NetworkingContext_h diff --git a/WebCore/platform/network/ResourceResponseBase.cpp b/WebCore/platform/network/ResourceResponseBase.cpp index f30344e..e231652 100644 --- a/WebCore/platform/network/ResourceResponseBase.cpp +++ b/WebCore/platform/network/ResourceResponseBase.cpp @@ -439,8 +439,8 @@ bool ResourceResponseBase::isAttachment() const DEFINE_STATIC_LOCAL(const AtomicString, headerName, ("content-disposition")); String value = m_httpHeaderFields.get(headerName); - int loc = value.find(';'); - if (loc != -1) + size_t loc = value.find(';'); + if (loc != notFound) value = value.left(loc); value = value.stripWhiteSpace(); DEFINE_STATIC_LOCAL(const AtomicString, attachmentString, ("attachment")); @@ -591,9 +591,9 @@ static void parseCacheHeader(const String& header, Vector<pair<String, String> > const String safeHeader = header.removeCharacters(isControlCharacter); unsigned max = safeHeader.length(); for (unsigned pos = 0; pos < max; /* pos incremented in loop */) { - int nextCommaPosition = safeHeader.find(',', pos); - int nextEqualSignPosition = safeHeader.find('=', pos); - if (nextEqualSignPosition >= 0 && (nextEqualSignPosition < nextCommaPosition || nextCommaPosition < 0)) { + size_t nextCommaPosition = safeHeader.find(',', pos); + size_t nextEqualSignPosition = safeHeader.find('=', pos); + if (nextEqualSignPosition != notFound && (nextEqualSignPosition < nextCommaPosition || nextCommaPosition == notFound)) { // Get directive name, parse right hand side of equal sign, then add to map String directive = trimToNextSeparator(safeHeader.substring(pos, nextEqualSignPosition - pos).stripWhiteSpace()); pos += nextEqualSignPosition - pos + 1; @@ -601,14 +601,14 @@ static void parseCacheHeader(const String& header, Vector<pair<String, String> > String value = safeHeader.substring(pos, max - pos).stripWhiteSpace(); if (value[0] == '"') { // The value is a quoted string - int nextDoubleQuotePosition = value.find('"', 1); - if (nextDoubleQuotePosition >= 0) { + size_t nextDoubleQuotePosition = value.find('"', 1); + if (nextDoubleQuotePosition != notFound) { // Store the value as a quoted string without quotes result.append(pair<String, String>(directive, value.substring(1, nextDoubleQuotePosition - 1).stripWhiteSpace())); pos += (safeHeader.find('"', pos) - pos) + nextDoubleQuotePosition + 1; // Move past next comma, if there is one - int nextCommaPosition2 = safeHeader.find(',', pos); - if (nextCommaPosition2 >= 0) + size_t nextCommaPosition2 = safeHeader.find(',', pos); + if (nextCommaPosition2 != notFound) pos += nextCommaPosition2 - pos + 1; else return; // Parse error if there is anything left with no comma @@ -619,8 +619,8 @@ static void parseCacheHeader(const String& header, Vector<pair<String, String> > } } else { // The value is a token until the next comma - int nextCommaPosition2 = value.find(',', 0); - if (nextCommaPosition2 >= 0) { + size_t nextCommaPosition2 = value.find(',', 0); + if (nextCommaPosition2 != notFound) { // The value is delimited by the next comma result.append(pair<String, String>(directive, trimToNextSeparator(value.substring(0, nextCommaPosition2).stripWhiteSpace()))); pos += (safeHeader.find(',', pos) - pos) + 1; @@ -630,7 +630,7 @@ static void parseCacheHeader(const String& header, Vector<pair<String, String> > return; } } - } else if (nextCommaPosition >= 0 && (nextCommaPosition < nextEqualSignPosition || nextEqualSignPosition < 0)) { + } else if (nextCommaPosition != notFound && (nextCommaPosition < nextEqualSignPosition || nextEqualSignPosition == notFound)) { // Add directive to map with empty string as value result.append(pair<String, String>(trimToNextSeparator(safeHeader.substring(pos, nextCommaPosition - pos).stripWhiteSpace()), "")); pos += nextCommaPosition - pos + 1; diff --git a/WebCore/platform/network/cf/DNSCFNet.cpp b/WebCore/platform/network/cf/DNSCFNet.cpp index bda9e41..fbceb7d 100644 --- a/WebCore/platform/network/cf/DNSCFNet.cpp +++ b/WebCore/platform/network/cf/DNSCFNet.cpp @@ -27,11 +27,11 @@ #include "config.h" #include "DNS.h" -#include "StringHash.h" #include "Timer.h" #include <wtf/HashSet.h> #include <wtf/RetainPtr.h> #include <wtf/StdLibExtras.h> +#include <wtf/text/StringHash.h> #if PLATFORM(WIN) #include "LoaderRunLoopCF.h" diff --git a/WebCore/platform/network/curl/CookieJarCurl.cpp b/WebCore/platform/network/curl/CookieJarCurl.cpp index 7c906a0..e05947c 100644 --- a/WebCore/platform/network/curl/CookieJarCurl.cpp +++ b/WebCore/platform/network/curl/CookieJarCurl.cpp @@ -21,9 +21,8 @@ #include "Document.h" #include "KURL.h" #include "PlatformString.h" -#include "StringHash.h" - #include <wtf/HashMap.h> +#include <wtf/text/StringHash.h> namespace WebCore { |