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> |
11 #include <sstream> | 11 #include <sstream> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
15 #include "base/trace_event/memory_usage_estimator.h" | 15 #include "base/trace_event/memory_usage_estimator.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class Value; | 18 class Value; |
19 using StringValue = Value; | |
20 } // namespace base | 19 } // namespace base |
21 | 20 |
22 namespace sql { | 21 namespace sql { |
23 class Statement; | 22 class Statement; |
24 } // namespace sql | 23 } // namespace sql |
25 | 24 |
26 namespace syncer { | 25 namespace syncer { |
27 namespace syncable { | 26 namespace syncable { |
28 | 27 |
29 class Id; | 28 class Id; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 64 |
66 const std::string& value() const { return s_; } | 65 const std::string& value() const { return s_; } |
67 | 66 |
68 // Return the next highest ID in the lexicographic ordering. This is | 67 // Return the next highest ID in the lexicographic ordering. This is |
69 // useful for computing upper bounds on std::sets that are ordered | 68 // useful for computing upper bounds on std::sets that are ordered |
70 // by operator<. | 69 // by operator<. |
71 Id GetLexicographicSuccessor() const; | 70 Id GetLexicographicSuccessor() const; |
72 | 71 |
73 // Dumps the ID as a value and returns it. Transfers ownership of | 72 // Dumps the ID as a value and returns it. Transfers ownership of |
74 // the StringValue to the caller. | 73 // the StringValue to the caller. |
75 base::StringValue* ToValue() const; | 74 base::Value* ToValue() const; |
76 | 75 |
77 // Three functions are used to work with our proto buffers. | 76 // Three functions are used to work with our proto buffers. |
78 std::string GetServerId() const; | 77 std::string GetServerId() const; |
79 static Id CreateFromServerId(const std::string& server_id); | 78 static Id CreateFromServerId(const std::string& server_id); |
80 // This should only be used if you get back a reference to a local | 79 // This should only be used if you get back a reference to a local |
81 // id from the server. Returns a client only opaque id. | 80 // id from the server. Returns a client only opaque id. |
82 static Id CreateFromClientString(const std::string& local_id); | 81 static Id CreateFromClientString(const std::string& local_id); |
83 | 82 |
84 // This method returns an ID that will compare less than any valid ID. | 83 // This method returns an ID that will compare less than any valid ID. |
85 // The returned ID is not a valid ID itself. This is useful for | 84 // The returned ID is not a valid ID itself. This is useful for |
(...skipping 14 matching lines...) Expand all Loading... |
100 }; | 99 }; |
101 | 100 |
102 inline size_t EstimateMemoryUsage(const Id& id) { | 101 inline size_t EstimateMemoryUsage(const Id& id) { |
103 return base::trace_event::EstimateMemoryUsage(id.value()); | 102 return base::trace_event::EstimateMemoryUsage(id.value()); |
104 } | 103 } |
105 | 104 |
106 } // namespace syncable | 105 } // namespace syncable |
107 } // namespace syncer | 106 } // namespace syncer |
108 | 107 |
109 #endif // COMPONENTS_SYNC_SYNCABLE_SYNCABLE_ID_H_ | 108 #endif // COMPONENTS_SYNC_SYNCABLE_SYNCABLE_ID_H_ |
OLD | NEW |