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

Unified Diff: components/autofill/core/browser/webdata/autofill_change.cc

Issue 1110833002: [autofill] Sync server card and address metadata. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Class comment and one more expectation in test. Created 5 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/webdata/autofill_change.cc
diff --git a/components/autofill/core/browser/webdata/autofill_change.cc b/components/autofill/core/browser/webdata/autofill_change.cc
index c02bdd8464d8476d974f1cfd0a04e2c60f55af10..2d2ff6742b0a622c3ddf9702ea7be4414beb6244 100644
--- a/components/autofill/core/browser/webdata/autofill_change.cc
+++ b/components/autofill/core/browser/webdata/autofill_change.cc
@@ -17,13 +17,11 @@ AutofillChange::AutofillChange(Type type, const AutofillKey& key)
AutofillChange::~AutofillChange() {
}
-AutofillProfileChange::AutofillProfileChange(
- Type type, const std::string& key, const AutofillProfile* profile)
- : GenericAutofillChange<std::string>(type, key),
- profile_(profile) {
- DCHECK(type == ADD ? (profile && profile->guid() == key) : true);
- DCHECK(type == UPDATE ? (profile && profile->guid() == key) : true);
- DCHECK(type == REMOVE ? !profile : true);
+AutofillProfileChange::AutofillProfileChange(Type type,
+ const std::string& key,
+ const AutofillProfile* profile)
+ : GenericAutofillChange<std::string>(type, key), profile_(profile) {
+ DCHECK(type == REMOVE ? !profile : profile && profile->guid() == key);
}
AutofillProfileChange::~AutofillProfileChange() {
@@ -31,9 +29,23 @@ AutofillProfileChange::~AutofillProfileChange() {
bool AutofillProfileChange::operator==(
const AutofillProfileChange& change) const {
- return type() == change.type() &&
- key() == change.key() &&
- (type() != REMOVE) ? *profile() == *change.profile() : true;
+ return type() == change.type() && key() == change.key() &&
+ (type() == REMOVE || *profile() == *change.profile());
+}
+
+CreditCardChange::CreditCardChange(Type type,
+ const std::string& key,
+ const CreditCard* card)
+ : GenericAutofillChange<std::string>(type, key), card_(card) {
+ DCHECK(type == REMOVE ? !card : card && card->guid() == key);
+}
+
+CreditCardChange::~CreditCardChange() {
+}
+
+bool CreditCardChange::operator==(const CreditCardChange& change) const {
+ return type() == change.type() && key() == change.key() &&
+ (type() == REMOVE || *card() == *change.card());
}
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698