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

Side by Side Diff: sync/protocol/proto_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 the .proto files in this directory.
6
7 #include "sync/protocol/proto_enum_conversions.h"
8
9 #include "base/logging.h"
10
11 namespace syncer {
12
13 #define ASSERT_ENUM_BOUNDS(enum_parent, enum_type, enum_min, enum_max) \
14 static_assert(enum_parent::enum_type##_MIN == enum_parent::enum_min, \
15 #enum_type "_MIN should be " #enum_min); \
16 static_assert(enum_parent::enum_type##_MAX == enum_parent::enum_max, \
17 #enum_type "_MAX should be " #enum_max);
18
19 #define ENUM_CASE(enum_parent, enum_value) \
20 case enum_parent::enum_value: return #enum_value
21
22 const char* GetAppListItemTypeString(
23 sync_pb::AppListSpecifics::AppListItemType item_type) {
24 ASSERT_ENUM_BOUNDS(sync_pb::AppListSpecifics, AppListItemType,
25 TYPE_APP, TYPE_URL);
26 switch (item_type) {
27 ENUM_CASE(sync_pb::AppListSpecifics, TYPE_APP);
28 ENUM_CASE(sync_pb::AppListSpecifics, TYPE_REMOVE_DEFAULT_APP);
29 ENUM_CASE(sync_pb::AppListSpecifics, TYPE_FOLDER);
30 ENUM_CASE(sync_pb::AppListSpecifics, TYPE_URL);
31 }
32 NOTREACHED();
33 return "";
34 }
35
36 const char* GetBrowserTypeString(
37 sync_pb::SessionWindow::BrowserType browser_type) {
38 ASSERT_ENUM_BOUNDS(sync_pb::SessionWindow, BrowserType,
39 TYPE_TABBED, TYPE_POPUP);
40 switch (browser_type) {
41 ENUM_CASE(sync_pb::SessionWindow, TYPE_TABBED);
42 ENUM_CASE(sync_pb::SessionWindow, TYPE_POPUP);
43 }
44 NOTREACHED();
45 return "";
46 }
47
48 const char* GetPageTransitionString(
49 sync_pb::SyncEnums::PageTransition page_transition) {
50 ASSERT_ENUM_BOUNDS(sync_pb::SyncEnums, PageTransition,
51 LINK, KEYWORD_GENERATED);
52 switch (page_transition) {
53 ENUM_CASE(sync_pb::SyncEnums, LINK);
54 ENUM_CASE(sync_pb::SyncEnums, TYPED);
55 ENUM_CASE(sync_pb::SyncEnums, AUTO_BOOKMARK);
56 ENUM_CASE(sync_pb::SyncEnums, AUTO_SUBFRAME);
57 ENUM_CASE(sync_pb::SyncEnums, MANUAL_SUBFRAME);
58 ENUM_CASE(sync_pb::SyncEnums, GENERATED);
59 ENUM_CASE(sync_pb::SyncEnums, AUTO_TOPLEVEL);
60 ENUM_CASE(sync_pb::SyncEnums, FORM_SUBMIT);
61 ENUM_CASE(sync_pb::SyncEnums, RELOAD);
62 ENUM_CASE(sync_pb::SyncEnums, KEYWORD);
63 ENUM_CASE(sync_pb::SyncEnums, KEYWORD_GENERATED);
64 }
65 NOTREACHED();
66 return "";
67 }
68
69 const char* GetPageTransitionRedirectTypeString(
70 sync_pb::SyncEnums::PageTransitionRedirectType
71 page_transition_qualifier) {
72 ASSERT_ENUM_BOUNDS(sync_pb::SyncEnums, PageTransitionRedirectType,
73 CLIENT_REDIRECT, SERVER_REDIRECT);
74 switch (page_transition_qualifier) {
75 ENUM_CASE(sync_pb::SyncEnums, CLIENT_REDIRECT);
76 ENUM_CASE(sync_pb::SyncEnums, SERVER_REDIRECT);
77 }
78 NOTREACHED();
79 return "";
80 }
81
82 const char* GetWifiCredentialSecurityClassString(
83 sync_pb::WifiCredentialSpecifics::SecurityClass security_class) {
84 ASSERT_ENUM_BOUNDS(sync_pb::WifiCredentialSpecifics, SecurityClass,
85 SECURITY_CLASS_INVALID, SECURITY_CLASS_PSK);
86 switch (security_class) {
87 ENUM_CASE(sync_pb::WifiCredentialSpecifics, SECURITY_CLASS_INVALID);
88 ENUM_CASE(sync_pb::WifiCredentialSpecifics, SECURITY_CLASS_NONE);
89 ENUM_CASE(sync_pb::WifiCredentialSpecifics, SECURITY_CLASS_WEP);
90 ENUM_CASE(sync_pb::WifiCredentialSpecifics, SECURITY_CLASS_PSK);
91 }
92 NOTREACHED();
93 return "";
94 }
95 const char* GetUpdatesSourceString(
96 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source) {
97 ASSERT_ENUM_BOUNDS(sync_pb::GetUpdatesCallerInfo, GetUpdatesSource,
98 UNKNOWN, PROGRAMMATIC);
99 switch (updates_source) {
100 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, UNKNOWN);
101 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, FIRST_UPDATE);
102 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, LOCAL);
103 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, NOTIFICATION);
104 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, PERIODIC);
105 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, SYNC_CYCLE_CONTINUATION);
106 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, NEWLY_SUPPORTED_DATATYPE);
107 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, MIGRATION);
108 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, NEW_CLIENT);
109 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, RECONFIGURATION);
110 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, DATATYPE_REFRESH);
111 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, RETRY);
112 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, PROGRAMMATIC);
113 }
114 NOTREACHED();
115 return "";
116 }
117
118 const char* GetUpdatesOriginString(
119 sync_pb::SyncEnums::GetUpdatesOrigin origin) {
120 ASSERT_ENUM_BOUNDS(sync_pb::SyncEnums, GetUpdatesOrigin,
121 UNKNOWN_ORIGIN, PROGRAMMATIC);
122 switch (origin) {
123 ENUM_CASE(sync_pb::SyncEnums, UNKNOWN_ORIGIN);
124 ENUM_CASE(sync_pb::SyncEnums, PERIODIC);
125 ENUM_CASE(sync_pb::SyncEnums, NEWLY_SUPPORTED_DATATYPE);
126 ENUM_CASE(sync_pb::SyncEnums, MIGRATION);
127 ENUM_CASE(sync_pb::SyncEnums, NEW_CLIENT);
128 ENUM_CASE(sync_pb::SyncEnums, RECONFIGURATION);
129 ENUM_CASE(sync_pb::SyncEnums, GU_TRIGGER);
130 ENUM_CASE(sync_pb::SyncEnums, RETRY);
131 ENUM_CASE(sync_pb::SyncEnums, PROGRAMMATIC);
132 }
133 NOTREACHED();
134 return "";
135 }
136
137 const char* GetResponseTypeString(
138 sync_pb::CommitResponse::ResponseType response_type) {
139 ASSERT_ENUM_BOUNDS(sync_pb::CommitResponse, ResponseType, SUCCESS,
140 TRANSIENT_ERROR);
141 switch (response_type) {
142 ENUM_CASE(sync_pb::CommitResponse, SUCCESS);
143 ENUM_CASE(sync_pb::CommitResponse, CONFLICT);
144 ENUM_CASE(sync_pb::CommitResponse, RETRY);
145 ENUM_CASE(sync_pb::CommitResponse, INVALID_MESSAGE);
146 ENUM_CASE(sync_pb::CommitResponse, OVER_QUOTA);
147 ENUM_CASE(sync_pb::CommitResponse, TRANSIENT_ERROR);
148 }
149 NOTREACHED();
150 return "";
151 }
152
153 const char* GetErrorTypeString(sync_pb::SyncEnums::ErrorType error_type) {
154 ASSERT_ENUM_BOUNDS(sync_pb::SyncEnums, ErrorType, SUCCESS, UNKNOWN);
155 switch (error_type) {
156 ENUM_CASE(sync_pb::SyncEnums, SUCCESS);
157 ENUM_CASE(sync_pb::SyncEnums, DEPRECATED_ACCESS_DENIED);
158 ENUM_CASE(sync_pb::SyncEnums, NOT_MY_BIRTHDAY);
159 ENUM_CASE(sync_pb::SyncEnums, THROTTLED);
160 ENUM_CASE(sync_pb::SyncEnums, DEPRECATED_AUTH_EXPIRED);
161 ENUM_CASE(sync_pb::SyncEnums, DEPRECATED_USER_NOT_ACTIVATED);
162 ENUM_CASE(sync_pb::SyncEnums, DEPRECATED_AUTH_INVALID);
163 ENUM_CASE(sync_pb::SyncEnums, CLEAR_PENDING);
164 ENUM_CASE(sync_pb::SyncEnums, TRANSIENT_ERROR);
165 ENUM_CASE(sync_pb::SyncEnums, MIGRATION_DONE);
166 ENUM_CASE(sync_pb::SyncEnums, DISABLED_BY_ADMIN);
167 ENUM_CASE(sync_pb::SyncEnums, DEPRECATED_USER_ROLLBACK);
168 ENUM_CASE(sync_pb::SyncEnums, PARTIAL_FAILURE);
169 ENUM_CASE(sync_pb::SyncEnums, CLIENT_DATA_OBSOLETE);
170 ENUM_CASE(sync_pb::SyncEnums, UNKNOWN);
171 }
172 NOTREACHED();
173 return "";
174 }
175
176 const char* GetActionString(sync_pb::SyncEnums::Action action) {
177 ASSERT_ENUM_BOUNDS(sync_pb::SyncEnums, Action,
178 UPGRADE_CLIENT, UNKNOWN_ACTION);
179 switch (action) {
180 ENUM_CASE(sync_pb::SyncEnums, UPGRADE_CLIENT);
181 ENUM_CASE(sync_pb::SyncEnums, CLEAR_USER_DATA_AND_RESYNC);
182 ENUM_CASE(sync_pb::SyncEnums, ENABLE_SYNC_ON_ACCOUNT);
183 ENUM_CASE(sync_pb::SyncEnums, STOP_AND_RESTART_SYNC);
184 ENUM_CASE(sync_pb::SyncEnums, DISABLE_SYNC_ON_CLIENT);
185 ENUM_CASE(sync_pb::SyncEnums, UNKNOWN_ACTION);
186 }
187 NOTREACHED();
188 return "";
189 }
190
191 const char* GetLaunchTypeString(sync_pb::AppSpecifics::LaunchType launch_type) {
192 ASSERT_ENUM_BOUNDS(sync_pb::AppSpecifics, LaunchType, PINNED, WINDOW);
193 switch (launch_type) {
194 ENUM_CASE(sync_pb::AppSpecifics, PINNED);
195 ENUM_CASE(sync_pb::AppSpecifics, REGULAR);
196 ENUM_CASE(sync_pb::AppSpecifics, FULLSCREEN);
197 ENUM_CASE(sync_pb::AppSpecifics, WINDOW);
198 }
199 NOTREACHED();
200 return "";
201 }
202
203 const char* GetWalletInfoTypeString(
204 sync_pb::AutofillWalletSpecifics::WalletInfoType wallet_info_type) {
205 ASSERT_ENUM_BOUNDS(sync_pb::AutofillWalletSpecifics, WalletInfoType,
206 UNKNOWN, POSTAL_ADDRESS);
207 switch (wallet_info_type) {
208 ENUM_CASE(sync_pb::AutofillWalletSpecifics, UNKNOWN);
209 ENUM_CASE(sync_pb::AutofillWalletSpecifics, MASKED_CREDIT_CARD);
210 ENUM_CASE(sync_pb::AutofillWalletSpecifics, POSTAL_ADDRESS);
211 }
212 NOTREACHED();
213 return "";
214 }
215
216 const char* GetWalletMetadataTypeString(
217 sync_pb::WalletMetadataSpecifics::Type wallet_metadata_type) {
218 ASSERT_ENUM_BOUNDS(sync_pb::WalletMetadataSpecifics, Type, UNKNOWN, ADDRESS);
219 switch (wallet_metadata_type) {
220 ENUM_CASE(sync_pb::WalletMetadataSpecifics, UNKNOWN);
221 ENUM_CASE(sync_pb::WalletMetadataSpecifics, CARD);
222 ENUM_CASE(sync_pb::WalletMetadataSpecifics, ADDRESS);
223 }
224 NOTREACHED();
225 return "";
226 }
227
228 const char* GetWalletCardStatusString(
229 sync_pb::WalletMaskedCreditCard::WalletCardStatus wallet_card_status) {
230 switch (wallet_card_status) {
231 ENUM_CASE(sync_pb::WalletMaskedCreditCard, VALID);
232 ENUM_CASE(sync_pb::WalletMaskedCreditCard, EXPIRED);
233 }
234 NOTREACHED();
235 return "";
236 }
237
238 const char* GetWalletCardTypeString(
239 sync_pb::WalletMaskedCreditCard::WalletCardType wallet_card_type) {
240 switch (wallet_card_type) {
241 ENUM_CASE(sync_pb::WalletMaskedCreditCard, UNKNOWN);
242 ENUM_CASE(sync_pb::WalletMaskedCreditCard, AMEX);
243 ENUM_CASE(sync_pb::WalletMaskedCreditCard, DISCOVER);
244 ENUM_CASE(sync_pb::WalletMaskedCreditCard, JCB);
245 ENUM_CASE(sync_pb::WalletMaskedCreditCard, MAESTRO);
246 ENUM_CASE(sync_pb::WalletMaskedCreditCard, MASTER_CARD);
247 ENUM_CASE(sync_pb::WalletMaskedCreditCard, SOLO);
248 ENUM_CASE(sync_pb::WalletMaskedCreditCard, SWITCH);
249 ENUM_CASE(sync_pb::WalletMaskedCreditCard, VISA);
250 }
251 NOTREACHED();
252 return "";
253 }
254
255 const char* GetDeviceTypeString(
256 sync_pb::SyncEnums::DeviceType device_type) {
257 ASSERT_ENUM_BOUNDS(sync_pb::SyncEnums, DeviceType, TYPE_WIN, TYPE_TABLET);
258 switch (device_type) {
259 ENUM_CASE(sync_pb::SyncEnums, TYPE_WIN);
260 ENUM_CASE(sync_pb::SyncEnums, TYPE_MAC);
261 ENUM_CASE(sync_pb::SyncEnums, TYPE_LINUX);
262 ENUM_CASE(sync_pb::SyncEnums, TYPE_CROS);
263 ENUM_CASE(sync_pb::SyncEnums, TYPE_OTHER);
264 ENUM_CASE(sync_pb::SyncEnums, TYPE_PHONE);
265 ENUM_CASE(sync_pb::SyncEnums, TYPE_TABLET);
266 }
267 NOTREACHED();
268 return "";
269 }
270
271 const char* GetFaviconTypeString(
272 sync_pb::SessionTab::FaviconType favicon_type) {
273 ASSERT_ENUM_BOUNDS(sync_pb::SessionTab, FaviconType, TYPE_WEB_FAVICON,
274 TYPE_WEB_FAVICON);
275 switch (favicon_type) {
276 ENUM_CASE(sync_pb::SessionTab, TYPE_WEB_FAVICON);
277 }
278 NOTREACHED();
279 return "";
280 }
281
282 const char* PassphraseTypeString(
283 sync_pb::NigoriSpecifics::PassphraseType type) {
284 ASSERT_ENUM_BOUNDS(sync_pb::NigoriSpecifics, PassphraseType,
285 IMPLICIT_PASSPHRASE, CUSTOM_PASSPHRASE);
286 switch (type) {
287 ENUM_CASE(sync_pb::NigoriSpecifics, IMPLICIT_PASSPHRASE);
288 ENUM_CASE(sync_pb::NigoriSpecifics, KEYSTORE_PASSPHRASE);
289 ENUM_CASE(sync_pb::NigoriSpecifics, FROZEN_IMPLICIT_PASSPHRASE);
290 ENUM_CASE(sync_pb::NigoriSpecifics, CUSTOM_PASSPHRASE);
291 }
292 NOTREACHED();
293 return "";
294 }
295
296 const char* SingletonDebugEventTypeString(
297 sync_pb::SyncEnums::SingletonDebugEventType type) {
298 ASSERT_ENUM_BOUNDS(sync_pb::SyncEnums, SingletonDebugEventType,
299 CONNECTION_STATUS_CHANGE, BOOTSTRAP_TOKEN_UPDATED);
300 switch (type) {
301 ENUM_CASE(sync_pb::SyncEnums, CONNECTION_STATUS_CHANGE);
302 ENUM_CASE(sync_pb::SyncEnums, UPDATED_TOKEN);
303 ENUM_CASE(sync_pb::SyncEnums, PASSPHRASE_REQUIRED);
304 ENUM_CASE(sync_pb::SyncEnums, PASSPHRASE_ACCEPTED);
305 ENUM_CASE(sync_pb::SyncEnums, INITIALIZATION_COMPLETE);
306 ENUM_CASE(sync_pb::SyncEnums, STOP_SYNCING_PERMANENTLY);
307 ENUM_CASE(sync_pb::SyncEnums, ENCRYPTION_COMPLETE);
308 ENUM_CASE(sync_pb::SyncEnums, ACTIONABLE_ERROR);
309 ENUM_CASE(sync_pb::SyncEnums, ENCRYPTED_TYPES_CHANGED);
310 ENUM_CASE(sync_pb::SyncEnums, PASSPHRASE_TYPE_CHANGED);
311 ENUM_CASE(sync_pb::SyncEnums, KEYSTORE_TOKEN_UPDATED);
312 ENUM_CASE(sync_pb::SyncEnums, CONFIGURE_COMPLETE);
313 ENUM_CASE(sync_pb::SyncEnums, BOOTSTRAP_TOKEN_UPDATED);
314 }
315 NOTREACHED();
316 return "";
317 }
318
319 const char* GetBlockedStateString(
320 sync_pb::TabNavigation::BlockedState state) {
321 ASSERT_ENUM_BOUNDS(sync_pb::TabNavigation, BlockedState,
322 STATE_ALLOWED, STATE_BLOCKED);
323 switch (state) {
324 ENUM_CASE(sync_pb::TabNavigation, STATE_ALLOWED);
325 ENUM_CASE(sync_pb::TabNavigation, STATE_BLOCKED);
326 }
327 NOTREACHED();
328 return "";
329 }
330
331 #undef ASSERT_ENUM_BOUNDS
332 #undef ENUM_CASE
333
334 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/protocol/proto_enum_conversions.h ('k') | sync/protocol/proto_enum_conversions_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698