diff --git a/browser/brave_ads/ads_service_browsertest.cc b/browser/brave_ads/ads_service_browsertest.cc index 0daf93015a0e..7a29d095aebd 100644 --- a/browser/brave_ads/ads_service_browsertest.cc +++ b/browser/brave_ads/ads_service_browsertest.cc @@ -3,7 +3,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include #include #include #include @@ -406,28 +405,28 @@ IN_PROC_BROWSER_TEST_F(BraveAdsBrowserTest, PRE_BraveAdsMigrateDefaultAdsPerHourFromVersion9) { GetPrefs()->SetInteger(brave_ads::prefs::kVersion, 9); - GetPrefs()->SetInteger(ads::prefs::kAdsPerHour, -1); + GetPrefs()->SetInt64(ads::prefs::kAdsPerHour, -1); ASSERT_TRUE(GetPrefs()->HasPrefPath(ads::prefs::kAdsPerHour)); } IN_PROC_BROWSER_TEST_F(BraveAdsBrowserTest, BraveAdsMigrateDefaultAdsPerHourFromVersion9) { EXPECT_FALSE(GetPrefs()->HasPrefPath(ads::prefs::kAdsPerHour)); - EXPECT_EQ(-1, GetPrefs()->GetInteger(ads::prefs::kAdsPerHour)); + EXPECT_EQ(-1, GetPrefs()->GetInt64(ads::prefs::kAdsPerHour)); } IN_PROC_BROWSER_TEST_F(BraveAdsBrowserTest, PRE_BraveAdsMigrateLegacyDefaultPerHourFromVersion9) { GetPrefs()->SetInteger(brave_ads::prefs::kVersion, 9); - GetPrefs()->SetInteger(ads::prefs::kAdsPerHour, 2); + GetPrefs()->SetInt64(ads::prefs::kAdsPerHour, 2); ASSERT_TRUE(GetPrefs()->HasPrefPath(ads::prefs::kAdsPerHour)); } IN_PROC_BROWSER_TEST_F(BraveAdsBrowserTest, BraveAdsMigrateLegacyDefaultPerHourFromVersion9) { EXPECT_FALSE(GetPrefs()->HasPrefPath(ads::prefs::kAdsPerHour)); - EXPECT_EQ(-1, GetPrefs()->GetInteger(ads::prefs::kAdsPerHour)); + EXPECT_EQ(-1, GetPrefs()->GetInt64(ads::prefs::kAdsPerHour)); } IN_PROC_BROWSER_TEST_F( @@ -441,7 +440,7 @@ IN_PROC_BROWSER_TEST_F( IN_PROC_BROWSER_TEST_F(BraveAdsBrowserTest, BraveAdsMigrateAdsPerHourForFreshInstallFromVersion9) { EXPECT_FALSE(GetPrefs()->HasPrefPath(ads::prefs::kAdsPerHour)); - EXPECT_EQ(-1, GetPrefs()->GetInteger(ads::prefs::kAdsPerHour)); + EXPECT_EQ(-1, GetPrefs()->GetInt64(ads::prefs::kAdsPerHour)); } IN_PROC_BROWSER_TEST_F( @@ -449,28 +448,28 @@ IN_PROC_BROWSER_TEST_F( PRE_BraveAdsMigrateAdsPerHourForIssue17155FromVersion10) { GetPrefs()->SetInteger(brave_ads::prefs::kVersion, 10); - GetPrefs()->SetInteger(ads::prefs::kAdsPerHour, 0); + GetPrefs()->SetInt64(ads::prefs::kAdsPerHour, 0); ASSERT_TRUE(GetPrefs()->HasPrefPath(ads::prefs::kAdsPerHour)); } IN_PROC_BROWSER_TEST_F(BraveAdsBrowserTest, BraveAdsMigrateAdsPerHourForIssue17155FromVersion10) { EXPECT_FALSE(GetPrefs()->HasPrefPath(ads::prefs::kAdsPerHour)); - EXPECT_EQ(-1, GetPrefs()->GetInteger(ads::prefs::kAdsPerHour)); + EXPECT_EQ(-1, GetPrefs()->GetInt64(ads::prefs::kAdsPerHour)); } IN_PROC_BROWSER_TEST_F(BraveAdsBrowserTest, PRE_BraveAdsMigrateDefaultAdsPerHourFromVersion10) { GetPrefs()->SetInteger(brave_ads::prefs::kVersion, 10); - GetPrefs()->SetInteger(ads::prefs::kAdsPerHour, -1); + GetPrefs()->SetInt64(ads::prefs::kAdsPerHour, -1); ASSERT_TRUE(GetPrefs()->HasPrefPath(ads::prefs::kAdsPerHour)); } IN_PROC_BROWSER_TEST_F(BraveAdsBrowserTest, BraveAdsMigrateDefaultAdsPerHourFromVersion10) { EXPECT_FALSE(GetPrefs()->HasPrefPath(ads::prefs::kAdsPerHour)); - EXPECT_EQ(-1, GetPrefs()->GetInteger(ads::prefs::kAdsPerHour)); + EXPECT_EQ(-1, GetPrefs()->GetInt64(ads::prefs::kAdsPerHour)); } IN_PROC_BROWSER_TEST_F( @@ -484,7 +483,7 @@ IN_PROC_BROWSER_TEST_F( IN_PROC_BROWSER_TEST_F(BraveAdsBrowserTest, BraveAdsMigrateAdsPerHourForFreshInstallFromVersion10) { EXPECT_FALSE(GetPrefs()->HasPrefPath(ads::prefs::kAdsPerHour)); - EXPECT_EQ(-1, GetPrefs()->GetInteger(ads::prefs::kAdsPerHour)); + EXPECT_EQ(-1, GetPrefs()->GetInt64(ads::prefs::kAdsPerHour)); } class BraveAdsUpgradeBrowserTest diff --git a/browser/brave_ads/ads_tab_helper.cc b/browser/brave_ads/ads_tab_helper.cc index d17fdc678a86..de9ce41d3ed5 100644 --- a/browser/brave_ads/ads_tab_helper.cc +++ b/browser/brave_ads/ads_tab_helper.cc @@ -115,8 +115,8 @@ void AdsTabHelper::DidFinishNavigation( } if (navigation_handle->HasUserGesture()) { - const uint32_t page_transition = - static_cast(navigation_handle->GetPageTransition()); + const int32_t page_transition = + static_cast(navigation_handle->GetPageTransition()); ads_service_->OnUserGesture(page_transition); } diff --git a/components/brave_ads/browser/ads_service.cc b/components/brave_ads/browser/ads_service.cc index e375d16ed111..03bde4023c54 100644 --- a/components/brave_ads/browser/ads_service.cc +++ b/components/brave_ads/browser/ads_service.cc @@ -49,7 +49,7 @@ void AdsService::RegisterProfilePrefs( registry->RegisterBooleanPref(ads::prefs::kShouldAllowConversionTracking, true); - registry->RegisterIntegerPref(ads::prefs::kAdsPerHour, -1); + registry->RegisterInt64Pref(ads::prefs::kAdsPerHour, -1); registry->RegisterIntegerPref(ads::prefs::kIdleTimeThreshold, 15); diff --git a/components/brave_ads/browser/ads_service.h b/components/brave_ads/browser/ads_service.h index e17b193c1a88..8a44d3cb70e0 100644 --- a/components/brave_ads/browser/ads_service.h +++ b/components/brave_ads/browser/ads_service.h @@ -6,7 +6,6 @@ #ifndef BRAVE_COMPONENTS_BRAVE_ADS_BROWSER_ADS_SERVICE_H_ #define BRAVE_COMPONENTS_BRAVE_ADS_BROWSER_ADS_SERVICE_H_ -#include #include #include @@ -85,8 +84,8 @@ class AdsService : public KeyedService { virtual void SetAllowConversionTracking(const bool should_allow) = 0; - virtual int GetAdsPerHour() const = 0; - virtual void SetAdsPerHour(const int ads_per_hour) = 0; + virtual int64_t GetAdsPerHour() const = 0; + virtual void SetAdsPerHour(const int64_t ads_per_hour) = 0; virtual bool ShouldAllowAdsSubdivisionTargeting() const = 0; virtual std::string GetAdsSubdivisionTargetingCode() const = 0; @@ -119,7 +118,7 @@ class AdsService : public KeyedService { const std::vector& redirect_chain, const std::string& text) = 0; - virtual void OnUserGesture(const uint32_t page_transition_type) = 0; + virtual void OnUserGesture(const int32_t page_transition_type) = 0; virtual void OnMediaStart(const SessionID& tab_id) = 0; virtual void OnMediaStop(const SessionID& tab_id) = 0; diff --git a/components/brave_ads/browser/ads_service_impl.cc b/components/brave_ads/browser/ads_service_impl.cc index 41e9615b4ff0..a7d51d66d9bf 100644 --- a/components/brave_ads/browser/ads_service_impl.cc +++ b/components/brave_ads/browser/ads_service_impl.cc @@ -276,10 +276,10 @@ void AdsServiceImpl::SetAllowConversionTracking(const bool should_allow) { SetBooleanPref(ads::prefs::kShouldAllowConversionTracking, should_allow); } -void AdsServiceImpl::SetAdsPerHour(const int ads_per_hour) { +void AdsServiceImpl::SetAdsPerHour(const int64_t ads_per_hour) { DCHECK(ads_per_hour >= ads::kMinimumNotificationAdsPerHour && ads_per_hour <= ads::kMaximumNotificationAdsPerHour); - SetIntegerPref(ads::prefs::kAdsPerHour, ads_per_hour); + SetInt64Pref(ads::prefs::kAdsPerHour, ads_per_hour); } void AdsServiceImpl::SetAdsSubdivisionTargetingCode( @@ -336,7 +336,7 @@ void AdsServiceImpl::OnTextLoaded(const SessionID& tab_id, bat_ads_->OnTextLoaded(tab_id.id(), redirect_chain, text); } -void AdsServiceImpl::OnUserGesture(const uint32_t page_transition_type) { +void AdsServiceImpl::OnUserGesture(const int32_t page_transition_type) { if (!connected()) { return; } @@ -517,16 +517,17 @@ bool AdsServiceImpl::ShouldStart() const { return IsEnabled() || IsBraveNewsEnabled(); } -int AdsServiceImpl::GetAdsPerHour() const { - int ads_per_hour = GetIntegerPref(ads::prefs::kAdsPerHour); +int64_t AdsServiceImpl::GetAdsPerHour() const { + int64_t ads_per_hour = GetInt64Pref(ads::prefs::kAdsPerHour); if (ads_per_hour == -1) { ads_per_hour = base::GetFieldTrialParamByFeatureAsInt( kServing, "default_ad_notifications_per_hour", ads::kDefaultNotificationAdsPerHour); } - return base::clamp(ads_per_hour, ads::kMinimumNotificationAdsPerHour, - ads::kMaximumNotificationAdsPerHour); + return base::clamp(ads_per_hour, + static_cast(ads::kMinimumNotificationAdsPerHour), + static_cast(ads::kMaximumNotificationAdsPerHour)); } bool AdsServiceImpl::ShouldAllowAdsSubdivisionTargeting() const { @@ -1737,7 +1738,7 @@ void AdsServiceImpl::MigratePrefsVersion9To10() { return; } - const int ads_per_hour = GetIntegerPref(ads::prefs::kAdsPerHour); + const int64_t ads_per_hour = GetInt64Pref(ads::prefs::kAdsPerHour); if (ads_per_hour == -1 || ads_per_hour == 2) { // The user did not change the ads per hour setting from the legacy default // value of 2 so we should clear the preference to transition to @@ -1751,7 +1752,7 @@ void AdsServiceImpl::MigratePrefsVersion10To11() { return; } - const int ads_per_hour = GetIntegerPref(ads::prefs::kAdsPerHour); + const int64_t ads_per_hour = GetInt64Pref(ads::prefs::kAdsPerHour); if (ads_per_hour == 0 || ads_per_hour == -1) { // Clear the ads per hour preference to transition to // |kDefaultNotificationAdsPerHour| diff --git a/components/brave_ads/browser/ads_service_impl.h b/components/brave_ads/browser/ads_service_impl.h index e7d5003a2e91..ae54f5995d6c 100644 --- a/components/brave_ads/browser/ads_service_impl.h +++ b/components/brave_ads/browser/ads_service_impl.h @@ -107,8 +107,8 @@ class AdsServiceImpl : public AdsService, void SetAllowConversionTracking(const bool should_allow) override; - int GetAdsPerHour() const override; - void SetAdsPerHour(const int ads_per_hour) override; + int64_t GetAdsPerHour() const override; + void SetAdsPerHour(const int64_t ads_per_hour) override; bool ShouldAllowAdsSubdivisionTargeting() const override; std::string GetAdsSubdivisionTargetingCode() const override; @@ -143,7 +143,7 @@ class AdsServiceImpl : public AdsService, const std::vector& redirect_chain, const std::string& text) override; - void OnUserGesture(const uint32_t page_transition_type) override; + void OnUserGesture(const int32_t page_transition_type) override; void OnMediaStart(const SessionID& tab_id) override; void OnMediaStop(const SessionID& tab_id) override; diff --git a/components/brave_ads/browser/mock_ads_service.h b/components/brave_ads/browser/mock_ads_service.h index 53f6dbee0b00..501af62898a3 100644 --- a/components/brave_ads/browser/mock_ads_service.h +++ b/components/brave_ads/browser/mock_ads_service.h @@ -29,8 +29,8 @@ class MockAdsService : public AdsService { MOCK_METHOD1(SetAllowConversionTracking, void(bool)); - MOCK_CONST_METHOD0(GetAdsPerHour, int()); - MOCK_METHOD1(SetAdsPerHour, void(int)); + MOCK_CONST_METHOD0(GetAdsPerHour, int64_t()); + MOCK_METHOD1(SetAdsPerHour, void(int64_t)); MOCK_CONST_METHOD0(ShouldAllowAdsSubdivisionTargeting, bool()); MOCK_CONST_METHOD0(GetAdsSubdivisionTargetingCode, std::string()); @@ -63,7 +63,7 @@ class MockAdsService : public AdsService { const std::vector&, const std::string&)); - MOCK_METHOD1(OnUserGesture, void(uint32_t)); + MOCK_METHOD1(OnUserGesture, void(int32_t)); MOCK_METHOD1(OnMediaStart, void(const SessionID&)); MOCK_METHOD1(OnMediaStop, void(const SessionID&)); diff --git a/components/services/bat_ads/bat_ads_client_mojo_bridge.h b/components/services/bat_ads/bat_ads_client_mojo_bridge.h index bd9cb74f60b0..af7ecddd89ee 100644 --- a/components/services/bat_ads/bat_ads_client_mojo_bridge.h +++ b/components/services/bat_ads/bat_ads_client_mojo_bridge.h @@ -112,7 +112,9 @@ class BatAdsClientMojoBridge int64_t GetInt64Pref(const std::string& path) const override; void SetInt64Pref(const std::string& path, const int64_t value) override; uint64_t GetUint64Pref(const std::string& path) const override; - void SetUint64Pref(const std::string& path, const uint64_t value) override; + void SetUint64Pref( + const std::string& path, + const uint64_t value) override; base::Time GetTimePref(const std::string& path) const override; void SetTimePref(const std::string& path, const base::Time value) override; void ClearPref(const std::string& path) override; diff --git a/components/services/bat_ads/bat_ads_impl.cc b/components/services/bat_ads/bat_ads_impl.cc index 33c93a3c560e..679c9d23c6cd 100644 --- a/components/services/bat_ads/bat_ads_impl.cc +++ b/components/services/bat_ads/bat_ads_impl.cc @@ -80,7 +80,7 @@ void BatAdsImpl::OnTextLoaded(const int32_t tab_id, ads_->OnTextLoaded(tab_id, redirect_chain, text); } -void BatAdsImpl::OnUserGesture(const uint32_t page_transition_type) { +void BatAdsImpl::OnUserGesture(const int32_t page_transition_type) { ads_->OnUserGesture(page_transition_type); } diff --git a/components/services/bat_ads/bat_ads_impl.h b/components/services/bat_ads/bat_ads_impl.h index f220b4ea3ea3..e9a91e4b5b6f 100644 --- a/components/services/bat_ads/bat_ads_impl.h +++ b/components/services/bat_ads/bat_ads_impl.h @@ -56,7 +56,7 @@ class BatAdsImpl : const std::vector& redirect_chain, const std::string& text) override; - void OnUserGesture(const uint32_t page_transition_type) override; + void OnUserGesture(const int32_t page_transition_type) override; void OnUnIdle(const int idle_time, const bool was_locked) override; void OnIdle() override; diff --git a/components/services/bat_ads/public/interfaces/bat_ads.mojom b/components/services/bat_ads/public/interfaces/bat_ads.mojom index 886d6719b2fc..4293d5c9f8fa 100644 --- a/components/services/bat_ads/public/interfaces/bat_ads.mojom +++ b/components/services/bat_ads/public/interfaces/bat_ads.mojom @@ -87,7 +87,7 @@ interface BatAds { OnPrefChanged(string path); OnHtmlLoaded(int32 tab_id, array redirect_chain, string html); OnTextLoaded(int32 tab_id, array redirect_chain, string text); - OnUserGesture(uint32 page_transition_type); + OnUserGesture(int32 page_transition_type); OnUnIdle(int32 idle_time, bool was_locked); OnIdle(); OnBrowserDidEnterForeground(); diff --git a/vendor/bat-native-ads/include/bat/ads/ads.h b/vendor/bat-native-ads/include/bat/ads/ads.h index e189cd8a28c3..2ca3f07b9979 100644 --- a/vendor/bat-native-ads/include/bat/ads/ads.h +++ b/vendor/bat-native-ads/include/bat/ads/ads.h @@ -93,7 +93,7 @@ class ADS_EXPORT Ads { // Called when a page navigation was initiated by a user gesture. // |page_transition_type| containing the page transition type, see enums for // |PageTransitionType|. - virtual void OnUserGesture(const uint32_t page_transition_type) = 0; + virtual void OnUserGesture(const int32_t page_transition_type) = 0; // Called when a user is no longer idle. |idle_time| is the amount of time in // seconds that the user was idle. |was_locked| should be |true| if the screen diff --git a/vendor/bat-native-ads/include/bat/ads/database.h b/vendor/bat-native-ads/include/bat/ads/database.h index ba8bf474aa0b..5efc0cc14fa6 100644 --- a/vendor/bat-native-ads/include/bat/ads/database.h +++ b/vendor/bat-native-ads/include/bat/ads/database.h @@ -6,6 +6,7 @@ #ifndef BRAVE_VENDOR_BAT_NATIVE_ADS_INCLUDE_BAT_ADS_DATABASE_H_ #define BRAVE_VENDOR_BAT_NATIVE_ADS_INCLUDE_BAT_ADS_DATABASE_H_ +#include #include #include "base/memory/memory_pressure_listener.h" @@ -34,8 +35,8 @@ class ADS_EXPORT Database final { private: mojom::DBCommandResponse::Status Initialize( - const int version, - const int compatible_version, + const int32_t version, + const int32_t compatible_version, mojom::DBCommandResponse* command_response); mojom::DBCommandResponse::Status Execute(mojom::DBCommand* command); @@ -46,8 +47,8 @@ class ADS_EXPORT Database final { mojom::DBCommand* command, mojom::DBCommandResponse* command_response); - mojom::DBCommandResponse::Status Migrate(const int version, - const int compatible_version); + mojom::DBCommandResponse::Status Migrate(const int32_t version, + const int32_t compatible_version); void OnErrorCallback(const int error, sql::Statement* statement); diff --git a/vendor/bat-native-ads/include/bat/ads/pref_names.h b/vendor/bat-native-ads/include/bat/ads/pref_names.h index 01adab261e5b..4445327c5d5f 100644 --- a/vendor/bat-native-ads/include/bat/ads/pref_names.h +++ b/vendor/bat-native-ads/include/bat/ads/pref_names.h @@ -6,12 +6,14 @@ #ifndef BRAVE_VENDOR_BAT_NATIVE_ADS_INCLUDE_BAT_ADS_PREF_NAMES_H_ #define BRAVE_VENDOR_BAT_NATIVE_ADS_INCLUDE_BAT_ADS_PREF_NAMES_H_ +#include + namespace ads { // Ads per hour are user configurable within the brave://rewards ads UI -const int kMinimumNotificationAdsPerHour = 0; -const int kMaximumNotificationAdsPerHour = 10; -const int kDefaultNotificationAdsPerHour = 5; +const int64_t kMinimumNotificationAdsPerHour = 0; +const int64_t kMaximumNotificationAdsPerHour = 10; +const int64_t kDefaultNotificationAdsPerHour = 5; namespace prefs { diff --git a/vendor/bat-native-ads/src/bat/ads/database.cc b/vendor/bat-native-ads/src/bat/ads/database.cc index 2df3f47cf2a6..80d1600c3f90 100644 --- a/vendor/bat-native-ads/src/bat/ads/database.cc +++ b/vendor/bat-native-ads/src/bat/ads/database.cc @@ -93,8 +93,8 @@ void Database::RunTransaction(mojom::DBTransactionPtr transaction, } mojom::DBCommandResponse::Status Database::Initialize( - const int version, - const int compatible_version, + const int32_t version, + const int32_t compatible_version, mojom::DBCommandResponse* command_response) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); @@ -203,8 +203,8 @@ mojom::DBCommandResponse::Status Database::Read( } mojom::DBCommandResponse::Status Database::Migrate( - const int version, - const int compatible_version) { + const int32_t version, + const int32_t compatible_version) { if (!is_initialized_) { return mojom::DBCommandResponse::Status::INITIALIZATION_ERROR; } diff --git a/vendor/bat-native-ads/src/bat/ads/internal/account/confirmations/confirmations.cc b/vendor/bat-native-ads/src/bat/ads/internal/account/confirmations/confirmations.cc index 8f594bedfd20..66207412047d 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/account/confirmations/confirmations.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/account/confirmations/confirmations.cc @@ -5,6 +5,7 @@ #include "bat/ads/internal/account/confirmations/confirmations.h" +#include #include #include "base/check_op.h" diff --git a/vendor/bat-native-ads/src/bat/ads/internal/account/issuers/issuers.cc b/vendor/bat-native-ads/src/bat/ads/internal/account/issuers/issuers.cc index b6490fc4cbee..f0a566326f8c 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/account/issuers/issuers.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/account/issuers/issuers.cc @@ -5,6 +5,7 @@ #include "bat/ads/internal/account/issuers/issuers.h" +#include #include #include #include diff --git a/vendor/bat-native-ads/src/bat/ads/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens.cc b/vendor/bat-native-ads/src/bat/ads/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens.cc index 34ccf02b2759..dafde0152307 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens.cc @@ -5,6 +5,7 @@ #include "bat/ads/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens.h" +#include #include #include @@ -30,8 +31,10 @@ namespace { constexpr base::TimeDelta kRetryAfter = base::Minutes(1); constexpr base::TimeDelta kExpiredNextTokenRedemptionAfter = base::Minutes(1); -constexpr base::TimeDelta kNextTokenRedemptionAfter = base::Hours(24); -constexpr base::TimeDelta kDebugNextTokenRedemptionAfter = base::Minutes(25); +constexpr int64_t kNextTokenRedemptionAfterSeconds = + 24 * base::Time::kSecondsPerHour; +constexpr int64_t kDebugNextTokenRedemptionAfterSeconds = + 25 * base::Time::kSecondsPerMinute; } // namespace @@ -210,18 +213,20 @@ base::TimeDelta RedeemUnblindedPaymentTokens::CalculateTokenRedemptionDelay() { } base::Time RedeemUnblindedPaymentTokens::CalculateNextTokenRedemptionDate() { - base::TimeDelta delay; + const base::Time now = base::Time::Now(); + + int64_t delay; if (!g_is_debug) { - delay = kNextTokenRedemptionAfter; + delay = kNextTokenRedemptionAfterSeconds; } else { - delay = kDebugNextTokenRedemptionAfter; + delay = kDebugNextTokenRedemptionAfterSeconds; } - const base::TimeDelta rand_delay = - base::Seconds(brave_base::random::Geometric(delay.InSeconds())); + const int64_t rand_delay = + static_cast(brave_base::random::Geometric(delay)); - return base::Time::Now() + rand_delay; + return now + base::Seconds(rand_delay); } } // namespace ads diff --git a/vendor/bat-native-ads/src/bat/ads/internal/account/utility/refill_unblinded_tokens/refill_unblinded_tokens.cc b/vendor/bat-native-ads/src/bat/ads/internal/account/utility/refill_unblinded_tokens/refill_unblinded_tokens.cc index 36162897b812..683612c5efef 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/account/utility/refill_unblinded_tokens/refill_unblinded_tokens.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/account/utility/refill_unblinded_tokens/refill_unblinded_tokens.cc @@ -5,6 +5,7 @@ #include "bat/ads/internal/account/utility/refill_unblinded_tokens/refill_unblinded_tokens.h" +#include #include #include diff --git a/vendor/bat-native-ads/src/bat/ads/internal/ads_impl.cc b/vendor/bat-native-ads/src/bat/ads/internal/ads_impl.cc index b6d2728fafe0..83664f8bbff8 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/ads_impl.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/ads_impl.cc @@ -286,7 +286,7 @@ void AdsImpl::OnTextLoaded(const int32_t tab_id, text_classification_processor_->Process(text); } -void AdsImpl::OnUserGesture(const uint32_t page_transition_type) { +void AdsImpl::OnUserGesture(const int32_t page_transition_type) { if (!IsInitialized()) { return; } diff --git a/vendor/bat-native-ads/src/bat/ads/internal/ads_impl.h b/vendor/bat-native-ads/src/bat/ads/internal/ads_impl.h index 61483a381820..444b476fa58c 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/ads_impl.h +++ b/vendor/bat-native-ads/src/bat/ads/internal/ads_impl.h @@ -141,7 +141,7 @@ class AdsImpl final : public Ads, const std::vector& redirect_chain, const std::string& text) override; - void OnUserGesture(const uint32_t page_transition_type) override; + void OnUserGesture(const int32_t page_transition_type) override; void OnIdle() override; void OnUnIdle(const int idle_time, const bool was_locked) override; diff --git a/vendor/bat-native-ads/src/bat/ads/internal/base/timer/timer.cc b/vendor/bat-native-ads/src/bat/ads/internal/base/timer/timer.cc index 2cc3c559f6c4..147005f419ee 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/base/timer/timer.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/base/timer/timer.cc @@ -5,6 +5,7 @@ #include "bat/ads/internal/base/timer/timer.h" +#include #include #include "base/check.h" @@ -36,10 +37,11 @@ base::Time Timer::Start(const base::Location& location, base::Time Timer::StartWithPrivacy(const base::Location& location, const base::TimeDelta delay, base::OnceClosure user_task) { - const base::TimeDelta rand_delay = - base::Seconds(brave_base::random::Geometric(delay.InSeconds())); + const int64_t rand_delay_in_seconds = + static_cast(brave_base::random::Geometric(delay.InSeconds())); - return Start(location, rand_delay, std::move(user_task)); + return Start(location, base::Seconds(rand_delay_in_seconds), + std::move(user_task)); } bool Timer::IsRunning() const { diff --git a/vendor/bat-native-ads/src/bat/ads/internal/base/unittest/unittest_base.cc b/vendor/bat-native-ads/src/bat/ads/internal/base/unittest/unittest_base.cc index d54700542133..2e5cb28dc0f3 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/base/unittest/unittest_base.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/base/unittest/unittest_base.cc @@ -244,7 +244,7 @@ void UnitTestBase::InitializeMocks() { void UnitTestBase::SetDefaultPrefs() { ads_client_mock_->SetBooleanPref(prefs::kEnabled, true); - ads_client_mock_->SetIntegerPref(prefs::kAdsPerHour, -1); + ads_client_mock_->SetInt64Pref(prefs::kAdsPerHour, -1); ads_client_mock_->SetIntegerPref(prefs::kIdleTimeThreshold, 15); diff --git a/vendor/bat-native-ads/src/bat/ads/internal/catalog/campaign/creative_set/creative/catalog_type_info.h b/vendor/bat-native-ads/src/bat/ads/internal/catalog/campaign/creative_set/creative/catalog_type_info.h index ac65c460e62e..17edc01b3e66 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/catalog/campaign/creative_set/creative/catalog_type_info.h +++ b/vendor/bat-native-ads/src/bat/ads/internal/catalog/campaign/creative_set/creative/catalog_type_info.h @@ -6,6 +6,7 @@ #ifndef BRAVE_VENDOR_BAT_NATIVE_ADS_SRC_BAT_ADS_INTERNAL_CATALOG_CAMPAIGN_CREATIVE_SET_CREATIVE_CATALOG_TYPE_INFO_H_ #define BRAVE_VENDOR_BAT_NATIVE_ADS_SRC_BAT_ADS_INTERNAL_CATALOG_CAMPAIGN_CREATIVE_SET_CREATIVE_CATALOG_TYPE_INFO_H_ +#include #include namespace ads { @@ -22,7 +23,7 @@ struct CatalogTypeInfo final { std::string code; std::string name; std::string platform; - int version = 0; + uint64_t version = 0; }; } // namespace ads diff --git a/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog.cc b/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog.cc index 97fe50dcbbb9..6e73530fb3f9 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog.cc @@ -5,6 +5,7 @@ #include "bat/ads/internal/catalog/catalog.h" +#include #include #include #include diff --git a/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog_json_reader.cc b/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog_json_reader.cc index de8257866935..c15912870efb 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog_json_reader.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog_json_reader.cc @@ -5,6 +5,8 @@ #include "bat/ads/internal/catalog/catalog_json_reader.h" +#include + #include "base/check.h" #include "base/notreached.h" #include "base/strings/string_number_conversions.h" @@ -38,7 +40,7 @@ absl::optional ReadCatalog(const std::string& json) { catalog.version = document["version"].GetInt(); - const int ping = document["ping"].GetInt(); + const int64_t ping = document["ping"].GetInt64(); catalog.ping = base::Milliseconds(ping); // Campaigns diff --git a/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog_util.cc b/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog_util.cc index 6c657aa7524a..d2b0cba92ff0 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog_util.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/catalog/catalog_util.cc @@ -5,6 +5,8 @@ #include "bat/ads/internal/catalog/catalog_util.h" +#include + #include "base/time/time.h" #include "bat/ads/internal/account/deposits/deposits_database_util.h" #include "bat/ads/internal/ads_client_helper.h" @@ -90,7 +92,8 @@ void SetCatalogVersion(const int version) { } base::TimeDelta GetCatalogPing() { - const int ping = AdsClientHelper::Get()->GetInt64Pref(prefs::kCatalogPing); + const int64_t ping = + AdsClientHelper::Get()->GetInt64Pref(prefs::kCatalogPing); return base::Milliseconds(ping); } diff --git a/vendor/bat-native-ads/src/bat/ads/internal/conversions/conversions.cc b/vendor/bat-native-ads/src/bat/ads/internal/conversions/conversions.cc index 5cbb9d96e11d..0a81f5056556 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/conversions/conversions.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/conversions/conversions.cc @@ -6,6 +6,7 @@ #include "bat/ads/internal/conversions/conversions.h" #include +#include #include #include @@ -35,9 +36,12 @@ namespace ads { namespace { -constexpr base::TimeDelta kConvertAfter = base::Days(1); -constexpr base::TimeDelta kDebugConvertAfter = base::Minutes(10); -constexpr base::TimeDelta kExpiredConvertAfter = base::Minutes(1); +constexpr int64_t kConvertAfterSeconds = + base::Time::kHoursPerDay * base::Time::kSecondsPerHour; +constexpr int64_t kDebugConvertAfterSeconds = + 10 * base::Time::kSecondsPerMinute; +constexpr int64_t kExpiredConvertAfterSeconds = + 1 * base::Time::kSecondsPerMinute; constexpr char kSearchInUrl[] = "url"; bool HasObservationWindowForAdEventExpired(const int observation_window, @@ -396,10 +400,10 @@ void Conversions::AddItemToQueue( conversion_queue_item.advertiser_public_key = verifiable_conversion.public_key; conversion_queue_item.ad_type = ad_event.type; - const base::TimeDelta delay = g_is_debug ? kDebugConvertAfter : kConvertAfter; - const base::TimeDelta rand_delay = - base::Seconds(brave_base::random::Geometric(delay.InSeconds())); - conversion_queue_item.process_at = base::Time::Now() + rand_delay; + const int64_t rand_delay = static_cast(brave_base::random::Geometric( + g_is_debug ? kDebugConvertAfterSeconds : kConvertAfterSeconds)); + conversion_queue_item.process_at = + base::Time::Now() + base::Seconds(rand_delay); database::table::ConversionQueue database_table; database_table.Save({conversion_queue_item}, [=](const bool success) { @@ -534,8 +538,9 @@ void Conversions::StartTimer( if (now < conversion_queue_item.process_at) { delay = conversion_queue_item.process_at - now; } else { - delay = base::Seconds( - brave_base::random::Geometric(kExpiredConvertAfter.InSeconds())); + const int64_t rand_delay = static_cast( + brave_base::random::Geometric(kExpiredConvertAfterSeconds)); + delay = base::Seconds(rand_delay); } const base::Time process_queue_at = timer_.Start( diff --git a/vendor/bat-native-ads/src/bat/ads/internal/conversions/verifiable_conversion_envelope_unittest_util.cc b/vendor/bat-native-ads/src/bat/ads/internal/conversions/verifiable_conversion_envelope_unittest_util.cc index 4c1c1e4088c9..07af8b36efbf 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/conversions/verifiable_conversion_envelope_unittest_util.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/conversions/verifiable_conversion_envelope_unittest_util.cc @@ -5,6 +5,7 @@ #include "bat/ads/internal/conversions/verifiable_conversion_envelope_unittest_util.h" +#include #include #include "base/base64.h" diff --git a/vendor/bat-native-ads/src/bat/ads/internal/creatives/notification_ads/notification_ad_manager.h b/vendor/bat-native-ads/src/bat/ads/internal/creatives/notification_ads/notification_ad_manager.h index 61d38334b3d7..3eddc69af8c8 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/creatives/notification_ads/notification_ad_manager.h +++ b/vendor/bat-native-ads/src/bat/ads/internal/creatives/notification_ads/notification_ad_manager.h @@ -6,6 +6,7 @@ #ifndef BRAVE_VENDOR_BAT_NATIVE_ADS_SRC_BAT_ADS_INTERNAL_CREATIVES_NOTIFICATION_ADS_NOTIFICATION_AD_MANAGER_H_ #define BRAVE_VENDOR_BAT_NATIVE_ADS_SRC_BAT_ADS_INTERNAL_CREATIVES_NOTIFICATION_ADS_NOTIFICATION_AD_MANAGER_H_ +#include #include #include "base/containers/circular_deque.h" diff --git a/vendor/bat-native-ads/src/bat/ads/internal/deprecated/client/client_state_manager.cc b/vendor/bat-native-ads/src/bat/ads/internal/deprecated/client/client_state_manager.cc index 90d336e3a086..fda1359bf377 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/deprecated/client/client_state_manager.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/deprecated/client/client_state_manager.cc @@ -6,6 +6,7 @@ #include "bat/ads/internal/deprecated/client/client_state_manager.h" #include +#include #include #include "base/check_op.h" diff --git a/vendor/bat-native-ads/src/bat/ads/internal/deprecated/client/preferences/ad_preferences_info_unittest.cc b/vendor/bat-native-ads/src/bat/ads/internal/deprecated/client/preferences/ad_preferences_info_unittest.cc index c02fd6e06ec7..7d90c88f930e 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/deprecated/client/preferences/ad_preferences_info_unittest.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/deprecated/client/preferences/ad_preferences_info_unittest.cc @@ -51,16 +51,16 @@ class BatAdsAdPreferencesInfoTest : public UnitTestBase { EXPECT_TRUE(ad_preferences_info.FromJson(json)); // Assert - ASSERT_EQ(1U, ad_preferences_info.filtered_advertisers.size()); + ASSERT_EQ(1u, ad_preferences_info.filtered_advertisers.size()); EXPECT_EQ("filtered_advertiser_id", ad_preferences_info.filtered_advertisers[0].id); - ASSERT_EQ(1U, ad_preferences_info.filtered_categories.size()); + ASSERT_EQ(1u, ad_preferences_info.filtered_categories.size()); EXPECT_EQ("filtered_category_name", ad_preferences_info.filtered_categories[0].name); - ASSERT_EQ(1U, ad_preferences_info.saved_ads.size()); + ASSERT_EQ(1u, ad_preferences_info.saved_ads.size()); EXPECT_EQ("creative_instance_id", ad_preferences_info.saved_ads[0].creative_instance_id); - ASSERT_EQ(1U, ad_preferences_info.flagged_ads.size()); + ASSERT_EQ(1u, ad_preferences_info.flagged_ads.size()); EXPECT_EQ("creative_set_id", ad_preferences_info.flagged_ads[0].creative_set_id); } @@ -106,10 +106,10 @@ TEST_F(BatAdsAdPreferencesInfoTest, ParseEmptyJson) { EXPECT_TRUE(ad_preferences_info.FromJson("{}")); // Assert - EXPECT_EQ(0U, ad_preferences_info.filtered_advertisers.size()); - EXPECT_EQ(0U, ad_preferences_info.filtered_categories.size()); - EXPECT_EQ(0U, ad_preferences_info.saved_ads.size()); - EXPECT_EQ(0U, ad_preferences_info.flagged_ads.size()); + EXPECT_EQ(0u, ad_preferences_info.filtered_advertisers.size()); + EXPECT_EQ(0u, ad_preferences_info.filtered_categories.size()); + EXPECT_EQ(0u, ad_preferences_info.saved_ads.size()); + EXPECT_EQ(0u, ad_preferences_info.flagged_ads.size()); } TEST_F(BatAdsAdPreferencesInfoTest, ParsePreferencesWithNotValidMembers) { diff --git a/vendor/bat-native-ads/src/bat/ads/internal/deprecated/confirmations/confirmation_state_manager.cc b/vendor/bat-native-ads/src/bat/ads/internal/deprecated/confirmations/confirmation_state_manager.cc index 830a959e6c53..4de0228379f6 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/deprecated/confirmations/confirmation_state_manager.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/deprecated/confirmations/confirmation_state_manager.cc @@ -6,6 +6,7 @@ #include "bat/ads/internal/deprecated/confirmations/confirmation_state_manager.h" #include +#include #include #include "base/check_op.h" diff --git a/vendor/bat-native-ads/src/bat/ads/internal/features/purchase_intent_features.cc b/vendor/bat-native-ads/src/bat/ads/internal/features/purchase_intent_features.cc index 2584fe6f8fa6..b49cb71a2f0c 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/features/purchase_intent_features.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/features/purchase_intent_features.cc @@ -18,7 +18,7 @@ namespace { constexpr char kFeatureName[] = "PurchaseIntent"; constexpr char kFieldTrialParameterThreshold[] = "threshold"; -constexpr int kDefaultThreshold = 3; +constexpr uint16_t kDefaultThreshold = 3; constexpr char kFieldTrialParameterTimeWindow[] = "time_window_in_seconds"; constexpr base::TimeDelta kDefaultTimeWindow = base::Days(7); @@ -37,7 +37,7 @@ bool IsPurchaseIntentEnabled() { return base::FeatureList::IsEnabled(kPurchaseIntent); } -int GetPurchaseIntentThreshold() { +uint16_t GetPurchaseIntentThreshold() { return GetFieldTrialParamByFeatureAsInt( kPurchaseIntent, kFieldTrialParameterThreshold, kDefaultThreshold); } diff --git a/vendor/bat-native-ads/src/bat/ads/internal/features/purchase_intent_features.h b/vendor/bat-native-ads/src/bat/ads/internal/features/purchase_intent_features.h index 9ca2ae17487e..8071ab4d8d16 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/features/purchase_intent_features.h +++ b/vendor/bat-native-ads/src/bat/ads/internal/features/purchase_intent_features.h @@ -6,6 +6,8 @@ #ifndef BRAVE_VENDOR_BAT_NATIVE_ADS_SRC_BAT_ADS_INTERNAL_FEATURES_PURCHASE_INTENT_FEATURES_H_ #define BRAVE_VENDOR_BAT_NATIVE_ADS_SRC_BAT_ADS_INTERNAL_FEATURES_PURCHASE_INTENT_FEATURES_H_ +#include + #include "base/feature_list.h" namespace base { @@ -20,7 +22,7 @@ extern const base::Feature kPurchaseIntent; bool IsPurchaseIntentEnabled(); -int GetPurchaseIntentThreshold(); +uint16_t GetPurchaseIntentThreshold(); base::TimeDelta GetPurchaseIntentTimeWindow(); diff --git a/vendor/bat-native-ads/src/bat/ads/internal/features/purchase_intent_features_unittest.cc b/vendor/bat-native-ads/src/bat/ads/internal/features/purchase_intent_features_unittest.cc index bfcaebabf47b..5d08444f2008 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/features/purchase_intent_features_unittest.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/features/purchase_intent_features_unittest.cc @@ -5,6 +5,8 @@ #include "bat/ads/internal/features/purchase_intent_features.h" +#include + #include "base/time/time.h" #include "testing/gtest/include/gtest/gtest.h" @@ -29,7 +31,7 @@ TEST(BatAdsPurchaseIntentFeaturesTest, PurchaseIntentTreshold) { // Act // Assert - EXPECT_EQ(3, GetPurchaseIntentThreshold()); + EXPECT_EQ(3u, GetPurchaseIntentThreshold()); } TEST(BatAdsPurchaseIntentFeaturesTest, PurchaseIntentTimeWindowInSeconds) { diff --git a/vendor/bat-native-ads/src/bat/ads/internal/geographic/subdivision/subdivision_targeting.cc b/vendor/bat-native-ads/src/bat/ads/internal/geographic/subdivision/subdivision_targeting.cc index 0dea17107803..e7dd47f01bf3 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/geographic/subdivision/subdivision_targeting.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/geographic/subdivision/subdivision_targeting.cc @@ -5,6 +5,7 @@ #include "bat/ads/internal/geographic/subdivision/subdivision_targeting.h" +#include #include #include diff --git a/vendor/bat-native-ads/src/bat/ads/internal/legacy_migration/database/database_constants.h b/vendor/bat-native-ads/src/bat/ads/internal/legacy_migration/database/database_constants.h index 54e32399e2b0..ce1e05eeb0a8 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/legacy_migration/database/database_constants.h +++ b/vendor/bat-native-ads/src/bat/ads/internal/legacy_migration/database/database_constants.h @@ -6,11 +6,13 @@ #ifndef BRAVE_VENDOR_BAT_NATIVE_ADS_SRC_BAT_ADS_INTERNAL_LEGACY_MIGRATION_DATABASE_DATABASE_CONSTANTS_H_ #define BRAVE_VENDOR_BAT_NATIVE_ADS_SRC_BAT_ADS_INTERNAL_LEGACY_MIGRATION_DATABASE_DATABASE_CONSTANTS_H_ +#include + namespace ads { namespace database { -constexpr int kVersion = 24; -constexpr int kCompatibleVersion = 24; +constexpr int32_t kVersion = 24; +constexpr int32_t kCompatibleVersion = 24; } // namespace database } // namespace ads diff --git a/vendor/bat-native-ads/src/bat/ads/internal/ml/pipeline/text_processing/text_processing.h b/vendor/bat-native-ads/src/bat/ads/internal/ml/pipeline/text_processing/text_processing.h index 29a8dce3d3d7..a8075251453e 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/ml/pipeline/text_processing/text_processing.h +++ b/vendor/bat-native-ads/src/bat/ads/internal/ml/pipeline/text_processing/text_processing.h @@ -6,6 +6,7 @@ #ifndef BRAVE_VENDOR_BAT_NATIVE_ADS_SRC_BAT_ADS_INTERNAL_ML_PIPELINE_TEXT_PROCESSING_TEXT_PROCESSING_H_ #define BRAVE_VENDOR_BAT_NATIVE_ADS_SRC_BAT_ADS_INTERNAL_ML_PIPELINE_TEXT_PROCESSING_TEXT_PROCESSING_H_ +#include #include #include @@ -49,8 +50,8 @@ class TextProcessing final { private: bool is_initialized_ = false; - int version_ = 0; - std::string timestamp_; + uint16_t version_ = 0; + std::string timestamp_ = ""; std::string locale_ = "en"; TransformationVector transformations_; model::Linear linear_model_; diff --git a/vendor/bat-native-ads/src/bat/ads/internal/processors/behavioral/bandits/epsilon_greedy_bandit_processor_unittest.cc b/vendor/bat-native-ads/src/bat/ads/internal/processors/behavioral/bandits/epsilon_greedy_bandit_processor_unittest.cc index 0f616618a539..e5f91531ebe5 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/processors/behavioral/bandits/epsilon_greedy_bandit_processor_unittest.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/processors/behavioral/bandits/epsilon_greedy_bandit_processor_unittest.cc @@ -57,8 +57,8 @@ TEST_F(BatAdsEpsilonGreedyBanditProcessorTest, InitializeAllArmsFromResource) { EXPECT_EQ(30U, arms.size()); - EXPECT_EQ(0U, arms.count("foo")); - EXPECT_EQ(0U, arms.count("bar")); + EXPECT_EQ(0u, arms.count("foo")); + EXPECT_EQ(0u, arms.count("bar")); } TEST_F(BatAdsEpsilonGreedyBanditProcessorTest, NeverProcessed) { diff --git a/vendor/bat-native-ads/src/bat/ads/internal/resources/behavioral/anti_targeting/anti_targeting_info.h b/vendor/bat-native-ads/src/bat/ads/internal/resources/behavioral/anti_targeting/anti_targeting_info.h index 6dc5a8c2fc34..8df14aa7439b 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/resources/behavioral/anti_targeting/anti_targeting_info.h +++ b/vendor/bat-native-ads/src/bat/ads/internal/resources/behavioral/anti_targeting/anti_targeting_info.h @@ -6,6 +6,7 @@ #ifndef BRAVE_VENDOR_BAT_NATIVE_ADS_SRC_BAT_ADS_INTERNAL_RESOURCES_BEHAVIORAL_ANTI_TARGETING_ANTI_TARGETING_INFO_H_ #define BRAVE_VENDOR_BAT_NATIVE_ADS_SRC_BAT_ADS_INTERNAL_RESOURCES_BEHAVIORAL_ANTI_TARGETING_ANTI_TARGETING_INFO_H_ +#include #include #include @@ -29,7 +30,7 @@ struct AntiTargetingInfo final { base::Value resource_value, std::string* error_message); - int version = 0; + uint16_t version = 0; AntiTargetingMap sites; }; diff --git a/vendor/bat-native-ads/src/bat/ads/internal/resources/behavioral/conversions/conversions_resource_unittest.cc b/vendor/bat-native-ads/src/bat/ads/internal/resources/behavioral/conversions/conversions_resource_unittest.cc index 166272e14c8b..f21d4d72b566 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/resources/behavioral/conversions/conversions_resource_unittest.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/resources/behavioral/conversions/conversions_resource_unittest.cc @@ -44,7 +44,7 @@ TEST_F(BatAdsConversionsResourceTest, Get) { resource.get()->conversion_id_patterns; // Assert - EXPECT_EQ(2U, conversion_id_patterns.size()); + EXPECT_EQ(2u, conversion_id_patterns.size()); } } // namespace resource diff --git a/vendor/bat-native-ads/src/bat/ads/internal/resources/behavioral/purchase_intent/purchase_intent_info.h b/vendor/bat-native-ads/src/bat/ads/internal/resources/behavioral/purchase_intent/purchase_intent_info.h index 2755096f6779..17f178b17aa9 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/resources/behavioral/purchase_intent/purchase_intent_info.h +++ b/vendor/bat-native-ads/src/bat/ads/internal/resources/behavioral/purchase_intent/purchase_intent_info.h @@ -6,6 +6,7 @@ #ifndef BRAVE_VENDOR_BAT_NATIVE_ADS_SRC_BAT_ADS_INTERNAL_RESOURCES_BEHAVIORAL_PURCHASE_INTENT_PURCHASE_INTENT_INFO_H_ #define BRAVE_VENDOR_BAT_NATIVE_ADS_SRC_BAT_ADS_INTERNAL_RESOURCES_BEHAVIORAL_PURCHASE_INTENT_PURCHASE_INTENT_INFO_H_ +#include #include #include #include @@ -33,7 +34,7 @@ struct PurchaseIntentInfo final { base::Value resource_value, std::string* error_message); - int version = 0; + uint16_t version = 0; std::vector sites; std::vector segment_keywords; std::vector funnel_keywords; diff --git a/vendor/bat-native-ads/src/bat/ads/internal/serving/notification_ad_serving.cc b/vendor/bat-native-ads/src/bat/ads/internal/serving/notification_ad_serving.cc index 8d6a35d82450..3c17a00467d6 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/serving/notification_ad_serving.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/serving/notification_ad_serving.cc @@ -5,6 +5,8 @@ #include "bat/ads/internal/serving/notification_ad_serving.h" +#include + #include "base/check.h" #include "base/rand_util.h" #include "base/time/time.h" @@ -161,7 +163,7 @@ void Serving::MaybeServeAd() { /////////////////////////////////////////////////////////////////////////////// void Serving::OnAdsPerHourPrefChanged() { - const int ads_per_hour = settings::GetAdsPerHour(); + const int64_t ads_per_hour = settings::GetAdsPerHour(); BLOG(1, "Maximum ads per hour changed to " << ads_per_hour); if (!ShouldServeAdsAtRegularIntervals()) { @@ -224,13 +226,13 @@ void Serving::MaybeServeAdAtNextRegularInterval() { return; } - const int ads_per_hour = settings::GetAdsPerHour(); + const int64_t ads_per_hour = settings::GetAdsPerHour(); if (ads_per_hour == 0) { return; } - const base::TimeDelta delay = - base::Seconds(base::Time::kSecondsPerHour / ads_per_hour); + const int64_t seconds = base::Time::kSecondsPerHour / ads_per_hour; + const base::TimeDelta delay = base::Seconds(seconds); const base::Time serve_ad_at = MaybeServeAdAfter(delay); BLOG(1, "Maybe serve notification ad " << FriendlyDateAndTime(serve_ad_at)); } diff --git a/vendor/bat-native-ads/src/bat/ads/internal/serving/permission_rules/minimum_wait_time_permission_rule.cc b/vendor/bat-native-ads/src/bat/ads/internal/serving/permission_rules/minimum_wait_time_permission_rule.cc index 19858e0222ef..2a750e81b2be 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/serving/permission_rules/minimum_wait_time_permission_rule.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/serving/permission_rules/minimum_wait_time_permission_rule.cc @@ -5,6 +5,8 @@ #include "bat/ads/internal/serving/permission_rules/minimum_wait_time_permission_rule.h" +#include + #include "base/time/time.h" #include "bat/ads/ad_type.h" #include "bat/ads/confirmation_type.h" @@ -47,7 +49,7 @@ std::string MinimumWaitTimePermissionRule::GetLastMessage() const { bool MinimumWaitTimePermissionRule::DoesRespectCap( const std::vector& history) { - const int ads_per_hour = settings::GetAdsPerHour(); + const uint64_t ads_per_hour = settings::GetAdsPerHour(); if (ads_per_hour == 0) { return false; } diff --git a/vendor/bat-native-ads/src/bat/ads/internal/serving/permission_rules/minimum_wait_time_permission_rule_unittest.cc b/vendor/bat-native-ads/src/bat/ads/internal/serving/permission_rules/minimum_wait_time_permission_rule_unittest.cc index 47886facf959..927bef17e9be 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/serving/permission_rules/minimum_wait_time_permission_rule_unittest.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/serving/permission_rules/minimum_wait_time_permission_rule_unittest.cc @@ -34,7 +34,7 @@ TEST_F(BatAdsMinimumWaitTimePermissionRuleTest, AllowAdIfThereIsNoAdsHistory) { TEST_F(BatAdsMinimumWaitTimePermissionRuleTest, AllowAdIfDoesNotExceedCap) { // Arrange - AdsClientHelper::Get()->SetIntegerPref(prefs::kAdsPerHour, 5); + AdsClientHelper::Get()->SetInt64Pref(prefs::kAdsPerHour, 5); RecordAdEvent(AdType::kNotificationAd, ConfirmationType::kServed); @@ -50,7 +50,7 @@ TEST_F(BatAdsMinimumWaitTimePermissionRuleTest, AllowAdIfDoesNotExceedCap) { TEST_F(BatAdsMinimumWaitTimePermissionRuleTest, DoNotAllowAdIfExceedsCap) { // Arrange - AdsClientHelper::Get()->SetIntegerPref(prefs::kAdsPerHour, 5); + AdsClientHelper::Get()->SetInt64Pref(prefs::kAdsPerHour, 5); RecordAdEvent(AdType::kNotificationAd, ConfirmationType::kServed); diff --git a/vendor/bat-native-ads/src/bat/ads/internal/serving/permission_rules/notification_ads/ads_per_hour_permission_rule_unittest.cc b/vendor/bat-native-ads/src/bat/ads/internal/serving/permission_rules/notification_ads/ads_per_hour_permission_rule_unittest.cc index 04fe5d936033..43462daf2eaf 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/serving/permission_rules/notification_ads/ads_per_hour_permission_rule_unittest.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/serving/permission_rules/notification_ads/ads_per_hour_permission_rule_unittest.cc @@ -5,6 +5,8 @@ #include "bat/ads/internal/serving/permission_rules/notification_ads/ads_per_hour_permission_rule.h" +#include + #include "bat/ads/internal/ad_events/ad_event_unittest_util.h" #include "bat/ads/internal/ads_client_helper.h" #include "bat/ads/internal/base/unittest/unittest_base.h" @@ -37,9 +39,9 @@ TEST_F(BatAdsAdsPerHourPermissionRuleTest, AlwaysAllowAdOnAndroid) { // Arrange MockPlatformHelper(platform_helper_mock_, PlatformType::kAndroid); - const int ads_per_hour = 5; + const int64_t ads_per_hour = 5; - AdsClientHelper::Get()->SetIntegerPref(prefs::kAdsPerHour, ads_per_hour); + AdsClientHelper::Get()->SetInt64Pref(prefs::kAdsPerHour, ads_per_hour); RecordAdEvents(AdType::kNotificationAd, ConfirmationType::kServed, ads_per_hour); @@ -56,8 +58,8 @@ TEST_F(BatAdsAdsPerHourPermissionRuleTest, AlwaysAllowAdOnIOS) { // Arrange MockPlatformHelper(platform_helper_mock_, PlatformType::kIOS); - const int ads_per_hour = 5; - AdsClientHelper::Get()->SetIntegerPref(prefs::kAdsPerHour, ads_per_hour); + const int64_t ads_per_hour = 5; + AdsClientHelper::Get()->SetInt64Pref(prefs::kAdsPerHour, ads_per_hour); RecordAdEvents(AdType::kNotificationAd, ConfirmationType::kServed, ads_per_hour); @@ -72,9 +74,9 @@ TEST_F(BatAdsAdsPerHourPermissionRuleTest, AlwaysAllowAdOnIOS) { TEST_F(BatAdsAdsPerHourPermissionRuleTest, AllowAdIfDoesNotExceedCap) { // Arrange - const int ads_per_hour = 5; + const int64_t ads_per_hour = 5; - AdsClientHelper::Get()->SetIntegerPref(prefs::kAdsPerHour, ads_per_hour); + AdsClientHelper::Get()->SetInt64Pref(prefs::kAdsPerHour, ads_per_hour); RecordAdEvents(AdType::kNotificationAd, ConfirmationType::kServed, ads_per_hour - 1); @@ -90,9 +92,9 @@ TEST_F(BatAdsAdsPerHourPermissionRuleTest, AllowAdIfDoesNotExceedCap) { TEST_F(BatAdsAdsPerHourPermissionRuleTest, AllowAdIfDoesNotExceedCapAfter1Hour) { // Arrange - const int ads_per_hour = 5; + const int64_t ads_per_hour = 5; - AdsClientHelper::Get()->SetIntegerPref(prefs::kAdsPerHour, ads_per_hour); + AdsClientHelper::Get()->SetInt64Pref(prefs::kAdsPerHour, ads_per_hour); RecordAdEvents(AdType::kNotificationAd, ConfirmationType::kServed, ads_per_hour); @@ -110,9 +112,9 @@ TEST_F(BatAdsAdsPerHourPermissionRuleTest, TEST_F(BatAdsAdsPerHourPermissionRuleTest, DoNotAllowAdIfExceedsCapWithin1Hour) { // Arrange - const int ads_per_hour = 5; + const int64_t ads_per_hour = 5; - AdsClientHelper::Get()->SetIntegerPref(prefs::kAdsPerHour, ads_per_hour); + AdsClientHelper::Get()->SetInt64Pref(prefs::kAdsPerHour, ads_per_hour); RecordAdEvents(AdType::kNotificationAd, ConfirmationType::kServed, ads_per_hour); diff --git a/vendor/bat-native-ads/src/bat/ads/internal/settings/settings.cc b/vendor/bat-native-ads/src/bat/ads/internal/settings/settings.cc index 08aa92a41fdb..8f3d6f8d0cc2 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/settings/settings.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/settings/settings.cc @@ -5,6 +5,8 @@ #include "bat/ads/internal/settings/settings.h" +#include + #include "base/cxx17_backports.h" #include "bat/ads/internal/ads_client_helper.h" #include "bat/ads/internal/serving/serving_features.h" @@ -14,13 +16,19 @@ namespace ads { namespace settings { int GetAdsPerHour() { - int ads_per_hour = AdsClientHelper::Get()->GetIntegerPref(prefs::kAdsPerHour); + int64_t ads_per_hour = + AdsClientHelper::Get()->GetInt64Pref(prefs::kAdsPerHour); + if (ads_per_hour == -1) { - ads_per_hour = features::GetDefaultNotificationAdsPerHour(); + ads_per_hour = + static_cast(features::GetDefaultNotificationAdsPerHour()); } - return base::clamp(ads_per_hour, kMinimumNotificationAdsPerHour, - kMaximumNotificationAdsPerHour); + const int64_t clamped_ads_per_hour = base::clamp( + ads_per_hour, static_cast(kMinimumNotificationAdsPerHour), + static_cast(kMaximumNotificationAdsPerHour)); + + return static_cast(clamped_ads_per_hour); } } // namespace settings diff --git a/vendor/bat-native-ads/src/bat/ads/internal/settings/settings_unittest.cc b/vendor/bat-native-ads/src/bat/ads/internal/settings/settings_unittest.cc index 45ef286cefd0..8c14770c5a2f 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/settings/settings_unittest.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/settings/settings_unittest.cc @@ -5,6 +5,7 @@ #include "bat/ads/internal/settings/settings.h" +#include #include #include "base/test/scoped_feature_list.h" @@ -37,13 +38,13 @@ TEST_F(BatAdsSettingsTest, AdsPerHourWhenUserHasChangedDefaultSetting) { scoped_feature_list.InitWithFeaturesAndParameters(enabled_features, disabled_features); - AdsClientHelper::Get()->SetIntegerPref(prefs::kAdsPerHour, 3); + AdsClientHelper::Get()->SetInt64Pref(prefs::kAdsPerHour, 3); // Act - const int ads_per_hour = settings::GetAdsPerHour(); + const uint64_t ads_per_hour = settings::GetAdsPerHour(); // Assert - const int expected_ads_per_hour = 3; + const uint64_t expected_ads_per_hour = 3; EXPECT_EQ(expected_ads_per_hour, ads_per_hour); } @@ -62,10 +63,10 @@ TEST_F(BatAdsSettingsTest, AdsPerHourWhenUserHasNotChangedDefaultSetting) { disabled_features); // Act - const int ads_per_hour = settings::GetAdsPerHour(); + const uint64_t ads_per_hour = settings::GetAdsPerHour(); // Assert - const int expected_ads_per_hour = 2; + const uint64_t expected_ads_per_hour = 2; EXPECT_EQ(expected_ads_per_hour, ads_per_hour); } @@ -84,10 +85,10 @@ TEST_F(BatAdsSettingsTest, ClampMinAdsPerHour) { disabled_features); // Act - const int ads_per_hour = settings::GetAdsPerHour(); + const uint64_t ads_per_hour = settings::GetAdsPerHour(); // Assert - const int expected_ads_per_hour = 0; + const uint64_t expected_ads_per_hour = 0; EXPECT_EQ(expected_ads_per_hour, ads_per_hour); } @@ -106,10 +107,10 @@ TEST_F(BatAdsSettingsTest, ClampMaxAdsPerHour) { disabled_features); // Act - const int ads_per_hour = settings::GetAdsPerHour(); + const uint64_t ads_per_hour = settings::GetAdsPerHour(); // Assert - const int expected_ads_per_hour = 10; + const uint64_t expected_ads_per_hour = 10; EXPECT_EQ(expected_ads_per_hour, ads_per_hour); } diff --git a/vendor/bat-native-ads/src/bat/ads/internal/user_interaction/browsing/user_activity_manager.cc b/vendor/bat-native-ads/src/bat/ads/internal/user_interaction/browsing/user_activity_manager.cc index fc451848afe9..e56a11567d1f 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/user_interaction/browsing/user_activity_manager.cc +++ b/vendor/bat-native-ads/src/bat/ads/internal/user_interaction/browsing/user_activity_manager.cc @@ -91,7 +91,7 @@ void UserActivityManager::RecordEvent(const UserActivityEventType event_type) { LogEvent(event_type); } -void UserActivityManager::RecordEventForPageTransition(const uint32_t type) { +void UserActivityManager::RecordEventForPageTransition(const int32_t type) { const PageTransitionType page_transition_type = static_cast(type); diff --git a/vendor/bat-native-ads/src/bat/ads/internal/user_interaction/browsing/user_activity_manager.h b/vendor/bat-native-ads/src/bat/ads/internal/user_interaction/browsing/user_activity_manager.h index 59fa3e9e341d..45400998cea9 100644 --- a/vendor/bat-native-ads/src/bat/ads/internal/user_interaction/browsing/user_activity_manager.h +++ b/vendor/bat-native-ads/src/bat/ads/internal/user_interaction/browsing/user_activity_manager.h @@ -34,7 +34,7 @@ class UserActivityManager final : public BrowserManagerObserver, static bool HasInstance(); void RecordEvent(const UserActivityEventType event_type); - void RecordEventForPageTransition(const uint32_t type); + void RecordEventForPageTransition(const int32_t type); UserActivityEventList GetHistoryForTimeWindow( const base::TimeDelta time_window) const;