Skip to content

Commit

Permalink
Replace P3A usages of NOTREACHED_IN_MIGRATION
Browse files Browse the repository at this point in the history
  • Loading branch information
DJAndries committed Oct 30, 2024
1 parent be3fe14 commit 6d3f691
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 49 deletions.
14 changes: 4 additions & 10 deletions components/brave_news/browser/brave_news_p3a.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void NewsMetrics::RecordTotalActionCount(ActionType action,
uint64_t count_delta) {
DVLOG(1) << __FUNCTION__ << " action: " << static_cast<int>(action)
<< ", count_delta: " << count_delta;
const char* pref_name;
const char* pref_name = nullptr;
switch (action) {
case ActionType::kCardView:
pref_name = prefs::kBraveNewsTotalCardViews;
Expand All @@ -131,10 +131,8 @@ void NewsMetrics::RecordTotalActionCount(ActionType action,
case ActionType::kSidebarFilterUsage:
pref_name = prefs::kBraveNewsTotalSidebarFilterUsages;
break;
default:
NOTREACHED_IN_MIGRATION();
return;
}
CHECK(pref_name);

WeeklyStorage total_storage(prefs_, pref_name);

Expand Down Expand Up @@ -164,8 +162,6 @@ void NewsMetrics::RecordTotalActionCount(ActionType action,
p3a_utils::RecordToHistogramBucket(kSidebarFilterUsageHistogramName,
kSidebarFilterUsageBuckets, total);
break;
default:
NOTREACHED_IN_MIGRATION();
}
}

Expand Down Expand Up @@ -204,18 +200,16 @@ void NewsMetrics::RecordTotalSubscribedCount(SubscribeType subscribe_type,
subscription_counts_[subscribe_type] = *total;
}

const char* histogram_name;
const char* histogram_name = nullptr;
switch (subscribe_type) {
case SubscribeType::kChannels:
histogram_name = kChannelCountHistogramName;
break;
case SubscribeType::kPublishers:
histogram_name = kPublisherCountHistogramName;
break;
default:
NOTREACHED_IN_MIGRATION();
return;
}
CHECK(histogram_name);

if (!IsMonthlyActiveUser()) {
// Only report for active users in the past month.
Expand Down
16 changes: 4 additions & 12 deletions components/brave_wallet/browser/brave_wallet_p3a.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void BraveWalletP3A::ReportJSProvider(mojom::JSProviderType provider_type,
histogram_name = kSolProviderHistogramName;
break;
default:
NOTREACHED_NORETURN();
return;
}

JSProviderAnswer answer = JSProviderAnswer::kNoWallet;
Expand Down Expand Up @@ -180,8 +180,6 @@ void BraveWalletP3A::ReportJSProvider(mojom::JSProviderType provider_type,
: JSProviderAnswer::kNativeNotOverridden;
}
break;
default:
NOTREACHED_NORETURN();
}

base::UmaHistogramEnumeration(histogram_name, answer);
Expand Down Expand Up @@ -256,12 +254,9 @@ void BraveWalletP3A::ReportTransactionSent(mojom::CoinType coin,
case mojom::CoinType::ZEC:
histogram_name = kZecTransactionSentHistogramName;
break;
default:
NOTREACHED_IN_MIGRATION() << coin;
return;
}

DCHECK(histogram_name);
CHECK(histogram_name);

ScopedDictPrefUpdate last_sent_time_update(
profile_prefs_, kBraveWalletLastTransactionSentTimeDict);
Expand Down Expand Up @@ -309,12 +304,9 @@ void BraveWalletP3A::RecordActiveWalletCount(int count,
case mojom::CoinType::ZEC:
histogram_name = kZecActiveAccountHistogramName;
break;
default:
NOTREACHED_IN_MIGRATION() << coin_type;
return;
}

DCHECK(histogram_name);
CHECK(histogram_name);

const base::Value::Dict& active_wallet_dict =
profile_prefs_->GetDict(kBraveWalletP3AActiveWalletDict);
Expand Down Expand Up @@ -472,7 +464,7 @@ void BraveWalletP3A::OnTransactionStatusChanged(
return;
}
} else {
NOTREACHED_IN_MIGRATION();
return;
}
ReportTransactionSent(tx_coin, true);
}
Expand Down
2 changes: 1 addition & 1 deletion components/misc_metrics/menu_metrics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const char* GetMenuGroupPrefKey(MenuGroup group) {
case MenuGroup::kBrowserViews:
return kBrowserViewsPrefKey;
}
NOTREACHED_IN_MIGRATION();
NOTREACHED();
}

} // namespace
Expand Down
4 changes: 2 additions & 2 deletions components/p3a/constellation_helper_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class P3AConstellationHelperTest : public testing::Test {
case MetricLogType::kExpress:
return kTestExpressEpoch;
}
NOTREACHED_IN_MIGRATION();
NOTREACHED();
}

const char* GetTestNextEpochTime(MetricLogType log_type) {
Expand All @@ -137,7 +137,7 @@ class P3AConstellationHelperTest : public testing::Test {
case MetricLogType::kExpress:
return kTestExpressNextEpochTime;
}
NOTREACHED_IN_MIGRATION();
NOTREACHED();
}

void CheckInfoRequestMade(MetricLogType log_type) {
Expand Down
11 changes: 4 additions & 7 deletions components/p3a/constellation_log_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,15 @@ const std::string& ConstellationLogStore::staged_log_histogram_name() const {
}

const std::string& ConstellationLogStore::staged_log_hash() const {
NOTREACHED_IN_MIGRATION();
return staged_log_hash_;
NOTREACHED();
}

const std::string& ConstellationLogStore::staged_log_signature() const {
NOTREACHED_IN_MIGRATION();
return staged_log_signature_;
NOTREACHED();
}

std::optional<uint64_t> ConstellationLogStore::staged_log_user_id() const {
NOTREACHED_IN_MIGRATION();
return std::nullopt;
NOTREACHED();
}

void ConstellationLogStore::StageNextLog() {
Expand Down Expand Up @@ -175,7 +172,7 @@ void ConstellationLogStore::MarkStagedLogAsSent() {

void ConstellationLogStore::TrimAndPersistUnsentLogs(
bool overwrite_in_memory_store) {
NOTREACHED_IN_MIGRATION();
NOTREACHED();
}

size_t ConstellationLogStore::GetMaxEpochsToRetain() const {
Expand Down
2 changes: 1 addition & 1 deletion components/p3a/constellation_log_store_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class P3AConstellationLogStoreTest : public testing::Test {
case MetricLogType::kExpress:
return kExpressMaxEpochsToRetain;
}
NOTREACHED_IN_MIGRATION();
NOTREACHED();
}

void UpdateSomeMessages(uint8_t epoch, size_t message_count) {
Expand Down
2 changes: 1 addition & 1 deletion components/p3a/histograms_braveizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void HistogramsBraveizer::DoHistogramBravetization(
answer = 1;
break;
default:
NOTREACHED_IN_MIGRATION();
return;
}
UMA_HISTOGRAM_BOOLEAN("Brave.Core.IsDefault", answer);
}
Expand Down
2 changes: 1 addition & 1 deletion components/p3a/message_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class P3AMessageManagerTest : public testing::Test,
histogram_names_end = kCollectedTypicalHistograms.cend();
break;
default:
NOTREACHED_IN_MIGRATION();
NOTREACHED();
}
for (auto histogram_name_i = histogram_names_begin;
histogram_name_i != histogram_names_end; histogram_name_i++) {
Expand Down
11 changes: 4 additions & 7 deletions components/p3a/metric_log_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,18 +219,15 @@ const std::string& MetricLogStore::staged_log_key() const {
}

const std::string& MetricLogStore::staged_log_hash() const {
NOTREACHED_IN_MIGRATION();
return staged_log_hash_;
NOTREACHED();
}

const std::string& MetricLogStore::staged_log_signature() const {
NOTREACHED_IN_MIGRATION();
return staged_log_signature_;
NOTREACHED();
}

std::optional<uint64_t> MetricLogStore::staged_log_user_id() const {
NOTREACHED_IN_MIGRATION();
return std::nullopt;
NOTREACHED();
}

void MetricLogStore::StageNextLog() {
Expand Down Expand Up @@ -277,7 +274,7 @@ void MetricLogStore::DiscardStagedLog(std::string_view reason) {
void MetricLogStore::MarkStagedLogAsSent() {}

void MetricLogStore::TrimAndPersistUnsentLogs(bool overwrite_in_memory_store) {
NOTREACHED_IN_MIGRATION();
NOTREACHED();
}

void MetricLogStore::LoadPersistedUnsentLogs() {
Expand Down
2 changes: 1 addition & 1 deletion components/p3a/metric_log_type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const char* MetricLogTypeToString(MetricLogType log_type) {
case MetricLogType::kExpress:
return kExpressStr;
}
NOTREACHED_IN_MIGRATION();
NOTREACHED();
}

std::optional<MetricLogType> StringToMetricLogType(
Expand Down
1 change: 0 additions & 1 deletion components/p3a/p3a_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ void P3AService::OnHistogramChanged(const char* histogram_name,
const bool ok = samples->Iterator()->GetBucketIndex(&bucket);
if (!ok) {
LOG(ERROR) << "Only linear histograms are supported at the moment!";
NOTREACHED_IN_MIGRATION();
return;
}

Expand Down
8 changes: 3 additions & 5 deletions components/p3a/rotation_scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ base::Time GetNextJsonRotationTime(MetricLogType log_type,
case MetricLogType::kExpress:
return NextDay(last_rotation);
default:
NOTREACHED_IN_MIGRATION();
NOTREACHED();
}
}

Expand All @@ -90,9 +90,8 @@ const char* GetJsonRotationTimestampPref(MetricLogType log_type) {
case MetricLogType::kExpress:
return kLastExpressJsonRotationTimeStampPref;
default:
NOTREACHED_IN_MIGRATION();
NOTREACHED();
}
return nullptr;
}

const char* GetConstellationRotationTimestampPref(MetricLogType log_type) {
Expand All @@ -104,9 +103,8 @@ const char* GetConstellationRotationTimestampPref(MetricLogType log_type) {
case MetricLogType::kExpress:
return kLastExpressConstellationRotationTimeStampPref;
default:
NOTREACHED_IN_MIGRATION();
NOTREACHED();
}
return nullptr;
}

} // namespace
Expand Down

0 comments on commit 6d3f691

Please sign in to comment.