diff options
Diffstat (limited to 'webkit/blob/blob_data.h')
-rw-r--r-- | webkit/blob/blob_data.h | 87 |
1 files changed, 2 insertions, 85 deletions
diff --git a/webkit/blob/blob_data.h b/webkit/blob/blob_data.h index 9599394..63947f4 100644 --- a/webkit/blob/blob_data.h +++ b/webkit/blob/blob_data.h @@ -14,69 +14,13 @@ #include "googleurl/src/gurl.h" #include "webkit/blob/blob_export.h" #include "webkit/blob/shareable_file_reference.h" - -namespace WebKit { -class WebBlobData; -} +#include "webkit/base/data_element.h" namespace webkit_blob { class BLOB_EXPORT BlobData : public base::RefCounted<BlobData> { public: - enum Type { - TYPE_DATA, - TYPE_DATA_EXTERNAL, - TYPE_FILE, - TYPE_BLOB - }; - - struct BLOB_EXPORT Item { - Item(); - ~Item(); - - void SetToData(const std::string& data) { - SetToData(data.c_str(), data.size()); - } - - void SetToData(const char* data, size_t length) { - type = TYPE_DATA; - this->data.assign(data, length); - this->offset = 0; - this->length = length; - } - - void SetToDataExternal(const char* data, size_t length) { - type = TYPE_DATA_EXTERNAL; - this->data_external = data; - this->offset = 0; - this->length = length; - } - - void SetToFile(const FilePath& file_path, uint64 offset, uint64 length, - const base::Time& expected_modification_time) { - type = TYPE_FILE; - this->file_path = file_path; - this->offset = offset; - this->length = length; - this->expected_modification_time = expected_modification_time; - } - - void SetToBlob(const GURL& blob_url, uint64 offset, uint64 length) { - type = TYPE_BLOB; - this->blob_url = blob_url; - this->offset = offset; - this->length = length; - } - - Type type; - std::string data; // For Data type. - const char* data_external; // For DataExternal type. - GURL blob_url; // For Blob type. - FilePath file_path; // For File type. - base::Time expected_modification_time; // Also for File type. - uint64 offset; - uint64 length; - }; + typedef webkit_base::DataElement Item; BlobData(); @@ -113,7 +57,6 @@ class BLOB_EXPORT BlobData : public base::RefCounted<BlobData> { private: friend class base::RefCounted<BlobData>; - virtual ~BlobData(); std::string content_type_; @@ -125,32 +68,6 @@ class BLOB_EXPORT BlobData : public base::RefCounted<BlobData> { }; #if defined(UNIT_TEST) -inline bool operator==(const BlobData::Item& a, const BlobData::Item& b) { - if (a.type != b.type) - return false; - if (a.type == BlobData::TYPE_DATA) { - return a.data == b.data && - a.offset == b.offset && - a.length == b.length; - } - if (a.type == BlobData::TYPE_FILE) { - return a.file_path == b.file_path && - a.offset == b.offset && - a.length == b.length && - a.expected_modification_time == b.expected_modification_time; - } - if (a.type == BlobData::TYPE_BLOB) { - return a.blob_url == b.blob_url && - a.offset == b.offset && - a.length == b.length; - } - return false; -} - -inline bool operator!=(const BlobData::Item& a, const BlobData::Item& b) { - return !(a == b); -} - inline bool operator==(const BlobData& a, const BlobData& b) { if (a.content_type() != b.content_type()) return false; |