Commit 0823526b authored by Rouslan Solomakhin's avatar Rouslan Solomakhin Committed by Commit Bot

[Payment Request] Enable Jumbo build

Speed up builds in /components/payments with "use_jumbo_build = true"
setting in GN args.

Bug: NONE
Change-Id: I18890875b46450dde461e126573e44958e6ac7d9
Reviewed-on: https://chromium-review.googlesource.com/1180555
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Reviewed-by: default avatarGanggui Tang <gogerald@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584321}
parent e57c623d
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
static_library("content") { import("//build/config/jumbo.gni")
jumbo_static_library("content") {
sources = [ sources = [
"can_make_payment_query_factory.cc", "can_make_payment_query_factory.cc",
"can_make_payment_query_factory.h", "can_make_payment_query_factory.h",
...@@ -45,7 +47,7 @@ static_library("content") { ...@@ -45,7 +47,7 @@ static_library("content") {
} }
# Files used by content and utility. # Files used by content and utility.
static_library("content_common") { jumbo_static_library("content_common") {
sources = [ sources = [
"web_app_manifest.cc", "web_app_manifest.cc",
"web_app_manifest.h", "web_app_manifest.h",
...@@ -56,7 +58,7 @@ static_library("content_common") { ...@@ -56,7 +58,7 @@ static_library("content_common") {
] ]
} }
static_library("utils") { jumbo_static_library("utils") {
sources = [ sources = [
"installable_payment_app_crawler.cc", "installable_payment_app_crawler.cc",
"installable_payment_app_crawler.h", "installable_payment_app_crawler.h",
...@@ -94,7 +96,7 @@ static_library("utils") { ...@@ -94,7 +96,7 @@ static_library("utils") {
] ]
} }
source_set("unit_tests") { jumbo_source_set("unit_tests") {
testonly = true testonly = true
sources = [ sources = [
"payment_method_manifest_table_unittest.cc", "payment_method_manifest_table_unittest.cc",
......
...@@ -16,9 +16,9 @@ namespace payments { ...@@ -16,9 +16,9 @@ namespace payments {
namespace { namespace {
// Data valid duration in seconds. // Data valid duration in seconds.
const time_t DATA_VALID_TIME_IN_SECONDS = 90 * 24 * 60 * 60; const time_t PAYMENT_METHOD_MANIFEST_VALID_TIME_IN_SECONDS = 90 * 24 * 60 * 60;
WebDatabaseTable::TypeKey GetKey() { WebDatabaseTable::TypeKey GetPaymentMethodManifestKey() {
// We just need a unique constant. Use the address of a static that // We just need a unique constant. Use the address of a static that
// COMDAT folding won't touch in an optimizing linker. // COMDAT folding won't touch in an optimizing linker.
static int table_key = 0; static int table_key = 0;
...@@ -33,11 +33,12 @@ PaymentMethodManifestTable::~PaymentMethodManifestTable() {} ...@@ -33,11 +33,12 @@ PaymentMethodManifestTable::~PaymentMethodManifestTable() {}
PaymentMethodManifestTable* PaymentMethodManifestTable::FromWebDatabase( PaymentMethodManifestTable* PaymentMethodManifestTable::FromWebDatabase(
WebDatabase* db) { WebDatabase* db) {
return static_cast<PaymentMethodManifestTable*>(db->GetTable(GetKey())); return static_cast<PaymentMethodManifestTable*>(
db->GetTable(GetPaymentMethodManifestKey()));
} }
WebDatabaseTable::TypeKey PaymentMethodManifestTable::GetTypeKey() const { WebDatabaseTable::TypeKey PaymentMethodManifestTable::GetTypeKey() const {
return GetKey(); return GetPaymentMethodManifestKey();
} }
bool PaymentMethodManifestTable::CreateTablesIfNecessary() { bool PaymentMethodManifestTable::CreateTablesIfNecessary() {
...@@ -88,7 +89,8 @@ bool PaymentMethodManifestTable::AddManifest( ...@@ -88,7 +89,8 @@ bool PaymentMethodManifestTable::AddManifest(
"(expire_date, method_name, web_app_id) " "(expire_date, method_name, web_app_id) "
"VALUES (?, ?, ?) ")); "VALUES (?, ?, ?) "));
const time_t expire_date_in_seconds = const time_t expire_date_in_seconds =
base::Time::NowFromSystemTime().ToTimeT() + DATA_VALID_TIME_IN_SECONDS; base::Time::NowFromSystemTime().ToTimeT() +
PAYMENT_METHOD_MANIFEST_VALID_TIME_IN_SECONDS;
for (const auto& id : web_app_ids) { for (const auto& id : web_app_ids) {
int index = 0; int index = 0;
s2.BindInt64(index++, expire_date_in_seconds); s2.BindInt64(index++, expire_date_in_seconds);
......
...@@ -18,12 +18,12 @@ namespace payments { ...@@ -18,12 +18,12 @@ namespace payments {
namespace { namespace {
// Data valid duration in seconds. // Data valid duration in seconds.
const time_t DATA_VALID_TIME_IN_SECONDS = 90 * 24 * 60 * 60; const time_t WEB_APP_MANIFEST_VALID_TIME_IN_SECONDS = 90 * 24 * 60 * 60;
// Note that the fingerprint is calculated with SHA-256. // Note that the fingerprint is calculated with SHA-256.
const size_t kFingerPrintLength = 32; const size_t kFingerPrintLength = 32;
WebDatabaseTable::TypeKey GetKey() { WebDatabaseTable::TypeKey GetWebAppManifestKey() {
// We just need a unique constant. Use the address of a static that // We just need a unique constant. Use the address of a static that
// COMDAT folding won't touch in an optimizing linker. // COMDAT folding won't touch in an optimizing linker.
static int table_key = 0; static int table_key = 0;
...@@ -69,11 +69,12 @@ WebAppManifestSectionTable::~WebAppManifestSectionTable() {} ...@@ -69,11 +69,12 @@ WebAppManifestSectionTable::~WebAppManifestSectionTable() {}
WebAppManifestSectionTable* WebAppManifestSectionTable::FromWebDatabase( WebAppManifestSectionTable* WebAppManifestSectionTable::FromWebDatabase(
WebDatabase* db) { WebDatabase* db) {
return static_cast<WebAppManifestSectionTable*>(db->GetTable(GetKey())); return static_cast<WebAppManifestSectionTable*>(
db->GetTable(GetWebAppManifestKey()));
} }
WebDatabaseTable::TypeKey WebAppManifestSectionTable::GetTypeKey() const { WebDatabaseTable::TypeKey WebAppManifestSectionTable::GetTypeKey() const {
return GetKey(); return GetWebAppManifestKey();
} }
bool WebAppManifestSectionTable::CreateTablesIfNecessary() { bool WebAppManifestSectionTable::CreateTablesIfNecessary() {
...@@ -129,7 +130,8 @@ bool WebAppManifestSectionTable::AddWebAppManifest( ...@@ -129,7 +130,8 @@ bool WebAppManifestSectionTable::AddWebAppManifest(
"(expire_date, id, min_version, fingerprints) " "(expire_date, id, min_version, fingerprints) "
"VALUES (?, ?, ?, ?)")); "VALUES (?, ?, ?, ?)"));
const time_t expire_date_in_seconds = const time_t expire_date_in_seconds =
base::Time::NowFromSystemTime().ToTimeT() + DATA_VALID_TIME_IN_SECONDS; base::Time::NowFromSystemTime().ToTimeT() +
WEB_APP_MANIFEST_VALID_TIME_IN_SECONDS;
for (const auto& section : manifest) { for (const auto& section : manifest) {
int index = 0; int index = 0;
s2.BindInt64(index++, expire_date_in_seconds); s2.BindInt64(index++, expire_date_in_seconds);
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
static_library("core") { import("//build/config/jumbo.gni")
jumbo_static_library("core") {
sources = [ sources = [
"autofill_payment_instrument.cc", "autofill_payment_instrument.cc",
"autofill_payment_instrument.h", "autofill_payment_instrument.h",
...@@ -82,7 +84,7 @@ static_library("core") { ...@@ -82,7 +84,7 @@ static_library("core") {
] ]
} }
static_library("test_support") { jumbo_static_library("test_support") {
testonly = true testonly = true
sources = [ sources = [
"payments_test_util.cc", "payments_test_util.cc",
...@@ -106,7 +108,7 @@ static_library("test_support") { ...@@ -106,7 +108,7 @@ static_library("test_support") {
] ]
} }
source_set("unit_tests") { jumbo_source_set("unit_tests") {
testonly = true testonly = true
sources = [ sources = [
"autofill_payment_instrument_unittest.cc", "autofill_payment_instrument_unittest.cc",
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
namespace payments { namespace payments {
namespace { namespace {
struct TestCase { struct QueryTestCase {
TestCase(const char* first_origin, QueryTestCase(const char* first_origin,
const char* second_origin, const char* second_origin,
bool expected_second_origin_different_query_allowed) bool expected_second_origin_different_query_allowed)
: first_origin(first_origin), : first_origin(first_origin),
...@@ -20,14 +20,14 @@ struct TestCase { ...@@ -20,14 +20,14 @@ struct TestCase {
expected_second_origin_different_query_allowed( expected_second_origin_different_query_allowed(
expected_second_origin_different_query_allowed) {} expected_second_origin_different_query_allowed) {}
~TestCase() {} ~QueryTestCase() {}
const char* const first_origin; const char* const first_origin;
const char* const second_origin; const char* const second_origin;
const bool expected_second_origin_different_query_allowed; const bool expected_second_origin_different_query_allowed;
}; };
class CanMakePaymentQueryTest : public ::testing::TestWithParam<TestCase> { class CanMakePaymentQueryTest : public ::testing::TestWithParam<QueryTestCase> {
private: private:
base::MessageLoop message_loop_; base::MessageLoop message_loop_;
}; };
...@@ -50,17 +50,21 @@ INSTANTIATE_TEST_CASE_P( ...@@ -50,17 +50,21 @@ INSTANTIATE_TEST_CASE_P(
Denied, Denied,
CanMakePaymentQueryTest, CanMakePaymentQueryTest,
testing::Values( testing::Values(
TestCase("https://example.com", "https://example.com", false), QueryTestCase("https://example.com", "https://example.com", false),
TestCase("http://localhost", "http://localhost", false), QueryTestCase("http://localhost", "http://localhost", false),
TestCase("file:///tmp/test.html", "file:///tmp/test.html", false))); QueryTestCase("file:///tmp/test.html",
"file:///tmp/test.html",
false)));
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
Allowed, Allowed,
CanMakePaymentQueryTest, CanMakePaymentQueryTest,
testing::Values( testing::Values(
TestCase("https://example.com", "https://not-example.com", true), QueryTestCase("https://example.com", "https://not-example.com", true),
TestCase("http://localhost", "http://not-localhost", true), QueryTestCase("http://localhost", "http://not-localhost", true),
TestCase("file:///tmp/test.html", "file:///tmp/not-test.html", true))); QueryTestCase("file:///tmp/test.html",
"file:///tmp/not-test.html",
true)));
} // namespace } // namespace
} // namespace payments } // namespace payments
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
namespace payments { namespace payments {
namespace { namespace {
struct TestCase { struct CurrencyTestCase {
TestCase(const char* amount, CurrencyTestCase(const char* amount,
const char* currency_code, const char* currency_code,
const char* locale_name, const char* locale_name,
const std::string& expected_amount, const std::string& expected_amount,
...@@ -22,7 +22,7 @@ struct TestCase { ...@@ -22,7 +22,7 @@ struct TestCase {
locale_name(locale_name), locale_name(locale_name),
expected_amount(expected_amount), expected_amount(expected_amount),
expected_currency_code(expected_currency_code) {} expected_currency_code(expected_currency_code) {}
~TestCase() {} ~CurrencyTestCase() {}
const char* const amount; const char* const amount;
const char* const currency_code; const char* const currency_code;
...@@ -31,12 +31,11 @@ struct TestCase { ...@@ -31,12 +31,11 @@ struct TestCase {
const char* const expected_currency_code; const char* const expected_currency_code;
}; };
class PaymentsCurrencyFormatterTest : public testing::TestWithParam<TestCase> { class PaymentsCurrencyFormatterTest
}; : public testing::TestWithParam<CurrencyTestCase> {};
TEST_P(PaymentsCurrencyFormatterTest, IsValidCurrencyFormat) { TEST_P(PaymentsCurrencyFormatterTest, IsValidCurrencyFormat) {
CurrencyFormatter formatter(GetParam().currency_code, CurrencyFormatter formatter(GetParam().currency_code, GetParam().locale_name);
GetParam().locale_name);
base::string16 output_amount = formatter.Format(GetParam().amount); base::string16 output_amount = formatter.Format(GetParam().amount);
// Convenience so the test cases can use regular spaces. // Convenience so the test cases can use regular spaces.
...@@ -57,74 +56,82 @@ INSTANTIATE_TEST_CASE_P( ...@@ -57,74 +56,82 @@ INSTANTIATE_TEST_CASE_P(
CurrencyAmounts, CurrencyAmounts,
PaymentsCurrencyFormatterTest, PaymentsCurrencyFormatterTest,
testing::Values( testing::Values(
TestCase("55.00", "USD", "en_US", "$55.00", "USD"), CurrencyTestCase("55.00", "USD", "en_US", "$55.00", "USD"),
TestCase("55.00", "USD", "en_CA", "$55.00", "USD"), CurrencyTestCase("55.00", "USD", "en_CA", "$55.00", "USD"),
TestCase("55.00", "USD", "fr_CA", "55,00 $", "USD"), CurrencyTestCase("55.00", "USD", "fr_CA", "55,00 $", "USD"),
TestCase("55.00", "USD", "fr_FR", "55,00 $", "USD"), CurrencyTestCase("55.00", "USD", "fr_FR", "55,00 $", "USD"),
TestCase("1234", "USD", "fr_FR", "1 234,00 $", "USD"), CurrencyTestCase("1234", "USD", "fr_FR", "1 234,00 $", "USD"),
// Known oddity about the en_AU formatting in ICU. It will strip the // Known oddity about the en_AU formatting in ICU. It will strip the
// currency symbol in non-AUD currencies. Useful to document in tests. // currency symbol in non-AUD currencies. Useful to document in tests.
// See crbug.com/739812. // See crbug.com/739812.
TestCase("55.00", "AUD", "en_AU", "$55.00", "AUD"), CurrencyTestCase("55.00", "AUD", "en_AU", "$55.00", "AUD"),
TestCase("55.00", "USD", "en_AU", "55.00", "USD"), CurrencyTestCase("55.00", "USD", "en_AU", "55.00", "USD"),
TestCase("55.00", "CAD", "en_AU", "55.00", "CAD"), CurrencyTestCase("55.00", "CAD", "en_AU", "55.00", "CAD"),
TestCase("55.00", "JPY", "en_AU", "55", "JPY"), CurrencyTestCase("55.00", "JPY", "en_AU", "55", "JPY"),
TestCase("-55.00", "USD", "en_AU", "-55.00", "USD"), CurrencyTestCase("-55.00", "USD", "en_AU", "-55.00", "USD"),
TestCase("55.5", "USD", "en_US", "$55.50", "USD"), CurrencyTestCase("55.5", "USD", "en_US", "$55.50", "USD"),
TestCase("55", "USD", "en_US", "$55.00", "USD"), CurrencyTestCase("55", "USD", "en_US", "$55.00", "USD"),
TestCase("123", "USD", "en_US", "$123.00", "USD"), CurrencyTestCase("123", "USD", "en_US", "$123.00", "USD"),
TestCase("1234", "USD", "en_US", "$1,234.00", "USD"), CurrencyTestCase("1234", "USD", "en_US", "$1,234.00", "USD"),
TestCase("0.1234", "USD", "en_US", "$0.1234", "USD"), CurrencyTestCase("0.1234", "USD", "en_US", "$0.1234", "USD"),
TestCase("55.00", "EUR", "en_US", "€55.00", "EUR"), CurrencyTestCase("55.00", "EUR", "en_US", "€55.00", "EUR"),
TestCase("55.00", "EUR", "fr_CA", "55,00 €", "EUR"), CurrencyTestCase("55.00", "EUR", "fr_CA", "55,00 €", "EUR"),
TestCase("55.00", "EUR", "fr_FR", "55,00 €", "EUR"), CurrencyTestCase("55.00", "EUR", "fr_FR", "55,00 €", "EUR"),
TestCase("55.00", "CAD", "en_US", "$55.00", "CAD"), CurrencyTestCase("55.00", "CAD", "en_US", "$55.00", "CAD"),
TestCase("55.00", "CAD", "en_CA", "$55.00", "CAD"), CurrencyTestCase("55.00", "CAD", "en_CA", "$55.00", "CAD"),
TestCase("55.00", "CAD", "fr_CA", "55,00 $", "CAD"), CurrencyTestCase("55.00", "CAD", "fr_CA", "55,00 $", "CAD"),
TestCase("55.00", "CAD", "fr_FR", "55,00 $", "CAD"), CurrencyTestCase("55.00", "CAD", "fr_FR", "55,00 $", "CAD"),
TestCase("55.00", "AUD", "en_US", "$55.00", "AUD"), CurrencyTestCase("55.00", "AUD", "en_US", "$55.00", "AUD"),
TestCase("55.00", "AUD", "en_CA", "$55.00", "AUD"), CurrencyTestCase("55.00", "AUD", "en_CA", "$55.00", "AUD"),
TestCase("55.00", "AUD", "fr_CA", "55,00 $", "AUD"), CurrencyTestCase("55.00", "AUD", "fr_CA", "55,00 $", "AUD"),
TestCase("55.00", "AUD", "fr_FR", "55,00 $", "AUD"), CurrencyTestCase("55.00", "AUD", "fr_FR", "55,00 $", "AUD"),
TestCase("55.00", "BRL", "en_US", "R$55.00", "BRL"), CurrencyTestCase("55.00", "BRL", "en_US", "R$55.00", "BRL"),
TestCase("55.00", "BRL", "fr_CA", "55,00 R$", "BRL"), CurrencyTestCase("55.00", "BRL", "fr_CA", "55,00 R$", "BRL"),
TestCase("55.00", "BRL", "pt_BR", "R$ 55,00", "BRL"), CurrencyTestCase("55.00", "BRL", "pt_BR", "R$ 55,00", "BRL"),
TestCase("55.00", "RUB", "en_US", "55.00", "RUB"), CurrencyTestCase("55.00", "RUB", "en_US", "55.00", "RUB"),
TestCase("55.00", "RUB", "fr_CA", "55,00", "RUB"), CurrencyTestCase("55.00", "RUB", "fr_CA", "55,00", "RUB"),
TestCase("55.00", "RUB", "ru_RU", "55,00 ₽", "RUB"), CurrencyTestCase("55.00", "RUB", "ru_RU", "55,00 ₽", "RUB"),
TestCase("55", "JPY", "ja_JP", "¥55", "JPY"), CurrencyTestCase("55", "JPY", "ja_JP", "¥55", "JPY"),
TestCase("55.0", "JPY", "ja_JP", "¥55", "JPY"), CurrencyTestCase("55.0", "JPY", "ja_JP", "¥55", "JPY"),
TestCase("55.00", "JPY", "ja_JP", "¥55", "JPY"), CurrencyTestCase("55.00", "JPY", "ja_JP", "¥55", "JPY"),
TestCase("55.12", "JPY", "ja_JP", "¥55.12", "JPY"), CurrencyTestCase("55.12", "JPY", "ja_JP", "¥55.12", "JPY"),
TestCase("55.49", "JPY", "ja_JP", "¥55.49", "JPY"), CurrencyTestCase("55.49", "JPY", "ja_JP", "¥55.49", "JPY"),
TestCase("55.50", "JPY", "ja_JP", "¥55.5", "JPY"), CurrencyTestCase("55.50", "JPY", "ja_JP", "¥55.5", "JPY"),
TestCase("55.9999", "JPY", "ja_JP", "¥55.9999", "JPY"), CurrencyTestCase("55.9999", "JPY", "ja_JP", "¥55.9999", "JPY"),
// Unofficial ISO 4217 currency code. // Unofficial ISO 4217 currency code.
TestCase("55.00", "BTC", "en_US", "55.00", "BTC"), CurrencyTestCase("55.00", "BTC", "en_US", "55.00", "BTC"),
TestCase("-0.0000000001", "BTC", "en_US", "-0.0000000001", "BTC"), CurrencyTestCase("-0.0000000001",
TestCase("-55.00", "BTC", "fr_FR", "-55,00", "BTC"), "BTC",
"en_US",
"-0.0000000001",
"BTC"),
CurrencyTestCase("-55.00", "BTC", "fr_FR", "-55,00", "BTC"),
// Any string of at most 2048 characters can be a valid currency code. // Any string of at most 2048 characters can be a valid currency code.
TestCase("55.00", "", "en_US", "55.00", ""), CurrencyTestCase("55.00", "", "en_US", "55.00", ""),
TestCase("55,00", "", "fr_CA", "55,00", ""), CurrencyTestCase("55,00", "", "fr_CA", "55,00", ""),
TestCase("55,00", "", "fr-CA", "55,00", ""), CurrencyTestCase("55,00", "", "fr-CA", "55,00", ""),
TestCase("55.00", "ABCDEF", "en_US", "55.00", "ABCDE\xE2\x80\xA6"), CurrencyTestCase("55.00",
"ABCDEF",
"en_US",
"55.00",
"ABCDE\xE2\x80\xA6"),
// Edge cases. // Edge cases.
TestCase("", "", "", "", ""), CurrencyTestCase("", "", "", "", ""),
TestCase("-1", "", "", "-1.00", ""), CurrencyTestCase("-1", "", "", "-1.00", ""),
TestCase("-1.1255", "", "", "-1.1255", ""), CurrencyTestCase("-1.1255", "", "", "-1.1255", ""),
// Handles big numbers. // Handles big numbers.
TestCase( CurrencyTestCase(
"123456789012345678901234567890.123456789012345678901234567890", "123456789012345678901234567890.123456789012345678901234567890",
"USD", "USD",
"fr_FR", "fr_FR",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment