Skip to content

Commit

Permalink
Add UNSPECIFIED to UserConsent::ConsentStatus enum
Browse files Browse the repository at this point in the history
It is best practice to have UNSPECIFIED as first value in an enum for
consistent behavior between proto2 and proto3.
No one is sending these events yet, so changing the proto should
be fine.

Bug: 781765
Change-Id: I0b045b8654462f694620144a3f83817043c0e914
Reviewed-on: https://chromium-review.googlesource.com/848973
Reviewed-by: Sky Malice <skym@chromium.org>
Reviewed-by: Martin Šrámek <msramek@chromium.org>
Reviewed-by: Mikel Astiz <mastiz@chromium.org>
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#526941}
  • Loading branch information
xchrdw authored and Commit Bot committed Jan 4, 2018
1 parent bb53e83 commit 44643e3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components/consent_auditor/consent_auditor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ UserEventSpecifics::UserConsent::ConsentStatus ToProtoEnum(
return UserEventSpecifics::UserConsent::GIVEN;
}
NOTREACHED();
return UserEventSpecifics::UserConsent::GIVEN;
return UserEventSpecifics::UserConsent::UNSPECIFIED;
}

} // namespace
Expand Down
3 changes: 2 additions & 1 deletion components/sync/protocol/proto_enum_conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,9 @@ const char* ProtoEnumToString(
const char* ProtoEnumToString(
sync_pb::UserEventSpecifics::UserConsent::ConsentStatus status) {
ASSERT_ENUM_BOUNDS(sync_pb::UserEventSpecifics::UserConsent, ConsentStatus,
REVOKED, GIVEN);
UNSPECIFIED, GIVEN);
switch (status) {
ENUM_CASE(sync_pb::UserEventSpecifics::UserConsent, UNSPECIFIED);
ENUM_CASE(sync_pb::UserEventSpecifics::UserConsent, REVOKED);
ENUM_CASE(sync_pb::UserEventSpecifics::UserConsent, GIVEN);
}
Expand Down
5 changes: 3 additions & 2 deletions components/sync/protocol/user_event_specifics.proto
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ message UserEventSpecifics {
optional string locale = 4;
// Was the consent for |feature| given or revoked?
enum ConsentStatus {
REVOKED = 0;
GIVEN = 1;
UNSPECIFIED = 0;
REVOKED = 1;
GIVEN = 2;
}
optional ConsentStatus status = 5;
}
Expand Down

0 comments on commit 44643e3

Please sign in to comment.