Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: sync/syncable/syncable_enum_conversions.cc

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Keep this file in sync with entry_kernel.h.
6
7 #include "sync/syncable/syncable_enum_conversions.h"
8
9 #include "base/logging.h"
10
11 namespace syncer {
12 namespace syncable {
13
14 // We can't tokenize expected_min/expected_max since it can be a
15 // general expression.
16 #define ASSERT_ENUM_BOUNDS(enum_min, enum_max, expected_min, expected_max) \
17 static_assert(static_cast<int>(enum_min) == \
18 static_cast<int>(expected_min), \
19 #enum_min " not " #expected_min); \
20 static_assert(static_cast<int>(enum_max) == \
21 static_cast<int>(expected_max), \
22 #enum_max " not " #expected_max);
23
24 #define ENUM_CASE(enum_value) case enum_value: return #enum_value
25
26 const char* GetMetahandleFieldString(MetahandleField metahandle_field) {
27 ASSERT_ENUM_BOUNDS(META_HANDLE, META_HANDLE,
28 INT64_FIELDS_BEGIN, BASE_VERSION - 1);
29 switch (metahandle_field) {
30 ENUM_CASE(META_HANDLE);
31 }
32 NOTREACHED();
33 return "";
34 }
35
36 const char* GetBaseVersionString(BaseVersion base_version) {
37 ASSERT_ENUM_BOUNDS(BASE_VERSION, BASE_VERSION,
38 META_HANDLE + 1, SERVER_VERSION - 1);
39 switch (base_version) {
40 ENUM_CASE(BASE_VERSION);
41 }
42 NOTREACHED();
43 return "";
44 }
45
46 const char* GetInt64FieldString(Int64Field int64_field) {
47 ASSERT_ENUM_BOUNDS(SERVER_VERSION, TRANSACTION_VERSION,
48 BASE_VERSION + 1, INT64_FIELDS_END - 1);
49 switch (int64_field) {
50 ENUM_CASE(SERVER_VERSION);
51 ENUM_CASE(LOCAL_EXTERNAL_ID);
52 ENUM_CASE(TRANSACTION_VERSION);
53 case INT64_FIELDS_END: break;
54 }
55 NOTREACHED();
56 return "";
57 }
58
59 const char* GetTimeFieldString(TimeField time_field) {
60 ASSERT_ENUM_BOUNDS(MTIME, SERVER_CTIME,
61 TIME_FIELDS_BEGIN, TIME_FIELDS_END - 1);
62 switch (time_field) {
63 ENUM_CASE(MTIME);
64 ENUM_CASE(SERVER_MTIME);
65 ENUM_CASE(CTIME);
66 ENUM_CASE(SERVER_CTIME);
67 case TIME_FIELDS_END: break;
68 }
69 NOTREACHED();
70 return "";
71 }
72
73 const char* GetIdFieldString(IdField id_field) {
74 ASSERT_ENUM_BOUNDS(ID, SERVER_PARENT_ID,
75 ID_FIELDS_BEGIN, ID_FIELDS_END - 1);
76 switch (id_field) {
77 ENUM_CASE(ID);
78 ENUM_CASE(PARENT_ID);
79 ENUM_CASE(SERVER_PARENT_ID);
80 case ID_FIELDS_END: break;
81 }
82 NOTREACHED();
83 return "";
84 }
85
86 const char* GetIndexedBitFieldString(IndexedBitField indexed_bit_field) {
87 ASSERT_ENUM_BOUNDS(IS_UNSYNCED, IS_UNAPPLIED_UPDATE,
88 BIT_FIELDS_BEGIN, INDEXED_BIT_FIELDS_END - 1);
89 switch (indexed_bit_field) {
90 ENUM_CASE(IS_UNSYNCED);
91 ENUM_CASE(IS_UNAPPLIED_UPDATE);
92 case INDEXED_BIT_FIELDS_END: break;
93 }
94 NOTREACHED();
95 return "";
96 }
97
98 const char* GetIsDelFieldString(IsDelField is_del_field) {
99 ASSERT_ENUM_BOUNDS(IS_DEL, IS_DEL,
100 INDEXED_BIT_FIELDS_END, IS_DIR - 1);
101 switch (is_del_field) {
102 ENUM_CASE(IS_DEL);
103 }
104 NOTREACHED();
105 return "";
106 }
107
108 const char* GetBitFieldString(BitField bit_field) {
109 ASSERT_ENUM_BOUNDS(IS_DIR, SERVER_IS_DEL,
110 IS_DEL + 1, BIT_FIELDS_END - 1);
111 switch (bit_field) {
112 ENUM_CASE(IS_DIR);
113 ENUM_CASE(SERVER_IS_DIR);
114 ENUM_CASE(SERVER_IS_DEL);
115 case BIT_FIELDS_END: break;
116 }
117 NOTREACHED();
118 return "";
119 }
120
121 const char* GetStringFieldString(StringField string_field) {
122 ASSERT_ENUM_BOUNDS(NON_UNIQUE_NAME, UNIQUE_BOOKMARK_TAG,
123 STRING_FIELDS_BEGIN, STRING_FIELDS_END - 1);
124 switch (string_field) {
125 ENUM_CASE(NON_UNIQUE_NAME);
126 ENUM_CASE(SERVER_NON_UNIQUE_NAME);
127 ENUM_CASE(UNIQUE_SERVER_TAG);
128 ENUM_CASE(UNIQUE_CLIENT_TAG);
129 ENUM_CASE(UNIQUE_BOOKMARK_TAG);
130 case STRING_FIELDS_END: break;
131 }
132 NOTREACHED();
133 return "";
134 }
135
136 const char* GetProtoFieldString(ProtoField proto_field) {
137 ASSERT_ENUM_BOUNDS(SPECIFICS, BASE_SERVER_SPECIFICS,
138 PROTO_FIELDS_BEGIN, PROTO_FIELDS_END - 1);
139 switch (proto_field) {
140 ENUM_CASE(SPECIFICS);
141 ENUM_CASE(SERVER_SPECIFICS);
142 ENUM_CASE(BASE_SERVER_SPECIFICS);
143 case PROTO_FIELDS_END: break;
144 }
145 NOTREACHED();
146 return "";
147 }
148
149 const char* GetUniquePositionFieldString(UniquePositionField position_field) {
150 ASSERT_ENUM_BOUNDS(SERVER_UNIQUE_POSITION, UNIQUE_POSITION,
151 UNIQUE_POSITION_FIELDS_BEGIN,
152 UNIQUE_POSITION_FIELDS_END - 1);
153 switch (position_field) {
154 ENUM_CASE(SERVER_UNIQUE_POSITION);
155 ENUM_CASE(UNIQUE_POSITION);
156 case UNIQUE_POSITION_FIELDS_END: break;
157 }
158 NOTREACHED();
159 return "";
160 }
161
162 const char* GetAttachmentMetadataFieldString(
163 AttachmentMetadataField attachment_metadata_field) {
164 ASSERT_ENUM_BOUNDS(ATTACHMENT_METADATA,
165 SERVER_ATTACHMENT_METADATA,
166 ATTACHMENT_METADATA_FIELDS_BEGIN,
167 ATTACHMENT_METADATA_FIELDS_END - 1);
168 switch (attachment_metadata_field) {
169 ENUM_CASE(ATTACHMENT_METADATA);
170 ENUM_CASE(SERVER_ATTACHMENT_METADATA);
171 case ATTACHMENT_METADATA_FIELDS_END: break;
172 }
173 NOTREACHED();
174 return "";
175 }
176
177 const char* GetBitTempString(BitTemp bit_temp) {
178 ASSERT_ENUM_BOUNDS(SYNCING, DIRTY_SYNC,
179 BIT_TEMPS_BEGIN, BIT_TEMPS_END - 1);
180 switch (bit_temp) {
181 ENUM_CASE(SYNCING);
182 ENUM_CASE(DIRTY_SYNC);
183 case BIT_TEMPS_END: break;
184 }
185 NOTREACHED();
186 return "";
187 }
188
189 #undef ENUM_CASE
190 #undef ASSERT_ENUM_BOUNDS
191
192 } // namespace syncable
193 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/syncable/syncable_enum_conversions.h ('k') | sync/syncable/syncable_enum_conversions_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698