| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_SYNCABLE_SYNCABLE_ID_H_ | 5 #ifndef COMPONENTS_SYNC_SYNCABLE_SYNCABLE_ID_H_ |
| 6 #define COMPONENTS_SYNC_SYNCABLE_SYNCABLE_ID_H_ | 6 #define COMPONENTS_SYNC_SYNCABLE_SYNCABLE_ID_H_ |
| 7 | 7 |
| 8 #include <iosfwd> | 8 #include <iosfwd> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 inline bool operator<(const Id& that) const { return s_ < that.s_; } | 62 inline bool operator<(const Id& that) const { return s_ < that.s_; } |
| 63 inline bool operator>(const Id& that) const { return s_ > that.s_; } | 63 inline bool operator>(const Id& that) const { return s_ > that.s_; } |
| 64 | 64 |
| 65 const std::string& value() const { return s_; } | 65 const std::string& value() const { return s_; } |
| 66 | 66 |
| 67 // Return the next highest ID in the lexicographic ordering. This is | 67 // Return the next highest ID in the lexicographic ordering. This is |
| 68 // useful for computing upper bounds on std::sets that are ordered | 68 // useful for computing upper bounds on std::sets that are ordered |
| 69 // by operator<. | 69 // by operator<. |
| 70 Id GetLexicographicSuccessor() const; | 70 Id GetLexicographicSuccessor() const; |
| 71 | 71 |
| 72 // Dumps the ID as a value and returns it. Transfers ownership of | 72 // Dumps the ID as a value and returns it. |
| 73 // the StringValue to the caller. | 73 std::unique_ptr<base::Value> ToValue() const; |
| 74 base::Value* ToValue() const; | |
| 75 | 74 |
| 76 // Three functions are used to work with our proto buffers. | 75 // Three functions are used to work with our proto buffers. |
| 77 std::string GetServerId() const; | 76 std::string GetServerId() const; |
| 78 static Id CreateFromServerId(const std::string& server_id); | 77 static Id CreateFromServerId(const std::string& server_id); |
| 79 // This should only be used if you get back a reference to a local | 78 // This should only be used if you get back a reference to a local |
| 80 // id from the server. Returns a client only opaque id. | 79 // id from the server. Returns a client only opaque id. |
| 81 static Id CreateFromClientString(const std::string& local_id); | 80 static Id CreateFromClientString(const std::string& local_id); |
| 82 | 81 |
| 83 // This method returns an ID that will compare less than any valid ID. | 82 // This method returns an ID that will compare less than any valid ID. |
| 84 // The returned ID is not a valid ID itself. This is useful for | 83 // The returned ID is not a valid ID itself. This is useful for |
| (...skipping 14 matching lines...) Expand all Loading... |
| 99 }; | 98 }; |
| 100 | 99 |
| 101 inline size_t EstimateMemoryUsage(const Id& id) { | 100 inline size_t EstimateMemoryUsage(const Id& id) { |
| 102 return base::trace_event::EstimateMemoryUsage(id.value()); | 101 return base::trace_event::EstimateMemoryUsage(id.value()); |
| 103 } | 102 } |
| 104 | 103 |
| 105 } // namespace syncable | 104 } // namespace syncable |
| 106 } // namespace syncer | 105 } // namespace syncer |
| 107 | 106 |
| 108 #endif // COMPONENTS_SYNC_SYNCABLE_SYNCABLE_ID_H_ | 107 #endif // COMPONENTS_SYNC_SYNCABLE_SYNCABLE_ID_H_ |
| OLD | NEW |