summaryrefslogtreecommitdiffstats
path: root/webkit/base
diff options
context:
space:
mode:
authormichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-01 21:28:33 +0000
committermichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-01 21:28:33 +0000
commit23d951f5824da20e311c088a35068529002b87fc (patch)
treec098f2952f8d4890c64ceefa4c521350f25d44ee /webkit/base
parentf787848ac2338b858d8b8cbb7d4a36675ac54772 (diff)
downloadchromium_src-23d951f5824da20e311c088a35068529002b87fc.zip
chromium_src-23d951f5824da20e311c088a35068529002b87fc.tar.gz
chromium_src-23d951f5824da20e311c088a35068529002b87fc.tar.bz2
New BlobStorageContext for use in the main browser process. This class is not used yet, just added it with some tests in this CL.
BUG=174200 R=ericu@chromium.org, kinuko@chromium.org Review URL: https://codereview.chromium.org/14139026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197720 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/base')
-rw-r--r--webkit/base/data_element.cc15
-rw-r--r--webkit/base/data_element.h29
2 files changed, 39 insertions, 5 deletions
diff --git a/webkit/base/data_element.cc b/webkit/base/data_element.cc
index 472a88b..7d27f0e 100644
--- a/webkit/base/data_element.cc
+++ b/webkit/base/data_element.cc
@@ -30,9 +30,20 @@ void DataElement::SetToBlobUrlRange(
const GURL& blob_url,
uint64 offset, uint64 length) {
type_ = TYPE_BLOB;
- url_ = blob_url;
+ blob_url_ = blob_url;
offset_ = offset;
length_ = length;
+ blob_uuid_.clear();
+}
+
+void DataElement::SetToBlobRange(
+ const std::string& blob_uuid,
+ uint64 offset, uint64 length) {
+ type_ = TYPE_BLOB;
+ blob_uuid_ = blob_uuid;
+ offset_ = offset;
+ length_ = length;
+ blob_url_ = GURL();
}
void DataElement::SetToFileSystemUrlRange(
@@ -40,7 +51,7 @@ void DataElement::SetToFileSystemUrlRange(
uint64 offset, uint64 length,
const base::Time& expected_modification_time) {
type_ = TYPE_FILE_FILESYSTEM;
- url_ = filesystem_url;
+ filesystem_url_ = filesystem_url;
offset_ = offset;
length_ = length;
expected_modification_time_ = expected_modification_time;
diff --git a/webkit/base/data_element.h b/webkit/base/data_element.h
index c75242b..7e1e489 100644
--- a/webkit/base/data_element.h
+++ b/webkit/base/data_element.h
@@ -5,6 +5,7 @@
#ifndef WEBKIT_BASE_DATA_ELEMENT_H_
#define WEBKIT_BASE_DATA_ELEMENT_H_
+#include <string>
#include <vector>
#include "base/basictypes.h"
@@ -34,13 +35,26 @@ class WEBKIT_BASE_EXPORT DataElement {
Type type() const { return type_; }
const char* bytes() const { return bytes_ ? bytes_ : &buf_[0]; }
const base::FilePath& path() const { return path_; }
- const GURL& url() const { return url_; }
+ const GURL& filesystem_url() const { return filesystem_url_; }
+
+ // TODO(michaeln): crbug/174200, fully switch to using string uuids.
+ // Note: Identifying blobs by url is being deprecated, but while
+ // transitioning, there's a little of both going on in the project.
+ const std::string& blob_uuid() const { return blob_uuid_; }
+ const GURL& blob_url() const { return blob_url_; }
uint64 offset() const { return offset_; }
uint64 length() const { return length_; }
const base::Time& expected_modification_time() const {
return expected_modification_time_;
}
+ // TODO(michaeln): fixup callers to use filesytem_url() and blob_uuid().
+ const GURL& url() const {
+ if (type_ == TYPE_FILE_FILESYSTEM)
+ return filesystem_url_;
+ return blob_url_;
+ }
+
// Sets TYPE_BYTES data. This copies the given data into the element.
void SetToBytes(const char* bytes, int bytes_len) {
type_ = TYPE_BYTES;
@@ -65,6 +79,9 @@ class WEBKIT_BASE_EXPORT DataElement {
void SetToBlobUrl(const GURL& blob_url) {
SetToBlobUrlRange(blob_url, 0, kuint64max);
}
+ void SetToBlob(const std::string& uuid) {
+ SetToBlobRange(uuid, 0, kuint64max);
+ }
// Sets TYPE_FILE data with range.
void SetToFilePathRange(const base::FilePath& path,
@@ -74,6 +91,8 @@ class WEBKIT_BASE_EXPORT DataElement {
// Sets TYPE_BLOB data with range.
void SetToBlobUrlRange(const GURL& blob_url,
uint64 offset, uint64 length);
+ void SetToBlobRange(const std::string& blob_uuid,
+ uint64 offset, uint64 length);
// Sets TYPE_FILE_FILESYSTEM with range.
void SetToFileSystemUrlRange(const GURL& filesystem_url,
@@ -85,7 +104,9 @@ class WEBKIT_BASE_EXPORT DataElement {
std::vector<char> buf_; // For TYPE_BYTES.
const char* bytes_; // For TYPE_BYTES.
base::FilePath path_; // For TYPE_FILE.
- GURL url_; // For TYPE_BLOB or TYPE_FILE_FILESYSTEM.
+ GURL filesystem_url_; // For TYPE_FILE_FILESYSTEM.
+ GURL blob_url_;
+ std::string blob_uuid_;
uint64 offset_;
uint64 length_;
base::Time expected_modification_time_;
@@ -104,8 +125,10 @@ inline bool operator==(const DataElement& a, const DataElement& b) {
return a.path() == b.path() &&
a.expected_modification_time() == b.expected_modification_time();
case DataElement::TYPE_BLOB:
+ return a.blob_uuid().empty() ? (a.blob_url() == b.blob_url())
+ : (a.blob_uuid() == b.blob_uuid());
case DataElement::TYPE_FILE_FILESYSTEM:
- return a.url() == b.url();
+ return a.filesystem_url() == b.filesystem_url();
case DataElement::TYPE_UNKNOWN:
NOTREACHED();
return false;