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 COMPONENTS_SYNC_BASE_UNIQUE_POSITION_H_ | 5 #ifndef COMPONENTS_SYNC_BASE_UNIQUE_POSITION_H_ |
6 #define COMPONENTS_SYNC_BASE_UNIQUE_POSITION_H_ | 6 #define COMPONENTS_SYNC_BASE_UNIQUE_POSITION_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 std::string GetSuffixForTest() const; | 94 std::string GetSuffixForTest() const; |
95 | 95 |
96 // Performs a lossy conversion to an int64_t position. Positions converted to | 96 // Performs a lossy conversion to an int64_t position. Positions converted to |
97 // and from int64_ts using this and the FromInt64 function should maintain | 97 // and from int64_ts using this and the FromInt64 function should maintain |
98 // their | 98 // their |
99 // relative orderings unless the int64_t values conflict. | 99 // relative orderings unless the int64_t values conflict. |
100 int64_t ToInt64() const; | 100 int64_t ToInt64() const; |
101 | 101 |
102 bool IsValid() const; | 102 bool IsValid() const; |
103 | 103 |
| 104 size_t EstimateMemoryUsage() const; |
| 105 |
104 private: | 106 private: |
105 friend class UniquePositionTest; | 107 friend class UniquePositionTest; |
106 | 108 |
107 // Returns a string X such that (X ++ |suffix|) < |str|. | 109 // Returns a string X such that (X ++ |suffix|) < |str|. |
108 // |str| must be a trailing substring of a valid ordinal. | 110 // |str| must be a trailing substring of a valid ordinal. |
109 // |suffix| must be a valid unique suffix. | 111 // |suffix| must be a valid unique suffix. |
110 static std::string FindSmallerWithSuffix(const std::string& str, | 112 static std::string FindSmallerWithSuffix(const std::string& str, |
111 const std::string& suffix); | 113 const std::string& suffix); |
112 // Returns a string X such that (X ++ |suffix|) > |str|. | 114 // Returns a string X such that (X ++ |suffix|) > |str|. |
113 // |str| must be a trailing substring of a valid ordinal. | 115 // |str| must be a trailing substring of a valid ordinal. |
(...skipping 22 matching lines...) Expand all Loading... |
136 | 138 |
137 // The position value after it has been run through the custom compression | 139 // The position value after it has been run through the custom compression |
138 // algorithm. See Compress() and Uncompress() functions above. | 140 // algorithm. See Compress() and Uncompress() functions above. |
139 std::string compressed_; | 141 std::string compressed_; |
140 bool is_valid_; | 142 bool is_valid_; |
141 }; | 143 }; |
142 | 144 |
143 } // namespace syncer | 145 } // namespace syncer |
144 | 146 |
145 #endif // COMPONENTS_SYNC_BASE_UNIQUE_POSITION_H_ | 147 #endif // COMPONENTS_SYNC_BASE_UNIQUE_POSITION_H_ |
OLD | NEW |