Skip to content

Commit

Permalink
[Payments] Properly clear PaymentsCustomerData
Browse files Browse the repository at this point in the history
In this change we properly clear PaymentsCustomerData from disk and
update several sync integration tests to take this into account.

Bug: 884689
Test: sync_integration_tests, components_unittests
Change-Id: I851d17fc0d0f1e02817e73d94e6cb7cf8341d6ae
Reviewed-on: https://chromium-review.googlesource.com/c/1256283
Commit-Queue: Mathieu Perreault <mathp@chromium.org>
Reviewed-by: Sebastien Seguin-Gagnon <sebsg@chromium.org>
Reviewed-by: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596645}
  • Loading branch information
Mathieu Perreault authored and Commit Bot committed Oct 4, 2018
1 parent 0aea215 commit 0065d50
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 68 deletions.
19 changes: 19 additions & 0 deletions chrome/browser/sync/test/integration/autofill_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "components/autofill/core/browser/autofill_profile.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/payments/payments_customer_data.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/webdata/autofill_entry.h"
#include "components/autofill/core/browser/webdata/autofill_table.h"
Expand Down Expand Up @@ -126,6 +127,14 @@ void SetServerProfilesOnDBSequence(
->SetServerProfiles(profiles);
}

void SetPaymentsCustomerDataOnDBSequence(
AutofillWebDataService* wds,
const autofill::PaymentsCustomerData& customer_data) {
DCHECK(wds->GetDBTaskRunner()->RunsTasksInCurrentSequence());
AutofillTable::FromWebDatabase(wds->GetDatabase())
->SetPaymentsCustomerData(&customer_data);
}

bool ProfilesMatchImpl(
int profile_a,
const std::vector<AutofillProfile*>& autofill_profiles_a,
Expand Down Expand Up @@ -319,6 +328,16 @@ void SetServerProfiles(int profile,
WaitForCurrentTasksToComplete(wds->GetDBTaskRunner());
}

void SetPaymentsCustomerData(
int profile,
const autofill::PaymentsCustomerData& customer_data) {
scoped_refptr<AutofillWebDataService> wds = GetProfileWebDataService(profile);
wds->GetDBTaskRunner()->PostTask(
FROM_HERE, base::BindOnce(&SetPaymentsCustomerDataOnDBSequence,
base::Unretained(wds.get()), customer_data));
WaitForCurrentTasksToComplete(wds->GetDBTaskRunner());
}

void AddProfile(int profile, const AutofillProfile& autofill_profile) {
std::vector<AutofillProfile> autofill_profiles;
for (AutofillProfile* profile : GetAllAutoFillProfiles(profile)) {
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/sync/test/integration/autofill_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class AutofillProfile;
class AutofillType;
class AutofillWebDataService;
class CreditCard;
struct PaymentsCustomerData;
class PersonalDataManager;
} // namespace autofill

Expand Down Expand Up @@ -82,6 +83,10 @@ void SetServerCreditCards(
void SetServerProfiles(int profile,
const std::vector<autofill::AutofillProfile>& profiles);

void SetPaymentsCustomerData(
int profile,
const autofill::PaymentsCustomerData& customer_data);

// Adds the autofill profile |autofill_profile| to sync profile |profile|.
void AddProfile(int profile, const autofill::AutofillProfile& autofill_profile);

Expand Down
Loading

0 comments on commit 0065d50

Please sign in to comment.