Commit 60409623 authored by jianli@chromium.org's avatar jianli@chromium.org
Browse files

[chromium] Update WebBlobData.

https://bugs.webkit.org/show_bug.cgi?id=44481

Reviewed by Darin Fisher.

Some changes to WebBlobData to match with chromium implementation.
1) Change to use WebCString for data, instead of WebData.
2) Separate path from URL.

* public/WebBlobData.h:
* src/WebBlobData.cpp:
(WebKit::WebBlobData::itemAt):
(WebKit::WebBlobData::appendData):
(WebKit::WebBlobData::appendBlob):
* src/WebBlobStorageData.cpp:
(WebKit::WebBlobStorageData::itemAt):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65946 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1d6278b8
2010-08-24 Jian Li <jianli@chromium.org>
Reviewed by Darin Fisher.
[chromium] Update WebBlobData.
https://bugs.webkit.org/show_bug.cgi?id=44481
Some changes to WebBlobData to match with chromium implementation.
1) Change to use WebCString for data, instead of WebData.
2) Separate path from URL.
* public/WebBlobData.h:
* src/WebBlobData.cpp:
(WebKit::WebBlobData::itemAt):
(WebKit::WebBlobData::appendData):
(WebKit::WebBlobData::appendBlob):
* src/WebBlobStorageData.cpp:
(WebKit::WebBlobStorageData::itemAt):
2010-08-24 Marcus Bulach <bulach@chromium.org>
 
Reviewed by Jeremy Orlow.
......
......@@ -31,8 +31,9 @@
#ifndef WebBlobData_h
#define WebBlobData_h
#include "WebData.h"
#include "WebCString.h"
#include "WebString.h"
#include "WebURL.h"
#if WEBKIT_IMPLEMENTATION
namespace WebCore { class BlobData; }
......@@ -47,8 +48,9 @@ class WebBlobData {
public:
struct Item {
enum { TypeData, TypeFile, TypeBlob } type;
WebData data;
WebString pathOrURL;
WebCString data;
WebString filePath;
WebURL blobURL;
long long offset;
long long length; // -1 means go to the end of the file/blob.
double expectedModificationTime; // 0.0 means that the time is not set.
......@@ -71,10 +73,10 @@ public:
WEBKIT_API bool itemAt(size_t index, Item& result) const;
// Appends to the list of items.
WEBKIT_API void appendData(const WebData&);
WEBKIT_API void appendData(const WebCString&);
WEBKIT_API void appendFile(const WebString& filePath);
WEBKIT_API void appendFile(const WebString& filePath, long long offset, long long length, double expectedModificationTime);
WEBKIT_API void appendBlob(const WebString& blobURL, long long offset, long long length);
WEBKIT_API void appendBlob(const WebURL& blobURL, long long offset, long long length);
WEBKIT_API WebString contentType() const;
WEBKIT_API void setContentType(const WebString&);
......
......@@ -64,34 +64,35 @@ bool WebBlobData::itemAt(size_t index, Item& result) const
return false;
const BlobDataItem& item = m_private->items()[index];
result.data.reset();
result.filePath.reset();
result.blobURL = KURL();
result.offset = item.offset;
result.length = item.length;
result.expectedModificationTime = item.expectedModificationTime;
switch (item.type) {
case BlobDataItem::Data:
result.type = Item::TypeData;
result.data.assign(item.data.data(), static_cast<size_t>(item.data.length()));
result.pathOrURL.reset();
result.data = item.data;
return true;
case BlobDataItem::File:
result.type = Item::TypeFile;
result.data.reset();
result.pathOrURL = item.path;
result.filePath = item.path;
return true;
case BlobDataItem::Blob:
result.type = Item::TypeBlob;
result.data.reset();
result.pathOrURL = item.url;
result.blobURL = item.url;
return true;
}
ASSERT_NOT_REACHED();
return false;
}
void WebBlobData::appendData(const WebData& data)
void WebBlobData::appendData(const WebCString& data)
{
ASSERT(!isNull());
m_private->appendData(CString(data.data(), data.size()));
m_private->appendData(data);
}
void WebBlobData::appendFile(const WebString& filePath)
......@@ -106,10 +107,10 @@ void WebBlobData::appendFile(const WebString& filePath, long long offset, long l
m_private->appendFile(filePath, offset, length, expectedModificationTime);
}
void WebBlobData::appendBlob(const WebString& blobURL, long long offset, long long length)
void WebBlobData::appendBlob(const WebURL& blobURL, long long offset, long long length)
{
ASSERT(!isNull());
m_private->appendBlob(KURL(ParsedURLString, blobURL), offset, length);
m_private->appendBlob(blobURL, offset, length);
}
WebString WebBlobData::contentType() const
......
......@@ -69,7 +69,7 @@ bool WebBlobStorageData::itemAt(size_t index, WebBlobData::Item& result) const
} else {
ASSERT(item.type == BlobDataItem::File);
result.type = WebBlobData::Item::TypeFile;
result.pathOrURL = item.path;
result.filePath = item.path;
return true;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment