OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/common/page_state_serialization.h" | 5 #include "content/common/page_state_serialization.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 http_body->elements.push_back(element); | 44 http_body->elements.push_back(element); |
45 } | 45 } |
46 | 46 |
47 void AppendURLRangeToHttpBody(ExplodedHttpBody* http_body, | 47 void AppendURLRangeToHttpBody(ExplodedHttpBody* http_body, |
48 const GURL& url, | 48 const GURL& url, |
49 int file_start, | 49 int file_start, |
50 int file_length, | 50 int file_length, |
51 double file_modification_time) { | 51 double file_modification_time) { |
52 ExplodedHttpBodyElement element; | 52 ExplodedHttpBodyElement element; |
53 element.type = WebKit::WebHTTPBody::Element::TypeURL; | 53 element.type = WebKit::WebHTTPBody::Element::TypeURL; |
54 element.url = url; | 54 element.filesystem_url = url; |
55 element.file_start = file_start; | 55 element.file_start = file_start; |
56 element.file_length = file_length; | 56 element.file_length = file_length; |
57 element.file_modification_time = file_modification_time; | 57 element.file_modification_time = file_modification_time; |
58 http_body->elements.push_back(element); | 58 http_body->elements.push_back(element); |
59 } | 59 } |
60 | 60 |
61 void AppendBlobToHttpBody(ExplodedHttpBody* http_body, const GURL& url) { | 61 void DeprecatedAppendBlobToHttpBody(ExplodedHttpBody* http_body, |
| 62 const GURL& url) { |
62 ExplodedHttpBodyElement element; | 63 ExplodedHttpBodyElement element; |
63 element.type = WebKit::WebHTTPBody::Element::TypeBlob; | 64 element.type = WebKit::WebHTTPBody::Element::TypeBlob; |
64 element.url = url; | 65 element.deprecated_blob_url = url; |
65 http_body->elements.push_back(element); | 66 http_body->elements.push_back(element); |
66 } | 67 } |
67 | 68 |
68 //---------------------------------------------------------------------------- | 69 //---------------------------------------------------------------------------- |
69 | 70 |
70 void AppendReferencedFilesFromHttpBody( | 71 void AppendReferencedFilesFromHttpBody( |
71 const std::vector<ExplodedHttpBodyElement>& elements, | 72 const std::vector<ExplodedHttpBodyElement>& elements, |
72 std::vector<base::NullableString16>* referenced_files) { | 73 std::vector<base::NullableString16>* referenced_files) { |
73 for (size_t i = 0; i < elements.size(); ++i) { | 74 for (size_t i = 0; i < elements.size(); ++i) { |
74 if (elements[i].type == WebKit::WebHTTPBody::Element::TypeFile) | 75 if (elements[i].type == WebKit::WebHTTPBody::Element::TypeFile) |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 WriteInteger(element.type, obj); | 390 WriteInteger(element.type, obj); |
390 if (element.type == WebKit::WebHTTPBody::Element::TypeData) { | 391 if (element.type == WebKit::WebHTTPBody::Element::TypeData) { |
391 WriteData(element.data.data(), static_cast<int>(element.data.size()), | 392 WriteData(element.data.data(), static_cast<int>(element.data.size()), |
392 obj); | 393 obj); |
393 } else if (element.type == WebKit::WebHTTPBody::Element::TypeFile) { | 394 } else if (element.type == WebKit::WebHTTPBody::Element::TypeFile) { |
394 WriteString(element.file_path, obj); | 395 WriteString(element.file_path, obj); |
395 WriteInteger64(element.file_start, obj); | 396 WriteInteger64(element.file_start, obj); |
396 WriteInteger64(element.file_length, obj); | 397 WriteInteger64(element.file_length, obj); |
397 WriteReal(element.file_modification_time, obj); | 398 WriteReal(element.file_modification_time, obj); |
398 } else if (element.type == WebKit::WebHTTPBody::Element::TypeURL) { | 399 } else if (element.type == WebKit::WebHTTPBody::Element::TypeURL) { |
399 WriteGURL(element.url, obj); | 400 WriteGURL(element.filesystem_url, obj); |
400 WriteInteger64(element.file_start, obj); | 401 WriteInteger64(element.file_start, obj); |
401 WriteInteger64(element.file_length, obj); | 402 WriteInteger64(element.file_length, obj); |
402 WriteReal(element.file_modification_time, obj); | 403 WriteReal(element.file_modification_time, obj); |
403 } else { | 404 } else { |
404 WriteGURL(element.url, obj); | 405 DCHECK(element.type == WebKit::WebHTTPBody::Element::TypeBlob); |
| 406 WriteGURL(element.deprecated_blob_url, obj); |
405 } | 407 } |
406 } | 408 } |
407 WriteInteger64(http_body.identifier, obj); | 409 WriteInteger64(http_body.identifier, obj); |
408 WriteBoolean(http_body.contains_passwords, obj); | 410 WriteBoolean(http_body.contains_passwords, obj); |
409 } | 411 } |
410 | 412 |
411 void ReadHttpBody(SerializeObject* obj, ExplodedHttpBody* http_body) { | 413 void ReadHttpBody(SerializeObject* obj, ExplodedHttpBody* http_body) { |
412 // An initial boolean indicates if we have an HTTP body. | 414 // An initial boolean indicates if we have an HTTP body. |
413 if (!ReadBoolean(obj)) | 415 if (!ReadBoolean(obj)) |
414 return; | 416 return; |
(...skipping 20 matching lines...) Expand all Loading... |
435 file_modification_time); | 437 file_modification_time); |
436 } else if (type == WebKit::WebHTTPBody::Element::TypeURL) { | 438 } else if (type == WebKit::WebHTTPBody::Element::TypeURL) { |
437 GURL url = ReadGURL(obj); | 439 GURL url = ReadGURL(obj); |
438 int64 file_start = ReadInteger64(obj); | 440 int64 file_start = ReadInteger64(obj); |
439 int64 file_length = ReadInteger64(obj); | 441 int64 file_length = ReadInteger64(obj); |
440 double file_modification_time = ReadReal(obj); | 442 double file_modification_time = ReadReal(obj); |
441 AppendURLRangeToHttpBody(http_body, url, file_start, file_length, | 443 AppendURLRangeToHttpBody(http_body, url, file_start, file_length, |
442 file_modification_time); | 444 file_modification_time); |
443 } else if (type == WebKit::WebHTTPBody::Element::TypeBlob) { | 445 } else if (type == WebKit::WebHTTPBody::Element::TypeBlob) { |
444 GURL blob_url = ReadGURL(obj); | 446 GURL blob_url = ReadGURL(obj); |
445 AppendBlobToHttpBody(http_body, blob_url); | 447 DeprecatedAppendBlobToHttpBody(http_body, blob_url); |
446 } | 448 } |
447 } | 449 } |
448 http_body->identifier = ReadInteger64(obj); | 450 http_body->identifier = ReadInteger64(obj); |
449 | 451 |
450 if (obj->version >= 12) | 452 if (obj->version >= 12) |
451 http_body->contains_passwords = ReadBoolean(obj); | 453 http_body->contains_passwords = ReadBoolean(obj); |
452 } | 454 } |
453 | 455 |
454 // Writes the ExplodedFrameState data into the SerializeObject object for | 456 // Writes the ExplodedFrameState data into the SerializeObject object for |
455 // serialization. | 457 // serialization. |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 float device_scale_factor, | 675 float device_scale_factor, |
674 ExplodedPageState* exploded) { | 676 ExplodedPageState* exploded) { |
675 g_device_scale_factor_for_testing = device_scale_factor; | 677 g_device_scale_factor_for_testing = device_scale_factor; |
676 bool rv = DecodePageState(encoded, exploded); | 678 bool rv = DecodePageState(encoded, exploded); |
677 g_device_scale_factor_for_testing = 0.0; | 679 g_device_scale_factor_for_testing = 0.0; |
678 return rv; | 680 return rv; |
679 } | 681 } |
680 #endif | 682 #endif |
681 | 683 |
682 } // namespace content | 684 } // namespace content |
OLD | NEW |