diff options
Diffstat (limited to 'Source/WebKit2/Shared/FileAPI')
-rw-r--r-- | Source/WebKit2/Shared/FileAPI/BlobRegistrationData.cpp | 182 | ||||
-rw-r--r-- | Source/WebKit2/Shared/FileAPI/BlobRegistrationData.h | 61 |
2 files changed, 0 insertions, 243 deletions
diff --git a/Source/WebKit2/Shared/FileAPI/BlobRegistrationData.cpp b/Source/WebKit2/Shared/FileAPI/BlobRegistrationData.cpp deleted file mode 100644 index 24939a964..000000000 --- a/Source/WebKit2/Shared/FileAPI/BlobRegistrationData.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (C) 2013 Apple 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: - * 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 "BlobRegistrationData.h" - -#if ENABLE(BLOB) && ENABLE(NETWORK_PROCESS) - -#include "ArgumentCoders.h" -#include "DataReference.h" -#include "WebCoreArgumentCoders.h" -#include <WebCore/BlobData.h> - -using namespace WebCore; - -namespace WebKit { - -BlobRegistrationData::BlobRegistrationData() -{ -} - -BlobRegistrationData::BlobRegistrationData(std::unique_ptr<BlobData> data) - : m_data(std::move(data)) -{ - const BlobDataItemList& items = m_data->items(); - size_t fileCount = 0; - for (size_t i = 0, count = items.size(); i < count; ++i) { - // File path can be empty when submitting a form file input without a file, see bug 111778. - if (items[i].type == BlobDataItem::File && !items[i].path.isEmpty()) - ++fileCount; - } - - m_sandboxExtensions.allocate(fileCount); - size_t extensionIndex = 0; - for (size_t i = 0, count = items.size(); i < count; ++i) { - const BlobDataItem& item = items[i]; - if (item.type == BlobDataItem::File && !items[i].path.isEmpty()) - SandboxExtension::createHandle(item.path, SandboxExtension::ReadOnly, m_sandboxExtensions[extensionIndex++]); - } -} - -BlobRegistrationData::~BlobRegistrationData() -{ -} - -std::unique_ptr<BlobData> BlobRegistrationData::releaseData() const -{ - return std::move(m_data); -} - -void BlobRegistrationData::encode(IPC::ArgumentEncoder& encoder) const -{ - encoder << m_data->contentType(); - encoder << m_data->contentDisposition(); - - const BlobDataItemList& items = m_data->items(); - encoder << static_cast<uint64_t>(items.size()); - for (size_t i = 0, count = items.size(); i < count; ++i) { - const BlobDataItem& item = items[i]; - encoder << static_cast<uint32_t>(item.type); - switch (item.type) { - case BlobDataItem::Data: - // There is no way to create a partial data item. - ASSERT(!item.offset); - ASSERT(item.length == BlobDataItem::toEndOfFile); - encoder << IPC::DataReference(reinterpret_cast<const uint8_t*>(item.data->data()), item.data->length()); - break; - case BlobDataItem::File: - encoder << static_cast<int64_t>(item.offset); - encoder << static_cast<int64_t>(item.length); - encoder << item.expectedModificationTime; - encoder << item.path; - break; - case BlobDataItem::Blob: - encoder << static_cast<int64_t>(item.offset); - encoder << static_cast<int64_t>(item.length); - encoder << item.url; - break; - } - } - - encoder << m_sandboxExtensions; -} - -bool BlobRegistrationData::decode(IPC::ArgumentDecoder& decoder, BlobRegistrationData& result) -{ - ASSERT(!result.m_data); - result.m_data = std::make_unique<BlobData>(); - - String contentType; - if (!decoder.decode(contentType)) - return false; - result.m_data->setContentType(contentType); - - String contentDisposition; - if (!decoder.decode(contentDisposition)) - return false; - result.m_data->setContentDisposition(contentDisposition); - - uint64_t itemCount; - if (!decoder.decode(itemCount)) - return false; - - for (uint64_t i = 0; i < itemCount; ++i) { - uint32_t type; - if (!decoder.decode(type)) - return false; - switch (type) { - case BlobDataItem::Data: { - IPC::DataReference data; - if (!decoder.decode(data)) - return false; - RefPtr<RawData> rawData = RawData::create(); - rawData->mutableData()->append(data.data(), data.size()); - result.m_data->appendData(rawData.release(), 0, BlobDataItem::toEndOfFile); - break; - } - case BlobDataItem::File: { - int64_t offset; - if (!decoder.decode(offset)) - return false; - int64_t length; - if (!decoder.decode(length)) - return false; - double expectedModificationTime; - if (!decoder.decode(expectedModificationTime)) - return false; - String path; - if (!decoder.decode(path)) - return false; - result.m_data->appendFile(path, offset, length, expectedModificationTime); - break; - } - case BlobDataItem::Blob: { - int64_t offset; - if (!decoder.decode(offset)) - return false; - int64_t length; - if (!decoder.decode(length)) - return false; - String url; - if (!decoder.decode(url)) - return false; - result.m_data->appendBlob(URL(URL(), url), offset, length); - break; - } - default: - return false; - } - } - - if (!decoder.decode(result.m_sandboxExtensions)) - return false; - - return true; -} - -} - -#endif // ENABLE(BLOB) && ENABLE(NETWORK_PROCESS) diff --git a/Source/WebKit2/Shared/FileAPI/BlobRegistrationData.h b/Source/WebKit2/Shared/FileAPI/BlobRegistrationData.h deleted file mode 100644 index 71f9c0920..000000000 --- a/Source/WebKit2/Shared/FileAPI/BlobRegistrationData.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2013 Apple 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: - * 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. - */ - -#ifndef BlobRegistrationData_h -#define BlobRegistrationData_h - -#if ENABLE(BLOB) && ENABLE(NETWORK_PROCESS) - -#include "SandboxExtension.h" - -namespace WebCore { -class BlobData; -} - -namespace WebKit { - -class BlobRegistrationData { -WTF_MAKE_NONCOPYABLE(BlobRegistrationData); -public: - BlobRegistrationData(); - BlobRegistrationData(std::unique_ptr<WebCore::BlobData>); - ~BlobRegistrationData(); - - void encode(IPC::ArgumentEncoder&) const; - static bool decode(IPC::ArgumentDecoder&, BlobRegistrationData&); - - std::unique_ptr<WebCore::BlobData> releaseData() const; - const SandboxExtension::HandleArray& sandboxExtensions() const { return m_sandboxExtensions; } - -private: - mutable std::unique_ptr<WebCore::BlobData> m_data; - SandboxExtension::HandleArray m_sandboxExtensions; -}; - -} - -#endif // ENABLE(BLOB) && ENABLE(NETWORK_PROCESS) - -#endif // BlobRegistrationData_h |