| 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/glue/glue_serialize.h" | 5 #include "webkit/glue/glue_serialize.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
| 12 #include "third_party/WebKit/WebKit/chromium/public/WebData.h" | 12 #include "third_party/WebKit/WebKit/chromium/public/WebData.h" |
| 13 #include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h" | 13 #include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h" |
| 14 #include "third_party/WebKit/WebKit/chromium/public/WebHTTPBody.h" | 14 #include "third_party/WebKit/WebKit/chromium/public/WebHTTPBody.h" |
| 15 #include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" | 15 #include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" |
| 16 #include "third_party/WebKit/WebKit/chromium/public/WebSerializedScriptValue.h" | 16 #include "third_party/WebKit/WebKit/chromium/public/WebSerializedScriptValue.h" |
| 17 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" | 17 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
| 18 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" | 18 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" |
| 19 #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" | 19 #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" |
| 20 #include "webkit/glue/webkit_glue.h" | 20 #include "webkit/glue/webkit_glue.h" |
| 21 | 21 |
| 22 using WebKit::WebData; | 22 using WebKit::WebData; |
| 23 using WebKit::WebFileInfo; | |
| 24 using WebKit::WebHistoryItem; | 23 using WebKit::WebHistoryItem; |
| 25 using WebKit::WebHTTPBody; | 24 using WebKit::WebHTTPBody; |
| 26 using WebKit::WebPoint; | 25 using WebKit::WebPoint; |
| 27 using WebKit::WebSerializedScriptValue; | 26 using WebKit::WebSerializedScriptValue; |
| 28 using WebKit::WebString; | 27 using WebKit::WebString; |
| 29 using WebKit::WebUChar; | 28 using WebKit::WebUChar; |
| 30 using WebKit::WebVector; | 29 using WebKit::WebVector; |
| 31 | 30 |
| 32 namespace webkit_glue { | 31 namespace webkit_glue { |
| 33 | 32 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 WebHTTPBody::Element element; | 232 WebHTTPBody::Element element; |
| 234 for (size_t i = 0; http_body.elementAt(i, element); ++i) { | 233 for (size_t i = 0; http_body.elementAt(i, element); ++i) { |
| 235 WriteInteger(element.type, obj); | 234 WriteInteger(element.type, obj); |
| 236 if (element.type == WebHTTPBody::Element::TypeData) { | 235 if (element.type == WebHTTPBody::Element::TypeData) { |
| 237 WriteData(element.data.data(), static_cast<int>(element.data.size()), | 236 WriteData(element.data.data(), static_cast<int>(element.data.size()), |
| 238 obj); | 237 obj); |
| 239 } else if (element.type == WebHTTPBody::Element::TypeFile) { | 238 } else if (element.type == WebHTTPBody::Element::TypeFile) { |
| 240 WriteString(element.filePath, obj); | 239 WriteString(element.filePath, obj); |
| 241 WriteInteger64(element.fileStart, obj); | 240 WriteInteger64(element.fileStart, obj); |
| 242 WriteInteger64(element.fileLength, obj); | 241 WriteInteger64(element.fileLength, obj); |
| 243 WriteReal(element.fileInfo.modificationTime, obj); | 242 WriteReal(element.modificationTime, obj); |
| 244 } else { | 243 } else { |
| 245 WriteGURL(element.blobURL, obj); | 244 WriteGURL(element.blobURL, obj); |
| 246 } | 245 } |
| 247 } | 246 } |
| 248 WriteInteger64(http_body.identifier(), obj); | 247 WriteInteger64(http_body.identifier(), obj); |
| 249 } | 248 } |
| 250 | 249 |
| 251 static WebHTTPBody ReadFormData(const SerializeObject* obj) { | 250 static WebHTTPBody ReadFormData(const SerializeObject* obj) { |
| 252 // In newer versions, an initial boolean indicates if we have form data. | 251 // In newer versions, an initial boolean indicates if we have form data. |
| 253 if (obj->version >= 5 && !ReadBoolean(obj)) | 252 if (obj->version >= 5 && !ReadBoolean(obj)) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 266 if (type == WebHTTPBody::Element::TypeData) { | 265 if (type == WebHTTPBody::Element::TypeData) { |
| 267 const void* data; | 266 const void* data; |
| 268 int length = -1; | 267 int length = -1; |
| 269 ReadData(obj, &data, &length); | 268 ReadData(obj, &data, &length); |
| 270 if (length >= 0) | 269 if (length >= 0) |
| 271 http_body.appendData(WebData(static_cast<const char*>(data), length)); | 270 http_body.appendData(WebData(static_cast<const char*>(data), length)); |
| 272 } else if (type == WebHTTPBody::Element::TypeFile) { | 271 } else if (type == WebHTTPBody::Element::TypeFile) { |
| 273 WebString file_path = ReadString(obj); | 272 WebString file_path = ReadString(obj); |
| 274 long long file_start = 0; | 273 long long file_start = 0; |
| 275 long long file_length = -1; | 274 long long file_length = -1; |
| 276 WebFileInfo file_info; | 275 double modification_time = 0.0; |
| 277 if (obj->version >= 8) { | 276 if (obj->version >= 8) { |
| 278 file_start = ReadInteger64(obj); | 277 file_start = ReadInteger64(obj); |
| 279 file_length = ReadInteger64(obj); | 278 file_length = ReadInteger64(obj); |
| 280 file_info.modificationTime = ReadReal(obj); | 279 modification_time = ReadReal(obj); |
| 281 } | 280 } |
| 282 http_body.appendFileRange(file_path, file_start, file_length, file_info); | 281 http_body.appendFileRange(file_path, file_start, file_length, |
| 282 modification_time); |
| 283 } else if (obj->version >= 10) { | 283 } else if (obj->version >= 10) { |
| 284 GURL blob_url = ReadGURL(obj); | 284 GURL blob_url = ReadGURL(obj); |
| 285 http_body.appendBlob(blob_url); | 285 http_body.appendBlob(blob_url); |
| 286 } | 286 } |
| 287 } | 287 } |
| 288 if (obj->version >= 4) | 288 if (obj->version >= 4) |
| 289 http_body.setIdentifier(ReadInteger64(obj)); | 289 http_body.setIdentifier(ReadInteger64(obj)); |
| 290 | 290 |
| 291 return http_body; | 291 return http_body; |
| 292 } | 292 } |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 const WebHistoryItem& item = HistoryItemFromString(content_state, false); | 473 const WebHistoryItem& item = HistoryItemFromString(content_state, false); |
| 474 if (item.isNull()) { | 474 if (item.isNull()) { |
| 475 // Couldn't parse the string, return an empty string. | 475 // Couldn't parse the string, return an empty string. |
| 476 return std::string(); | 476 return std::string(); |
| 477 } | 477 } |
| 478 | 478 |
| 479 return HistoryItemToString(item); | 479 return HistoryItemToString(item); |
| 480 } | 480 } |
| 481 | 481 |
| 482 } // namespace webkit_glue | 482 } // namespace webkit_glue |
| OLD | NEW |