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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 bool parse_error; | 180 bool parse_error; |
181 }; | 181 }; |
182 | 182 |
183 // Version ID of serialized format. | 183 // Version ID of serialized format. |
184 // 11: Min version | 184 // 11: Min version |
185 // 12: Adds support for contains_passwords in HTTP body | 185 // 12: Adds support for contains_passwords in HTTP body |
186 // 13: Adds support for URL (FileSystem URL) | 186 // 13: Adds support for URL (FileSystem URL) |
187 // 14: Adds list of referenced files, version written only for first item. | 187 // 14: Adds list of referenced files, version written only for first item. |
188 // 15: Removes a bunch of values we defined but never used. | 188 // 15: Removes a bunch of values we defined but never used. |
189 // 16: Switched from blob urls to blob uuids. | 189 // 16: Switched from blob urls to blob uuids. |
| 190 // 17: Add a target frame id number. |
190 // | 191 // |
191 // NOTE: If the version is -1, then the pickle contains only a URL string. | 192 // NOTE: If the version is -1, then the pickle contains only a URL string. |
192 // See ReadPageState. | 193 // See ReadPageState. |
193 // | 194 // |
194 const int kMinVersion = 11; | 195 const int kMinVersion = 11; |
195 const int kCurrentVersion = 16; | 196 const int kCurrentVersion = 17; |
196 | 197 |
197 // A bunch of convenience functions to read/write to SerializeObjects. The | 198 // A bunch of convenience functions to read/write to SerializeObjects. The |
198 // de-serializers assume the input data will be in the correct format and fall | 199 // de-serializers assume the input data will be in the correct format and fall |
199 // back to returning safe defaults when not. | 200 // back to returning safe defaults when not. |
200 | 201 |
201 void WriteData(const void* data, int length, SerializeObject* obj) { | 202 void WriteData(const void* data, int length, SerializeObject* obj) { |
202 obj->pickle.WriteData(static_cast<const char*>(data), length); | 203 obj->pickle.WriteData(static_cast<const char*>(data), length); |
203 } | 204 } |
204 | 205 |
205 void ReadData(SerializeObject* obj, const void** data, int* length) { | 206 void ReadData(SerializeObject* obj, const void** data, int* length) { |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 WriteString(state.target, obj); | 496 WriteString(state.target, obj); |
496 WriteInteger(state.scroll_offset.x(), obj); | 497 WriteInteger(state.scroll_offset.x(), obj); |
497 WriteInteger(state.scroll_offset.y(), obj); | 498 WriteInteger(state.scroll_offset.y(), obj); |
498 WriteString(state.referrer, obj); | 499 WriteString(state.referrer, obj); |
499 | 500 |
500 WriteStringVector(state.document_state, obj); | 501 WriteStringVector(state.document_state, obj); |
501 | 502 |
502 WriteReal(state.page_scale_factor, obj); | 503 WriteReal(state.page_scale_factor, obj); |
503 WriteInteger64(state.item_sequence_number, obj); | 504 WriteInteger64(state.item_sequence_number, obj); |
504 WriteInteger64(state.document_sequence_number, obj); | 505 WriteInteger64(state.document_sequence_number, obj); |
| 506 WriteInteger64(state.target_frame_id, obj); |
505 | 507 |
506 bool has_state_object = !state.state_object.is_null(); | 508 bool has_state_object = !state.state_object.is_null(); |
507 WriteBoolean(has_state_object, obj); | 509 WriteBoolean(has_state_object, obj); |
508 if (has_state_object) | 510 if (has_state_object) |
509 WriteString(state.state_object, obj); | 511 WriteString(state.state_object, obj); |
510 | 512 |
511 WriteHttpBody(state.http_body, obj); | 513 WriteHttpBody(state.http_body, obj); |
512 | 514 |
513 // NOTE: It is a quirk of the format that we still have to write the | 515 // NOTE: It is a quirk of the format that we still have to write the |
514 // http_content_type field when the HTTP body is null. That's why this code | 516 // http_content_type field when the HTTP body is null. That's why this code |
(...skipping 30 matching lines...) Expand all Loading... |
545 ConsumeBoolean(obj); // Skip obsolete target item flag. | 547 ConsumeBoolean(obj); // Skip obsolete target item flag. |
546 ConsumeInteger(obj); // Skip obsolete visit count field. | 548 ConsumeInteger(obj); // Skip obsolete visit count field. |
547 } | 549 } |
548 state->referrer = ReadString(obj); | 550 state->referrer = ReadString(obj); |
549 | 551 |
550 ReadStringVector(obj, &state->document_state); | 552 ReadStringVector(obj, &state->document_state); |
551 | 553 |
552 state->page_scale_factor = ReadReal(obj); | 554 state->page_scale_factor = ReadReal(obj); |
553 state->item_sequence_number = ReadInteger64(obj); | 555 state->item_sequence_number = ReadInteger64(obj); |
554 state->document_sequence_number = ReadInteger64(obj); | 556 state->document_sequence_number = ReadInteger64(obj); |
| 557 if (obj->version >= 17) |
| 558 state->target_frame_id = ReadInteger64(obj); |
555 | 559 |
556 bool has_state_object = ReadBoolean(obj); | 560 bool has_state_object = ReadBoolean(obj); |
557 if (has_state_object) | 561 if (has_state_object) |
558 state->state_object = ReadString(obj); | 562 state->state_object = ReadString(obj); |
559 | 563 |
560 ReadHttpBody(obj, &state->http_body); | 564 ReadHttpBody(obj, &state->http_body); |
561 | 565 |
562 // NOTE: It is a quirk of the format that we still have to read the | 566 // NOTE: It is a quirk of the format that we still have to read the |
563 // http_content_type field when the HTTP body is null. That's why this code | 567 // http_content_type field when the HTTP body is null. That's why this code |
564 // is here instead of inside ReadHttpBody. | 568 // is here instead of inside ReadHttpBody. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 contains_passwords(false), | 657 contains_passwords(false), |
654 is_null(true) { | 658 is_null(true) { |
655 } | 659 } |
656 | 660 |
657 ExplodedHttpBody::~ExplodedHttpBody() { | 661 ExplodedHttpBody::~ExplodedHttpBody() { |
658 } | 662 } |
659 | 663 |
660 ExplodedFrameState::ExplodedFrameState() | 664 ExplodedFrameState::ExplodedFrameState() |
661 : item_sequence_number(0), | 665 : item_sequence_number(0), |
662 document_sequence_number(0), | 666 document_sequence_number(0), |
| 667 target_frame_id(0), |
663 page_scale_factor(0.0) { | 668 page_scale_factor(0.0) { |
664 } | 669 } |
665 | 670 |
666 ExplodedFrameState::~ExplodedFrameState() { | 671 ExplodedFrameState::~ExplodedFrameState() { |
667 } | 672 } |
668 | 673 |
669 ExplodedPageState::ExplodedPageState() { | 674 ExplodedPageState::ExplodedPageState() { |
670 } | 675 } |
671 | 676 |
672 ExplodedPageState::~ExplodedPageState() { | 677 ExplodedPageState::~ExplodedPageState() { |
(...skipping 24 matching lines...) Expand all Loading... |
697 float device_scale_factor, | 702 float device_scale_factor, |
698 ExplodedPageState* exploded) { | 703 ExplodedPageState* exploded) { |
699 g_device_scale_factor_for_testing = device_scale_factor; | 704 g_device_scale_factor_for_testing = device_scale_factor; |
700 bool rv = DecodePageState(encoded, exploded); | 705 bool rv = DecodePageState(encoded, exploded); |
701 g_device_scale_factor_for_testing = 0.0; | 706 g_device_scale_factor_for_testing = 0.0; |
702 return rv; | 707 return rv; |
703 } | 708 } |
704 #endif | 709 #endif |
705 | 710 |
706 } // namespace content | 711 } // namespace content |
OLD | NEW |