| Index: components/payments/android/payment_method_manifest_table.cc
|
| diff --git a/components/payments/android/payment_method_manifest_table.cc b/components/payments/android/payment_method_manifest_table.cc
|
| index 8e7ac7f3d864516e3e0da6728e250fc8995d2f92..1c79556ed585be1a860027ccba7393fdee46959d 100644
|
| --- a/components/payments/android/payment_method_manifest_table.cc
|
| +++ b/components/payments/android/payment_method_manifest_table.cc
|
| @@ -4,11 +4,17 @@
|
|
|
| #include "components/payments/android/payment_method_manifest_table.h"
|
|
|
| +#include <time.h>
|
| +
|
| +#include "base/time/time.h"
|
| #include "sql/statement.h"
|
| #include "sql/transaction.h"
|
|
|
| namespace payments {
|
| namespace {
|
| +// Data valid duration in seconds.
|
| +const time_t DATA_VALID_TIME_IN_SECONDS = 90 * 24 * 60 * 60;
|
| +
|
| WebDatabaseTable::TypeKey GetKey() {
|
| // We just need a unique constant. Use the address of a static that
|
| // COMDAT folding won't touch in an optimizing linker.
|
| @@ -32,6 +38,7 @@ WebDatabaseTable::TypeKey PaymentMethodManifestTable::GetTypeKey() const {
|
|
|
| bool PaymentMethodManifestTable::CreateTablesIfNecessary() {
|
| if (!db_->Execute("CREATE TABLE IF NOT EXISTS payment_method_manifest ( "
|
| + "expire_date INTEGER NOT NULL DEFAULT 0, "
|
| "method_name VARCHAR, "
|
| "web_app_id VARCHAR) ")) {
|
| NOTREACHED();
|
| @@ -51,6 +58,14 @@ bool PaymentMethodManifestTable::MigrateToVersion(
|
| return true;
|
| }
|
|
|
| +void PaymentMethodManifestTable::RemoveExpiredData() {
|
| + const time_t now_date_in_seconds = base::Time::NowFromSystemTime().ToTimeT();
|
| + sql::Statement s(db_->GetUniqueStatement(
|
| + "DELETE FROM payment_method_manifest WHERE expire_date < ? "));
|
| + s.BindInt64(0, now_date_in_seconds);
|
| + s.Run();
|
| +}
|
| +
|
| bool PaymentMethodManifestTable::AddManifest(
|
| const std::string& payment_method,
|
| const std::vector<std::string>& web_app_ids) {
|
| @@ -66,10 +81,13 @@ bool PaymentMethodManifestTable::AddManifest(
|
|
|
| sql::Statement s2(
|
| db_->GetUniqueStatement("INSERT INTO payment_method_manifest "
|
| - "(method_name, web_app_id) "
|
| - "VALUES (?, ?) "));
|
| + "(expire_date, method_name, web_app_id) "
|
| + "VALUES (?, ?, ?) "));
|
| + const time_t expire_date_in_seconds =
|
| + base::Time::NowFromSystemTime().ToTimeT() + DATA_VALID_TIME_IN_SECONDS;
|
| for (const auto& id : web_app_ids) {
|
| int index = 0;
|
| + s2.BindInt64(index++, expire_date_in_seconds);
|
| s2.BindString(index++, payment_method);
|
| s2.BindString(index, id);
|
| if (!s2.Run())
|
|
|