| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "webkit/blob/blob_data.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/time.h" |
| 9 #include "third_party/WebKit/WebKit/chromium/public/WebBlobData.h" |
| 10 #include "third_party/WebKit/WebKit/chromium/public/WebCString.h" |
| 11 #include "third_party/WebKit/WebKit/chromium/public/WebData.h" |
| 12 #include "webkit/glue/webkit_glue.h" |
| 13 |
| 14 using WebKit::WebBlobData; |
| 15 using WebKit::WebData; |
| 16 using WebKit::WebString; |
| 17 |
| 18 namespace { |
| 19 |
| 20 // Time::FromDoubleT() does not return empty Time object when dt is 0. |
| 21 // We have to work around this problem here. |
| 22 base::Time DoubleTToTime(double dt) { |
| 23 return dt ? base::Time::FromDoubleT(dt) : base::Time(); |
| 24 } |
| 25 |
| 26 } |
| 27 |
| 28 namespace webkit_blob { |
| 29 |
| 30 BlobData::BlobData(const WebBlobData& data) { |
| 31 size_t i = 0; |
| 32 WebBlobData::Item item; |
| 33 while (data.itemAt(i++, item)) { |
| 34 switch (item.type) { |
| 35 case WebBlobData::Item::TypeData: |
| 36 if (!item.data.isEmpty()) |
| 37 AppendData(item.data); |
| 38 break; |
| 39 case WebBlobData::Item::TypeFile: |
| 40 AppendFile( |
| 41 webkit_glue::WebStringToFilePath(item.filePath), |
| 42 static_cast<uint64>(item.offset), |
| 43 static_cast<uint64>(item.length), |
| 44 DoubleTToTime(item.expectedModificationTime)); |
| 45 break; |
| 46 case WebBlobData::Item::TypeBlob: |
| 47 if (item.length) { |
| 48 AppendBlob( |
| 49 item.blobURL, |
| 50 static_cast<uint64>(item.offset), |
| 51 static_cast<uint64>(item.length)); |
| 52 } |
| 53 break; |
| 54 default: |
| 55 NOTREACHED(); |
| 56 } |
| 57 } |
| 58 content_type_= data.contentType().utf8().data(); |
| 59 content_disposition_ = data.contentDisposition().utf8().data(); |
| 60 } |
| 61 |
| 62 } // namespace webkit_blob |
| OLD | NEW |