Skip to content

Commit

Permalink
Merge pull request #19522 from brave/issues/32017
Browse files Browse the repository at this point in the history
Reload Brave Private Ads resources after Brave Rewards reset
  • Loading branch information
aseren authored Aug 3, 2023
2 parents 4728ee3 + eadf9f9 commit 993d991
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
8 changes: 1 addition & 7 deletions components/brave_ads/browser/ads_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,6 @@ AdsServiceImpl::AdsServiceImpl(
g_brave_browser_process->resource_component()->AddObserver(this);

rewards_service_->AddObserver(this);

if (ShouldAlwaysRunService()) {
RegisterResourceComponentsForDefaultLocale();
}
}

AdsServiceImpl::~AdsServiceImpl() {
Expand Down Expand Up @@ -503,9 +499,7 @@ void AdsServiceImpl::InitializeBatAdsCallback(const bool success) {

is_bat_ads_initialized_ = true;

if (!ShouldAlwaysRunService()) {
RegisterResourceComponentsForDefaultLocale();
}
RegisterResourceComponentsForDefaultLocale();

BackgroundHelper::GetInstance()->AddObserver(this);

Expand Down
16 changes: 16 additions & 0 deletions components/brave_ads/core/internal/database/database_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <utility>

#include "base/check_op.h"
#include "base/debug/crash_logging.h"
#include "base/debug/dump_without_crashing.h"
#include "base/functional/bind.h"
#include "brave/components/brave_ads/common/interfaces/brave_ads.mojom.h"
#include "brave/components/brave_ads/core/internal/ads_client_helper.h"
Expand All @@ -19,6 +21,18 @@

namespace brave_ads {

namespace {

// TODO(https://github.com/brave/brave-browser/issues/32066): Remove brave ads
// migration failure dumps
void DoDumpWithoutCrashing(const int from_version, const int to_version) {
SCOPED_CRASH_KEY_NUMBER("FromVersion", "value", from_version);
SCOPED_CRASH_KEY_NUMBER("ToVersion", "value", to_version);
base::debug::DumpWithoutCrashing();
}

} // namespace

DatabaseManager::DatabaseManager() = default;

DatabaseManager::~DatabaseManager() = default;
Expand Down Expand Up @@ -143,6 +157,8 @@ void DatabaseManager::MigrateFromVersionCallback(const int from_version,
const int to_version = database::kVersion;

if (!success) {
DoDumpWithoutCrashing(from_version, to_version);

BLOG(1, "Failed to migrate database from schema version "
<< from_version << " to schema version " << to_version);
NotifyFailedToMigrateDatabase(from_version, to_version);
Expand Down

0 comments on commit 993d991

Please sign in to comment.