OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // 4: Adds support for storing FormData::identifier(). | 62 // 4: Adds support for storing FormData::identifier(). |
63 // 5: Adds support for empty FormData | 63 // 5: Adds support for empty FormData |
64 // 6: Adds support for documentSequenceNumbers | 64 // 6: Adds support for documentSequenceNumbers |
65 // 7: Adds support for stateObject | 65 // 7: Adds support for stateObject |
66 // 8: Adds support for file range and modification time | 66 // 8: Adds support for file range and modification time |
67 // 9: Adds support for itemSequenceNumbers | 67 // 9: Adds support for itemSequenceNumbers |
68 // 10: Adds support for blob | 68 // 10: Adds support for blob |
69 // 11: Adds support for pageScaleFactor | 69 // 11: Adds support for pageScaleFactor |
70 // 12: Adds support for hasPasswordData in HTTP body | 70 // 12: Adds support for hasPasswordData in HTTP body |
71 // 13: Adds support for URL (FileSystem URL) | 71 // 13: Adds support for URL (FileSystem URL) |
| 72 // 14: Use blob UUID strings in stead of URLs. |
72 // Should be const, but unit tests may modify it. | 73 // Should be const, but unit tests may modify it. |
73 // | 74 // |
74 // NOTE: If the version is -1, then the pickle contains only a URL string. | 75 // NOTE: If the version is -1, then the pickle contains only a URL string. |
75 // See CreateHistoryStateForURL. | 76 // See CreateHistoryStateForURL. |
76 // | 77 // |
77 int kVersion = 13; | 78 int kVersion = 14; |
78 | 79 |
79 // A bunch of convenience functions to read/write to SerializeObjects. | 80 // A bunch of convenience functions to read/write to SerializeObjects. |
80 // The serializers assume the input data is in the correct format and so does | 81 // The serializers assume the input data is in the correct format and so does |
81 // no error checking. | 82 // no error checking. |
82 inline void WriteData(const void* data, int length, SerializeObject* obj) { | 83 inline void WriteData(const void* data, int length, SerializeObject* obj) { |
83 obj->pickle.WriteData(static_cast<const char*>(data), length); | 84 obj->pickle.WriteData(static_cast<const char*>(data), length); |
84 } | 85 } |
85 | 86 |
86 inline void ReadData(const SerializeObject* obj, const void** data, | 87 inline void ReadData(const SerializeObject* obj, const void** data, |
87 int* length) { | 88 int* length) { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 for (size_t i = 0; http_body.elementAt(i, element); ++i) { | 253 for (size_t i = 0; http_body.elementAt(i, element); ++i) { |
253 WriteInteger(element.type, obj); | 254 WriteInteger(element.type, obj); |
254 if (element.type == WebHTTPBody::Element::TypeData) { | 255 if (element.type == WebHTTPBody::Element::TypeData) { |
255 WriteData(element.data.data(), static_cast<int>(element.data.size()), | 256 WriteData(element.data.data(), static_cast<int>(element.data.size()), |
256 obj); | 257 obj); |
257 } else if (element.type == WebHTTPBody::Element::TypeFile) { | 258 } else if (element.type == WebHTTPBody::Element::TypeFile) { |
258 WriteString(element.filePath, obj); | 259 WriteString(element.filePath, obj); |
259 WriteInteger64(element.fileStart, obj); | 260 WriteInteger64(element.fileStart, obj); |
260 WriteInteger64(element.fileLength, obj); | 261 WriteInteger64(element.fileLength, obj); |
261 WriteReal(element.modificationTime, obj); | 262 WriteReal(element.modificationTime, obj); |
262 } else if (element.type == WebHTTPBody::Element::TypeURL) { | 263 } else if (element.type == WebHTTPBody::Element::TypeFileSystemURL) { |
263 WriteGURL(element.url, obj); | 264 WriteGURL(element.fileSystemURL, obj); |
264 WriteInteger64(element.fileStart, obj); | 265 WriteInteger64(element.fileStart, obj); |
265 WriteInteger64(element.fileLength, obj); | 266 WriteInteger64(element.fileLength, obj); |
266 WriteReal(element.modificationTime, obj); | 267 WriteReal(element.modificationTime, obj); |
267 } else { | 268 } else { |
268 WriteGURL(element.url, obj); | 269 DCHECK(element.type == WebHTTPBody::Element::TypeBlob); |
| 270 WriteString(element.blobUUID, obj); |
269 } | 271 } |
270 } | 272 } |
271 WriteInteger64(http_body.identifier(), obj); | 273 WriteInteger64(http_body.identifier(), obj); |
272 WriteBoolean(http_body.containsPasswordData(), obj); | 274 WriteBoolean(http_body.containsPasswordData(), obj); |
273 } | 275 } |
274 | 276 |
275 WebHTTPBody ReadFormData(const SerializeObject* obj) { | 277 WebHTTPBody ReadFormData(const SerializeObject* obj) { |
276 // In newer versions, an initial boolean indicates if we have form data. | 278 // In newer versions, an initial boolean indicates if we have form data. |
277 if (obj->version >= 5 && !ReadBoolean(obj)) | 279 if (obj->version >= 5 && !ReadBoolean(obj)) |
278 return WebHTTPBody(); | 280 return WebHTTPBody(); |
(...skipping 19 matching lines...) Expand all Loading... |
298 long long file_start = 0; | 300 long long file_start = 0; |
299 long long file_length = -1; | 301 long long file_length = -1; |
300 double modification_time = 0.0; | 302 double modification_time = 0.0; |
301 if (obj->version >= 8) { | 303 if (obj->version >= 8) { |
302 file_start = ReadInteger64(obj); | 304 file_start = ReadInteger64(obj); |
303 file_length = ReadInteger64(obj); | 305 file_length = ReadInteger64(obj); |
304 modification_time = ReadReal(obj); | 306 modification_time = ReadReal(obj); |
305 } | 307 } |
306 http_body.appendFileRange(file_path, file_start, file_length, | 308 http_body.appendFileRange(file_path, file_start, file_length, |
307 modification_time); | 309 modification_time); |
308 } else if (type == WebHTTPBody::Element::TypeURL) { | 310 } else if (type == WebHTTPBody::Element::TypeFileSystemURL) { |
309 GURL url = ReadGURL(obj); | 311 GURL url = ReadGURL(obj); |
310 long long file_start = 0; | 312 long long file_start = 0; |
311 long long file_length = -1; | 313 long long file_length = -1; |
312 double modification_time = 0.0; | 314 double modification_time = 0.0; |
313 file_start = ReadInteger64(obj); | 315 file_start = ReadInteger64(obj); |
314 file_length = ReadInteger64(obj); | 316 file_length = ReadInteger64(obj); |
315 modification_time = ReadReal(obj); | 317 modification_time = ReadReal(obj); |
316 http_body.appendURLRange(url, file_start, file_length, | 318 http_body.appendURLRange(url, file_start, file_length, |
317 modification_time); | 319 modification_time); |
318 } else if (obj->version >= 10) { | 320 } else if (obj->version >= 10) { |
319 GURL blob_url = ReadGURL(obj); | 321 DCHECK(type == WebHTTPBody::Element::TypeBlob); |
320 http_body.appendBlob(blob_url); | 322 if (obj->version >= 14) { |
| 323 WebString blob_uuid = ReadString(obj); |
| 324 http_body.appendBlob(blob_uuid); |
| 325 } else { |
| 326 GURL obsolete_format = ReadGURL(obj); |
| 327 } |
321 } | 328 } |
322 } | 329 } |
323 if (obj->version >= 4) | 330 if (obj->version >= 4) |
324 http_body.setIdentifier(ReadInteger64(obj)); | 331 http_body.setIdentifier(ReadInteger64(obj)); |
325 | 332 |
326 if (obj->version >= 12) | 333 if (obj->version >= 12) |
327 http_body.setContainsPasswordData(ReadBoolean(obj)); | 334 http_body.setContainsPasswordData(ReadBoolean(obj)); |
328 | 335 |
329 return http_body; | 336 return http_body; |
330 } | 337 } |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 // serialization of the given URL with a dummy version number of -1. This | 604 // serialization of the given URL with a dummy version number of -1. This |
598 // will be interpreted by ReadHistoryItem as a request to create a default | 605 // will be interpreted by ReadHistoryItem as a request to create a default |
599 // WebHistoryItem. | 606 // WebHistoryItem. |
600 SerializeObject obj; | 607 SerializeObject obj; |
601 WriteInteger(-1, &obj); | 608 WriteInteger(-1, &obj); |
602 WriteGURL(url, &obj); | 609 WriteGURL(url, &obj); |
603 return obj.GetAsString(); | 610 return obj.GetAsString(); |
604 } | 611 } |
605 | 612 |
606 } // namespace webkit_glue | 613 } // namespace webkit_glue |
OLD | NEW |