[ads][CodeHealth] Use get() instead of &* to extract raw pointers (#35805)
Use the idiomatic Chromium form `.get()` to extract a raw pointer from smart pointers (mojo::StructPtr, std::unique_ptr, base::ScopedFILE) rather than the non-idiomatic `&*` dereference-and-address pattern. The three `raw_ref` sites are left unchanged because `raw_ref::get()` returns a reference, not a pointer, so `&*` is the correct form there. No behavioral changes.
This commit is contained in:
@@ -378,7 +378,7 @@ void AdsImpl::SuccessfullyInitialized(mojom::WalletInfoPtr mojom_wallet,
|
||||
|
||||
std::optional<WalletInfo> wallet;
|
||||
if (mojom_wallet) {
|
||||
wallet = CreateWalletFromRecoverySeed(&*mojom_wallet);
|
||||
wallet = CreateWalletFromRecoverySeed(mojom_wallet.get());
|
||||
if (!wallet) {
|
||||
BLOG(0, "Invalid wallet");
|
||||
return FailedToInitialize(std::move(callback));
|
||||
@@ -415,7 +415,7 @@ void AdsImpl::LoadClientStateCallback(mojom::WalletInfoPtr mojom_wallet,
|
||||
|
||||
std::optional<WalletInfo> wallet;
|
||||
if (mojom_wallet) {
|
||||
wallet = CreateWalletFromRecoverySeed(&*mojom_wallet);
|
||||
wallet = CreateWalletFromRecoverySeed(mojom_wallet.get());
|
||||
if (!wallet) {
|
||||
BLOG(0, "Invalid wallet");
|
||||
return FailedToInitialize(std::move(callback));
|
||||
|
||||
@@ -40,7 +40,7 @@ std::optional<T> LoadAndParseResourceComponentOnBackgroundThread(
|
||||
|
||||
std::string content;
|
||||
const base::ScopedFILE scoped_file(base::FileToFILE(std::move(file), "rb"));
|
||||
if (!base::ReadStreamToString(&*scoped_file, &content)) {
|
||||
if (!base::ReadStreamToString(scoped_file.get(), &content)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -110,7 +110,7 @@ class BraveAdsSubdivisionTargetingExclusionRuleTest
|
||||
|
||||
subdivision_targeting_ = std::make_unique<SubdivisionTargeting>();
|
||||
subdivision_ = std::make_unique<Subdivision>();
|
||||
subdivision_->AddObserver(&*subdivision_targeting_);
|
||||
subdivision_->AddObserver(subdivision_targeting_.get());
|
||||
exclusion_rule_ = std::make_unique<SubdivisionTargetingExclusionRule>(
|
||||
*subdivision_targeting_);
|
||||
}
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ class BraveAdsSubdivisionTargetingTest : public test::TestBase {
|
||||
|
||||
subdivision_targeting_ = std::make_unique<SubdivisionTargeting>();
|
||||
subdivision_ = std::make_unique<Subdivision>();
|
||||
subdivision_->AddObserver(&*subdivision_targeting_);
|
||||
subdivision_->AddObserver(subdivision_targeting_.get());
|
||||
}
|
||||
|
||||
void MockHttpOkUrlResponse(const std::string& country_code,
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace brave_ads::test {
|
||||
AdsObserverMock* MockAdsObserver() {
|
||||
std::unique_ptr<AdsObserverMock> ads_observer_mock =
|
||||
std::make_unique<AdsObserverMock>();
|
||||
AdsObserverMock* const ads_observer_mock_ptr = &*ads_observer_mock;
|
||||
AdsObserverMock* const ads_observer_mock_ptr = ads_observer_mock.get();
|
||||
|
||||
// `AdsNotifierManager` takes ownership of `ads_observer_mock`.
|
||||
AdsNotifierManager::GetInstance().AddObserver(std::move(ads_observer_mock));
|
||||
|
||||
Reference in New Issue
Block a user