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

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

Issue 2092893002: arc: Create sync protos for Arc package. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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 #include "sync/internal_api/public/base/model_type.h" 5 #include "sync/internal_api/public/base/model_type.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 {ARTICLES, "ARTICLE", "articles", "Articles", 124 {ARTICLES, "ARTICLE", "articles", "Articles",
125 sync_pb::EntitySpecifics::kArticleFieldNumber, 28}, 125 sync_pb::EntitySpecifics::kArticleFieldNumber, 28},
126 {APP_LIST, "APP_LIST", "app_list", "App List", 126 {APP_LIST, "APP_LIST", "app_list", "App List",
127 sync_pb::EntitySpecifics::kAppListFieldNumber, 29}, 127 sync_pb::EntitySpecifics::kAppListFieldNumber, 29},
128 {WIFI_CREDENTIALS, "WIFI_CREDENTIAL", "wifi_credentials", 128 {WIFI_CREDENTIALS, "WIFI_CREDENTIAL", "wifi_credentials",
129 "WiFi Credentials", sync_pb::EntitySpecifics::kWifiCredentialFieldNumber, 129 "WiFi Credentials", sync_pb::EntitySpecifics::kWifiCredentialFieldNumber,
130 32}, 130 32},
131 {SUPERVISED_USER_WHITELISTS, "MANAGED_USER_WHITELIST", 131 {SUPERVISED_USER_WHITELISTS, "MANAGED_USER_WHITELIST",
132 "managed_user_whitelists", "Managed User Whitelists", 132 "managed_user_whitelists", "Managed User Whitelists",
133 sync_pb::EntitySpecifics::kManagedUserWhitelistFieldNumber, 33}, 133 sync_pb::EntitySpecifics::kManagedUserWhitelistFieldNumber, 33},
134 {ARC_PACKAGE, "ARC_PACKAGE", "arc_package", "ARC PACKAGE",
pavely 2016/06/27 18:51:33 Could you change model_type_string from "ARC PACKA
lgcheng 2016/06/27 19:54:38 Done.
135 sync_pb::EntitySpecifics::kArcPackageFieldNumber, 36},
134 {PROXY_TABS, "", "", "Tabs", -1, 25}, 136 {PROXY_TABS, "", "", "Tabs", -1, 25},
135 {NIGORI, "NIGORI", "nigori", "Encryption keys", 137 {NIGORI, "NIGORI", "nigori", "Encryption keys",
136 sync_pb::EntitySpecifics::kNigoriFieldNumber, 17}, 138 sync_pb::EntitySpecifics::kNigoriFieldNumber, 17},
137 {EXPERIMENTS, "EXPERIMENTS", "experiments", "Experiments", 139 {EXPERIMENTS, "EXPERIMENTS", "experiments", "Experiments",
138 sync_pb::EntitySpecifics::kExperimentsFieldNumber, 19}, 140 sync_pb::EntitySpecifics::kExperimentsFieldNumber, 19},
139 }; 141 };
140 142
141 static_assert(arraysize(kModelTypeInfoMap) == MODEL_TYPE_COUNT, 143 static_assert(arraysize(kModelTypeInfoMap) == MODEL_TYPE_COUNT,
142 "kModelTypeInfoMap should have MODEL_TYPE_COUNT elements"); 144 "kModelTypeInfoMap should have MODEL_TYPE_COUNT elements");
143 145
144 // Notes: 146 // Notes:
145 // 1) This list must contain exactly the same elements as the set returned by 147 // 1) This list must contain exactly the same elements as the set returned by
146 // UserSelectableTypes(). 148 // UserSelectableTypes().
147 // 2) This list must be in the same order as the respective values in the 149 // 2) This list must be in the same order as the respective values in the
148 // ModelType enum. 150 // ModelType enum.
149 const char* kUserSelectableDataTypeNames[] = { 151 const char* kUserSelectableDataTypeNames[] = {
150 "bookmarks", 152 "bookmarks",
151 "preferences", 153 "preferences",
152 "passwords", 154 "passwords",
153 "autofill", 155 "autofill",
154 "themes", 156 "themes",
155 "typedUrls", 157 "typedUrls",
156 "extensions", 158 "extensions",
157 "apps", 159 "apps",
158 "tabs", 160 "tabs",
159 }; 161 };
160 162
161 static_assert( 163 static_assert(
162 36 == MODEL_TYPE_COUNT, 164 37 == MODEL_TYPE_COUNT,
163 "update kUserSelectableDataTypeName to match UserSelectableTypes"); 165 "update kUserSelectableDataTypeName to match UserSelectableTypes");
164 166
165 void AddDefaultFieldValue(ModelType datatype, 167 void AddDefaultFieldValue(ModelType datatype,
166 sync_pb::EntitySpecifics* specifics) { 168 sync_pb::EntitySpecifics* specifics) {
167 if (!ProtocolTypes().Has(datatype)) { 169 if (!ProtocolTypes().Has(datatype)) {
168 NOTREACHED() << "Only protocol types have field values."; 170 NOTREACHED() << "Only protocol types have field values.";
169 return; 171 return;
170 } 172 }
171 switch (datatype) { 173 switch (datatype) {
172 case BOOKMARKS: 174 case BOOKMARKS:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 break; 212 break;
211 case APPS: 213 case APPS:
212 specifics->mutable_app(); 214 specifics->mutable_app();
213 break; 215 break;
214 case APP_LIST: 216 case APP_LIST:
215 specifics->mutable_app_list(); 217 specifics->mutable_app_list();
216 break; 218 break;
217 case APP_SETTINGS: 219 case APP_SETTINGS:
218 specifics->mutable_app_setting(); 220 specifics->mutable_app_setting();
219 break; 221 break;
222 case ARC_PACKAGE:
223 specifics->mutable_arc_package();
224 break;
220 case EXTENSION_SETTINGS: 225 case EXTENSION_SETTINGS:
221 specifics->mutable_extension_setting(); 226 specifics->mutable_extension_setting();
222 break; 227 break;
223 case APP_NOTIFICATIONS: 228 case APP_NOTIFICATIONS:
224 specifics->mutable_app_notification(); 229 specifics->mutable_app_notification();
225 break; 230 break;
226 case HISTORY_DELETE_DIRECTIVES: 231 case HISTORY_DELETE_DIRECTIVES:
227 specifics->mutable_history_delete_directive(); 232 specifics->mutable_history_delete_directive();
228 break; 233 break;
229 case SYNCED_NOTIFICATIONS: 234 case SYNCED_NOTIFICATIONS:
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 364
360 if (specifics.has_nigori()) 365 if (specifics.has_nigori())
361 return NIGORI; 366 return NIGORI;
362 367
363 if (specifics.has_app()) 368 if (specifics.has_app())
364 return APPS; 369 return APPS;
365 370
366 if (specifics.has_app_list()) 371 if (specifics.has_app_list())
367 return APP_LIST; 372 return APP_LIST;
368 373
374 if (specifics.has_arc_package())
375 return ARC_PACKAGE;
376
369 if (specifics.has_search_engine()) 377 if (specifics.has_search_engine())
370 return SEARCH_ENGINES; 378 return SEARCH_ENGINES;
371 379
372 if (specifics.has_session()) 380 if (specifics.has_session())
373 return SESSIONS; 381 return SESSIONS;
374 382
375 if (specifics.has_app_setting()) 383 if (specifics.has_app_setting())
376 return APP_SETTINGS; 384 return APP_SETTINGS;
377 385
378 if (specifics.has_extension_setting()) 386 if (specifics.has_extension_setting())
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 755
748 bool TypeSupportsOrdering(ModelType model_type) { 756 bool TypeSupportsOrdering(ModelType model_type) {
749 return model_type == BOOKMARKS; 757 return model_type == BOOKMARKS;
750 } 758 }
751 759
752 const char* ModelTypeToTag(ModelType model_type) { 760 const char* ModelTypeToTag(ModelType model_type) {
753 return kModelTypeInfoMap[model_type].root_tag; 761 return kModelTypeInfoMap[model_type].root_tag;
754 } 762 }
755 763
756 } // namespace syncer 764 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698