diff options
author | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-27 18:29:24 +0000 |
---|---|---|
committer | jianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-27 18:29:24 +0000 |
commit | 22339b123c68805c7c293c67f6f47ea45f0fd1a1 (patch) | |
tree | bb05e2e3eb0362338e921a4dce9d5c350437326e /webkit/blob/blob_data.cc | |
parent | e840afdedd33728491639312a268fbf37a48f078 (diff) | |
download | chromium_src-22339b123c68805c7c293c67f6f47ea45f0fd1a1.zip chromium_src-22339b123c68805c7c293c67f6f47ea45f0fd1a1.tar.gz chromium_src-22339b123c68805c7c293c67f6f47ea45f0fd1a1.tar.bz2 |
Support sending BlobData to browser process. Also support sending UploadData
with the blob info to browser process.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3108042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57707 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/blob/blob_data.cc')
-rw-r--r-- | webkit/blob/blob_data.cc | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/webkit/blob/blob_data.cc b/webkit/blob/blob_data.cc new file mode 100644 index 0000000..d72750e --- /dev/null +++ b/webkit/blob/blob_data.cc @@ -0,0 +1,62 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/blob/blob_data.h" + +#include "base/logging.h" +#include "base/time.h" +#include "third_party/WebKit/WebKit/chromium/public/WebBlobData.h" +#include "third_party/WebKit/WebKit/chromium/public/WebCString.h" +#include "third_party/WebKit/WebKit/chromium/public/WebData.h" +#include "webkit/glue/webkit_glue.h" + +using WebKit::WebBlobData; +using WebKit::WebData; +using WebKit::WebString; + +namespace { + +// Time::FromDoubleT() does not return empty Time object when dt is 0. +// We have to work around this problem here. +base::Time DoubleTToTime(double dt) { + return dt ? base::Time::FromDoubleT(dt) : base::Time(); +} + +} + +namespace webkit_blob { + +BlobData::BlobData(const WebBlobData& data) { + size_t i = 0; + WebBlobData::Item item; + while (data.itemAt(i++, item)) { + switch (item.type) { + case WebBlobData::Item::TypeData: + if (!item.data.isEmpty()) + AppendData(item.data); + break; + case WebBlobData::Item::TypeFile: + AppendFile( + webkit_glue::WebStringToFilePath(item.filePath), + static_cast<uint64>(item.offset), + static_cast<uint64>(item.length), + DoubleTToTime(item.expectedModificationTime)); + break; + case WebBlobData::Item::TypeBlob: + if (item.length) { + AppendBlob( + item.blobURL, + static_cast<uint64>(item.offset), + static_cast<uint64>(item.length)); + } + break; + default: + NOTREACHED(); + } + } + content_type_= data.contentType().utf8().data(); + content_disposition_ = data.contentDisposition().utf8().data(); +} + +} // namespace webkit_blob |