0

[BRP] Rewriter run

This is a run of
`rewrite-multiple-platforms.sh linux,win,android`.

Patchset 1 contains the verbatim rewrite run against
`5a63e387e3a2c2641af7d279652355535f436706`
(resulting in a broken build).
Subsequent patchsets add in manual tweaks to fix the build.

Bug: 1415845
Change-Id: I6140c5f60da97b030f8bfb790d082707e90510d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4259465
Reviewed-by: Keishi Hattori <keishi@chromium.org>
Owners-Override: Keishi Hattori <keishi@chromium.org>
Commit-Queue: Kalvin Lee <kdlee@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1107424}
This commit is contained in:
Kalvin Lee
2023-02-20 13:47:56 +00:00
committed by Chromium LUCI CQ
parent 94f3707536
commit b8743ff466
56 changed files with 392 additions and 299 deletions
base/task
chrome/browser
components
content
extensions/browser/api/declarative_net_request
gpu/ipc
media/muxers
mojo
remoting/host/linux
services/network
third_party/blink/common/storage_key
ui/views
controls
widget

@ -319,7 +319,7 @@ TaskAnnotator::LongTaskTracker::~LongTaskTracker() {
TRACE_EVENT_BEGIN("scheduler.long_tasks", "LongTaskTracker",
perfetto::Track::ThreadScoped(task_annotator_),
task_start_time_, [&](perfetto::EventContext& ctx) {
TaskAnnotator::EmitTaskLocation(ctx, pending_task_);
TaskAnnotator::EmitTaskLocation(ctx, *pending_task_);
EmitReceivedIPCDetails(ctx);
});
TRACE_EVENT_END("scheduler.long_tasks",
@ -384,9 +384,9 @@ void TaskAnnotator::LongTaskTracker::MaybeTraceInterestingTaskDetails() {
// start of the flow between task queue time and task execution start time.
TRACE_EVENT_INSTANT("scheduler.long_tasks", "InterestingTask_QueueingTime",
perfetto::Track::ThreadScoped(task_annotator_),
pending_task_.queue_time,
pending_task_->queue_time,
perfetto::Flow::ProcessScoped(
task_annotator_->GetTaskTraceID(pending_task_)));
task_annotator_->GetTaskTraceID(*pending_task_)));
// Record the equivalent of a top-level event with enough IPC information
// to calculate the input to browser interval. This event will be the
@ -396,7 +396,7 @@ void TaskAnnotator::LongTaskTracker::MaybeTraceInterestingTaskDetails() {
perfetto::Track::ThreadScoped(task_annotator_), task_start_time_,
[&](perfetto::EventContext& ctx) {
perfetto::TerminatingFlow::ProcessScoped(
task_annotator_->GetTaskTraceID(pending_task_))(ctx);
task_annotator_->GetTaskTraceID(*pending_task_))(ctx);
auto* info = ctx.event()->set_chrome_mojo_event_info();
info->set_mojo_interface_tag(ipc_interface_name_);
});

@ -9,6 +9,7 @@
#include "base/base_export.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ref.h"
#include "base/pending_task.h"
#include "base/strings/string_piece.h"
#include "base/time/tick_clock.h"
@ -183,7 +184,7 @@ class BASE_EXPORT TaskAnnotator::LongTaskTracker {
// known. Note that this will not compile in the Native client.
uint32_t (*ipc_method_info_)();
bool is_response_ = false;
PendingTask& pending_task_;
const raw_ref<PendingTask> pending_task_;
raw_ptr<TaskAnnotator> task_annotator_;
};

@ -270,7 +270,7 @@ void ThreadController::RunLevelTracker::RunLevel::UpdateState(State new_state) {
// Flow emission is found at
// ThreadController::RunLevelTracker::RecordScheduleWork.
TRACE_EVENT_BEGIN("base", "ThreadController active",
terminating_wakeup_flow_lambda_);
*terminating_wakeup_flow_lambda_);
// Overriding the annotation from the previous RunLevel is intentional. Only
// the top RunLevel is ever updated, which holds the relevant state.
thread_controller_sample_metadata_.Set(

@ -414,7 +414,7 @@ class BASE_EXPORT ThreadController {
SampleMetadata thread_controller_sample_metadata_;
size_t thread_controller_active_id_ = 0;
#if BUILDFLAG(ENABLE_BASE_TRACING)
TerminatingFlowLambda& terminating_wakeup_flow_lambda_;
const raw_ref<TerminatingFlowLambda> terminating_wakeup_flow_lambda_;
#endif
// Toggles to true when used as RunLevel&& input to construct another

@ -225,7 +225,7 @@ sessions::TabRestoreService::Entries::const_iterator TabIterator::CurrentEntry()
TabIterator& TabIterator::operator++() {
// Early out at end.
if (current_entry_ == entries_.cend()) {
if (current_entry_ == entries_->cend()) {
return *this;
}
@ -241,7 +241,7 @@ TabIterator& TabIterator::operator++() {
tabs_ = nullptr;
current_tab_ = absl::nullopt;
current_entry_++;
if (current_entry_ == entries_.cend()) {
if (current_entry_ == entries_->cend()) {
return *this;
}
@ -278,7 +278,7 @@ const sessions::TabRestoreService::Tab* TabIterator::operator->() const {
}
void TabIterator::SetupInnerTabList() {
if (current_entry_ == entries_.cend()) {
if (current_entry_ == entries_->cend()) {
return;
}

@ -11,6 +11,7 @@
#include "base/android/scoped_java_ref.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ref.h"
#include "chrome/browser/ui/android/tab_model/android_live_tab_context_wrapper.h"
#include "components/sessions/core/tab_restore_service.h"
#include "components/sessions/core/tab_restore_service_observer.h"
@ -55,7 +56,7 @@ class TabIterator {
private:
void SetupInnerTabList();
const sessions::TabRestoreService::Entries& entries_;
const raw_ref<const sessions::TabRestoreService::Entries> entries_;
sessions::TabRestoreService::Entries::const_iterator current_entry_;
raw_ptr<const std::vector<std::unique_ptr<sessions::TabRestoreService::Tab>>>
tabs_ = nullptr;

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/memory/raw_ptr.h"
#include "chrome/browser/browsing_data/access_context_audit_service_factory.h"
#include "chrome/browser/browsing_data/cookies_tree_model.h"
#include "chrome/browser/chrome_content_browser_client.h"
@ -231,7 +232,7 @@ class ScopedNonDefaultStoragePartitionContentBrowserClient
private:
const char* target_host_;
content::StoragePartitionConfig storage_partition_config_;
content::ContentBrowserClient* original_client_;
raw_ptr<content::ContentBrowserClient> original_client_;
};
IN_PROC_BROWSER_TEST_F(CookiesTreeModelBrowserTest,

@ -752,8 +752,8 @@ class DIPSPrepopulateTest : public PlatformBrowserTest {
->FlushLossyWebsiteSettings();
}
DIPSService* dips_service;
base::SequenceBound<DIPSStorage>* storage;
raw_ptr<DIPSService> dips_service;
raw_ptr<base::SequenceBound<DIPSStorage>> storage;
private:
base::test::ScopedFeatureList feature_list_;

@ -362,7 +362,7 @@ class DownloadDisplayControllerTest : public testing::Test {
raw_ptr<Profile> profile_;
std::unique_ptr<TestBrowserWindow> window_;
std::unique_ptr<Browser> browser_;
MockDownloadCoreService* mock_download_core_service_;
raw_ptr<MockDownloadCoreService> mock_download_core_service_;
std::unique_ptr<ChromeDownloadManagerDelegate> delegate_;
};

@ -6,6 +6,7 @@
#include <memory>
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/task/thread_pool.h"
#include "base/test/bind.h"
@ -105,7 +106,8 @@ class PlatformAuthNavigationThrottleTest : public testing::Test {
std::unique_ptr<::testing::StrictMock<MockPlatformAuthProvider>>
owned_provider_{
std::make_unique<::testing::StrictMock<MockPlatformAuthProvider>>()};
::testing::StrictMock<MockPlatformAuthProvider>* mock_provider_ = nullptr;
raw_ptr<::testing::StrictMock<MockPlatformAuthProvider>> mock_provider_ =
nullptr;
};
// The manager is disabled, so no origins or data are fetched.

@ -4,6 +4,7 @@
#include "chrome/browser/enterprise/platform_auth/platform_auth_provider_manager.h"
#include "base/memory/raw_ptr.h"
#include "base/numerics/safe_conversions.h"
#include "base/run_loop.h"
#include "base/test/metrics/histogram_tester.h"
@ -55,7 +56,8 @@ class PlatformAuthProviderManagerTest : public ::testing::Test {
std::unique_ptr<::testing::StrictMock<MockPlatformAuthProvider>>
owned_provider_{
std::make_unique<::testing::StrictMock<MockPlatformAuthProvider>>()};
::testing::StrictMock<MockPlatformAuthProvider>* mock_provider_ = nullptr;
raw_ptr<::testing::StrictMock<MockPlatformAuthProvider>> mock_provider_ =
nullptr;
base::test::TaskEnvironment task_environment_;
};

@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_EXTENSIONS_API_PASSWORDS_PRIVATE_PASSWORDS_PRIVATE_DELEGATE_FACTORY_H_
#define CHROME_BROWSER_EXTENSIONS_API_PASSWORDS_PRIVATE_PASSWORDS_PRIVATE_DELEGATE_FACTORY_H_
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/no_destructor.h"
#include "chrome/browser/profiles/profile_keyed_service_factory.h"
@ -41,7 +42,7 @@ class PasswordsPrivateDelegateProxy : public KeyedService {
// KeyedService
void Shutdown() override;
content::BrowserContext* browser_context_ = nullptr;
raw_ptr<content::BrowserContext> browser_context_ = nullptr;
base::WeakPtr<PasswordsPrivateDelegate> weak_instance_;
// TODO(crbug.com/1412348): Remove this after the feature is enabled by
// default.

@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_SIGNIN_SIGNIN_BROWSER_TEST_BASE_H_
#define CHROME_BROWSER_SIGNIN_SIGNIN_BROWSER_TEST_BASE_H_
#include "base/memory/raw_ptr.h"
#include "chrome/browser/signin/identity_test_environment_profile_adaptor.h"
#include "chrome/test/base/in_process_browser_test.h"
@ -60,7 +61,7 @@ class SigninBrowserTestBase : public InProcessBrowserTest {
std::unique_ptr<IdentityTestEnvironmentProfileAdaptor>
identity_test_env_profile_adaptor_;
base::CallbackListSubscription create_services_subscription_;
Profile* profile_ = nullptr;
raw_ptr<Profile> profile_ = nullptr;
const bool use_main_profile_;
network::TestURLLoaderFactory test_url_loader_factory_;

@ -12,6 +12,7 @@
#include "base/containers/flat_set.h"
#include "base/functional/callback_forward.h"
#include "base/lazy_instance.h"
#include "base/memory/raw_ref.h"
#include "base/observer_list.h"
#include "build/build_config.h"
@ -43,12 +44,12 @@ class BrowserList {
void* operator new(size_t) = delete;
void* operator new(size_t, void*) = delete;
const BrowserList& browser_list;
const raw_ref<const BrowserList> browser_list;
const_reverse_iterator begin() const {
return browser_list.begin_browsers_ordered_by_activation();
return browser_list->begin_browsers_ordered_by_activation();
}
const_reverse_iterator end() const {
return browser_list.end_browsers_ordered_by_activation();
return browser_list->end_browsers_ordered_by_activation();
}
};
@ -80,7 +81,7 @@ class BrowserList {
// Example:
// for (Browser* browser : BrowserList::GetInstance()->OrderedByActivation())
BrowsersOrderedByActivationRange OrderedByActivation() const {
return {*this};
return {raw_ref(*this)};
}
// Returns the set of browsers that are currently in the closing state.

@ -4,6 +4,7 @@
#include "chrome/browser/ui/global_media_controls/cast_device_list_host.h"
#include "base/memory/raw_ptr.h"
#include "chrome/browser/ui/media_router/cast_dialog_controller.h"
#include "chrome/browser/ui/media_router/cast_dialog_model.h"
#include "chrome/browser/ui/media_router/media_route_starter.h"
@ -79,7 +80,7 @@ class CastDeviceListHostTest : public testing::Test {
protected:
content::BrowserTaskEnvironment task_environment_;
std::unique_ptr<CastDeviceListHost> host_;
MockCastDialogController* dialog_controller_ = nullptr;
raw_ptr<MockCastDialogController> dialog_controller_ = nullptr;
mojo::PendingReceiver<global_media_controls::mojom::DeviceListClient>
client_receiver_;
};

@ -9,6 +9,7 @@
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/json/json_string_value_serializer.h"
#include "base/memory/raw_ref.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/test/bind.h"
@ -57,13 +58,13 @@ class PolicyUpdateObserver : public policy::PolicyService::Observer {
: policy_service_(policy_service),
policy_updated_callback_(std::move(policy_updated_callback)) {
DCHECK(policy_updated_callback_);
policy_service_.AddObserver(policy::PolicyDomain::POLICY_DOMAIN_CHROME,
this);
policy_service_->AddObserver(policy::PolicyDomain::POLICY_DOMAIN_CHROME,
this);
}
~PolicyUpdateObserver() override {
policy_service_.RemoveObserver(policy::PolicyDomain::POLICY_DOMAIN_CHROME,
this);
policy_service_->RemoveObserver(policy::PolicyDomain::POLICY_DOMAIN_CHROME,
this);
}
void OnPolicyUpdated(const policy::PolicyNamespace& ns,
@ -73,12 +74,12 @@ class PolicyUpdateObserver : public policy::PolicyService::Observer {
return;
}
policy_service_.RemoveObserver(policy::PolicyDomain::POLICY_DOMAIN_CHROME,
this);
policy_service_->RemoveObserver(policy::PolicyDomain::POLICY_DOMAIN_CHROME,
this);
std::move(policy_updated_callback_).Run();
}
policy::PolicyService& policy_service_;
const raw_ref<policy::PolicyService> policy_service_;
base::OnceClosure policy_updated_callback_;
};

@ -8,6 +8,7 @@
#include "base/functional/bind.h"
#include "base/i18n/number_formatting.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/strcat.h"
#include "cc/paint/paint_flags.h"
#include "chrome/app/vector_icons/vector_icons.h"
@ -96,7 +97,7 @@ class CircleBadgeImageSource : public gfx::CanvasImageSource {
private:
// Pointee may be modified to change the text color upon painting.
gfx::RenderText* const render_text_ = nullptr;
const raw_ptr<gfx::RenderText> render_text_ = nullptr;
const SkColor text_color_;
const SkColor background_color_;
};

@ -43,8 +43,8 @@ void SimpleOverlayWindowImageButton::OnBoundsChanged(
void SimpleOverlayWindowImageButton::UpdateImage() {
const int icon_size = std::max(0, width() - (2 * kPipWindowIconPadding));
SetImageModel(views::Button::STATE_NORMAL,
ui::ImageModel::FromVectorIcon(icon_, kColorPipWindowForeground,
icon_size));
ui::ImageModel::FromVectorIcon(
*icon_, kColorPipWindowForeground, icon_size));
}
BEGIN_METADATA(SimpleOverlayWindowImageButton, OverlayWindowImageButton)

@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_VIEWS_OVERLAY_SIMPLE_OVERLAY_WINDOW_IMAGE_BUTTON_H_
#define CHROME_BROWSER_UI_VIEWS_OVERLAY_SIMPLE_OVERLAY_WINDOW_IMAGE_BUTTON_H_
#include "base/memory/raw_ref.h"
#include "chrome/browser/ui/views/overlay/overlay_window_image_button.h"
#include "ui/base/metadata/metadata_header_macros.h"
@ -36,7 +37,7 @@ class SimpleOverlayWindowImageButton : public OverlayWindowImageButton {
private:
void UpdateImage();
const gfx::VectorIcon& icon_;
const raw_ref<const gfx::VectorIcon> icon_;
// Last visible size of the image button.
gfx::Size last_visible_size_;

@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_VIEW_H_
#include "base/memory/raw_ptr.h"
#include "chrome/browser/ui/passwords/bubble_controllers/items_bubble_controller.h"
#include "chrome/browser/ui/views/passwords/password_bubble_view_base.h"
#include "components/password_manager/core/browser/password_form.h"
@ -69,12 +70,12 @@ class ManagePasswordsView : public PasswordBubbleViewBase {
// currently selected password.
absl::optional<password_manager::PasswordForm> currently_selected_password_;
views::View* display_username_row_ = nullptr;
views::View* edit_username_row_ = nullptr;
raw_ptr<views::View> display_username_row_ = nullptr;
raw_ptr<views::View> edit_username_row_ = nullptr;
views::Textfield* username_textfield_ = nullptr;
views::View* display_note_row_ = nullptr;
views::View* edit_note_row_ = nullptr;
raw_ptr<views::View> display_note_row_ = nullptr;
raw_ptr<views::View> edit_note_row_ = nullptr;
views::Textarea* note_textarea_ = nullptr;
ItemsBubbleController controller_;

@ -219,7 +219,7 @@ class CompoundTabContainer : public TabContainer,
// The sub-container that handled the last drag/drop update, if any. Used to
// ensure HandleDragExited is called when necessary.
TabContainer* current_text_drop_target_ = nullptr;
raw_ptr<TabContainer> current_text_drop_target_ = nullptr;
};
#endif // CHROME_BROWSER_UI_VIEWS_TABS_COMPOUND_TAB_CONTAINER_H_

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/memory/raw_ptr.h"
#include "base/strings/strcat.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/views/tabs/tab_strip.h"
@ -43,7 +44,7 @@ class WebUIWebAppBrowserTest : public WebAppControllerBrowserTest {
std::string start_url;
raw_ptr<Browser> browser;
raw_ptr<BrowserView> browser_view;
content::WebContents* web_contents;
raw_ptr<content::WebContents> web_contents;
};
App InstallAndLaunch() {

@ -82,7 +82,7 @@ class SiteSettingsPermissionsHandler : public settings::SettingsPageUIHandler {
const raw_ptr<Profile> profile_;
base::Clock* clock_;
raw_ptr<base::Clock> clock_;
void SetClockForTesting(base::Clock* clock);
};

@ -7,6 +7,7 @@
#include <memory>
#include "base/memory/raw_ptr.h"
#include "chrome/browser/ui/webui/side_panel/search_companion/search_companion.mojom.h"
#include "chrome/browser/ui/webui/webui_load_timer.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
@ -51,7 +52,7 @@ class SearchCompanionSidePanelUI
std::unique_ptr<SearchCompanionPageHandler> search_companion_page_handler_;
mojo::Receiver<side_panel::mojom::SearchCompanionPageHandlerFactory>
search_companion_page_factory_receiver_{this};
content::WebUI* web_ui_;
raw_ptr<content::WebUI> web_ui_;
WEB_UI_CONTROLLER_TYPE_DECL();
};

@ -5,6 +5,7 @@
#include "components/autofill/core/browser/contact_info_sync_util.h"
#include "base/guid.h"
#include "base/memory/raw_ref.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "components/autofill/core/browser/field_types.h"
@ -64,13 +65,13 @@ class EntryDataSetter {
void Set(ContactInfoSpecifics::StringToken* token,
ServerFieldType type) const {
token->set_value(base::UTF16ToUTF8(profile_.GetRawInfo(type)));
token->set_value(base::UTF16ToUTF8(profile_->GetRawInfo(type)));
SetMetadata(token->mutable_metadata(), type);
}
void Set(ContactInfoSpecifics::IntegerToken* token,
ServerFieldType type) const {
token->set_value(profile_.GetRawInfoAsInt(type));
token->set_value(profile_->GetRawInfoAsInt(type));
SetMetadata(token->mutable_metadata(), type);
}
@ -78,10 +79,10 @@ class EntryDataSetter {
void SetMetadata(ContactInfoSpecifics::TokenMetadata* metadata,
ServerFieldType type) const {
metadata->set_status(ConvertProfileToSpecificsVerificationStatus(
profile_.GetVerificationStatus(type)));
profile_->GetVerificationStatus(type)));
}
const AutofillProfile& profile_;
const raw_ref<const AutofillProfile> profile_;
};
// Helper class to set the info and verification status of an AutofillProfile
@ -92,20 +93,20 @@ class ProfileSetter {
void Set(const ContactInfoSpecifics::StringToken& token,
ServerFieldType type) {
profile_.SetRawInfoWithVerificationStatus(
profile_->SetRawInfoWithVerificationStatus(
type, base::UTF8ToUTF16(token.value()),
ConvertSpecificsToProfileVerificationStatus(token.metadata().status()));
}
void Set(const ContactInfoSpecifics::IntegerToken& token,
ServerFieldType type) {
profile_.SetRawInfoAsIntWithVerificationStatus(
profile_->SetRawInfoAsIntWithVerificationStatus(
type, token.value(),
ConvertSpecificsToProfileVerificationStatus(token.metadata().status()));
}
private:
AutofillProfile& profile_;
const raw_ref<AutofillProfile> profile_;
};
} // namespace

@ -8,6 +8,7 @@
#include "base/containers/contains.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ref.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/test/scoped_run_loop_timeout.h"
@ -288,20 +289,20 @@ const FormStructure* WaitForMatchingForm(
private:
void OnAutofillManagerDestroyed(AutofillManager& manager) override {
DCHECK_EQ(&manager, &manager_);
DCHECK_EQ(&manager, &manager_.get());
run_loop_.Quit();
observation_.Reset();
}
void OnAutofillManagerReset(AutofillManager& manager) override {
DCHECK_EQ(&manager, &manager_);
DCHECK_EQ(&manager, &manager_.get());
run_loop_.Quit();
observation_.Reset();
}
void OnAfterFormsSeen(AutofillManager& manager,
base::span<const FormGlobalId> forms) override {
DCHECK_EQ(&manager, &manager_);
DCHECK_EQ(&manager, &manager_.get());
if (const auto* form = FindForm()) {
matching_form_ = form;
run_loop_.Quit();
@ -310,15 +311,15 @@ const FormStructure* WaitForMatchingForm(
FormStructure* FindForm() const {
auto it = base::ranges::find_if(
manager_.form_structures(),
manager_->form_structures(),
[&](const auto& p) { return pred_.Run(*p.second); });
return it != manager_.form_structures().end() ? it->second.get()
: nullptr;
return it != manager_->form_structures().end() ? it->second.get()
: nullptr;
}
base::ScopedObservation<AutofillManager, AutofillManager::Observer>
observation_{this};
AutofillManager& manager_;
const raw_ref<AutofillManager> manager_;
base::RepeatingCallback<bool(const FormStructure&)> pred_;
base::RunLoop run_loop_;
raw_ptr<const FormStructure> matching_form_ = nullptr;

@ -6,6 +6,7 @@
#include <utility>
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
@ -112,7 +113,7 @@ class AgentSignalsCollectorTest : public testing::Test {
base::test::TaskEnvironment task_environment_{
base::test::TaskEnvironment::TimeSource::MOCK_TIME};
StrictMock<MockCrowdStrikeClient>* mocked_crowdstrike_client_;
raw_ptr<StrictMock<MockCrowdStrikeClient>> mocked_crowdstrike_client_;
std::unique_ptr<AgentSignalsCollector> collector_;
base::HistogramTester histogram_tester_;
};

@ -79,13 +79,15 @@ bool OriginTrialPolicyImpl::IsFeatureDisabledForUser(
base::StringPiece feature) const {
struct OriginTrialFeatureToBaseFeatureMap {
const char* origin_trial_feature_name;
const base::Feature& field_trial_feature;
const raw_ref<const base::Feature> field_trial_feature;
} origin_trial_feature_to_field_trial_feature_map[] = {
{"FrobulateThirdParty", kOriginTrialsSampleAPIThirdPartyAlternativeUsage},
{"ConversionMeasurement", kConversionMeasurementAPIAlternativeUsage}};
{"FrobulateThirdParty",
raw_ref(kOriginTrialsSampleAPIThirdPartyAlternativeUsage)},
{"ConversionMeasurement",
raw_ref(kConversionMeasurementAPIAlternativeUsage)}};
for (const auto& mapping : origin_trial_feature_to_field_trial_feature_map) {
if (feature == mapping.origin_trial_feature_name) {
return !base::FeatureList::IsEnabled(mapping.field_trial_feature);
return !base::FeatureList::IsEnabled(*mapping.field_trial_feature);
}
}
return false;

@ -14,6 +14,7 @@
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ref.h"
#include "base/metrics/field_trial_params.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
@ -503,7 +504,7 @@ std::vector<std::string> FlattenGroupsAndFeatures(
// the provided items with parsed data. If any field is null, then it won't be
// parsed.
struct ConfigParseOutput {
uint32_t& parse_errors;
const raw_ref<uint32_t> parse_errors;
raw_ptr<Comparator> session_rate = nullptr;
raw_ptr<SessionRateImpact> session_rate_impact = nullptr;
raw_ptr<Blocking> blocking = nullptr;
@ -540,7 +541,7 @@ void ParseConfigFields(const base::Feature* feature,
if (!ParseEventConfig(param_value, &event_config)) {
stats::RecordConfigParsingEvent(
stats::ConfigParsingEvent::FAILURE_USED_EVENT_PARSE);
++output.parse_errors;
++*output.parse_errors;
continue;
}
*output.used = event_config;
@ -549,7 +550,7 @@ void ParseConfigFields(const base::Feature* feature,
if (!ParseEventConfig(param_value, &event_config)) {
stats::RecordConfigParsingEvent(
stats::ConfigParsingEvent::FAILURE_TRIGGER_EVENT_PARSE);
++output.parse_errors;
++*output.parse_errors;
continue;
}
*output.trigger = event_config;
@ -558,7 +559,7 @@ void ParseConfigFields(const base::Feature* feature,
if (!ParseComparator(param_value, &comparator)) {
stats::RecordConfigParsingEvent(
stats::ConfigParsingEvent::FAILURE_SESSION_RATE_PARSE);
++output.parse_errors;
++*output.parse_errors;
continue;
}
*output.session_rate = comparator;
@ -568,7 +569,7 @@ void ParseConfigFields(const base::Feature* feature,
feature, all_features, all_groups)) {
stats::RecordConfigParsingEvent(
stats::ConfigParsingEvent::FAILURE_SESSION_RATE_IMPACT_PARSE);
++output.parse_errors;
++*output.parse_errors;
continue;
}
*output.session_rate_impact = parsed_session_rate_impact;
@ -577,7 +578,7 @@ void ParseConfigFields(const base::Feature* feature,
if (!ParseBlocking(param_value, &parsed_blocking)) {
stats::RecordConfigParsingEvent(
stats::ConfigParsingEvent::FAILURE_BLOCKING_PARSE);
++output.parse_errors;
++*output.parse_errors;
continue;
}
*output.blocking = parsed_blocking;
@ -587,7 +588,7 @@ void ParseConfigFields(const base::Feature* feature,
all_features, all_groups)) {
stats::RecordConfigParsingEvent(
stats::ConfigParsingEvent::FAILURE_BLOCKED_BY_PARSE);
++output.parse_errors;
++*output.parse_errors;
continue;
}
*output.blocked_by = parsed_blocked_by;
@ -596,7 +597,7 @@ void ParseConfigFields(const base::Feature* feature,
if (!ParseTrackingOnly(param_value, &parsed_tracking_only)) {
stats::RecordConfigParsingEvent(
stats::ConfigParsingEvent::FAILURE_TRACKING_ONLY_PARSE);
++output.parse_errors;
++*output.parse_errors;
continue;
}
*output.tracking_only = parsed_tracking_only;
@ -605,7 +606,7 @@ void ParseConfigFields(const base::Feature* feature,
if (!ParseComparator(param_value, &comparator)) {
stats::RecordConfigParsingEvent(
stats::ConfigParsingEvent::FAILURE_AVAILABILITY_PARSE);
++output.parse_errors;
++*output.parse_errors;
continue;
}
*output.availability = comparator;
@ -614,7 +615,7 @@ void ParseConfigFields(const base::Feature* feature,
if (!ParseSnoozeParams(param_value, &parsed_snooze_params)) {
stats::RecordConfigParsingEvent(
stats::ConfigParsingEvent::FAILURE_SNOOZE_PARAMS_PARSE);
++output.parse_errors;
++*output.parse_errors;
continue;
}
*output.snooze_params = parsed_snooze_params;
@ -626,7 +627,7 @@ void ParseConfigFields(const base::Feature* feature,
if (!ParseGroups(param_value, &groups, feature, all_groups)) {
stats::RecordConfigParsingEvent(
stats::ConfigParsingEvent::FAILURE_GROUPS_PARSE);
++output.parse_errors;
++*output.parse_errors;
continue;
}
*output.groups = groups;
@ -637,7 +638,7 @@ void ParseConfigFields(const base::Feature* feature,
if (!ParseEventConfig(param_value, &event_config)) {
stats::RecordConfigParsingEvent(
stats::ConfigParsingEvent::FAILURE_OTHER_EVENT_PARSE);
++output.parse_errors;
++*output.parse_errors;
continue;
}
output.event_configs->insert(event_config);

@ -1270,8 +1270,8 @@ MetricsReporter::GoodVisitState::GoodVisitState(PersistentMetricsData& data)
void MetricsReporter::GoodVisitState::OnScroll() {
ExtendOrStartNewVisit();
data_.did_scroll_in_visit = true;
if (data_.time_in_feed_for_good_visit >= kGoodTimeInFeed) {
data_->did_scroll_in_visit = true;
if (data_->time_in_feed_for_good_visit >= kGoodTimeInFeed) {
MaybeReportGoodVisit();
}
}
@ -1292,13 +1292,14 @@ void MetricsReporter::GoodVisitState::ExtendOrStartNewVisit() {
const base::Time now = base::Time::Now();
// Reset visit state if enough time has passed since visit_end_.
if (now - data_.visit_end >= kVisitTimeout) {
if (now - data_->visit_end >= kVisitTimeout) {
Reset();
}
if (data_.visit_start == base::Time())
data_.visit_start = now;
data_.visit_end = now;
if (data_->visit_start == base::Time()) {
data_->visit_start = now;
}
data_->visit_end = now;
}
void MetricsReporter::GoodVisitState::AddTimeInFeed(base::TimeDelta time) {
@ -1312,26 +1313,27 @@ void MetricsReporter::GoodVisitState::AddTimeInFeed(base::TimeDelta time) {
ExtendOrStartNewVisit();
data_.time_in_feed_for_good_visit += time;
if (data_.did_scroll_in_visit &&
data_.time_in_feed_for_good_visit >= kGoodTimeInFeed) {
data_->time_in_feed_for_good_visit += time;
if (data_->did_scroll_in_visit &&
data_->time_in_feed_for_good_visit >= kGoodTimeInFeed) {
MaybeReportGoodVisit();
}
}
void MetricsReporter::GoodVisitState::MaybeReportGoodVisit() {
if (data_.did_report_good_visit)
if (data_->did_report_good_visit) {
return;
}
ReportCombinedEngagementTypeHistogram(FeedEngagementType::kGoodVisit);
data_.did_report_good_visit = true;
data_->did_report_good_visit = true;
}
void MetricsReporter::GoodVisitState::Reset() {
data_.visit_start = base::Time();
data_.visit_end = base::Time();
data_.did_report_good_visit = false;
data_.time_in_feed_for_good_visit = base::Seconds(0);
data_.did_scroll_in_visit = false;
data_->visit_start = base::Time();
data_->visit_end = base::Time();
data_->did_report_good_visit = false;
data_->time_in_feed_for_good_visit = base::Seconds(0);
data_->did_scroll_in_visit = false;
}
void MetricsReporter::ReportContentDuplication(

@ -9,6 +9,7 @@
#include <map>
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ref.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "components/feed/core/proto/v2/store.pb.h"
@ -271,7 +272,7 @@ class MetricsReporter {
// Owned by MetricsReporter. Will live through the lifetime of
// GoodVisitState.
PersistentMetricsData& data_;
const raw_ref<PersistentMetricsData> data_;
};
GoodVisitState good_visit_state_;

@ -9,6 +9,7 @@
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/test/task_environment.h"
#include "base/time/default_tick_clock.h"
@ -225,7 +226,7 @@ class RemotingSenderTest : public ::testing::Test {
base::test::TaskEnvironment task_environment_;
const scoped_refptr<media::cast::CastEnvironment> cast_environment_;
testing::StrictMock<FakeSender>* sender_;
raw_ptr<testing::StrictMock<FakeSender>> sender_;
bool expecting_error_callback_run_ = false;
std::unique_ptr<MojoSenderWrapper> mojo_sender_wrapper_;

@ -23,7 +23,7 @@ CachedResultProvider::CachedResultProvider(
: configs_(configs), result_prefs_(std::move(prefs)) {
PostProcessor post_processor;
for (const auto& config : configs_) {
for (const auto& config : *configs_) {
absl::optional<proto::ClientResult> client_result =
result_prefs_->ReadClientResultFromPrefs(config->segmentation_key);
bool has_valid_result = client_result.has_value() &&

@ -8,6 +8,7 @@
#include <string>
#include "base/functional/callback.h"
#include "base/memory/raw_ref.h"
#include "components/segmentation_platform/internal/selection/client_result_prefs.h"
#include "components/segmentation_platform/public/result.h"
@ -42,7 +43,7 @@ class CachedResultProvider {
private:
// Configs for all registered clients.
const std::vector<std::unique_ptr<Config>>& configs_;
const raw_ref<const std::vector<std::unique_ptr<Config>>> configs_;
// The underlying pref backed store to read the pref values from.
std::unique_ptr<ClientResultPrefs> result_prefs_;

@ -29,7 +29,7 @@ void RequestDispatcher::OnPlatformInitialized(
// Only set request handlers if it has not been set for testing already.
if (request_handlers_.empty()) {
for (const auto& config : configs_) {
for (const auto& config : *configs_) {
request_handlers_[config->segmentation_key] = RequestHandler::Create(
*config, std::move(result_providers[config->segmentation_key]),
execution_service);

@ -11,6 +11,7 @@
#include "base/containers/circular_deque.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ref.h"
#include "base/memory/scoped_refptr.h"
#include "components/segmentation_platform/internal/selection/cached_result_provider.h"
#include "components/segmentation_platform/internal/selection/request_handler.h"
@ -61,7 +62,7 @@ class RequestDispatcher {
private:
// Configs for all registered clients.
const std::vector<std::unique_ptr<Config>>& configs_;
const raw_ref<const std::vector<std::unique_ptr<Config>>> configs_;
// Request handlers associated with the clients.
std::map<std::string, std::unique_ptr<RequestHandler>> request_handlers_;

@ -4,6 +4,7 @@
#include "components/segmentation_platform/internal/selection/request_handler.h"
#include "base/memory/raw_ref.h"
#include "base/memory/scoped_refptr.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/clock.h"
@ -58,7 +59,7 @@ class RequestHandlerImpl : public RequestHandler {
std::unique_ptr<SegmentResultProvider::SegmentResult> result);
// The config for providing client config params.
const Config& config_;
const raw_ref<const Config> config_;
// The result provider responsible for getting the result, either by running
// the model or getting results from the cache as necessary.
@ -96,12 +97,12 @@ void RequestHandlerImpl::GetModelResult(
const PredictionOptions& options,
scoped_refptr<InputContext> input_context,
SegmentResultProvider::SegmentResultCallback callback) {
DCHECK_EQ(config_.segments.size(), 1u);
DCHECK_EQ(config_->segments.size(), 1u);
auto result_options =
std::make_unique<SegmentResultProvider::GetResultOptions>();
// Note that, this assumes that a client has only one model.
result_options->segment_id = config_.segments.begin()->first;
result_options->segment_id = config_->segments.begin()->first;
result_options->ignore_db_scores = options.on_demand_execution;
result_options->input_context = input_context;
result_options->callback = std::move(callback);
@ -123,7 +124,7 @@ void RequestHandlerImpl::OnGetModelResultForClassification(
// might be null in testing.
if (execution_service_ && execution_service_->training_data_collector()) {
execution_service_->training_data_collector()->OnDecisionTime(
config_.segments.begin()->first, input_context,
config_->segments.begin()->first, input_context,
proto::TrainingOutputs::TriggerConfig::ONDEMAND);
}
}

@ -8,6 +8,7 @@
#include <map>
#include <memory>
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/process/kill.h"
@ -99,7 +100,7 @@ class ChildProcessLauncherHelper
base::Process process;
#if BUILDFLAG(USE_ZYGOTE)
ZygoteCommunication* zygote = nullptr;
raw_ptr<ZygoteCommunication> zygote = nullptr;
#endif // BUILDFLAG(USE_ZYGOTE)
#if BUILDFLAG(IS_FUCHSIA)

@ -143,7 +143,7 @@ struct RuntimeFeatureToChromiumFeatureMap {
// or the string name of the feature in runtime_enabled_features.json5.
T feature_enabler;
// The chromium base::Feature to check.
const base::Feature& chromium_feature;
const raw_ref<const base::Feature> chromium_feature;
const RuntimeFeatureEnableOptions option = kDefault;
};
@ -183,128 +183,152 @@ void SetRuntimeFeaturesFromChromiumFeatures() {
const RuntimeFeatureToChromiumFeatureMap<void (*)(bool)>
blinkFeatureToBaseFeatureMapping[] =
{ {wf::EnableAccessibilityAriaVirtualContent,
features::kEnableAccessibilityAriaVirtualContent},
raw_ref(features::kEnableAccessibilityAriaVirtualContent)},
{wf::EnableAccessibilityExposeHTMLElement,
features::kEnableAccessibilityExposeHTMLElement},
raw_ref(features::kEnableAccessibilityExposeHTMLElement)},
{wf::EnableAccessibilityExposeIgnoredNodes,
features::kEnableAccessibilityExposeIgnoredNodes},
raw_ref(features::kEnableAccessibilityExposeIgnoredNodes)},
#if BUILDFLAG(IS_ANDROID)
{wf::EnableAccessibilityPageZoom, features::kAccessibilityPageZoom},
{wf::EnableAccessibilityPageZoom,
raw_ref(features::kAccessibilityPageZoom)},
{wf::EnableAutoDisableAccessibilityV2,
features::kAutoDisableAccessibilityV2},
raw_ref(features::kAutoDisableAccessibilityV2)},
#endif
{wf::EnableAccessibilityUseAXPositionForDocumentMarkers,
features::kUseAXPositionForDocumentMarkers},
raw_ref(features::kUseAXPositionForDocumentMarkers)},
{wf::EnableAOMAriaRelationshipProperties,
features::kEnableAriaElementReflection},
{wf::EnableAutoplayIgnoresWebAudio, media::kAutoplayIgnoreWebAudio},
{wf::EnableBackgroundFetch, features::kBackgroundFetch},
raw_ref(features::kEnableAriaElementReflection)},
{wf::EnableAutoplayIgnoresWebAudio,
raw_ref(media::kAutoplayIgnoreWebAudio)},
{wf::EnableBackgroundFetch, raw_ref(features::kBackgroundFetch)},
{wf::EnableBrowserVerifiedUserActivationKeyboard,
features::kBrowserVerifiedUserActivationKeyboard},
raw_ref(features::kBrowserVerifiedUserActivationKeyboard)},
{wf::EnableBrowserVerifiedUserActivationMouse,
features::kBrowserVerifiedUserActivationMouse},
{wf::EnableCompositeBGColorAnimation, features::kCompositeBGColorAnimation},
raw_ref(features::kBrowserVerifiedUserActivationMouse)},
{wf::EnableCompositeBGColorAnimation,
raw_ref(features::kCompositeBGColorAnimation)},
{wf::EnableCompositeClipPathAnimation,
features::kCompositeClipPathAnimation},
{wf::EnableConsolidatedMovementXY, features::kConsolidatedMovementXY},
{wf::EnableCooperativeScheduling, features::kCooperativeScheduling},
{wf::EnableDevicePosture, features::kDevicePosture},
{wf::EnableDigitalGoods, features::kDigitalGoodsApi, kSetOnlyIfOverridden},
{wf::EnableDirectSockets, features::kIsolatedWebApps},
{wf::EnableDocumentPolicy, features::kDocumentPolicy},
{wf::EnableDocumentPolicyNegotiation, features::kDocumentPolicyNegotiation},
{wf::EnableFedCm, features::kFedCm, kSetOnlyIfOverridden},
{wf::EnableFedCmAutoReauthn, features::kFedCmAutoReauthn,
raw_ref(features::kCompositeClipPathAnimation)},
{wf::EnableConsolidatedMovementXY,
raw_ref(features::kConsolidatedMovementXY)},
{wf::EnableCooperativeScheduling,
raw_ref(features::kCooperativeScheduling)},
{wf::EnableDevicePosture, raw_ref(features::kDevicePosture)},
{wf::EnableDigitalGoods, raw_ref(features::kDigitalGoodsApi),
kSetOnlyIfOverridden},
{wf::EnableFedCmIdPRegistration, features::kFedCmIdPRegistration, kDefault},
{wf::EnableFedCmIframeSupport, features::kFedCmIframeSupport,
{wf::EnableDirectSockets, raw_ref(features::kIsolatedWebApps)},
{wf::EnableDocumentPolicy, raw_ref(features::kDocumentPolicy)},
{wf::EnableDocumentPolicyNegotiation,
raw_ref(features::kDocumentPolicyNegotiation)},
{wf::EnableFedCm, raw_ref(features::kFedCm), kSetOnlyIfOverridden},
{wf::EnableFedCmAutoReauthn, raw_ref(features::kFedCmAutoReauthn),
kSetOnlyIfOverridden},
{wf::EnableFedCmLoginHint, features::kFedCmLoginHint, kSetOnlyIfOverridden},
{wf::EnableFedCmMultipleIdentityProviders,
features::kFedCmMultipleIdentityProviders, kDefault},
{wf::EnableFedCmRpContext, features::kFedCmRpContext, kDefault},
{wf::EnableFedCmUserInfo, features::kFedCmUserInfo, kSetOnlyIfOverridden},
{wf::EnableFedCmSelectiveDisclosure, features::kFedCmSelectiveDisclosure,
{wf::EnableFedCmIdPRegistration, raw_ref(features::kFedCmIdPRegistration),
kDefault},
{wf::EnableFencedFrames, features::kPrivacySandboxAdsAPIsOverride,
{wf::EnableFedCmIframeSupport, raw_ref(features::kFedCmIframeSupport),
kSetOnlyIfOverridden},
{wf::EnableSharedStorageAPI, features::kPrivacySandboxAdsAPIsOverride,
{wf::EnableFedCmLoginHint, raw_ref(features::kFedCmLoginHint),
kSetOnlyIfOverridden},
{wf::EnableForcedColors, features::kForcedColors},
{wf::EnableFractionalScrollOffsets, features::kFractionalScrollOffsets},
{wf::EnableSensorExtraClasses, features::kGenericSensorExtraClasses},
{wf::EnableFedCmMultipleIdentityProviders,
raw_ref(features::kFedCmMultipleIdentityProviders), kDefault},
{wf::EnableFedCmRpContext, raw_ref(features::kFedCmRpContext), kDefault},
{wf::EnableFedCmUserInfo, raw_ref(features::kFedCmUserInfo),
kSetOnlyIfOverridden},
{wf::EnableFedCmSelectiveDisclosure,
raw_ref(features::kFedCmSelectiveDisclosure), kDefault},
{wf::EnableFencedFrames, raw_ref(features::kPrivacySandboxAdsAPIsOverride),
kSetOnlyIfOverridden},
{wf::EnableSharedStorageAPI,
raw_ref(features::kPrivacySandboxAdsAPIsOverride), kSetOnlyIfOverridden},
{wf::EnableForcedColors, raw_ref(features::kForcedColors)},
{wf::EnableFractionalScrollOffsets,
raw_ref(features::kFractionalScrollOffsets)},
{wf::EnableSensorExtraClasses,
raw_ref(features::kGenericSensorExtraClasses)},
#if BUILDFLAG(IS_ANDROID)
{wf::EnableGetDisplayMedia, features::kUserMediaScreenCapturing},
{wf::EnableGetDisplayMedia, raw_ref(features::kUserMediaScreenCapturing)},
#endif
{wf::EnableIdleDetection, features::kIdleDetection, kSetOnlyIfOverridden},
{wf::EnableInstalledApp, features::kInstalledApp},
{wf::EnableIdleDetection, raw_ref(features::kIdleDetection),
kSetOnlyIfOverridden},
{wf::EnableInstalledApp, raw_ref(features::kInstalledApp)},
{wf::EnableLazyInitializeMediaControls,
features::kLazyInitializeMediaControls},
{wf::EnableLazyFrameLoading, features::kLazyFrameLoading},
{wf::EnableLazyImageLoading, features::kLazyImageLoading},
raw_ref(features::kLazyInitializeMediaControls)},
{wf::EnableLazyFrameLoading, raw_ref(features::kLazyFrameLoading)},
{wf::EnableLazyImageLoading, raw_ref(features::kLazyImageLoading)},
{wf::EnableLazyImageVisibleLoadTimeMetrics,
features::kLazyImageVisibleLoadTimeMetrics},
{wf::EnableMediaCastOverlayButton, media::kMediaCastOverlayButton},
raw_ref(features::kLazyImageVisibleLoadTimeMetrics)},
{wf::EnableMediaCastOverlayButton, raw_ref(media::kMediaCastOverlayButton)},
{wf::EnableMediaEngagementBypassAutoplayPolicies,
media::kMediaEngagementBypassAutoplayPolicies},
raw_ref(media::kMediaEngagementBypassAutoplayPolicies)},
{wf::EnableMouseSubframeNoImplicitCapture,
features::kMouseSubframeNoImplicitCapture},
{wf::EnableNotificationContentImage, features::kNotificationContentImage,
kSetOnlyIfOverridden},
{wf::EnablePaymentApp, features::kServiceWorkerPaymentApps},
{wf::EnablePaymentRequest, features::kWebPayments},
{wf::EnablePercentBasedScrolling, features::kWindowsScrollingPersonality},
{wf::EnablePeriodicBackgroundSync, features::kPeriodicBackgroundSync},
{wf::EnablePointerLockOptions, features::kPointerLockOptions},
raw_ref(features::kMouseSubframeNoImplicitCapture)},
{wf::EnableNotificationContentImage,
raw_ref(features::kNotificationContentImage), kSetOnlyIfOverridden},
{wf::EnablePaymentApp, raw_ref(features::kServiceWorkerPaymentApps)},
{wf::EnablePaymentRequest, raw_ref(features::kWebPayments)},
{wf::EnablePercentBasedScrolling,
raw_ref(features::kWindowsScrollingPersonality)},
{wf::EnablePeriodicBackgroundSync,
raw_ref(features::kPeriodicBackgroundSync)},
{wf::EnablePointerLockOptions, raw_ref(features::kPointerLockOptions)},
{wf::EnablePushMessagingSubscriptionChange,
features::kPushSubscriptionChangeEvent},
{wf::EnableRestrictGamepadAccess, features::kRestrictGamepadAccess},
{wf::EnableSecurePaymentConfirmation, features::kSecurePaymentConfirmation},
raw_ref(features::kPushSubscriptionChangeEvent)},
{wf::EnableRestrictGamepadAccess,
raw_ref(features::kRestrictGamepadAccess)},
{wf::EnableSecurePaymentConfirmation,
raw_ref(features::kSecurePaymentConfirmation)},
{wf::EnableSecurePaymentConfirmationDebug,
features::kSecurePaymentConfirmationDebug},
raw_ref(features::kSecurePaymentConfirmationDebug)},
{wf::EnableSendBeaconThrowForBlobWithNonSimpleType,
features::kSendBeaconThrowForBlobWithNonSimpleType},
{wf::EnableSharedArrayBuffer, features::kSharedArrayBuffer},
raw_ref(features::kSendBeaconThrowForBlobWithNonSimpleType)},
{wf::EnableSharedArrayBuffer, raw_ref(features::kSharedArrayBuffer)},
{wf::EnableSharedArrayBufferOnDesktop,
features::kSharedArrayBufferOnDesktop},
{wf::EnableSharedAutofill, autofill::features::kAutofillSharedAutofill},
{wf::EnableTouchDragAndContextMenu, features::kTouchDragAndContextMenu},
raw_ref(features::kSharedArrayBufferOnDesktop)},
{wf::EnableSharedAutofill,
raw_ref(autofill::features::kAutofillSharedAutofill)},
{wf::EnableTouchDragAndContextMenu,
raw_ref(features::kTouchDragAndContextMenu)},
{wf::EnableUserActivationSameOriginVisibility,
features::kUserActivationSameOriginVisibility},
{wf::EnableVideoPlaybackQuality, features::kVideoPlaybackQuality},
raw_ref(features::kUserActivationSameOriginVisibility)},
{wf::EnableVideoPlaybackQuality, raw_ref(features::kVideoPlaybackQuality)},
{wf::EnableVideoWakeLockOptimisationHiddenMuted,
media::kWakeLockOptimisationHiddenMuted},
{wf::EnableWebBluetooth, features::kWebBluetooth, kSetOnlyIfOverridden},
raw_ref(media::kWakeLockOptimisationHiddenMuted)},
{wf::EnableWebBluetooth, raw_ref(features::kWebBluetooth),
kSetOnlyIfOverridden},
{wf::EnableWebBluetoothGetDevices,
features::kWebBluetoothNewPermissionsBackend, kSetOnlyIfOverridden},
raw_ref(features::kWebBluetoothNewPermissionsBackend),
kSetOnlyIfOverridden},
{wf::EnableWebBluetoothWatchAdvertisements,
features::kWebBluetoothNewPermissionsBackend, kSetOnlyIfOverridden},
raw_ref(features::kWebBluetoothNewPermissionsBackend),
kSetOnlyIfOverridden},
#if BUILDFLAG(IS_ANDROID)
{wf::EnableWebNFC, features::kWebNfc, kSetOnlyIfOverridden},
{wf::EnableWebNFC, raw_ref(features::kWebNfc), kSetOnlyIfOverridden},
#endif
{wf::EnableWebOTP, features::kWebOTP, kSetOnlyIfOverridden},
{wf::EnableWebOTP, raw_ref(features::kWebOTP), kSetOnlyIfOverridden},
{wf::EnableWebOTPAssertionFeaturePolicy,
features::kWebOTPAssertionFeaturePolicy, kSetOnlyIfOverridden},
{wf::EnableWebUSB, features::kWebUsb},
{wf::EnableWebXR, features::kWebXr},
raw_ref(features::kWebOTPAssertionFeaturePolicy), kSetOnlyIfOverridden},
{wf::EnableWebUSB, raw_ref(features::kWebUsb)},
{wf::EnableWebXR, raw_ref(features::kWebXr)},
#if BUILDFLAG(ENABLE_VR)
{wf::EnableWebXRFrontFacing, device::features::kWebXrIncubations},
{wf::EnableWebXRHandInput, device::features::kWebXrHandInput},
{wf::EnableWebXRImageTracking, device::features::kWebXrIncubations},
{wf::EnableWebXRLayers, device::features::kWebXrLayers},
{wf::EnableWebXRPlaneDetection, device::features::kWebXrIncubations},
{wf::EnableWebXRFrontFacing, raw_ref(device::features::kWebXrIncubations)},
{wf::EnableWebXRHandInput, raw_ref(device::features::kWebXrHandInput)},
{wf::EnableWebXRImageTracking,
raw_ref(device::features::kWebXrIncubations)},
{wf::EnableWebXRLayers, raw_ref(device::features::kWebXrLayers)},
{wf::EnableWebXRPlaneDetection,
raw_ref(device::features::kWebXrIncubations)},
#endif
{wf::EnableRemoveMobileViewportDoubleTap,
features::kRemoveMobileViewportDoubleTap},
{wf::EnableGetDisplayMediaSet, features::kGetDisplayMediaSet},
raw_ref(features::kRemoveMobileViewportDoubleTap)},
{wf::EnableGetDisplayMediaSet, raw_ref(features::kGetDisplayMediaSet)},
{wf::EnableGetDisplayMediaSetAutoSelectAllScreens,
features::kGetDisplayMediaSetAutoSelectAllScreens},
raw_ref(features::kGetDisplayMediaSetAutoSelectAllScreens)},
{wf::EnableServiceWorkerBypassFetchHandler,
features::kServiceWorkerBypassFetchHandler},
raw_ref(features::kServiceWorkerBypassFetchHandler)},
};
for (const auto& mapping : blinkFeatureToBaseFeatureMapping) {
SetRuntimeFeatureFromChromiumFeature(
mapping.chromium_feature, mapping.option, mapping.feature_enabler);
*mapping.chromium_feature, mapping.option, mapping.feature_enabler);
}
// TODO(crbug/832393): Cleanup the inconsistency between custom WRF enabler
@ -312,34 +336,38 @@ void SetRuntimeFeaturesFromChromiumFeatures() {
const RuntimeFeatureToChromiumFeatureMap<const char*>
runtimeFeatureNameToChromiumFeatureMapping[] = {
{"AllowContentInitiatedDataUrlNavigations",
features::kAllowContentInitiatedDataUrlNavigations},
{"AttributionReporting", features::kPrivacySandboxAdsAPIsOverride,
raw_ref(features::kAllowContentInitiatedDataUrlNavigations)},
{"AttributionReporting",
raw_ref(features::kPrivacySandboxAdsAPIsOverride),
kSetOnlyIfOverridden},
{"AndroidDownloadableFontsMatching",
features::kAndroidDownloadableFontsMatching},
{"Fledge", blink::features::kFledge, kSetOnlyIfOverridden},
{"Fledge", features::kPrivacySandboxAdsAPIsOverride,
raw_ref(features::kAndroidDownloadableFontsMatching)},
{"Fledge", raw_ref(blink::features::kFledge), kSetOnlyIfOverridden},
{"Fledge", raw_ref(features::kPrivacySandboxAdsAPIsOverride),
kSetOnlyIfOverridden},
{"FontSrcLocalMatching", features::kFontSrcLocalMatching},
{"FontSrcLocalMatching", raw_ref(features::kFontSrcLocalMatching)},
{"LegacyWindowsDWriteFontFallback",
features::kLegacyWindowsDWriteFontFallback},
{"OriginIsolationHeader", features::kOriginIsolationHeader},
{"PartitionedCookies", net::features::kPartitionedCookies},
{"ReduceAcceptLanguage", network::features::kReduceAcceptLanguage},
{"StorageAccessAPI", features::kFirstPartySets},
{"TopicsAPI", features::kPrivacySandboxAdsAPIsOverride,
raw_ref(features::kLegacyWindowsDWriteFontFallback)},
{"OriginIsolationHeader", raw_ref(features::kOriginIsolationHeader)},
{"PartitionedCookies", raw_ref(net::features::kPartitionedCookies)},
{"ReduceAcceptLanguage",
raw_ref(network::features::kReduceAcceptLanguage)},
{"StorageAccessAPI", raw_ref(features::kFirstPartySets)},
{"TopicsAPI", raw_ref(features::kPrivacySandboxAdsAPIsOverride),
kSetOnlyIfOverridden},
{"TopicsXHR", features::kPrivacySandboxAdsAPIsOverride,
{"TopicsXHR", raw_ref(features::kPrivacySandboxAdsAPIsOverride),
kSetOnlyIfOverridden},
{"TrustedTypesFromLiteral", features::kTrustedTypesFromLiteral},
{"WebAppTabStrip", features::kDesktopPWAsTabStrip},
{"TrustedTypesFromLiteral",
raw_ref(features::kTrustedTypesFromLiteral)},
{"WebAppTabStrip", raw_ref(features::kDesktopPWAsTabStrip)},
{"WGIGamepadTriggerRumble",
features::kEnableWindowsGamingInputDataFetcher},
{"UserAgentFull", blink::features::kFullUserAgent},
{"MediaStreamTrackTransfer", features::kMediaStreamTrackTransfer}};
raw_ref(features::kEnableWindowsGamingInputDataFetcher)},
{"UserAgentFull", raw_ref(blink::features::kFullUserAgent)},
{"MediaStreamTrackTransfer",
raw_ref(features::kMediaStreamTrackTransfer)}};
for (const auto& mapping : runtimeFeatureNameToChromiumFeatureMapping) {
SetRuntimeFeatureFromChromiumFeature(
mapping.chromium_feature, mapping.option, [&mapping](bool enabled) {
*mapping.chromium_feature, mapping.option, [&mapping](bool enabled) {
wf::EnableFeatureFromString(mapping.feature_enabler, enabled);
});
}

@ -107,7 +107,7 @@ DeclarativeNetRequestPrefsHelper::UpdateDisabledStaticRulesResult::
const base::Value::Dict*
DeclarativeNetRequestPrefsHelper::GetDisabledRuleIdsDict(
const ExtensionId& extension_id) const {
return prefs_.ReadPrefAsDict(
return prefs_->ReadPrefAsDict(
extension_id,
ExtensionPrefs::JoinPrefs(
{ExtensionPrefs::kDNRStaticRulesetPref, kDNRDisabledStaticRuleIds}));
@ -132,7 +132,7 @@ void DeclarativeNetRequestPrefsHelper::SetDisabledStaticRuleIds(
std::string key = ExtensionPrefs::JoinPrefs(
{ExtensionPrefs::kDNRStaticRulesetPref, kDNRDisabledStaticRuleIds});
ExtensionPrefs::ScopedDictionaryUpdate update(&prefs_, extension_id, key);
ExtensionPrefs::ScopedDictionaryUpdate update(&*prefs_, extension_id, key);
if (disabled_rule_ids.empty()) {
std::unique_ptr<prefs::DictionaryValueUpdate> disabled_rule_ids_dict =

@ -8,6 +8,7 @@
#include <vector>
#include "base/containers/flat_set.h"
#include "base/memory/raw_ref.h"
#include "base/values.h"
#include "extensions/common/api/declarative_net_request/constants.h"
#include "extensions/common/extension_id.h"
@ -87,7 +88,7 @@ class DeclarativeNetRequestPrefsHelper {
RulesetID ruleset_id,
const base::flat_set<int>& disabled_rule_ids);
ExtensionPrefs& prefs_;
const raw_ref<ExtensionPrefs> prefs_;
};
} // namespace declarative_net_request

@ -247,7 +247,7 @@ gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread(
task_executor_->mailbox_manager(), std::move(memory_tracker),
task_executor_->shader_translator_cache(),
task_executor_->framebuffer_completeness_cache(), feature_info,
params.attribs.bind_generates_resource, nullptr /* progress_reporter */,
params.attribs->bind_generates_resource, nullptr /* progress_reporter */,
task_executor_->gpu_feature_info(), task_executor_->discardable_manager(),
task_executor_->passthrough_discardable_manager(),
task_executor_->shared_image_manager());
@ -256,7 +256,7 @@ gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread(
// Virtualize GpuPreference:::kLowPower contexts by default on OS X to prevent
// performance regressions when enabling FCM. https://crbug.com/180463
use_virtualized_gl_context_ |=
(params.attribs.gpu_preference == gl::GpuPreference::kLowPower);
(params.attribs->gpu_preference == gl::GpuPreference::kLowPower);
#endif
use_virtualized_gl_context_ |= task_executor_->ForceVirtualizedGLContexts();
@ -304,7 +304,7 @@ gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread(
gl_share_group_ = task_executor_->GetShareGroup();
}
if (params.attribs.context_type == CONTEXT_TYPE_WEBGPU) {
if (params.attribs->context_type == CONTEXT_TYPE_WEBGPU) {
if (!task_executor_->gpu_preferences().enable_webgpu) {
DLOG(ERROR) << "ContextResult::kFatalFailure: WebGPU not enabled";
return gpu::ContextResult::kFatalFailure;
@ -323,8 +323,8 @@ gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread(
}
decoder_ = std::move(webgpu_decoder);
} else {
if (params.attribs.enable_raster_interface &&
!params.attribs.enable_gles2_interface) {
if (params.attribs->enable_raster_interface &&
!params.attribs->enable_gles2_interface) {
// RasterDecoder uses the shared context.
use_virtualized_gl_context_ = false;
@ -364,7 +364,7 @@ gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread(
if (!real_context) {
real_context = gl::init::CreateGLContext(
gl_share_group_.get(), surface_.get(),
GenerateGLContextAttribs(params.attribs, context_group_.get()));
GenerateGLContextAttribs(*params.attribs, context_group_.get()));
if (!real_context) {
// TODO(piman): This might not be fatal, we could recurse into
// CreateGLContext to get more info, tho it should be exceedingly
@ -398,7 +398,7 @@ gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread(
gl_share_group_.get(), real_context.get(), decoder_->AsWeakPtr());
if (!context_->Initialize(surface_.get(),
GenerateGLContextAttribs(
params.attribs, context_group_.get()))) {
*params.attribs, context_group_.get()))) {
// TODO(piman): This might not be fatal, we could recurse into
// CreateGLContext to get more info, tho it should be exceedingly
// rare and may not be recoverable anyway.
@ -429,7 +429,7 @@ gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread(
gles2::DisallowedFeatures disallowed_features;
auto result = decoder_->Initialize(surface_, context_, /*offscreen=*/true,
disallowed_features, params.attribs);
disallowed_features, *params.attribs);
if (result != gpu::ContextResult::kSuccess) {
DestroyOnGpuThread();
DLOG(ERROR) << "Failed to initialize decoder.";

@ -17,6 +17,7 @@
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ref.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/synchronization/lock.h"
@ -176,7 +177,7 @@ class GL_IN_PROCESS_CONTEXT_EXPORT InProcessCommandBuffer
private:
struct InitializeOnGpuThreadParams {
const ContextCreationAttribs& attribs;
const raw_ref<const ContextCreationAttribs> attribs;
raw_ptr<Capabilities> capabilities; // Ouptut.
raw_ptr<gpu::raster::GrShaderCache> gr_shader_cache;
raw_ptr<GpuProcessActivityFlags> activity_flags;

@ -612,7 +612,7 @@ base::TimeTicks WebmMuxer::MonotonicTimestampSequence::UpdateAndGetNext(
DLOG_IF(WARNING, timestamp < last_timestamp_)
<< "Encountered a non-monotonically increasing timestamp. Was: "
<< last_timestamp_ << ", timestamp: " << timestamp;
did_adjust_timestamp_ |= (timestamp < last_timestamp_);
*did_adjust_timestamp_ |= (timestamp < last_timestamp_);
last_timestamp_ = std::max(last_timestamp_, timestamp);
return last_timestamp_;
}

@ -11,6 +11,7 @@
#include <string>
#include "base/containers/circular_deque.h"
#include "base/memory/raw_ref.h"
#include "base/numerics/safe_math.h"
#include "base/sequence_checker.h"
#include "base/time/time.h"
@ -155,7 +156,7 @@ class MEDIA_EXPORT WebmMuxer : public Muxer {
private:
base::TimeTicks last_timestamp_;
bool& did_adjust_timestamp_;
const raw_ref<bool> did_adjust_timestamp_;
};
// Methods for creating and adding video and audio tracks, called upon

@ -14,6 +14,7 @@
#include "base/containers/span.h"
#include "base/files/file.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/raw_ref.h"
#include "base/memory/scoped_refptr.h"
#include "base/ranges/algorithm.h"
#include "base/synchronization/condition_variable.h"
@ -153,12 +154,12 @@ class MojoIpczTransportTest : public test::MojoTestBase {
class TransportListener {
public:
explicit TransportListener(Transport& transport) : transport_(transport) {
transport_.Activate(reinterpret_cast<IpczHandle>(this),
&TransportListener::OnActivity);
transport_->Activate(reinterpret_cast<IpczHandle>(this),
&TransportListener::OnActivity);
}
~TransportListener() {
transport_.Deactivate();
transport_->Deactivate();
deactivation_event_.Wait();
}
@ -214,7 +215,7 @@ class TransportListener {
have_messages_.Signal();
}
Transport& transport_;
const raw_ref<Transport> transport_;
base::Lock lock_;
base::ConditionVariable have_messages_{&lock_};

@ -8,6 +8,7 @@
#include <utility>
#include "base/check.h"
#include "base/memory/raw_ref.h"
#include "mojo/core/system_impl_export.h"
#include "third_party/ipcz/include/ipcz/ipcz.h"
@ -35,14 +36,14 @@ class MOJO_SYSTEM_IMPL_EXPORT ScopedIpczHandle {
~Receiver() {
if (received_handle_ != IPCZ_INVALID_HANDLE) {
target_ = ScopedIpczHandle(received_handle_);
(*target_) = ScopedIpczHandle(received_handle_);
}
}
operator IpczHandle*() { return &received_handle_; }
private:
ScopedIpczHandle& target_;
const raw_ref<ScopedIpczHandle> target_;
IpczHandle received_handle_ = IPCZ_INVALID_HANDLE;
};

@ -11,6 +11,7 @@
#include "base/check_op.h"
#include "base/component_export.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "mojo/public/cpp/bindings/lib/bindings_internal.h"
#include "mojo/public/cpp/bindings/message.h"
@ -86,7 +87,9 @@ class MessageFragment {
}
private:
Message& message_;
// Exclude from `raw_ref` rewriter - increases Android binary size by
// ~350K.
RAW_PTR_EXCLUSION Message& message_;
size_t index_ = kInvalidFragmentIndex;
};
@ -158,7 +161,9 @@ class MessageFragment<Array_Data<T>> {
}
private:
Message& message_;
// Exclude from `raw_ref` rewriter - increases Android binary size by
// ~350K.
RAW_PTR_EXCLUSION Message& message_;
size_t index_ = kInvalidFragmentIndex;
};

@ -4,6 +4,7 @@
#include "mojo/public/cpp/bindings/tests/validation_test_input_parser.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ref.h"
#include <assert.h>
#include <stddef.h>
@ -109,7 +110,7 @@ class ValidationTestInputParser {
static const DataType kDataTypes[];
static const size_t kDataTypeCount;
const std::string& input_;
const raw_ref<const std::string> input_;
size_t input_cursor_;
raw_ptr<std::vector<uint8_t>> data_;
@ -198,23 +199,23 @@ bool ValidationTestInputParser::GetNextItem(Range* range) {
// Skip leading whitespaces.
// If there are no non-whitespace characters left, |input_cursor_| will be
// set to std::npos.
input_cursor_ = input_.find_first_not_of(kWhitespaceChars, input_cursor_);
input_cursor_ = input_->find_first_not_of(kWhitespaceChars, input_cursor_);
if (input_cursor_ >= input_.size())
if (input_cursor_ >= input_->size()) {
return false;
}
if (StartsWith(
Range(&input_[0] + input_cursor_, &input_[0] + input_.size()),
"//",
2)) {
if (StartsWith(Range(&(*input_)[0] + input_cursor_,
&(*input_)[0] + input_->size()),
"//", 2)) {
// Skip contents until the end of the line.
input_cursor_ = input_.find_first_of(kEndOfLineChars, input_cursor_);
input_cursor_ = input_->find_first_of(kEndOfLineChars, input_cursor_);
} else {
range->first = &input_[0] + input_cursor_;
input_cursor_ = input_.find_first_of(kItemDelimiters, input_cursor_);
range->second = input_cursor_ >= input_.size()
? &input_[0] + input_.size()
: &input_[0] + input_cursor_;
range->first = &(*input_)[0] + input_cursor_;
input_cursor_ = input_->find_first_of(kItemDelimiters, input_cursor_);
range->second = input_cursor_ >= input_->size()
? &(*input_)[0] + input_->size()
: &(*input_)[0] + input_cursor_;
return true;
}
}

@ -8,6 +8,7 @@
#include <string>
#include <utility>
#include "base/memory/raw_ref.h"
#include "base/run_loop.h"
#include "mojo/public/cpp/bindings/message.h"
#include "mojo/public/cpp/bindings/struct_ptr.h"
@ -134,11 +135,11 @@ class ScopedSwapImplForTesting {
ScopedSwapImplForTesting(T& receiver, ImplPointerType new_impl)
: receiver_(receiver) {
old_impl_ = receiver_.SwapImplForTesting(new_impl);
old_impl_ = receiver_->SwapImplForTesting(new_impl);
}
~ScopedSwapImplForTesting() {
std::ignore = receiver_.SwapImplForTesting(old_impl_);
std::ignore = receiver_->SwapImplForTesting(old_impl_);
}
ImplPointerType old_impl() const { return old_impl_; }
@ -147,7 +148,7 @@ class ScopedSwapImplForTesting {
ScopedSwapImplForTesting& operator=(const ScopedSwapImplForTesting&) = delete;
private:
T& receiver_;
const raw_ref<T> receiver_;
ImplPointerType old_impl_;
};

@ -143,7 +143,8 @@ class RemoteDesktopPortal
std::unique_ptr<ClipboardPortal> clipboard_portal_
GUARDED_BY_CONTEXT(sequence_checker_);
GMainContext* context_ GUARDED_BY_CONTEXT(sequence_checker_) = nullptr;
raw_ptr<GMainContext> context_ GUARDED_BY_CONTEXT(sequence_checker_) =
nullptr;
SEQUENCE_CHECKER(sequence_checker_);
};

@ -9,6 +9,8 @@
#include <xdg-output-unstable-v1-client-protocol.h>
#include "base/memory/raw_ptr.h"
namespace remoting {
// Collection of parameters for each Wayland Display object available on the
@ -43,8 +45,8 @@ struct DisplayInfo {
int physical_height = -1;
int subpixel = -1;
struct wl_output* output = nullptr;
struct zxdg_output_v1* xdg_output = nullptr;
raw_ptr<struct wl_output> output = nullptr;
raw_ptr<struct zxdg_output_v1> xdg_output = nullptr;
// Whether last write to x, y was done by an event emitted from the xdg_output
// interface. If yes, we would to preserve these writes over the ones from

@ -264,7 +264,7 @@ class RestrictedCookieManagerMetrics
SEQUENCE_CHECKER(sequence_checker_);
uint64_t get_cookies_string_count_{0};
base::HistogramBase* histogram_;
raw_ptr<base::HistogramBase> histogram_;
base::RepeatingTimer timer_;
};

@ -7,6 +7,8 @@
#include <utility>
#include "base/feature_list.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/memory/raw_ref.h"
#include "base/test/gtest_util.h"
#include "base/test/scoped_feature_list.h"
#include "base/unguessable_token.h"
@ -1263,69 +1265,75 @@ TEST_F(StorageKeyTest, FromWireReturnValue) {
base::UnguessableToken nonce1 = base::UnguessableToken::Create();
const struct TestCase {
const url::Origin& origin;
const net::SchemefulSite& top_level_site;
const net::SchemefulSite& top_level_site_if_third_party_enabled;
const absl::optional<base::UnguessableToken>& nonce;
AncestorChainBit ancestor_chain_bit;
AncestorChainBit ancestor_chain_bit_if_third_party_enabled;
bool result;
const raw_ref<const url::Origin> origin;
const raw_ref<const net::SchemefulSite> top_level_site;
const raw_ref<const net::SchemefulSite>
top_level_site_if_third_party_enabled;
// Excluded: can't wrap `absl::nullopt` in `raw_ref`.
RAW_PTR_EXCLUSION const absl::optional<base::UnguessableToken>& nonce;
AncestorChainBit ancestor_chain_bit;
AncestorChainBit ancestor_chain_bit_if_third_party_enabled;
bool result;
} test_cases[] = {
// Passing cases:
{o1, site1, site1, absl::nullopt, AncestorChainBit::kSameSite,
AncestorChainBit::kSameSite, true},
{o1, site1, site1, nonce1, AncestorChainBit::kCrossSite,
AncestorChainBit::kCrossSite, true},
{o1, site1, site2, absl::nullopt, AncestorChainBit::kSameSite,
AncestorChainBit::kCrossSite, true},
{o1, site1, site1, absl::nullopt, AncestorChainBit::kSameSite,
AncestorChainBit::kCrossSite, true},
{o1, site1, site1, nonce1, AncestorChainBit::kCrossSite,
AncestorChainBit::kCrossSite, true},
{opaque, site1, site1, absl::nullopt, AncestorChainBit::kCrossSite,
AncestorChainBit::kCrossSite, true},
{o1, site1, opaque_site, absl::nullopt, AncestorChainBit::kSameSite,
AncestorChainBit::kCrossSite, true},
{o1, opaque_site, opaque_site, absl::nullopt,
{raw_ref(o1), raw_ref(site1), raw_ref(site1), absl::nullopt,
AncestorChainBit::kSameSite, AncestorChainBit::kSameSite, true},
{raw_ref(o1), raw_ref(site1), raw_ref(site1), nonce1,
AncestorChainBit::kCrossSite, AncestorChainBit::kCrossSite, true},
{opaque, opaque_site, opaque_site, absl::nullopt,
{raw_ref(o1), raw_ref(site1), raw_ref(site2), absl::nullopt,
AncestorChainBit::kSameSite, AncestorChainBit::kCrossSite, true},
{raw_ref(o1), raw_ref(site1), raw_ref(site1), absl::nullopt,
AncestorChainBit::kSameSite, AncestorChainBit::kCrossSite, true},
{raw_ref(o1), raw_ref(site1), raw_ref(site1), nonce1,
AncestorChainBit::kCrossSite, AncestorChainBit::kCrossSite, true},
{raw_ref(opaque), raw_ref(site1), raw_ref(site1), absl::nullopt,
AncestorChainBit::kCrossSite, AncestorChainBit::kCrossSite, true},
{raw_ref(o1), raw_ref(site1), raw_ref(opaque_site), absl::nullopt,
AncestorChainBit::kSameSite, AncestorChainBit::kCrossSite, true},
{raw_ref(o1), raw_ref(opaque_site), raw_ref(opaque_site), absl::nullopt,
AncestorChainBit::kCrossSite, AncestorChainBit::kCrossSite, true},
{raw_ref(opaque), raw_ref(opaque_site), raw_ref(opaque_site),
absl::nullopt, AncestorChainBit::kCrossSite,
AncestorChainBit::kCrossSite, true},
// Failing cases:
// If a 3p key is indicated, the *if_third_party_enabled pieces should
// match their counterparts.
{o1, site2, site3, absl::nullopt, AncestorChainBit::kSameSite,
AncestorChainBit::kSameSite, false},
{o1, site1, site1, absl::nullopt, AncestorChainBit::kCrossSite,
AncestorChainBit::kSameSite, false},
{raw_ref(o1), raw_ref(site2), raw_ref(site3), absl::nullopt,
AncestorChainBit::kSameSite, AncestorChainBit::kSameSite, false},
{raw_ref(o1), raw_ref(site1), raw_ref(site1), absl::nullopt,
AncestorChainBit::kCrossSite, AncestorChainBit::kSameSite, false},
// If the top_level_site* is cross-site to the origin, the
// ancestor_chain_bit* must indicate cross-site.
{o1, site2, site2, absl::nullopt, AncestorChainBit::kSameSite,
AncestorChainBit::kCrossSite, false},
{o1, site1, site2, absl::nullopt, AncestorChainBit::kSameSite,
AncestorChainBit::kSameSite, false},
{o1, site2, site2, absl::nullopt, AncestorChainBit::kSameSite,
AncestorChainBit::kSameSite, false},
{raw_ref(o1), raw_ref(site2), raw_ref(site2), absl::nullopt,
AncestorChainBit::kSameSite, AncestorChainBit::kCrossSite, false},
{raw_ref(o1), raw_ref(site1), raw_ref(site2), absl::nullopt,
AncestorChainBit::kSameSite, AncestorChainBit::kSameSite, false},
{raw_ref(o1), raw_ref(site2), raw_ref(site2), absl::nullopt,
AncestorChainBit::kSameSite, AncestorChainBit::kSameSite, false},
// If there is a nonce, all other values must indicate same-site to
// origin.
{o1, site2, site2, nonce1, AncestorChainBit::kSameSite,
AncestorChainBit::kSameSite, false},
{o1, site1, site1, nonce1, AncestorChainBit::kSameSite,
AncestorChainBit::kSameSite, false},
{o1, site1, site1, nonce1, AncestorChainBit::kSameSite,
AncestorChainBit::kCrossSite, false},
{raw_ref(o1), raw_ref(site2), raw_ref(site2), nonce1,
AncestorChainBit::kSameSite, AncestorChainBit::kSameSite, false},
{raw_ref(o1), raw_ref(site1), raw_ref(site1), nonce1,
AncestorChainBit::kSameSite, AncestorChainBit::kSameSite, false},
{raw_ref(o1), raw_ref(site1), raw_ref(site1), nonce1,
AncestorChainBit::kSameSite, AncestorChainBit::kCrossSite, false},
// If the top_level_site* is opaque, the ancestor_chain_bit* must be
// cross-site.
{o1, site1, opaque_site, absl::nullopt, AncestorChainBit::kCrossSite,
AncestorChainBit::kSameSite, false},
{o1, opaque_site, opaque_site, absl::nullopt, AncestorChainBit::kSameSite,
AncestorChainBit::kSameSite, false},
// If the origin is opaque, the ancestor_chain_bit* must be cross-site.
{opaque, opaque_site, opaque_site, absl::nullopt,
AncestorChainBit::kSameSite, AncestorChainBit::kSameSite, false},
{opaque, opaque_site, opaque_site, absl::nullopt,
{raw_ref(o1), raw_ref(site1), raw_ref(opaque_site), absl::nullopt,
AncestorChainBit::kCrossSite, AncestorChainBit::kSameSite, false},
{opaque, opaque_site, opaque_site, absl::nullopt,
AncestorChainBit::kSameSite, AncestorChainBit::kCrossSite, false},
{raw_ref(o1), raw_ref(opaque_site), raw_ref(opaque_site), absl::nullopt,
AncestorChainBit::kSameSite, AncestorChainBit::kSameSite, false},
// If the origin is opaque, the ancestor_chain_bit* must be cross-site.
{raw_ref(opaque), raw_ref(opaque_site), raw_ref(opaque_site),
absl::nullopt, AncestorChainBit::kSameSite, AncestorChainBit::kSameSite,
false},
{raw_ref(opaque), raw_ref(opaque_site), raw_ref(opaque_site),
absl::nullopt, AncestorChainBit::kCrossSite, AncestorChainBit::kSameSite,
false},
{raw_ref(opaque), raw_ref(opaque_site), raw_ref(opaque_site),
absl::nullopt, AncestorChainBit::kSameSite, AncestorChainBit::kCrossSite,
false},
};
const StorageKey starting_key;
@ -1335,8 +1343,8 @@ TEST_F(StorageKeyTest, FromWireReturnValue) {
EXPECT_EQ(
test_case.result,
StorageKey::FromWire(
test_case.origin, test_case.top_level_site,
test_case.top_level_site_if_third_party_enabled, test_case.nonce,
*test_case.origin, *test_case.top_level_site,
*test_case.top_level_site_if_third_party_enabled, test_case.nonce,
test_case.ancestor_chain_bit,
test_case.ancestor_chain_bit_if_third_party_enabled, result_key));
if (!test_case.result) {

@ -9,7 +9,7 @@
#include <vector>
#include "base/gtest_prod_util.h"
#include "base/memory/raw_ref.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/models/simple_menu_model.h"
@ -59,7 +59,11 @@ class VIEWS_EXPORT Label : public View,
// TODO(tapted): Change this to a size delta and font weight since that's
// typically all the callers really care about, and would allow Label to
// guarantee caching of the FontList in ResourceBundle.
const gfx::FontList& font_list;
//
// Exclude from `raw_ref` rewriter because there are usages (e.g.
// `indexed_suggestion_candidate_button.cc` that attempt to bind
// temporaries (`T&&`) to `font_list`, which `raw_ref` forbids.
RAW_PTR_EXCLUSION const gfx::FontList& font_list;
};
// Create Labels with style::CONTEXT_CONTROL_LABEL and style::STYLE_PRIMARY.

@ -9,6 +9,8 @@
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/memory/raw_ref.h"
#include "base/scoped_observation.h"
#include "base/strings/string_piece.h"
#include "build/build_config.h"
@ -80,7 +82,12 @@ class DanglingMouseMoveHandlerOnViewDestroyingChecker
private:
base::ScopedObservation<views::View, views::ViewObserver> scoped_observation{
this};
const raw_ptr<views::View, DanglingUntriaged>& mouse_move_handler_;
// Excluded from `raw_ref` rewriter which would otherwise turn this
// into a `raw_ref<raw_ptr<>>`. The current `raw_ptr&` setup is
// intentional and used to observe the pointer without counting as a
// live reference to the underlying memory.
RAW_PTR_EXCLUSION const raw_ptr<views::View, DanglingUntriaged>&
mouse_move_handler_;
};
} // namespace