summaryrefslogtreecommitdiffstats
path: root/webkit/blob
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-28 10:19:45 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-28 10:19:45 +0000
commit2cd2107178cc1c885a545c78f99e20ad4c1abe77 (patch)
tree73609092f90bf5f3c7de33830db408a4919ddb9c /webkit/blob
parent71de432bf0e324d829172814ad981b2a21d5a162 (diff)
downloadchromium_src-2cd2107178cc1c885a545c78f99e20ad4c1abe77.zip
chromium_src-2cd2107178cc1c885a545c78f99e20ad4c1abe77.tar.gz
chromium_src-2cd2107178cc1c885a545c78f99e20ad4c1abe77.tar.bz2
Support FileSystem URL in File
BUG=110119 TEST=existing tests (more will be added when we add more implementation) Review URL: https://chromiumcodereview.appspot.com/10828252 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153651 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/blob')
-rw-r--r--webkit/blob/blob_data.cc10
-rw-r--r--webkit/blob/blob_data.h3
-rw-r--r--webkit/blob/blob_storage_controller.cc17
-rw-r--r--webkit/blob/blob_storage_controller.h4
-rw-r--r--webkit/blob/blob_url_request_job.cc5
-rw-r--r--webkit/blob/view_blob_internals_job.cc9
6 files changed, 48 insertions, 0 deletions
diff --git a/webkit/blob/blob_data.cc b/webkit/blob/blob_data.cc
index e000ee2..2f62e32 100644
--- a/webkit/blob/blob_data.cc
+++ b/webkit/blob/blob_data.cc
@@ -36,6 +36,16 @@ void BlobData::AppendBlob(const GURL& blob_url, uint64 offset, uint64 length) {
items_.back().SetToBlobUrlRange(blob_url, offset, length);
}
+void BlobData::AppendFileSystemFile(
+ const GURL& url, uint64 offset,
+ uint64 length,
+ const base::Time& expected_modification_time) {
+ DCHECK(length > 0);
+ items_.push_back(Item());
+ items_.back().SetToFileSystemUrlRange(url, offset, length,
+ expected_modification_time);
+}
+
int64 BlobData::GetMemoryUsage() const {
int64 memory = 0;
for (std::vector<Item>::const_iterator iter = items_.begin();
diff --git a/webkit/blob/blob_data.h b/webkit/blob/blob_data.h
index 63947f4..1afab56 100644
--- a/webkit/blob/blob_data.h
+++ b/webkit/blob/blob_data.h
@@ -35,6 +35,9 @@ class BLOB_EXPORT BlobData : public base::RefCounted<BlobData> {
void AppendBlob(const GURL& blob_url, uint64 offset, uint64 length);
+ void AppendFileSystemFile(const GURL& url, uint64 offset, uint64 length,
+ const base::Time& expected_modification_time);
+
void AttachShareableFileReference(ShareableFileReference* reference) {
shareable_files_.push_back(reference);
}
diff --git a/webkit/blob/blob_storage_controller.cc b/webkit/blob/blob_storage_controller.cc
index 1092248..503c47e 100644
--- a/webkit/blob/blob_storage_controller.cc
+++ b/webkit/blob/blob_storage_controller.cc
@@ -64,6 +64,8 @@ void BlobStorageController::AppendBlobDataItem(
// 1) The Data item is denoted by the raw data and the range.
// 2) The File item is denoted by the file path, the range and the expected
// modification time.
+ // 3) The FileSystem File item is denoted by the FileSystem URL, the range
+ // and the expected modification time.
// All the Blob items in the passing blob data are resolved and expanded into
// a set of Data and File items.
@@ -80,6 +82,13 @@ void BlobStorageController::AppendBlobDataItem(
item.length(),
item.expected_modification_time());
break;
+ case BlobData::Item::TYPE_FILE_FILESYSTEM:
+ AppendFileSystemFileItem(target_blob_data,
+ item.url(),
+ item.offset(),
+ item.length(),
+ item.expected_modification_time());
+ break;
case BlobData::Item::TYPE_BLOB: {
BlobData* src_blob_data = GetBlobDataFromUrl(item.url());
DCHECK(src_blob_data);
@@ -218,6 +227,14 @@ void BlobStorageController::AppendFileItem(
target_blob_data->AttachShareableFileReference(shareable_file);
}
+void BlobStorageController::AppendFileSystemFileItem(
+ BlobData* target_blob_data,
+ const GURL& url, uint64 offset, uint64 length,
+ const base::Time& expected_modification_time) {
+ target_blob_data->AppendFileSystemFile(url, offset, length,
+ expected_modification_time);
+}
+
void BlobStorageController::IncrementBlobDataUsage(BlobData* blob_data) {
blob_data_usage_count_[blob_data] += 1;
}
diff --git a/webkit/blob/blob_storage_controller.h b/webkit/blob/blob_storage_controller.h
index c464da4..a3189d1 100644
--- a/webkit/blob/blob_storage_controller.h
+++ b/webkit/blob/blob_storage_controller.h
@@ -50,6 +50,10 @@ class BLOB_EXPORT BlobStorageController {
void AppendFileItem(BlobData* target_blob_data,
const FilePath& file_path, uint64 offset, uint64 length,
const base::Time& expected_modification_time);
+ void AppendFileSystemFileItem(
+ BlobData* target_blob_data,
+ const GURL& url, uint64 offset, uint64 length,
+ const base::Time& expected_modification_time);
bool RemoveFromMapHelper(BlobMap* map, const GURL& url);
diff --git a/webkit/blob/blob_url_request_job.cc b/webkit/blob/blob_url_request_job.cc
index 642f955..1ef9545 100644
--- a/webkit/blob/blob_url_request_job.cc
+++ b/webkit/blob/blob_url_request_job.cc
@@ -308,6 +308,9 @@ bool BlobURLRequestJob::ReadItem() {
case BlobData::Item::TYPE_FILE:
return ReadFileItem(GetFileStreamReader(current_item_index_),
bytes_to_read);
+ case BlobData::Item::TYPE_FILE_FILESYSTEM:
+ // TODO(kinuko): Support TYPE_FILE_FILESYSTEM case.
+ // http://crbug.com/141835
default:
DCHECK(false);
return false;
@@ -530,6 +533,8 @@ LocalFileStreamReader* BlobURLRequestJob::GetFileStreamReader(size_t index) {
const BlobData::Item& item = blob_data_->items().at(index);
if (item.type() != BlobData::Item::TYPE_FILE)
return NULL;
+ // TODO(kinuko): Create appropriate FileStreamReader for TYPE_FILE_FILESYSTEM.
+ // http://crbug.com/141835
if (index_to_reader_.find(index) == index_to_reader_.end()) {
index_to_reader_[index] = new LocalFileStreamReader(
file_thread_proxy_,
diff --git a/webkit/blob/view_blob_internals_job.cc b/webkit/blob/view_blob_internals_job.cc
index dfbf3a0..4256713 100644
--- a/webkit/blob/view_blob_internals_job.cc
+++ b/webkit/blob/view_blob_internals_job.cc
@@ -215,6 +215,15 @@ void ViewBlobInternalsJob::GenerateHTMLForBlobData(const BlobData& blob_data,
AddHTMLListItem(kType, "blob", out);
AddHTMLListItem(kURL, item.url().spec(), out);
break;
+ case BlobData::Item::TYPE_FILE_FILESYSTEM:
+ AddHTMLListItem(kType, "filesystem", out);
+ AddHTMLListItem(kURL, item.url().spec(), out);
+ if (!item.expected_modification_time().is_null()) {
+ AddHTMLListItem(kModificationTime, UTF16ToUTF8(
+ TimeFormatFriendlyDateAndTime(item.expected_modification_time())),
+ out);
+ }
+ break;
case BlobData::Item::TYPE_UNKNOWN:
NOTREACHED();
break;