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 // Returns memory usage estimate. |
| 105 size_t EstimateMemoryUsage() const; |
| 106 |
104 private: | 107 private: |
105 friend class UniquePositionTest; | 108 friend class UniquePositionTest; |
106 | 109 |
107 // Returns a string X such that (X ++ |suffix|) < |str|. | 110 // Returns a string X such that (X ++ |suffix|) < |str|. |
108 // |str| must be a trailing substring of a valid ordinal. | 111 // |str| must be a trailing substring of a valid ordinal. |
109 // |suffix| must be a valid unique suffix. | 112 // |suffix| must be a valid unique suffix. |
110 static std::string FindSmallerWithSuffix(const std::string& str, | 113 static std::string FindSmallerWithSuffix(const std::string& str, |
111 const std::string& suffix); | 114 const std::string& suffix); |
112 // Returns a string X such that (X ++ |suffix|) > |str|. | 115 // Returns a string X such that (X ++ |suffix|) > |str|. |
113 // |str| must be a trailing substring of a valid ordinal. | 116 // |str| must be a trailing substring of a valid ordinal. |
(...skipping 22 matching lines...) Expand all Loading... |
136 | 139 |
137 // The position value after it has been run through the custom compression | 140 // The position value after it has been run through the custom compression |
138 // algorithm. See Compress() and Uncompress() functions above. | 141 // algorithm. See Compress() and Uncompress() functions above. |
139 std::string compressed_; | 142 std::string compressed_; |
140 bool is_valid_; | 143 bool is_valid_; |
141 }; | 144 }; |
142 | 145 |
143 } // namespace syncer | 146 } // namespace syncer |
144 | 147 |
145 #endif // COMPONENTS_SYNC_BASE_UNIQUE_POSITION_H_ | 148 #endif // COMPONENTS_SYNC_BASE_UNIQUE_POSITION_H_ |
OLD | NEW |