OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_ID_H_ | 5 #ifndef CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_ID_H_ |
6 #define CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_ID_H_ | 6 #define CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_ID_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <iosfwd> | 9 #include <iosfwd> |
10 #include <limits> | 10 #include <limits> |
11 #include <sstream> | 11 #include <sstream> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/hash_tables.h" | 14 #include "base/hash_tables.h" |
15 | 15 |
| 16 namespace base { |
16 class StringValue; | 17 class StringValue; |
| 18 } |
17 | 19 |
18 namespace syncable { | 20 namespace syncable { |
19 struct EntryKernel; | 21 struct EntryKernel; |
20 class Id; | 22 class Id; |
21 } | 23 } |
22 | 24 |
23 class MockConnectionManager; | 25 class MockConnectionManager; |
24 class SQLStatement; | 26 class SQLStatement; |
25 | 27 |
26 namespace syncable { | 28 namespace syncable { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 inline bool operator > (const Id& that) const { | 90 inline bool operator > (const Id& that) const { |
89 return s_ > that.s_; | 91 return s_ > that.s_; |
90 } | 92 } |
91 // Return the next highest ID in the lexicographic ordering. This is | 93 // Return the next highest ID in the lexicographic ordering. This is |
92 // useful for computing upper bounds on std::sets that are ordered | 94 // useful for computing upper bounds on std::sets that are ordered |
93 // by operator<. | 95 // by operator<. |
94 Id GetLexicographicSuccessor() const; | 96 Id GetLexicographicSuccessor() const; |
95 | 97 |
96 // Dumps the ID as a value and returns it. Transfers ownership of | 98 // Dumps the ID as a value and returns it. Transfers ownership of |
97 // the StringValue to the caller. | 99 // the StringValue to the caller. |
98 StringValue* ToValue() const; | 100 base::StringValue* ToValue() const; |
99 | 101 |
100 // Three functions are used to work with our proto buffers. | 102 // Three functions are used to work with our proto buffers. |
101 std::string GetServerId() const; | 103 std::string GetServerId() const; |
102 static Id CreateFromServerId(const std::string& server_id); | 104 static Id CreateFromServerId(const std::string& server_id); |
103 // This should only be used if you get back a reference to a local | 105 // This should only be used if you get back a reference to a local |
104 // id from the server. Returns a client only opaque id. | 106 // id from the server. Returns a client only opaque id. |
105 static Id CreateFromClientString(const std::string& local_id); | 107 static Id CreateFromClientString(const std::string& local_id); |
106 | 108 |
107 // This method returns an ID that will compare less than any valid ID. | 109 // This method returns an ID that will compare less than any valid ID. |
108 // The returned ID is not a valid ID itself. This is useful for | 110 // The returned ID is not a valid ID itself. This is useful for |
109 // computing lower bounds on std::sets that are ordered by operator<. | 111 // computing lower bounds on std::sets that are ordered by operator<. |
110 static Id GetLeastIdForLexicographicComparison(); | 112 static Id GetLeastIdForLexicographicComparison(); |
111 | 113 |
112 private: | 114 private: |
113 std::string s_; | 115 std::string s_; |
114 }; | 116 }; |
115 | 117 |
116 extern const Id kNullId; | 118 extern const Id kNullId; |
117 | 119 |
118 } // namespace syncable | 120 } // namespace syncable |
119 | 121 |
120 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_ID_H_ | 122 #endif // CHROME_BROWSER_SYNC_SYNCABLE_SYNCABLE_ID_H_ |
OLD | NEW |