Skip to content

Commit

Permalink
[ads] Catalog code health
Browse files Browse the repository at this point in the history
  • Loading branch information
tmancey committed Oct 30, 2024
1 parent 366e9e0 commit ec7baf2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions components/brave_ads/core/internal/catalog/catalog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ void Catalog::MaybeFetchCatalog() const {
}
}

void Catalog::NotifyDidUpdateCatalog(const CatalogInfo& catalog) const {
void Catalog::NotifyDidFetchCatalog(const CatalogInfo& catalog) const {
for (CatalogObserver& observer : observers_) {
observer.OnDidUpdateCatalog(catalog);
observer.OnDidFetchCatalog(catalog);
}
}

void Catalog::NotifyFailedToUpdateCatalog() const {
void Catalog::NotifyFailedToFetchCatalog() const {
for (CatalogObserver& observer : observers_) {
observer.OnFailedToUpdateCatalog();
observer.OnFailedToFetchCatalog();
}
}

Expand Down Expand Up @@ -138,11 +138,11 @@ void Catalog::OnDidFetchCatalog(const CatalogInfo& catalog) {

SaveCatalog(catalog);

NotifyDidUpdateCatalog(catalog);
NotifyDidFetchCatalog(catalog);
}

void Catalog::OnFailedToFetchCatalog() {
NotifyFailedToUpdateCatalog();
NotifyFailedToFetchCatalog();
}

void Catalog::OnDidMigrateDatabase(const int /*from_version*/,
Expand Down
4 changes: 2 additions & 2 deletions components/brave_ads/core/internal/catalog/catalog.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class Catalog final : public AdsClientNotifierObserver,

void MaybeFetchCatalog() const;

void NotifyDidUpdateCatalog(const CatalogInfo& catalog) const;
void NotifyFailedToUpdateCatalog() const;
void NotifyDidFetchCatalog(const CatalogInfo& catalog) const;
void NotifyFailedToFetchCatalog() const;

// AdsClientNotifierObserver:
void OnNotifyDidInitializeAds() override;
Expand Down
8 changes: 4 additions & 4 deletions components/brave_ads/core/internal/catalog/catalog_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ struct CatalogInfo;

class CatalogObserver : public base::CheckedObserver {
public:
// Invoked when the catalog has updated.
virtual void OnDidUpdateCatalog(const CatalogInfo& catalog) {}
// Invoked when the catalog is successfully fetched.
virtual void OnDidFetchCatalog(const CatalogInfo& catalog) {}

// Invoked when the catalog failed to update.
virtual void OnFailedToUpdateCatalog() {}
// Invoked when the catalog fetch fails.
virtual void OnFailedToFetchCatalog() {}
};

} // namespace brave_ads
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class CatalogObserverMock : public CatalogObserver {

~CatalogObserverMock() override;

MOCK_METHOD(void, OnDidUpdateCatalog, (const CatalogInfo& catalog));
MOCK_METHOD(void, OnDidFetchCatalog, (const CatalogInfo& catalog));

MOCK_METHOD(void, OnFailedToUpdateCatalog, ());
MOCK_METHOD(void, OnFailedToFetchCatalog, ());
};

} // namespace brave_ads
Expand Down

0 comments on commit ec7baf2

Please sign in to comment.