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

Unified Diff: sync/internal_api/public/base/model_type.h

Issue 11490018: [Sync] Handle invalid specifics field numbers gracefully (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 side-by-side diff with in-line comments
Download patch
Index: sync/internal_api/public/base/model_type.h
diff --git a/sync/internal_api/public/base/model_type.h b/sync/internal_api/public/base/model_type.h
index 0585b7b0a407d37d9813920ae8df139f56bb4305..327d98015a3be44f35144ce3155b2851f8ec3761 100644
--- a/sync/internal_api/public/base/model_type.h
+++ b/sync/internal_api/public/base/model_type.h
@@ -160,7 +160,25 @@ ModelTypeSet ControlTypes();
bool IsControlType(ModelType model_type);
// Determine a model type from the field number of its associated
-// EntitySpecifics field.
+// EntitySpecifics field. Returns UNSPECIFIED if the field number is
+// not recognized.
+//
+// If you're putting the result in a ModelTypeSet, you should use the
+// following pattern:
+//
+// ModelTypeSet model_types;
+// // Say we're looping through a list of items, each of which has a
+// // field number.
+// for (...) {
+// int field_number = ...;
+// ModelType model_type =
+// GetModelTypeFromSpecificsFieldNumber(field_number);
+// if (!IsRealDataType(model_type)) {
+// NOTREACHED() << "Unknown field number " << field_number;
+// continue;
+// }
+// model_types.Put(model_type);
+// }
ModelType GetModelTypeFromSpecificsFieldNumber(int field_number);
// Return the field number of the EntitySpecifics field associated with

Powered by Google App Engine
This is Rietveld 408576698