| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/blob/blob_data.h" | 5 #include "webkit/blob/blob_data.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/time.h" | 8 #include "base/time.h" |
| 9 #include "third_party/WebKit/WebKit/chromium/public/WebBlobData.h" | 9 #include "third_party/WebKit/WebKit/chromium/public/WebBlobData.h" |
| 10 #include "third_party/WebKit/WebKit/chromium/public/WebCString.h" | 10 #include "third_party/WebKit/WebKit/chromium/public/WebCString.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace webkit_blob { | 28 namespace webkit_blob { |
| 29 | 29 |
| 30 BlobData::BlobData(const WebBlobData& data) { | 30 BlobData::BlobData(const WebBlobData& data) { |
| 31 size_t i = 0; | 31 size_t i = 0; |
| 32 WebBlobData::Item item; | 32 WebBlobData::Item item; |
| 33 while (data.itemAt(i++, item)) { | 33 while (data.itemAt(i++, item)) { |
| 34 switch (item.type) { | 34 switch (item.type) { |
| 35 case WebBlobData::Item::TypeData: | 35 case WebBlobData::Item::TypeData: |
| 36 if (!item.data.isEmpty()) | 36 if (!item.data.isEmpty()) { |
| 37 // WebBlobData does not allow partial data. |
| 38 DCHECK(!item.offset && item.length == -1); |
| 37 AppendData(item.data); | 39 AppendData(item.data); |
| 40 } |
| 38 break; | 41 break; |
| 39 case WebBlobData::Item::TypeFile: | 42 case WebBlobData::Item::TypeFile: |
| 40 AppendFile( | 43 AppendFile( |
| 41 webkit_glue::WebStringToFilePath(item.filePath), | 44 webkit_glue::WebStringToFilePath(item.filePath), |
| 42 static_cast<uint64>(item.offset), | 45 static_cast<uint64>(item.offset), |
| 43 static_cast<uint64>(item.length), | 46 static_cast<uint64>(item.length), |
| 44 DoubleTToTime(item.expectedModificationTime)); | 47 DoubleTToTime(item.expectedModificationTime)); |
| 45 break; | 48 break; |
| 46 case WebBlobData::Item::TypeBlob: | 49 case WebBlobData::Item::TypeBlob: |
| 47 if (item.length) { | 50 if (item.length) { |
| 48 AppendBlob( | 51 AppendBlob( |
| 49 item.blobURL, | 52 item.blobURL, |
| 50 static_cast<uint64>(item.offset), | 53 static_cast<uint64>(item.offset), |
| 51 static_cast<uint64>(item.length)); | 54 static_cast<uint64>(item.length)); |
| 52 } | 55 } |
| 53 break; | 56 break; |
| 54 default: | 57 default: |
| 55 NOTREACHED(); | 58 NOTREACHED(); |
| 56 } | 59 } |
| 57 } | 60 } |
| 58 content_type_= data.contentType().utf8().data(); | 61 content_type_= data.contentType().utf8().data(); |
| 59 content_disposition_ = data.contentDisposition().utf8().data(); | 62 content_disposition_ = data.contentDisposition().utf8().data(); |
| 60 } | 63 } |
| 61 | 64 |
| 62 } // namespace webkit_blob | 65 } // namespace webkit_blob |
| OLD | NEW |