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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/autofill/core/browser/webdata/autofill_change.h" 5 #include "components/autofill/core/browser/webdata/autofill_change.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "components/autofill/core/browser/autofill_profile.h" 8 #include "components/autofill/core/browser/autofill_profile.h"
9 #include "components/autofill/core/browser/credit_card.h" 9 #include "components/autofill/core/browser/credit_card.h"
10 10
11 namespace autofill { 11 namespace autofill {
12 12
13 AutofillChange::AutofillChange(Type type, const AutofillKey& key) 13 AutofillChange::AutofillChange(Type type, const AutofillKey& key)
14 : GenericAutofillChange<AutofillKey>(type, key) { 14 : GenericAutofillChange<AutofillKey>(type, key) {
15 } 15 }
16 16
17 AutofillChange::~AutofillChange() { 17 AutofillChange::~AutofillChange() {
18 } 18 }
19 19
20 AutofillProfileChange::AutofillProfileChange( 20 AutofillProfileChange::AutofillProfileChange(Type type,
21 Type type, const std::string& key, const AutofillProfile* profile) 21 const std::string& key,
22 : GenericAutofillChange<std::string>(type, key), 22 const AutofillProfile* profile)
23 profile_(profile) { 23 : GenericAutofillChange<std::string>(type, key), profile_(profile) {
24 DCHECK(type == ADD ? (profile && profile->guid() == key) : true); 24 DCHECK(type == REMOVE ? !profile : profile && profile->guid() == key);
25 DCHECK(type == UPDATE ? (profile && profile->guid() == key) : true);
26 DCHECK(type == REMOVE ? !profile : true);
27 } 25 }
28 26
29 AutofillProfileChange::~AutofillProfileChange() { 27 AutofillProfileChange::~AutofillProfileChange() {
30 } 28 }
31 29
32 bool AutofillProfileChange::operator==( 30 bool AutofillProfileChange::operator==(
33 const AutofillProfileChange& change) const { 31 const AutofillProfileChange& change) const {
34 return type() == change.type() && 32 return type() == change.type() && key() == change.key() &&
35 key() == change.key() && 33 (type() == REMOVE || *profile() == *change.profile());
36 (type() != REMOVE) ? *profile() == *change.profile() : true; 34 }
35
36 CreditCardChange::CreditCardChange(Type type,
37 const std::string& key,
38 const CreditCard* card)
39 : GenericAutofillChange<std::string>(type, key), card_(card) {
40 DCHECK(type == REMOVE ? !card : card && card->guid() == key);
41 }
42
43 CreditCardChange::~CreditCardChange() {
44 }
45
46 bool CreditCardChange::operator==(const CreditCardChange& change) const {
47 return type() == change.type() && key() == change.key() &&
48 (type() == REMOVE || *card() == *change.card());
37 } 49 }
38 50
39 } // namespace autofill 51 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698