Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Unified Diff: webkit/blob/blob_data.cc

Issue 3108042: Support sending BlobData to browser process. Also support sending UploadData... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/blob/blob_data.h ('k') | webkit/blob/blob_storage_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/blob/blob_data.cc
===================================================================
--- webkit/blob/blob_data.cc (revision 0)
+++ webkit/blob/blob_data.cc (revision 0)
@@ -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
Property changes on: webkit\blob\blob_data.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « webkit/blob/blob_data.h ('k') | webkit/blob/blob_storage_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698