Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 == ADD && profile && profile->guid() == key) || |
| 25 DCHECK(type == UPDATE ? (profile && profile->guid() == key) : true); | 25 (type == UPDATE && profile && profile->guid() == key) || |
| 26 DCHECK(type == REMOVE ? !profile : true); | 26 (type == REMOVE && !profile)); |
|
Peter Kasting
2015/05/20 23:11:21
Simpler:
DCHECK((type == REMOVE) ? !profile : (
please use gerrit instead
2015/05/21 00:13:48
That's a good one. I like that it's a one-liner.
| |
| 27 } | 27 } |
| 28 | 28 |
| 29 AutofillProfileChange::~AutofillProfileChange() { | 29 AutofillProfileChange::~AutofillProfileChange() { |
| 30 } | 30 } |
| 31 | 31 |
| 32 bool AutofillProfileChange::operator==( | 32 bool AutofillProfileChange::operator==( |
| 33 const AutofillProfileChange& change) const { | 33 const AutofillProfileChange& change) const { |
| 34 return type() == change.type() && | 34 return type() == change.type() && key() == change.key() && |
| 35 key() == change.key() && | 35 (type() == REMOVE || *profile() == *change.profile()); |
| 36 (type() != REMOVE) ? *profile() == *change.profile() : true; | 36 } |
| 37 | |
| 38 CreditCardChange::CreditCardChange(Type type, | |
| 39 const std::string& key, | |
| 40 const CreditCard* card) | |
| 41 : GenericAutofillChange<std::string>(type, key), card_(card) { | |
| 42 DCHECK((type == ADD && card && card->guid() == key) || | |
| 43 (type == UPDATE && card && card->guid() == key) || | |
| 44 (type == REMOVE && !card)); | |
|
Peter Kasting
2015/05/20 23:11:21
Simpler:
DCHECK((type == REMOVE) ? !card : (car
please use gerrit instead
2015/05/21 00:13:48
Ditto.
| |
| 45 } | |
| 46 | |
| 47 CreditCardChange::~CreditCardChange() { | |
| 48 } | |
| 49 | |
| 50 bool CreditCardChange::operator==(const CreditCardChange& change) const { | |
| 51 return type() == change.type() && key() == change.key() && | |
| 52 (type() == REMOVE || *card() == *change.card()); | |
| 37 } | 53 } |
| 38 | 54 |
| 39 } // namespace autofill | 55 } // namespace autofill |
| OLD | NEW |