Chromium Code Reviews| 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 SYNC_SYNCABLE_SYNCABLE_COLUMNS_H_ | 5 #ifndef SYNC_SYNCABLE_SYNCABLE_COLUMNS_H_ |
| 6 #define SYNC_SYNCABLE_SYNCABLE_COLUMNS_H_ | 6 #define SYNC_SYNCABLE_SYNCABLE_COLUMNS_H_ |
| 7 | 7 |
| 8 #include "sync/syncable/entry_kernel.h" | |
| 9 #include "sync/syncable/syncable_changes_version.h" | 8 #include "sync/syncable/syncable_changes_version.h" |
| 10 | 9 |
| 11 namespace syncer { | 10 namespace syncer { |
| 12 namespace syncable { | 11 namespace syncable { |
| 13 | 12 |
| 13 enum { | |
|
stanisc
2015/08/07 18:24:04
This is an unnecessary change. I'd prefer to keep
Gang Wu
2015/08/07 20:50:57
Done.
| |
| 14 BEGIN_FIELDS = 0, | |
| 15 INT64_FIELDS_BEGIN = BEGIN_FIELDS | |
| 16 }; | |
| 17 | |
| 18 enum MetahandleField { | |
| 19 // Primary key into the table. Keep this as a handle to the meta entry | |
| 20 // across transactions. | |
| 21 META_HANDLE = INT64_FIELDS_BEGIN | |
| 22 }; | |
| 23 | |
| 24 enum BaseVersion { | |
| 25 // After initial upload, the version is controlled by the server, and is | |
| 26 // increased whenever the data or metadata changes on the server. | |
| 27 BASE_VERSION = META_HANDLE + 1, | |
| 28 }; | |
| 29 | |
| 30 enum Int64Field { | |
| 31 SERVER_VERSION = BASE_VERSION + 1, | |
| 32 LOCAL_EXTERNAL_ID, // ID of an item in the external local storage that this | |
| 33 // entry is associated with. (such as bookmarks.js) | |
| 34 TRANSACTION_VERSION, | |
| 35 INT64_FIELDS_END | |
| 36 }; | |
| 37 | |
| 38 enum { | |
| 39 INT64_FIELDS_COUNT = INT64_FIELDS_END - INT64_FIELDS_BEGIN, | |
| 40 TIME_FIELDS_BEGIN = INT64_FIELDS_END, | |
| 41 }; | |
| 42 | |
| 43 enum TimeField { | |
| 44 MTIME = TIME_FIELDS_BEGIN, | |
| 45 SERVER_MTIME, | |
| 46 CTIME, | |
| 47 SERVER_CTIME, | |
| 48 TIME_FIELDS_END, | |
| 49 }; | |
| 50 | |
| 51 enum { | |
| 52 TIME_FIELDS_COUNT = TIME_FIELDS_END - TIME_FIELDS_BEGIN, | |
| 53 ID_FIELDS_BEGIN = TIME_FIELDS_END, | |
| 54 }; | |
| 55 | |
| 56 enum IdField { | |
| 57 // Code in InitializeTables relies on ID being the first IdField value. | |
| 58 ID = ID_FIELDS_BEGIN, | |
| 59 PARENT_ID, | |
| 60 SERVER_PARENT_ID, | |
| 61 ID_FIELDS_END | |
| 62 }; | |
| 63 | |
| 64 enum { | |
| 65 ID_FIELDS_COUNT = ID_FIELDS_END - ID_FIELDS_BEGIN, | |
| 66 BIT_FIELDS_BEGIN = ID_FIELDS_END | |
| 67 }; | |
| 68 | |
| 69 enum IndexedBitField { | |
| 70 IS_UNSYNCED = BIT_FIELDS_BEGIN, | |
| 71 IS_UNAPPLIED_UPDATE, | |
| 72 INDEXED_BIT_FIELDS_END, | |
| 73 }; | |
| 74 | |
| 75 enum IsDelField { | |
| 76 IS_DEL = INDEXED_BIT_FIELDS_END, | |
| 77 }; | |
| 78 | |
| 79 enum BitField { | |
| 80 IS_DIR = IS_DEL + 1, | |
| 81 SERVER_IS_DIR, | |
| 82 SERVER_IS_DEL, | |
| 83 BIT_FIELDS_END | |
| 84 }; | |
| 85 | |
| 86 enum { | |
| 87 BIT_FIELDS_COUNT = BIT_FIELDS_END - BIT_FIELDS_BEGIN, | |
| 88 STRING_FIELDS_BEGIN = BIT_FIELDS_END | |
| 89 }; | |
| 90 | |
| 91 enum StringField { | |
| 92 // Name, will be truncated by server. Can be duplicated in a folder. | |
| 93 NON_UNIQUE_NAME = STRING_FIELDS_BEGIN, | |
| 94 // The server version of |NON_UNIQUE_NAME|. | |
| 95 SERVER_NON_UNIQUE_NAME, | |
| 96 | |
| 97 // A tag string which identifies this node as a particular top-level | |
| 98 // permanent object. The tag can be thought of as a unique key that | |
| 99 // identifies a singleton instance. | |
| 100 UNIQUE_SERVER_TAG, // Tagged by the server | |
| 101 UNIQUE_CLIENT_TAG, // Tagged by the client | |
| 102 UNIQUE_BOOKMARK_TAG, // Client tags for bookmark items | |
| 103 STRING_FIELDS_END, | |
| 104 }; | |
| 105 | |
| 106 enum { | |
| 107 STRING_FIELDS_COUNT = STRING_FIELDS_END - STRING_FIELDS_BEGIN, | |
| 108 PROTO_FIELDS_BEGIN = STRING_FIELDS_END | |
| 109 }; | |
| 110 | |
| 111 // From looking at the sqlite3 docs, it's not directly stated, but it | |
| 112 // seems the overhead for storing a NULL blob is very small. | |
| 113 enum ProtoField { | |
| 114 SPECIFICS = PROTO_FIELDS_BEGIN, | |
| 115 SERVER_SPECIFICS, | |
| 116 BASE_SERVER_SPECIFICS, | |
| 117 PROTO_FIELDS_END, | |
| 118 }; | |
| 119 | |
| 120 enum { | |
| 121 PROTO_FIELDS_COUNT = PROTO_FIELDS_END - PROTO_FIELDS_BEGIN, | |
| 122 UNIQUE_POSITION_FIELDS_BEGIN = PROTO_FIELDS_END | |
| 123 }; | |
| 124 | |
| 125 enum UniquePositionField { | |
| 126 SERVER_UNIQUE_POSITION = UNIQUE_POSITION_FIELDS_BEGIN, | |
| 127 UNIQUE_POSITION, | |
| 128 UNIQUE_POSITION_FIELDS_END | |
| 129 }; | |
| 130 | |
| 131 enum { | |
| 132 UNIQUE_POSITION_FIELDS_COUNT = | |
| 133 UNIQUE_POSITION_FIELDS_END - UNIQUE_POSITION_FIELDS_BEGIN, | |
| 134 ATTACHMENT_METADATA_FIELDS_BEGIN = UNIQUE_POSITION_FIELDS_END | |
| 135 }; | |
| 136 | |
| 137 enum AttachmentMetadataField { | |
| 138 ATTACHMENT_METADATA = ATTACHMENT_METADATA_FIELDS_BEGIN, | |
| 139 SERVER_ATTACHMENT_METADATA, | |
| 140 ATTACHMENT_METADATA_FIELDS_END | |
| 141 }; | |
| 142 | |
| 143 enum { | |
| 144 ATTACHMENT_METADATA_FIELDS_COUNT = | |
| 145 ATTACHMENT_METADATA_FIELDS_END - ATTACHMENT_METADATA_FIELDS_BEGIN, | |
| 146 FIELD_COUNT = ATTACHMENT_METADATA_FIELDS_END - BEGIN_FIELDS, | |
| 147 // Past this point we have temporaries, stored in memory only. | |
| 148 BEGIN_TEMPS = ATTACHMENT_METADATA_FIELDS_END, | |
| 149 BIT_TEMPS_BEGIN = BEGIN_TEMPS, | |
| 150 }; | |
| 151 | |
| 152 enum BitTemp { | |
| 153 // Whether a server commit operation was started and has not yet completed | |
| 154 // for this entity. | |
| 155 SYNCING = BIT_TEMPS_BEGIN, | |
| 156 // Whether a local change was made to an entity that had SYNCING set to true, | |
| 157 // and was therefore in the middle of a commit operation. | |
| 158 // Note: must only be set if SYNCING is true. | |
| 159 DIRTY_SYNC, | |
| 160 BIT_TEMPS_END, | |
| 161 }; | |
| 162 | |
| 163 enum { | |
| 164 BIT_TEMPS_COUNT = BIT_TEMPS_END - BIT_TEMPS_BEGIN | |
| 165 }; | |
| 166 | |
| 14 struct ColumnSpec { | 167 struct ColumnSpec { |
| 15 const char* name; | 168 const char* name; |
| 16 const char* spec; | 169 const char* spec; |
| 17 }; | 170 }; |
| 18 | 171 |
| 19 // Must be in exact same order as fields in entry_kernel.h. | 172 // Must be in exact same order as fields in entry_kernel.h. |
| 20 static const ColumnSpec g_metas_columns[] = { | 173 static const ColumnSpec g_metas_columns[] = { |
| 21 ////////////////////////////////////// | 174 ////////////////////////////////////// |
| 22 // int64s | 175 // int64s |
| 23 {"metahandle", "bigint primary key ON CONFLICT FAIL"}, | 176 {"metahandle", "bigint primary key ON CONFLICT FAIL"}, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 | 230 |
| 78 static inline const char* ColumnName(int field) { | 231 static inline const char* ColumnName(int field) { |
| 79 DCHECK(field < BEGIN_TEMPS); | 232 DCHECK(field < BEGIN_TEMPS); |
| 80 return g_metas_columns[field].name; | 233 return g_metas_columns[field].name; |
| 81 } | 234 } |
| 82 | 235 |
| 83 } // namespace syncable | 236 } // namespace syncable |
| 84 } // namespace syncer | 237 } // namespace syncer |
| 85 | 238 |
| 86 #endif // SYNC_SYNCABLE_SYNCABLE_COLUMNS_H_ | 239 #endif // SYNC_SYNCABLE_SYNCABLE_COLUMNS_H_ |
| OLD | NEW |