cc: Allow fully solid layers to contribute pixels for telemetry
[chromium-blink-merge.git] / sync / protocol / proto_enum_conversions.cc
blob4c439833550b98246135ee2732470b65678ecc3f
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.
5 // Keep this file in sync with the .proto files in this directory.
7 #include "sync/protocol/proto_enum_conversions.h"
9 #include "base/basictypes.h"
10 #include "base/logging.h"
12 namespace syncer {
14 #define ASSERT_ENUM_BOUNDS(enum_parent, enum_type, enum_min, enum_max) \
15 COMPILE_ASSERT(enum_parent::enum_type##_MIN == enum_parent::enum_min, \
16 enum_type##_MIN_not_##enum_min); \
17 COMPILE_ASSERT(enum_parent::enum_type##_MAX == enum_parent::enum_max, \
18 enum_type##_MAX_not_##enum_max);
20 #define ENUM_CASE(enum_parent, enum_value) \
21 case enum_parent::enum_value: return #enum_value
23 const char* GetAppListItemTypeString(
24 sync_pb::AppListSpecifics::AppListItemType item_type) {
25 ASSERT_ENUM_BOUNDS(sync_pb::AppListSpecifics, AppListItemType,
26 TYPE_APP, TYPE_URL);
27 switch (item_type) {
28 ENUM_CASE(sync_pb::AppListSpecifics, TYPE_APP);
29 ENUM_CASE(sync_pb::AppListSpecifics, TYPE_REMOVE_DEFAULT_APP);
30 ENUM_CASE(sync_pb::AppListSpecifics, TYPE_FOLDER);
31 ENUM_CASE(sync_pb::AppListSpecifics, TYPE_URL);
33 NOTREACHED();
34 return "";
37 const char* GetBrowserTypeString(
38 sync_pb::SessionWindow::BrowserType browser_type) {
39 ASSERT_ENUM_BOUNDS(sync_pb::SessionWindow, BrowserType,
40 TYPE_TABBED, TYPE_POPUP);
41 switch (browser_type) {
42 ENUM_CASE(sync_pb::SessionWindow, TYPE_TABBED);
43 ENUM_CASE(sync_pb::SessionWindow, TYPE_POPUP);
45 NOTREACHED();
46 return "";
49 const char* GetPageTransitionString(
50 sync_pb::SyncEnums::PageTransition page_transition) {
51 ASSERT_ENUM_BOUNDS(sync_pb::SyncEnums, PageTransition,
52 LINK, KEYWORD_GENERATED);
53 switch (page_transition) {
54 ENUM_CASE(sync_pb::SyncEnums, LINK);
55 ENUM_CASE(sync_pb::SyncEnums, TYPED);
56 ENUM_CASE(sync_pb::SyncEnums, AUTO_BOOKMARK);
57 ENUM_CASE(sync_pb::SyncEnums, AUTO_SUBFRAME);
58 ENUM_CASE(sync_pb::SyncEnums, MANUAL_SUBFRAME);
59 ENUM_CASE(sync_pb::SyncEnums, GENERATED);
60 ENUM_CASE(sync_pb::SyncEnums, AUTO_TOPLEVEL);
61 ENUM_CASE(sync_pb::SyncEnums, FORM_SUBMIT);
62 ENUM_CASE(sync_pb::SyncEnums, RELOAD);
63 ENUM_CASE(sync_pb::SyncEnums, KEYWORD);
64 ENUM_CASE(sync_pb::SyncEnums, KEYWORD_GENERATED);
66 NOTREACHED();
67 return "";
70 const char* GetPageTransitionRedirectTypeString(
71 sync_pb::SyncEnums::PageTransitionRedirectType
72 page_transition_qualifier) {
73 ASSERT_ENUM_BOUNDS(sync_pb::SyncEnums, PageTransitionRedirectType,
74 CLIENT_REDIRECT, SERVER_REDIRECT);
75 switch (page_transition_qualifier) {
76 ENUM_CASE(sync_pb::SyncEnums, CLIENT_REDIRECT);
77 ENUM_CASE(sync_pb::SyncEnums, SERVER_REDIRECT);
79 NOTREACHED();
80 return "";
83 const char* GetUpdatesSourceString(
84 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource updates_source) {
85 ASSERT_ENUM_BOUNDS(sync_pb::GetUpdatesCallerInfo, GetUpdatesSource,
86 UNKNOWN, PROGRAMMATIC);
87 switch (updates_source) {
88 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, UNKNOWN);
89 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, FIRST_UPDATE);
90 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, LOCAL);
91 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, NOTIFICATION);
92 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, PERIODIC);
93 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, SYNC_CYCLE_CONTINUATION);
94 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, NEWLY_SUPPORTED_DATATYPE);
95 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, MIGRATION);
96 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, NEW_CLIENT);
97 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, RECONFIGURATION);
98 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, DATATYPE_REFRESH);
99 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, RETRY);
100 ENUM_CASE(sync_pb::GetUpdatesCallerInfo, PROGRAMMATIC);
102 NOTREACHED();
103 return "";
106 const char* GetUpdatesOriginString(
107 sync_pb::SyncEnums::GetUpdatesOrigin origin) {
108 ASSERT_ENUM_BOUNDS(sync_pb::SyncEnums, GetUpdatesOrigin,
109 UNKNOWN_ORIGIN, PROGRAMMATIC);
110 switch (origin) {
111 ENUM_CASE(sync_pb::SyncEnums, UNKNOWN_ORIGIN);
112 ENUM_CASE(sync_pb::SyncEnums, PERIODIC);
113 ENUM_CASE(sync_pb::SyncEnums, NEWLY_SUPPORTED_DATATYPE);
114 ENUM_CASE(sync_pb::SyncEnums, MIGRATION);
115 ENUM_CASE(sync_pb::SyncEnums, NEW_CLIENT);
116 ENUM_CASE(sync_pb::SyncEnums, RECONFIGURATION);
117 ENUM_CASE(sync_pb::SyncEnums, GU_TRIGGER);
118 ENUM_CASE(sync_pb::SyncEnums, RETRY);
119 ENUM_CASE(sync_pb::SyncEnums, PROGRAMMATIC);
121 NOTREACHED();
122 return "";
125 const char* GetResponseTypeString(
126 sync_pb::CommitResponse::ResponseType response_type) {
127 ASSERT_ENUM_BOUNDS(sync_pb::CommitResponse, ResponseType, SUCCESS,
128 TRANSIENT_ERROR);
129 switch (response_type) {
130 ENUM_CASE(sync_pb::CommitResponse, SUCCESS);
131 ENUM_CASE(sync_pb::CommitResponse, CONFLICT);
132 ENUM_CASE(sync_pb::CommitResponse, RETRY);
133 ENUM_CASE(sync_pb::CommitResponse, INVALID_MESSAGE);
134 ENUM_CASE(sync_pb::CommitResponse, OVER_QUOTA);
135 ENUM_CASE(sync_pb::CommitResponse, TRANSIENT_ERROR);
137 NOTREACHED();
138 return "";
141 const char* GetErrorTypeString(sync_pb::SyncEnums::ErrorType error_type) {
142 ASSERT_ENUM_BOUNDS(sync_pb::SyncEnums, ErrorType, SUCCESS, UNKNOWN);
143 switch (error_type) {
144 ENUM_CASE(sync_pb::SyncEnums, SUCCESS);
145 ENUM_CASE(sync_pb::SyncEnums, ACCESS_DENIED);
146 ENUM_CASE(sync_pb::SyncEnums, NOT_MY_BIRTHDAY);
147 ENUM_CASE(sync_pb::SyncEnums, THROTTLED);
148 ENUM_CASE(sync_pb::SyncEnums, AUTH_EXPIRED);
149 ENUM_CASE(sync_pb::SyncEnums, USER_NOT_ACTIVATED);
150 ENUM_CASE(sync_pb::SyncEnums, AUTH_INVALID);
151 ENUM_CASE(sync_pb::SyncEnums, CLEAR_PENDING);
152 ENUM_CASE(sync_pb::SyncEnums, TRANSIENT_ERROR);
153 ENUM_CASE(sync_pb::SyncEnums, MIGRATION_DONE);
154 ENUM_CASE(sync_pb::SyncEnums, DISABLED_BY_ADMIN);
155 ENUM_CASE(sync_pb::SyncEnums, USER_ROLLBACK);
156 ENUM_CASE(sync_pb::SyncEnums, UNKNOWN);
158 NOTREACHED();
159 return "";
162 const char* GetActionString(sync_pb::SyncEnums::Action action) {
163 ASSERT_ENUM_BOUNDS(sync_pb::SyncEnums, Action,
164 UPGRADE_CLIENT, UNKNOWN_ACTION);
165 switch (action) {
166 ENUM_CASE(sync_pb::SyncEnums, UPGRADE_CLIENT);
167 ENUM_CASE(sync_pb::SyncEnums, CLEAR_USER_DATA_AND_RESYNC);
168 ENUM_CASE(sync_pb::SyncEnums, ENABLE_SYNC_ON_ACCOUNT);
169 ENUM_CASE(sync_pb::SyncEnums, STOP_AND_RESTART_SYNC);
170 ENUM_CASE(sync_pb::SyncEnums, DISABLE_SYNC_ON_CLIENT);
171 ENUM_CASE(sync_pb::SyncEnums, UNKNOWN_ACTION);
173 NOTREACHED();
174 return "";
178 const char* GetLaunchTypeString(sync_pb::AppSpecifics::LaunchType launch_type) {
179 ASSERT_ENUM_BOUNDS(sync_pb::AppSpecifics, LaunchType, PINNED, WINDOW);
180 switch (launch_type) {
181 ENUM_CASE(sync_pb::AppSpecifics, PINNED);
182 ENUM_CASE(sync_pb::AppSpecifics, REGULAR);
183 ENUM_CASE(sync_pb::AppSpecifics, FULLSCREEN);
184 ENUM_CASE(sync_pb::AppSpecifics, WINDOW);
186 NOTREACHED();
187 return "";
190 const char* GetDeviceTypeString(
191 sync_pb::SyncEnums::DeviceType device_type) {
192 ASSERT_ENUM_BOUNDS(sync_pb::SyncEnums, DeviceType, TYPE_WIN, TYPE_TABLET);
193 switch (device_type) {
194 ENUM_CASE(sync_pb::SyncEnums, TYPE_WIN);
195 ENUM_CASE(sync_pb::SyncEnums, TYPE_MAC);
196 ENUM_CASE(sync_pb::SyncEnums, TYPE_LINUX);
197 ENUM_CASE(sync_pb::SyncEnums, TYPE_CROS);
198 ENUM_CASE(sync_pb::SyncEnums, TYPE_OTHER);
199 ENUM_CASE(sync_pb::SyncEnums, TYPE_PHONE);
200 ENUM_CASE(sync_pb::SyncEnums, TYPE_TABLET);
202 NOTREACHED();
203 return "";
206 const char* GetFaviconTypeString(
207 sync_pb::SessionTab::FaviconType favicon_type) {
208 ASSERT_ENUM_BOUNDS(sync_pb::SessionTab, FaviconType, TYPE_WEB_FAVICON,
209 TYPE_WEB_FAVICON);
210 switch (favicon_type) {
211 ENUM_CASE(sync_pb::SessionTab, TYPE_WEB_FAVICON);
213 NOTREACHED();
214 return "";
217 const char* PassphraseTypeString(
218 sync_pb::NigoriSpecifics::PassphraseType type) {
219 ASSERT_ENUM_BOUNDS(sync_pb::NigoriSpecifics, PassphraseType,
220 IMPLICIT_PASSPHRASE, CUSTOM_PASSPHRASE);
221 switch (type) {
222 ENUM_CASE(sync_pb::NigoriSpecifics, IMPLICIT_PASSPHRASE);
223 ENUM_CASE(sync_pb::NigoriSpecifics, KEYSTORE_PASSPHRASE);
224 ENUM_CASE(sync_pb::NigoriSpecifics, FROZEN_IMPLICIT_PASSPHRASE);
225 ENUM_CASE(sync_pb::NigoriSpecifics, CUSTOM_PASSPHRASE);
227 NOTREACHED();
228 return "";
231 const char* SingletonDebugEventTypeString(
232 sync_pb::SyncEnums::SingletonDebugEventType type) {
233 ASSERT_ENUM_BOUNDS(sync_pb::SyncEnums, SingletonDebugEventType,
234 CONNECTION_STATUS_CHANGE, BOOTSTRAP_TOKEN_UPDATED);
235 switch (type) {
236 ENUM_CASE(sync_pb::SyncEnums, CONNECTION_STATUS_CHANGE);
237 ENUM_CASE(sync_pb::SyncEnums, UPDATED_TOKEN);
238 ENUM_CASE(sync_pb::SyncEnums, PASSPHRASE_REQUIRED);
239 ENUM_CASE(sync_pb::SyncEnums, PASSPHRASE_ACCEPTED);
240 ENUM_CASE(sync_pb::SyncEnums, INITIALIZATION_COMPLETE);
241 ENUM_CASE(sync_pb::SyncEnums, STOP_SYNCING_PERMANENTLY);
242 ENUM_CASE(sync_pb::SyncEnums, ENCRYPTION_COMPLETE);
243 ENUM_CASE(sync_pb::SyncEnums, ACTIONABLE_ERROR);
244 ENUM_CASE(sync_pb::SyncEnums, ENCRYPTED_TYPES_CHANGED);
245 ENUM_CASE(sync_pb::SyncEnums, PASSPHRASE_TYPE_CHANGED);
246 ENUM_CASE(sync_pb::SyncEnums, KEYSTORE_TOKEN_UPDATED);
247 ENUM_CASE(sync_pb::SyncEnums, CONFIGURE_COMPLETE);
248 ENUM_CASE(sync_pb::SyncEnums, BOOTSTRAP_TOKEN_UPDATED);
250 NOTREACHED();
251 return "";
254 const char* GetBlockedStateString(
255 sync_pb::TabNavigation::BlockedState state) {
256 ASSERT_ENUM_BOUNDS(sync_pb::TabNavigation, BlockedState,
257 STATE_ALLOWED, STATE_BLOCKED);
258 switch (state) {
259 ENUM_CASE(sync_pb::TabNavigation, STATE_ALLOWED);
260 ENUM_CASE(sync_pb::TabNavigation, STATE_BLOCKED);
262 NOTREACHED();
263 return "";
266 #undef ASSERT_ENUM_BOUNDS
267 #undef ENUM_CASE
269 } // namespace syncer