| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 *exploded = ExplodedPageState(); | 734 *exploded = ExplodedPageState(); |
| 735 | 735 |
| 736 if (encoded.empty()) | 736 if (encoded.empty()) |
| 737 return true; | 737 return true; |
| 738 | 738 |
| 739 SerializeObject obj(encoded.data(), static_cast<int>(encoded.size())); | 739 SerializeObject obj(encoded.data(), static_cast<int>(encoded.size())); |
| 740 ReadPageState(&obj, exploded); | 740 ReadPageState(&obj, exploded); |
| 741 return !obj.parse_error; | 741 return !obj.parse_error; |
| 742 } | 742 } |
| 743 | 743 |
| 744 bool EncodePageState(const ExplodedPageState& exploded, std::string* encoded) { | 744 void EncodePageState(const ExplodedPageState& exploded, std::string* encoded) { |
| 745 SerializeObject obj; | 745 SerializeObject obj; |
| 746 obj.version = kCurrentVersion; | 746 obj.version = kCurrentVersion; |
| 747 WritePageState(exploded, &obj); | 747 WritePageState(exploded, &obj); |
| 748 *encoded = obj.GetAsString(); | 748 *encoded = obj.GetAsString(); |
| 749 return true; | |
| 750 } | 749 } |
| 751 | 750 |
| 752 #if defined(OS_ANDROID) | 751 #if defined(OS_ANDROID) |
| 753 bool DecodePageStateWithDeviceScaleFactorForTesting( | 752 bool DecodePageStateWithDeviceScaleFactorForTesting( |
| 754 const std::string& encoded, | 753 const std::string& encoded, |
| 755 float device_scale_factor, | 754 float device_scale_factor, |
| 756 ExplodedPageState* exploded) { | 755 ExplodedPageState* exploded) { |
| 757 g_device_scale_factor_for_testing = device_scale_factor; | 756 g_device_scale_factor_for_testing = device_scale_factor; |
| 758 bool rv = DecodePageState(encoded, exploded); | 757 bool rv = DecodePageState(encoded, exploded); |
| 759 g_device_scale_factor_for_testing = 0.0; | 758 g_device_scale_factor_for_testing = 0.0; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 773 const ResourceRequestBodyImpl& resource_request_body) { | 772 const ResourceRequestBodyImpl& resource_request_body) { |
| 774 SerializeObject obj; | 773 SerializeObject obj; |
| 775 obj.version = kCurrentVersion; | 774 obj.version = kCurrentVersion; |
| 776 WriteResourceRequestBody(resource_request_body, &obj); | 775 WriteResourceRequestBody(resource_request_body, &obj); |
| 777 return obj.GetAsString(); | 776 return obj.GetAsString(); |
| 778 } | 777 } |
| 779 | 778 |
| 780 #endif | 779 #endif |
| 781 | 780 |
| 782 } // namespace content | 781 } // namespace content |
| OLD | NEW |