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 #ifndef SYNC_INTERNAL_API_PUBLIC_BASE_UNIQUE_POSITION_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_BASE_UNIQUE_POSITION_H_ |
6 #define SYNC_INTERNAL_API_PUBLIC_BASE_UNIQUE_POSITION_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_BASE_UNIQUE_POSITION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 // This class currently has several bookmarks-related assumptions built in, | 39 // This class currently has several bookmarks-related assumptions built in, |
40 // though it could be adapted to be more generally useful. | 40 // though it could be adapted to be more generally useful. |
41 class SYNC_EXPORT_PRIVATE UniquePosition { | 41 class SYNC_EXPORT_PRIVATE UniquePosition { |
42 public: | 42 public: |
43 static const size_t kSuffixLength; | 43 static const size_t kSuffixLength; |
44 static const size_t kCompressBytesThreshold; | 44 static const size_t kCompressBytesThreshold; |
45 | 45 |
46 static bool IsValidSuffix(const std::string& suffix); | 46 static bool IsValidSuffix(const std::string& suffix); |
47 static bool IsValidBytes(const std::string& bytes); | 47 static bool IsValidBytes(const std::string& bytes); |
48 | 48 |
| 49 // Returns a valid, but mostly random suffix. |
| 50 // Avoid using this; it can lead to inconsistent sort orderings if misused. |
| 51 static std::string RandomSuffix(); |
| 52 |
49 // Returns an invalid position. | 53 // Returns an invalid position. |
50 static UniquePosition CreateInvalid(); | 54 static UniquePosition CreateInvalid(); |
51 | 55 |
52 // Converts from a 'sync_pb::UniquePosition' protobuf to a UniquePosition. | 56 // Converts from a 'sync_pb::UniquePosition' protobuf to a UniquePosition. |
53 // This may return an invalid position if the parsing fails. | 57 // This may return an invalid position if the parsing fails. |
54 static UniquePosition FromProto(const sync_pb::UniquePosition& proto); | 58 static UniquePosition FromProto(const sync_pb::UniquePosition& proto); |
55 | 59 |
56 // Creates a position with the given suffix. Ordering among positions created | 60 // Creates a position with the given suffix. Ordering among positions created |
57 // from this function is the same as that of the integer parameters that were | 61 // from this function is the same as that of the integer parameters that were |
58 // passed in. | 62 // passed in. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 135 |
132 // The position value after it has been run through the custom compression | 136 // The position value after it has been run through the custom compression |
133 // algorithm. See Compress() and Uncompress() functions above. | 137 // algorithm. See Compress() and Uncompress() functions above. |
134 std::string compressed_; | 138 std::string compressed_; |
135 bool is_valid_; | 139 bool is_valid_; |
136 }; | 140 }; |
137 | 141 |
138 } // namespace syncer; | 142 } // namespace syncer; |
139 | 143 |
140 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_UNIQUE_POSITION_H_ | 144 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_UNIQUE_POSITION_H_ |
OLD | NEW |