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

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

Issue 2701003002: [Sync] Clean up ModelType code. (Closed)
Patch Set: Switched int to size_t to fix compile. Created 3 years, 9 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 "components/sync/base/model_type.h" 5 #include "components/sync/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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // ModelType enum. 156 // ModelType enum.
157 const char* kUserSelectableDataTypeNames[] = { 157 const char* kUserSelectableDataTypeNames[] = {
158 "bookmarks", "preferences", "passwords", "autofill", 158 "bookmarks", "preferences", "passwords", "autofill",
159 "themes", "typedUrls", "extensions", "apps", 159 "themes", "typedUrls", "extensions", "apps",
160 #if BUILDFLAG(ENABLE_READING_LIST) 160 #if BUILDFLAG(ENABLE_READING_LIST)
161 "readingList", 161 "readingList",
162 #endif 162 #endif
163 "tabs", 163 "tabs",
164 }; 164 };
165 165
166 static_assert( 166 void AddDefaultFieldValue(ModelType type, sync_pb::EntitySpecifics* specifics) {
167 39 == MODEL_TYPE_COUNT, 167 switch (type) {
168 "update kUserSelectableDataTypeName to match UserSelectableTypes"); 168 case UNSPECIFIED:
169 169 case TOP_LEVEL_FOLDER:
170 void AddDefaultFieldValue(ModelType datatype, 170 NOTREACHED() << "No default field value for " << ModelTypeToString(type);
171 sync_pb::EntitySpecifics* specifics) { 171 break;
172 if (!ProtocolTypes().Has(datatype)) {
173 NOTREACHED() << "Only protocol types have field values.";
174 return;
175 }
176 switch (datatype) {
177 case BOOKMARKS: 172 case BOOKMARKS:
178 specifics->mutable_bookmark(); 173 specifics->mutable_bookmark();
179 break; 174 break;
175 case PREFERENCES:
176 specifics->mutable_preference();
177 break;
180 case PASSWORDS: 178 case PASSWORDS:
181 specifics->mutable_password(); 179 specifics->mutable_password();
182 break; 180 break;
183 case PREFERENCES: 181 case AUTOFILL_PROFILE:
184 specifics->mutable_preference(); 182 specifics->mutable_autofill_profile();
185 break; 183 break;
186 case AUTOFILL: 184 case AUTOFILL:
187 specifics->mutable_autofill(); 185 specifics->mutable_autofill();
188 break; 186 break;
189 case AUTOFILL_PROFILE:
190 specifics->mutable_autofill_profile();
191 break;
192 case AUTOFILL_WALLET_DATA: 187 case AUTOFILL_WALLET_DATA:
193 specifics->mutable_autofill_wallet(); 188 specifics->mutable_autofill_wallet();
194 break; 189 break;
195 case AUTOFILL_WALLET_METADATA: 190 case AUTOFILL_WALLET_METADATA:
196 specifics->mutable_wallet_metadata(); 191 specifics->mutable_wallet_metadata();
197 break; 192 break;
198 case THEMES: 193 case THEMES:
199 specifics->mutable_theme(); 194 specifics->mutable_theme();
200 break; 195 break;
201 case TYPED_URLS: 196 case TYPED_URLS:
202 specifics->mutable_typed_url(); 197 specifics->mutable_typed_url();
203 break; 198 break;
204 case EXTENSIONS: 199 case EXTENSIONS:
205 specifics->mutable_extension(); 200 specifics->mutable_extension();
206 break; 201 break;
207 case NIGORI:
208 specifics->mutable_nigori();
209 break;
210 case SEARCH_ENGINES: 202 case SEARCH_ENGINES:
211 specifics->mutable_search_engine(); 203 specifics->mutable_search_engine();
212 break; 204 break;
213 case SESSIONS: 205 case SESSIONS:
214 specifics->mutable_session(); 206 specifics->mutable_session();
215 break; 207 break;
216 case APPS: 208 case APPS:
217 specifics->mutable_app(); 209 specifics->mutable_app();
218 break; 210 break;
219 case APP_LIST:
220 specifics->mutable_app_list();
221 break;
222 case APP_SETTINGS: 211 case APP_SETTINGS:
223 specifics->mutable_app_setting(); 212 specifics->mutable_app_setting();
224 break; 213 break;
225 case ARC_PACKAGE:
226 specifics->mutable_arc_package();
227 break;
228 case EXTENSION_SETTINGS: 214 case EXTENSION_SETTINGS:
229 specifics->mutable_extension_setting(); 215 specifics->mutable_extension_setting();
230 break; 216 break;
231 case APP_NOTIFICATIONS: 217 case APP_NOTIFICATIONS:
232 specifics->mutable_app_notification(); 218 specifics->mutable_app_notification();
233 break; 219 break;
234 case HISTORY_DELETE_DIRECTIVES: 220 case HISTORY_DELETE_DIRECTIVES:
235 specifics->mutable_history_delete_directive(); 221 specifics->mutable_history_delete_directive();
236 break; 222 break;
237 case SYNCED_NOTIFICATIONS: 223 case SYNCED_NOTIFICATIONS:
238 specifics->mutable_synced_notification(); 224 specifics->mutable_synced_notification();
239 break; 225 break;
240 case SYNCED_NOTIFICATION_APP_INFO: 226 case SYNCED_NOTIFICATION_APP_INFO:
241 specifics->mutable_synced_notification_app_info(); 227 specifics->mutable_synced_notification_app_info();
242 break; 228 break;
243 case DEVICE_INFO:
244 specifics->mutable_device_info();
245 break;
246 case EXPERIMENTS:
247 specifics->mutable_experiments();
248 break;
249 case PRINTERS:
250 specifics->mutable_printer();
251 break;
252 case PRIORITY_PREFERENCES:
253 specifics->mutable_priority_preference();
254 break;
255 case DICTIONARY: 229 case DICTIONARY:
256 specifics->mutable_dictionary(); 230 specifics->mutable_dictionary();
257 break; 231 break;
258 case FAVICON_IMAGES: 232 case FAVICON_IMAGES:
259 specifics->mutable_favicon_image(); 233 specifics->mutable_favicon_image();
260 break; 234 break;
261 case FAVICON_TRACKING: 235 case FAVICON_TRACKING:
262 specifics->mutable_favicon_tracking(); 236 specifics->mutable_favicon_tracking();
263 break; 237 break;
238 case DEVICE_INFO:
239 specifics->mutable_device_info();
240 break;
241 case PRIORITY_PREFERENCES:
242 specifics->mutable_priority_preference();
243 break;
264 case SUPERVISED_USER_SETTINGS: 244 case SUPERVISED_USER_SETTINGS:
265 specifics->mutable_managed_user_setting(); 245 specifics->mutable_managed_user_setting();
266 break; 246 break;
267 case SUPERVISED_USERS: 247 case SUPERVISED_USERS:
268 specifics->mutable_managed_user(); 248 specifics->mutable_managed_user();
269 break; 249 break;
270 case SUPERVISED_USER_SHARED_SETTINGS: 250 case SUPERVISED_USER_SHARED_SETTINGS:
271 specifics->mutable_managed_user_shared_setting(); 251 specifics->mutable_managed_user_shared_setting();
252 case ARTICLES:
253 specifics->mutable_article();
254 break;
255 case APP_LIST:
256 specifics->mutable_app_list();
257 break;
258 case WIFI_CREDENTIALS:
259 specifics->mutable_wifi_credential();
272 break; 260 break;
273 case SUPERVISED_USER_WHITELISTS: 261 case SUPERVISED_USER_WHITELISTS:
274 specifics->mutable_managed_user_whitelist(); 262 specifics->mutable_managed_user_whitelist();
275 break; 263 break;
276 case ARTICLES: 264 case ARC_PACKAGE:
277 specifics->mutable_article(); 265 specifics->mutable_arc_package();
278 break; 266 break;
279 case WIFI_CREDENTIALS: 267 case PRINTERS:
280 specifics->mutable_wifi_credential(); 268 specifics->mutable_printer();
281 break; 269 break;
282 case READING_LIST: 270 case READING_LIST:
283 specifics->mutable_reading_list(); 271 specifics->mutable_reading_list();
284 break; 272 break;
285 default: 273 case PROXY_TABS:
286 NOTREACHED() << "No known extension for model type."; 274 NOTREACHED() << "No default field value for " << ModelTypeToString(type);
275 break;
276 case NIGORI:
277 specifics->mutable_nigori();
278 break;
279 case EXPERIMENTS:
280 specifics->mutable_experiments();
281 break;
282 case MODEL_TYPE_COUNT:
283 NOTREACHED() << "No default field value for " << ModelTypeToString(type);
284 break;
287 } 285 }
288 } 286 }
289 287
290 ModelType GetModelTypeFromSpecificsFieldNumber(int field_number) { 288 ModelType GetModelTypeFromSpecificsFieldNumber(int field_number) {
291 ModelTypeSet protocol_types = ProtocolTypes(); 289 ModelTypeSet protocol_types = ProtocolTypes();
292 for (ModelTypeSet::Iterator iter = protocol_types.First(); iter.Good(); 290 for (ModelTypeSet::Iterator iter = protocol_types.First(); iter.Good();
293 iter.Inc()) { 291 iter.Inc()) {
294 if (GetSpecificsFieldNumberFromModelType(iter.Get()) == field_number) 292 if (GetSpecificsFieldNumberFromModelType(iter.Get()) == field_number)
295 return iter.Get(); 293 return iter.Get();
296 } 294 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } 332 }
335 333
336 // This is an item of a datatype we can't understand. Maybe it's 334 // This is an item of a datatype we can't understand. Maybe it's
337 // from the future? Either we mis-encoded the object, or the 335 // from the future? Either we mis-encoded the object, or the
338 // server sent us entries it shouldn't have. 336 // server sent us entries it shouldn't have.
339 NOTREACHED() << "Unknown datatype in sync proto."; 337 NOTREACHED() << "Unknown datatype in sync proto.";
340 return UNSPECIFIED; 338 return UNSPECIFIED;
341 } 339 }
342 340
343 ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics& specifics) { 341 ModelType GetModelTypeFromSpecifics(const sync_pb::EntitySpecifics& specifics) {
342 static_assert(39 == MODEL_TYPE_COUNT,
343 "When adding new protocol types, the following type lookup "
344 "logic must be updated.");
344 if (specifics.has_bookmark()) 345 if (specifics.has_bookmark())
345 return BOOKMARKS; 346 return BOOKMARKS;
346 347 if (specifics.has_preference())
348 return PREFERENCES;
347 if (specifics.has_password()) 349 if (specifics.has_password())
348 return PASSWORDS; 350 return PASSWORDS;
349 351 if (specifics.has_autofill_profile())
350 if (specifics.has_preference()) 352 return AUTOFILL_PROFILE;
351 return PREFERENCES;
352
353 if (specifics.has_autofill()) 353 if (specifics.has_autofill())
354 return AUTOFILL; 354 return AUTOFILL;
355
356 if (specifics.has_autofill_profile())
357 return AUTOFILL_PROFILE;
358
359 if (specifics.has_autofill_wallet()) 355 if (specifics.has_autofill_wallet())
360 return AUTOFILL_WALLET_DATA; 356 return AUTOFILL_WALLET_DATA;
361
362 if (specifics.has_wallet_metadata()) 357 if (specifics.has_wallet_metadata())
363 return AUTOFILL_WALLET_METADATA; 358 return AUTOFILL_WALLET_METADATA;
364
365 if (specifics.has_theme()) 359 if (specifics.has_theme())
366 return THEMES; 360 return THEMES;
367
368 if (specifics.has_typed_url()) 361 if (specifics.has_typed_url())
369 return TYPED_URLS; 362 return TYPED_URLS;
370
371 if (specifics.has_extension()) 363 if (specifics.has_extension())
372 return EXTENSIONS; 364 return EXTENSIONS;
373 365 if (specifics.has_search_engine())
366 return SEARCH_ENGINES;
367 if (specifics.has_session())
368 return SESSIONS;
369 if (specifics.has_app())
370 return APPS;
371 if (specifics.has_app_setting())
372 return APP_SETTINGS;
373 if (specifics.has_extension_setting())
374 return EXTENSION_SETTINGS;
375 if (specifics.has_app_notification())
376 return APP_NOTIFICATIONS;
377 if (specifics.has_history_delete_directive())
378 return HISTORY_DELETE_DIRECTIVES;
379 if (specifics.has_synced_notification())
380 return SYNCED_NOTIFICATIONS;
381 if (specifics.has_synced_notification_app_info())
382 return SYNCED_NOTIFICATION_APP_INFO;
383 if (specifics.has_dictionary())
384 return DICTIONARY;
385 if (specifics.has_favicon_image())
386 return FAVICON_IMAGES;
387 if (specifics.has_favicon_tracking())
388 return FAVICON_TRACKING;
389 if (specifics.has_device_info())
390 return DEVICE_INFO;
391 if (specifics.has_priority_preference())
392 return PRIORITY_PREFERENCES;
393 if (specifics.has_managed_user_setting())
394 return SUPERVISED_USER_SETTINGS;
395 if (specifics.has_managed_user())
396 return SUPERVISED_USERS;
397 if (specifics.has_managed_user_shared_setting())
398 return SUPERVISED_USER_SHARED_SETTINGS;
399 if (specifics.has_article())
400 return ARTICLES;
401 if (specifics.has_app_list())
402 return APP_LIST;
403 if (specifics.has_wifi_credential())
404 return WIFI_CREDENTIALS;
405 if (specifics.has_managed_user_whitelist())
406 return SUPERVISED_USER_WHITELISTS;
407 if (specifics.has_arc_package())
408 return ARC_PACKAGE;
409 if (specifics.has_printer())
410 return PRINTERS;
411 if (specifics.has_reading_list())
412 return READING_LIST;
374 if (specifics.has_nigori()) 413 if (specifics.has_nigori())
375 return NIGORI; 414 return NIGORI;
376
377 if (specifics.has_app())
378 return APPS;
379
380 if (specifics.has_app_list())
381 return APP_LIST;
382
383 if (specifics.has_arc_package())
384 return ARC_PACKAGE;
385
386 if (specifics.has_search_engine())
387 return SEARCH_ENGINES;
388
389 if (specifics.has_session())
390 return SESSIONS;
391
392 if (specifics.has_app_setting())
393 return APP_SETTINGS;
394
395 if (specifics.has_extension_setting())
396 return EXTENSION_SETTINGS;
397
398 if (specifics.has_app_notification())
399 return APP_NOTIFICATIONS;
400
401 if (specifics.has_reading_list())
402 return READING_LIST;
403
404 if (specifics.has_history_delete_directive())
405 return HISTORY_DELETE_DIRECTIVES;
406
407 if (specifics.has_synced_notification())
408 return SYNCED_NOTIFICATIONS;
409
410 if (specifics.has_synced_notification_app_info())
411 return SYNCED_NOTIFICATION_APP_INFO;
412
413 if (specifics.has_device_info())
414 return DEVICE_INFO;
415
416 if (specifics.has_experiments()) 415 if (specifics.has_experiments())
417 return EXPERIMENTS; 416 return EXPERIMENTS;
418 417
419 if (specifics.has_priority_preference())
420 return PRIORITY_PREFERENCES;
421
422 if (specifics.has_printer())
423 return PRINTERS;
424
425 if (specifics.has_dictionary())
426 return DICTIONARY;
427
428 if (specifics.has_favicon_image())
429 return FAVICON_IMAGES;
430
431 if (specifics.has_favicon_tracking())
432 return FAVICON_TRACKING;
433
434 if (specifics.has_managed_user_setting())
435 return SUPERVISED_USER_SETTINGS;
436
437 if (specifics.has_managed_user())
438 return SUPERVISED_USERS;
439
440 if (specifics.has_managed_user_shared_setting())
441 return SUPERVISED_USER_SHARED_SETTINGS;
442
443 if (specifics.has_managed_user_whitelist())
444 return SUPERVISED_USER_WHITELISTS;
445
446 if (specifics.has_article())
447 return ARTICLES;
448
449 if (specifics.has_wifi_credential())
450 return WIFI_CREDENTIALS;
451
452 return UNSPECIFIED; 418 return UNSPECIFIED;
453 } 419 }
454 420
455 ModelTypeSet ProtocolTypes() { 421 ModelTypeSet ProtocolTypes() {
456 ModelTypeSet set = ModelTypeSet::All(); 422 return Difference(ModelTypeSet::All(), ProxyTypes());
457 set.RemoveAll(ProxyTypes());
458 return set;
459 } 423 }
460 424
461 ModelTypeSet UserTypes() { 425 ModelTypeSet UserTypes() {
462 ModelTypeSet set;
463 // TODO(sync): We should be able to build the actual enumset's internal 426 // TODO(sync): We should be able to build the actual enumset's internal
464 // bitset value here at compile time, rather than performing an iteration 427 // bitset value here at compile time, instead of makes a new one each time.
465 // every time. 428 return ModelTypeSet::FromRange(FIRST_USER_MODEL_TYPE, LAST_USER_MODEL_TYPE);
466 for (int i = FIRST_USER_MODEL_TYPE; i <= LAST_USER_MODEL_TYPE; ++i) {
467 set.Put(ModelTypeFromInt(i));
468 }
469 return set;
470 } 429 }
471 430
472 ModelTypeSet UserSelectableTypes() { 431 ModelTypeSet UserSelectableTypes() {
473 ModelTypeSet set; 432 return ModelTypeSet(BOOKMARKS, PREFERENCES, PASSWORDS, AUTOFILL, THEMES,
474 // Although the order doesn't technically matter here, it's clearer to keep 433 TYPED_URLS, EXTENSIONS, APPS,
475 // these in the same order as their definition in the ModelType enum.
476 set.Put(BOOKMARKS);
477 set.Put(PREFERENCES);
478 set.Put(PASSWORDS);
479 set.Put(AUTOFILL);
480 set.Put(THEMES);
481 set.Put(TYPED_URLS);
482 set.Put(EXTENSIONS);
483 set.Put(APPS);
484 #if BUILDFLAG(ENABLE_READING_LIST) 434 #if BUILDFLAG(ENABLE_READING_LIST)
485 set.Put(READING_LIST); 435 READING_LIST,
486 #endif 436 #endif
487 set.Put(PROXY_TABS); 437 PROXY_TABS);
488 return set;
489 } 438 }
490 439
491 bool IsUserSelectableType(ModelType model_type) { 440 bool IsUserSelectableType(ModelType model_type) {
492 return UserSelectableTypes().Has(model_type); 441 return UserSelectableTypes().Has(model_type);
493 } 442 }
494 443
495 ModelTypeNameMap GetUserSelectableTypeNameMap() { 444 ModelTypeNameMap GetUserSelectableTypeNameMap() {
496 ModelTypeNameMap type_names; 445 ModelTypeNameMap type_names;
497 ModelTypeSet type_set = UserSelectableTypes(); 446 ModelTypeSet type_set = UserSelectableTypes();
498 ModelTypeSet::Iterator it = type_set.First(); 447 ModelTypeSet::Iterator it = type_set.First();
499 DCHECK_EQ(arraysize(kUserSelectableDataTypeNames), type_set.Size()); 448 DCHECK_EQ(arraysize(kUserSelectableDataTypeNames), type_set.Size());
500 for (size_t i = 0; i < arraysize(kUserSelectableDataTypeNames) && it.Good(); 449 for (size_t i = 0; i < arraysize(kUserSelectableDataTypeNames) && it.Good();
501 ++i, it.Inc()) { 450 ++i, it.Inc()) {
502 type_names[it.Get()] = kUserSelectableDataTypeNames[i]; 451 type_names[it.Get()] = kUserSelectableDataTypeNames[i];
503 } 452 }
504 return type_names; 453 return type_names;
505 } 454 }
506 455
507 ModelTypeSet EncryptableUserTypes() { 456 ModelTypeSet EncryptableUserTypes() {
457 static_assert(39 == MODEL_TYPE_COUNT,
458 "If adding an unencryptable type, remove from "
459 "encryptable_user_types below.");
508 ModelTypeSet encryptable_user_types = UserTypes(); 460 ModelTypeSet encryptable_user_types = UserTypes();
461 // Wallet data is not encrypted since it actually originates on the server.
462 encryptable_user_types.Remove(AUTOFILL_WALLET_DATA);
509 // We never encrypt history delete directives. 463 // We never encrypt history delete directives.
510 encryptable_user_types.Remove(HISTORY_DELETE_DIRECTIVES); 464 encryptable_user_types.Remove(HISTORY_DELETE_DIRECTIVES);
511 // Synced notifications are not encrypted since the server must see changes. 465 // Synced notifications are not encrypted since the server must see changes.
512 encryptable_user_types.Remove(SYNCED_NOTIFICATIONS); 466 encryptable_user_types.Remove(SYNCED_NOTIFICATIONS);
513 // Synced Notification App Info does not have private data, so it is not 467 // Synced Notification App Info does not have private data, so it is not
514 // encrypted. 468 // encrypted.
515 encryptable_user_types.Remove(SYNCED_NOTIFICATION_APP_INFO); 469 encryptable_user_types.Remove(SYNCED_NOTIFICATION_APP_INFO);
516 // Device info data is not encrypted because it might be synced before 470 // Device info data is not encrypted because it might be synced before
517 // encryption is ready. 471 // encryption is ready.
518 encryptable_user_types.Remove(DEVICE_INFO); 472 encryptable_user_types.Remove(DEVICE_INFO);
519 // Priority preferences are not encrypted because they might be synced before 473 // Priority preferences are not encrypted because they might be synced before
520 // encryption is ready. 474 // encryption is ready.
521 encryptable_user_types.Remove(PRIORITY_PREFERENCES); 475 encryptable_user_types.Remove(PRIORITY_PREFERENCES);
522 // Supervised user settings are not encrypted since they are set server-side. 476 // Supervised user settings are not encrypted since they are set server-side.
523 encryptable_user_types.Remove(SUPERVISED_USER_SETTINGS); 477 encryptable_user_types.Remove(SUPERVISED_USER_SETTINGS);
524 // Supervised users are not encrypted since they are managed server-side. 478 // Supervised users are not encrypted since they are managed server-side.
525 encryptable_user_types.Remove(SUPERVISED_USERS); 479 encryptable_user_types.Remove(SUPERVISED_USERS);
526 // Supervised user shared settings are not encrypted since they are managed 480 // Supervised user shared settings are not encrypted since they are managed
527 // server-side and shared between manager and supervised user. 481 // server-side and shared between manager and supervised user.
528 encryptable_user_types.Remove(SUPERVISED_USER_SHARED_SETTINGS); 482 encryptable_user_types.Remove(SUPERVISED_USER_SHARED_SETTINGS);
529 // Supervised user whitelists are not encrypted since they are managed 483 // Supervised user whitelists are not encrypted since they are managed
530 // server-side. 484 // server-side.
531 encryptable_user_types.Remove(SUPERVISED_USER_WHITELISTS); 485 encryptable_user_types.Remove(SUPERVISED_USER_WHITELISTS);
532 // Proxy types have no sync representation and are therefore not encrypted. 486 // Proxy types have no sync representation and are therefore not encrypted.
533 // Note however that proxy types map to one or more protocol types, which 487 // Note however that proxy types map to one or more protocol types, which
534 // may or may not be encrypted themselves. 488 // may or may not be encrypted themselves.
535 encryptable_user_types.RemoveAll(ProxyTypes()); 489 encryptable_user_types.RemoveAll(ProxyTypes());
536 // Wallet data is not encrypted since it actually originates on the server.
537 encryptable_user_types.Remove(AUTOFILL_WALLET_DATA);
538 return encryptable_user_types; 490 return encryptable_user_types;
539 } 491 }
540 492
541 ModelTypeSet PriorityUserTypes() { 493 ModelTypeSet PriorityUserTypes() {
542 return ModelTypeSet(DEVICE_INFO, PRIORITY_PREFERENCES); 494 return ModelTypeSet(DEVICE_INFO, PRIORITY_PREFERENCES);
543 } 495 }
544 496
545 ModelTypeSet ControlTypes() { 497 ModelTypeSet ControlTypes() {
546 ModelTypeSet set;
547 // TODO(sync): We should be able to build the actual enumset's internal 498 // TODO(sync): We should be able to build the actual enumset's internal
548 // bitset value here at compile time, rather than performing an iteration 499 // bitset value here at compile time, instead of makes a new one each time.
549 // every time. 500 return ModelTypeSet::FromRange(FIRST_CONTROL_MODEL_TYPE,
550 for (int i = FIRST_CONTROL_MODEL_TYPE; i <= LAST_CONTROL_MODEL_TYPE; ++i) { 501 LAST_CONTROL_MODEL_TYPE);
551 set.Put(ModelTypeFromInt(i));
552 }
553
554 return set;
555 } 502 }
556 503
557 ModelTypeSet ProxyTypes() { 504 ModelTypeSet ProxyTypes() {
558 ModelTypeSet set; 505 return ModelTypeSet::FromRange(FIRST_PROXY_TYPE, LAST_PROXY_TYPE);
559 set.Put(PROXY_TABS);
560 return set;
561 } 506 }
562 507
563 bool IsControlType(ModelType model_type) { 508 bool IsControlType(ModelType model_type) {
564 return ControlTypes().Has(model_type); 509 return ControlTypes().Has(model_type);
565 } 510 }
566 511
567 ModelTypeSet CoreTypes() { 512 ModelTypeSet CoreTypes() {
568 ModelTypeSet result; 513 ModelTypeSet result = PriorityCoreTypes();
569 result.PutAll(PriorityCoreTypes());
570 514
571 // The following are low priority core types. 515 // The following are low priority core types.
572 result.Put(SYNCED_NOTIFICATIONS); 516 result.Put(SYNCED_NOTIFICATIONS);
573 result.Put(SYNCED_NOTIFICATION_APP_INFO); 517 result.Put(SYNCED_NOTIFICATION_APP_INFO);
574 result.Put(SUPERVISED_USER_SHARED_SETTINGS); 518 result.Put(SUPERVISED_USER_SHARED_SETTINGS);
575 result.Put(SUPERVISED_USER_WHITELISTS); 519 result.Put(SUPERVISED_USER_WHITELISTS);
576 520
577 return result; 521 return result;
578 } 522 }
579 523
580 ModelTypeSet PriorityCoreTypes() { 524 ModelTypeSet PriorityCoreTypes() {
581 ModelTypeSet result; 525 ModelTypeSet result = ControlTypes();
582 result.PutAll(ControlTypes());
583 526
584 // The following are non-control core types. 527 // The following are non-control core types.
585 result.Put(SUPERVISED_USERS); 528 result.Put(SUPERVISED_USERS);
586 result.Put(SUPERVISED_USER_SETTINGS); 529 result.Put(SUPERVISED_USER_SETTINGS);
587 530
588 return result; 531 return result;
589 } 532 }
590 533
591 const char* ModelTypeToString(ModelType model_type) { 534 const char* ModelTypeToString(ModelType model_type) {
592 // This is used in serialization routines as well as for displaying debug 535 // This is used in serialization routines as well as for displaying debug
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 bool TypeSupportsHierarchy(ModelType model_type) { 716 bool TypeSupportsHierarchy(ModelType model_type) {
774 // TODO(stanisc): crbug/438313: Should this also include TOP_LEVEL_FOLDER? 717 // TODO(stanisc): crbug/438313: Should this also include TOP_LEVEL_FOLDER?
775 return model_type == BOOKMARKS; 718 return model_type == BOOKMARKS;
776 } 719 }
777 720
778 bool TypeSupportsOrdering(ModelType model_type) { 721 bool TypeSupportsOrdering(ModelType model_type) {
779 return model_type == BOOKMARKS; 722 return model_type == BOOKMARKS;
780 } 723 }
781 724
782 } // namespace syncer 725 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/driver/user_selectable_sync_type.h ('k') | components/sync/syncable/nigori_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698