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 "components/sync/base/unique_position.h" | 5 #include "components/sync/base/unique_position.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 if (proto.has_custom_compressed_v1()) { | 59 if (proto.has_custom_compressed_v1()) { |
60 return UniquePosition(proto.custom_compressed_v1()); | 60 return UniquePosition(proto.custom_compressed_v1()); |
61 } else if (proto.has_value() && !proto.value().empty()) { | 61 } else if (proto.has_value() && !proto.value().empty()) { |
62 return UniquePosition(Compress(proto.value())); | 62 return UniquePosition(Compress(proto.value())); |
63 } else if (proto.has_compressed_value() && proto.has_uncompressed_length()) { | 63 } else if (proto.has_compressed_value() && proto.has_uncompressed_length()) { |
64 uLongf uncompressed_len = proto.uncompressed_length(); | 64 uLongf uncompressed_len = proto.uncompressed_length(); |
65 std::string un_gzipped; | 65 std::string un_gzipped; |
66 | 66 |
67 un_gzipped.resize(uncompressed_len); | 67 un_gzipped.resize(uncompressed_len); |
68 int result = uncompress( | 68 int result = uncompress( |
69 reinterpret_cast<Bytef*>(string_as_array(&un_gzipped)), | 69 reinterpret_cast<Bytef*>(base::string_as_array(&un_gzipped)), |
70 &uncompressed_len, | 70 &uncompressed_len, |
71 reinterpret_cast<const Bytef*>(proto.compressed_value().data()), | 71 reinterpret_cast<const Bytef*>(proto.compressed_value().data()), |
72 proto.compressed_value().size()); | 72 proto.compressed_value().size()); |
73 if (result != Z_OK) { | 73 if (result != Z_OK) { |
74 DLOG(ERROR) << "Unzip failed " << result; | 74 DLOG(ERROR) << "Unzip failed " << result; |
75 return UniquePosition::CreateInvalid(); | 75 return UniquePosition::CreateInvalid(); |
76 } | 76 } |
77 if (uncompressed_len != proto.uncompressed_length()) { | 77 if (uncompressed_len != proto.uncompressed_length()) { |
78 DLOG(ERROR) << "Uncompressed length " << uncompressed_len | 78 DLOG(ERROR) << "Uncompressed length " << uncompressed_len |
79 << " did not match specified length " | 79 << " did not match specified length " |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 return false; | 611 return false; |
612 } | 612 } |
613 } | 613 } |
614 } | 614 } |
615 // We don't bother looking for the existence or checking the validity of | 615 // We don't bother looking for the existence or checking the validity of |
616 // any partial blocks. There's no way they could be invalid anyway. | 616 // any partial blocks. There's no way they could be invalid anyway. |
617 return true; | 617 return true; |
618 } | 618 } |
619 | 619 |
620 } // namespace syncer | 620 } // namespace syncer |
OLD | NEW |