0

Rewrite map pointer values to raw_ptr

This cl rewrites CTN<key, T*> into CTN<key, raw_ptr<T, CtnExperimental>>
where CTN is one of: std::map, std::unordered_map, base::flat_map

The following benchmarks were launched to ensure the cl does not
introduce any performance regression:
https://pinpoint-dot-chromeperf.appspot.com/job/10ce4602210000
https://pinpoint-dot-chromeperf.appspot.com/job/11e2fc0c210000
https://pinpoint-dot-chromeperf.appspot.com/job/16ca4ca8210000
https://pinpoint-dot-chromeperf.appspot.com/job/168ae33c210000


The identified bottlenecks were excluded from the rewrite. These are the
initial values before exclusions on motionmark_ramp_composite (for
example): https://pinpoint-dot-chromeperf.appspot.com/job/16987bf4210000

After Exclusions:
https://pinpoint-dot-chromeperf.appspot.com/job/168ae33c210000

AX-Relnotes: n/a.
Change-Id: I35c52d7427140361410db74e25e0cb8f7bd516db
Bug: 329428315
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5867189
Reviewed-by: danakj <danakj@chromium.org>
Owners-Override: danakj <danakj@chromium.org>
Commit-Queue: Ali Hijazi <ahijazi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1361899}
This commit is contained in:
Ali Hijazi
2024-09-30 17:58:53 +00:00
committed by Chromium LUCI CQ
parent af52cffe20
commit 60a72b0afd
381 changed files with 1173 additions and 581 deletions
android_webview/browser/gfx
apps
ash
base
cc
chrome
browser
apps
ash
chromeos
devtools
download
enterprise
extensions
file_system_access
image_decoder
media
media_galleries
notifications
page_load_metrics
performance_manager
preloading
prefetch
privacy_sandbox
safe_browsing
incident_reporting
segmentation_platform
sharing
signin
supervised_user
sync_file_system
task_manager
transition_manager
ui
test
chromeos
components
app_restore
bookmarks
devtools
simple_devtools_protocol_client
discardable_memory
download
exo
gcm_driver
global_media_controls
guest_view
invalidation
keyed_service
media_router
metrics
offline_items_collection
performance_manager
policy
push_notification
safe_browsing
search_engines
segmentation_platform
embedder
services
sharing_message
subresource_filter
sync
sync_bookmarks
sync_sessions
ui_devtools
user_notes
value_store
viz
webdata
zucchini
content
dbus
device
extensions
gin
google_apis/gcm/engine
gpu
media
mojo/core/ports
net
printing/backend
remoting
services
accessibility
cert_verifier
device
image_annotation
preferences
resource_coordinator
memory_instrumentation
service_manager
webnn
storage/browser
testing/libfuzzer/renderer_fuzzing
ui

@ -243,7 +243,9 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient,
// A map from compositor's per-WebView unique ID to the compositor's raw
// pointer. A raw pointer here is fine because the entry will be erased when
// a compositor is destroyed.
std::map<viz::FrameSinkId, content::SynchronousCompositor*> compositor_map_;
std::map<viz::FrameSinkId,
raw_ptr<content::SynchronousCompositor, CtnExperimental>>
compositor_map_;
bool is_paused_;
bool view_visible_;

@ -180,7 +180,7 @@ class SavedFilesService::SavedFiles {
// The queue of file entries that have been retained, keyed by
// sequence_number. Values are a subset of values in registered_file_entries_.
// This should be kept in sync with file entries stored in extension prefs.
std::map<int, SavedFileEntry*> saved_file_lru_;
std::map<int, raw_ptr<SavedFileEntry, CtnExperimental>> saved_file_lru_;
};
// static
@ -327,8 +327,8 @@ void SavedFilesService::SavedFiles::EnqueueFileEntry(const std::string& id) {
if (!saved_file_lru_.empty()) {
// Get the sequence number after the last file entry in the LRU.
std::map<int, SavedFileEntry*>::reverse_iterator it =
saved_file_lru_.rbegin();
std::map<int, raw_ptr<SavedFileEntry, CtnExperimental>>::reverse_iterator
it = saved_file_lru_.rbegin();
if (it->second == file_entry)
return;
@ -346,7 +346,8 @@ void SavedFilesService::SavedFiles::EnqueueFileEntry(const std::string& id) {
} else {
AddSavedFileEntry(prefs, extension_id_, *file_entry);
if (saved_file_lru_.size() > g_max_saved_file_entries) {
std::map<int, SavedFileEntry*>::iterator it = saved_file_lru_.begin();
std::map<int, raw_ptr<SavedFileEntry, CtnExperimental>>::iterator it =
saved_file_lru_.begin();
it->second->sequence_number = 0;
RemoveSavedFileEntry(prefs, extension_id_, it->second->id);
saved_file_lru_.erase(it);
@ -383,8 +384,8 @@ void SavedFilesService::SavedFiles::MaybeCompactSequenceNumbers() {
DCHECK_GE(g_max_sequence_number, 0);
DCHECK_GE(static_cast<size_t>(g_max_sequence_number),
g_max_saved_file_entries);
std::map<int, SavedFileEntry*>::reverse_iterator last_it =
saved_file_lru_.rbegin();
std::map<int, raw_ptr<SavedFileEntry, CtnExperimental>>::reverse_iterator
last_it = saved_file_lru_.rbegin();
if (last_it == saved_file_lru_.rend())
return;
@ -395,9 +396,9 @@ void SavedFilesService::SavedFiles::MaybeCompactSequenceNumbers() {
int sequence_number = 0;
ExtensionPrefs* prefs = ExtensionPrefs::Get(context_);
for (std::map<int, SavedFileEntry*>::iterator it = saved_file_lru_.begin();
it != saved_file_lru_.end();
++it) {
for (std::map<int, raw_ptr<SavedFileEntry, CtnExperimental>>::iterator it =
saved_file_lru_.begin();
it != saved_file_lru_.end(); ++it) {
sequence_number++;
if (it->second->sequence_number == sequence_number)
continue;

@ -18,6 +18,7 @@
#include "ash/public/mojom/accelerator_info.mojom.h"
#include "base/containers/flat_set.h"
#include "base/containers/span.h"
#include "base/memory/raw_ptr.h"
#include "base/observer_list.h"
#include "base/observer_list_types.h"
#include "base/types/optional_ref.h"
@ -194,7 +195,8 @@ class ASH_EXPORT AshAcceleratorConfiguration : public AcceleratorConfiguration,
AcceleratorActionMap deprecated_accelerators_to_id_;
// A map of accelerator ID's that are deprecated.
std::map<AcceleratorActionId, const DeprecatedAcceleratorData*>
std::map<AcceleratorActionId,
raw_ptr<const DeprecatedAcceleratorData, CtnExperimental>>
actions_with_deprecations_;
// One accelerator action ID can potentially have multiple accelerators
@ -211,7 +213,8 @@ class ASH_EXPORT AshAcceleratorConfiguration : public AcceleratorConfiguration,
// data is set.
ActionIdToAcceleratorsMap default_id_to_accelerators_cache_;
AcceleratorActionMap default_accelerators_to_id_cache_;
std::map<AcceleratorActionId, const DeprecatedAcceleratorData*>
std::map<AcceleratorActionId,
raw_ptr<const DeprecatedAcceleratorData, CtnExperimental>>
default_actions_with_deprecations_cache_;
AcceleratorActionMap default_deprecated_accelerators_to_id_cache_;

@ -2,6 +2,8 @@
// 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"
#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
@ -142,7 +144,9 @@ class AccelerometerProviderMojoTest : public ::testing::Test {
FakeObserver observer_;
std::unique_ptr<chromeos::sensors::FakeSensorHalServer> sensor_hal_server_;
std::map<int32_t, chromeos::sensors::FakeSensorDevice*> sensor_devices_;
std::map<int32_t,
raw_ptr<chromeos::sensors::FakeSensorDevice, CtnExperimental>>
sensor_devices_;
scoped_refptr<AccelerometerProviderMojo> provider_;

@ -211,7 +211,7 @@ void AmbientAnimationFrameRateController::TrySetNewTrackingAnimation() {
return;
}
tracking_animation_ = windows_to_throttle_.begin()->second;
tracking_animation_ = windows_to_throttle_.begin()->second.get();
schedule_ = BuildSchedule(tracking_animation_.get());
// Set |current_section_| to be |schedule_.end()| temporarily so that
// FindCurrentSection() knows to start searching the new schedule from

@ -87,7 +87,8 @@ class ASH_EXPORT AmbientAnimationFrameRateController
// Points to the current section in the |schedule_| that's being played.
// Set to |schedule_.end()| if the animation is not playing currently.
AmbientAnimationFrameRateScheduleIterator current_section_;
base::flat_map<aura::Window*, lottie::Animation*> windows_to_throttle_;
base::flat_map<aura::Window*, raw_ptr<lottie::Animation, CtnExperimental>>
windows_to_throttle_;
base::ScopedMultiSourceObservation<lottie::Animation,
lottie::AnimationObserver>
animation_observations_{this};

@ -10,6 +10,7 @@
#include "ash/ash_export.h"
#include "ash/public/cpp/session/session_observer.h"
#include "base/memory/raw_ptr.h"
#include "components/account_id/account_id.h"
class PrefRegistrySimple;
@ -51,7 +52,8 @@ class ASH_EXPORT CalendarController : public SessionObserver {
// The currently active user account id.
AccountId active_user_account_id_;
std::map<const AccountId, CalendarClient*> clients_by_account_id_;
std::map<const AccountId, raw_ptr<CalendarClient, CtnExperimental>>
clients_by_account_id_;
};
} // namespace ash

@ -111,7 +111,8 @@ class ASH_EXPORT ClipboardHistoryMenuModelAdapter
class MenuModelWithWillCloseCallback;
class ScopedA11yIgnore;
using ItemViewsByCommandId = std::map<int, ClipboardHistoryItemView*>;
using ItemViewsByCommandId =
std::map<int, raw_ptr<ClipboardHistoryItemView, CtnExperimental>>;
ClipboardHistoryMenuModelAdapter(
std::unique_ptr<MenuModelWithWillCloseCallback> model,

@ -266,7 +266,8 @@ void MirrorWindowController::UpdateWindow(
->compositor();
gfx::Size mirror_size = source_compositor->size();
auto* mirroring_host_info = mirroring_host_info_map_[display_info.id()];
auto* mirroring_host_info =
mirroring_host_info_map_[display_info.id()].get();
const bool should_undo_rotation = ShouldUndoRotationForMirror();

@ -94,7 +94,8 @@ class ASH_EXPORT MirrorWindowController : public aura::WindowTreeHostObserver,
void CloseAndDeleteHost(MirroringHostInfo* host_info,
bool delay_host_deletion);
typedef std::map<int64_t, MirroringHostInfo*> MirroringHostInfoMap;
typedef std::map<int64_t, raw_ptr<MirroringHostInfo, CtnExperimental>>
MirroringHostInfoMap;
MirroringHostInfoMap mirroring_host_info_map_;
raw_ptr<aura::WindowTreeHost, DanglingUntriaged>

@ -186,7 +186,8 @@ class ASH_EXPORT WindowTreeHostManager
// are rendered on the correct display.
void UpdateHostOfDisplayProviders();
typedef std::map<int64_t, AshWindowTreeHost*> WindowTreeHostMap;
typedef std::map<int64_t, raw_ptr<AshWindowTreeHost, CtnExperimental>>
WindowTreeHostMap;
// The mapping from display ID to its window tree host.
WindowTreeHostMap window_tree_hosts_;

@ -10,6 +10,7 @@
#include "ash/quick_pair/message_stream/message_stream.h"
#include "ash/quick_pair/message_stream/message_stream_lookup.h"
#include "base/containers/flat_map.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/scoped_observation.h"
@ -64,7 +65,8 @@ class BatteryUpdateMessageHandler : public MessageStreamLookup::Observer,
void CleanUpMessageStream(const std::string& device_address);
// Map of the classic pairing address to their corresponding MessageStreams.
base::flat_map<std::string, MessageStream*> message_streams_;
base::flat_map<std::string, raw_ptr<MessageStream, CtnExperimental>>
message_streams_;
scoped_refptr<device::BluetoothAdapter> adapter_;

@ -5,11 +5,11 @@
#ifndef ASH_QUICK_PAIR_MESSAGE_STREAM_FAKE_MESSAGE_STREAM_LOOKUP_H_
#define ASH_QUICK_PAIR_MESSAGE_STREAM_FAKE_MESSAGE_STREAM_LOOKUP_H_
#include "ash/quick_pair/message_stream/message_stream_lookup.h"
#include <string>
#include "ash/quick_pair/message_stream/message_stream_lookup.h"
#include "base/containers/flat_map.h"
#include "base/memory/raw_ptr.h"
#include "base/observer_list.h"
namespace ash {
@ -42,7 +42,8 @@ class FakeMessageStreamLookup : public MessageStreamLookup {
MessageStream* message_stream);
private:
base::flat_map<std::string, MessageStream*> message_streams_;
base::flat_map<std::string, raw_ptr<MessageStream, CtnExperimental>>
message_streams_;
base::ObserverList<Observer> observers_;
};

@ -177,7 +177,8 @@ class RetroactivePairingDetectorImpl final
base::flat_set<std::string> potential_retroactive_addresses_;
// Map of the classic pairing address to their corresponding MessageStreams.
base::flat_map<std::string, MessageStream*> message_streams_;
base::flat_map<std::string, raw_ptr<MessageStream, CtnExperimental>>
message_streams_;
// Map of the classic pairing address to their corresponding model id and
// ble address, if they exist.

@ -2,6 +2,8 @@
// 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"
#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
@ -144,7 +146,9 @@ class SensorProviderTest : public testing::Test {
FakeObserver observer_;
std::unique_ptr<chromeos::sensors::FakeSensorHalServer> sensor_hal_server_;
std::map<int32_t, chromeos::sensors::FakeSensorDevice*> sensor_devices_;
std::map<int32_t,
raw_ptr<chromeos::sensors::FakeSensorDevice, CtnExperimental>>
sensor_devices_;
std::unique_ptr<SensorProvider> provider_;
};

@ -316,10 +316,11 @@ class UnifiedAudioDetailedViewControllerTest : public AshTestBase {
AudioDetailedView::AudioDetailedViewID::kNbsWarningView);
}
std::map<uint64_t, views::View*> input_sliders_map_;
std::map<uint64_t, views::View*> output_sliders_map_;
std::map<uint64_t, views::View*> toggles_map_;
std::map<uint64_t, views::View*> style_transfer_toggles_map_;
std::map<uint64_t, raw_ptr<views::View, CtnExperimental>> input_sliders_map_;
std::map<uint64_t, raw_ptr<views::View, CtnExperimental>> output_sliders_map_;
std::map<uint64_t, raw_ptr<views::View, CtnExperimental>> toggles_map_;
std::map<uint64_t, raw_ptr<views::View, CtnExperimental>>
style_transfer_toggles_map_;
MicGainSliderController::MapDeviceSliderCallback
map_input_device_sliders_callback_;
UnifiedVolumeSliderController::MapDeviceSliderCallback

@ -8,6 +8,7 @@
#include "ash/system/bluetooth/bluetooth_detailed_view.h"
#include "ash/system/bluetooth/bluetooth_device_list_item_view.h"
#include "base/check.h"
#include "base/memory/raw_ptr.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/view.h"
@ -65,8 +66,9 @@ void BluetoothDeviceListControllerImpl::UpdateDeviceList(
// view from this map when the corresponding device is found in |connected| or
// |previously_connected|. Before returning, any view remaining in
// |previous_views| is no longer needed and is deleted.
base::flat_map<std::string, BluetoothDeviceListItemView*> previous_views =
std::move(device_id_to_view_map_);
base::flat_map<std::string,
raw_ptr<BluetoothDeviceListItemView, CtnExperimental>>
previous_views = std::move(device_id_to_view_map_);
device_id_to_view_map_.clear();
// Since we re-use views when possible, we need to re-order them to match the
@ -138,7 +140,9 @@ BluetoothDeviceListControllerImpl::CreateSubHeaderIfMissingAndReorder(
size_t BluetoothDeviceListControllerImpl::CreateViewsIfMissingAndReorder(
const PairedBluetoothDevicePropertiesPtrs& device_property_list,
base::flat_map<std::string, BluetoothDeviceListItemView*>* previous_views,
base::flat_map<std::string,
raw_ptr<BluetoothDeviceListItemView, CtnExperimental>>*
previous_views,
size_t index) {
DCHECK(previous_views);

@ -59,13 +59,16 @@ class ASH_EXPORT BluetoothDeviceListControllerImpl
// the position after the final view that was added is returned.
size_t CreateViewsIfMissingAndReorder(
const PairedBluetoothDevicePropertiesPtrs& device_property_list,
base::flat_map<std::string, BluetoothDeviceListItemView*>* previous_views,
base::flat_map<std::string,
raw_ptr<BluetoothDeviceListItemView, CtnExperimental>>*
previous_views,
size_t index);
const raw_ptr<BluetoothDetailedView> bluetooth_detailed_view_;
bool is_bluetooth_enabled_ = false;
base::flat_map<std::string, BluetoothDeviceListItemView*>
base::flat_map<std::string,
raw_ptr<BluetoothDeviceListItemView, CtnExperimental>>
device_id_to_view_map_;
raw_ptr<views::View> connected_sub_header_ = nullptr;
raw_ptr<views::View> no_device_connected_sub_header_ = nullptr;

@ -153,7 +153,8 @@ class ASH_EXPORT HoldingSpaceItemViewsSection : public views::View {
raw_ptr<views::View> container_ = nullptr;
raw_ptr<views::View, DanglingUntriaged> placeholder_ = nullptr;
raw_ptr<views::ScrollView> scroll_view_ = nullptr;
std::map<std::string, HoldingSpaceItemView*> views_by_item_id_;
std::map<std::string, raw_ptr<HoldingSpaceItemView, CtnExperimental>>
views_by_item_id_;
// Bit flag representation of current `AnimationState`. Note that it is
// briefly possible to be both `kAnimatingIn` and `kAnimatingOut` when one

@ -10,6 +10,7 @@
#include "ash/ash_export.h"
#include "ash/public/cpp/pagination/pagination_model.h"
#include "base/memory/raw_ptr.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/views/view.h"
@ -59,7 +60,8 @@ class ASH_EXPORT QuickSettingsMediaView : public views::View {
// Helper functions for testing.
PaginationModel* pagination_model_for_testing() { return &pagination_model_; }
std::map<const std::string, global_media_controls::MediaItemUIView*>
std::map<const std::string,
raw_ptr<global_media_controls::MediaItemUIView, CtnExperimental>>
items_for_testing() {
return items_;
}
@ -75,7 +77,9 @@ class ASH_EXPORT QuickSettingsMediaView : public views::View {
raw_ptr<PaginationView> pagination_view_ = nullptr;
std::map<const std::string, global_media_controls::MediaItemUIView*> items_;
std::map<const std::string,
raw_ptr<global_media_controls::MediaItemUIView, CtnExperimental>>
items_;
};
} // namespace ash

@ -81,7 +81,8 @@ class ASH_EXPORT NetworkListViewControllerImpl
// Map of network guids and their corresponding list item views.
using NetworkIdToViewMap =
base::flat_map<std::string, NetworkListNetworkItemView*>;
base::flat_map<std::string,
raw_ptr<NetworkListNetworkItemView, CtnExperimental>>;
// multidevice_setup::mojom::HostStatusObserver:
void OnHostStatusChanged(

@ -111,7 +111,7 @@ class ASH_EXPORT PaletteToolManager : public PaletteTool::Delegate {
raw_ptr<Delegate> delegate_;
// Unowned pointer to the active tool / group.
std::map<PaletteGroup, PaletteTool*> active_tools_;
std::map<PaletteGroup, raw_ptr<PaletteTool, CtnExperimental>> active_tools_;
// Owned list of all tools.
std::vector<std::unique_ptr<PaletteTool>> tools_;

@ -50,7 +50,7 @@ class ASH_EXPORT TouchHudRenderer : public views::WidgetObserver {
raw_ptr<views::Widget> parent_widget_;
// A map of touch ids to TouchPointView.
std::map<int, TouchPointView*> points_;
std::map<int, raw_ptr<TouchPointView, CtnExperimental>> points_;
};
} // namespace ash

@ -62,7 +62,8 @@ class VirtualTrackpadView : public views::View {
// `finger_buttons_panel_`. The key represents the number of fingers that the
// `LabelButton` activates for future gestures. This map is ultimately used to
// highlight the active button with a different color.
base::flat_map<int, views::LabelButton*> finger_buttons_;
base::flat_map<int, raw_ptr<views::LabelButton, CtnExperimental>>
finger_buttons_;
raw_ptr<TrackpadInternalSurfaceView> trackpad_view_ = nullptr;
// Creates a new layer that blurs the background underneath the view layer.

@ -268,7 +268,8 @@ class FakeDeviceManager : public ui::DeviceManager {
};
class FakeInputDataEventWatcher;
typedef std::map<uint32_t, FakeInputDataEventWatcher*> watchers_t;
typedef std::map<uint32_t, raw_ptr<FakeInputDataEventWatcher, CtnExperimental>>
watchers_t;
// Fake evdev watcher class that lets us manually post input
// events into an InputDataProvider; this keeps an external

@ -9,6 +9,7 @@
#include "ash/webui/eche_app_ui/apps_access_setup_operation.h"
#include "base/containers/flat_map.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/observer_list_types.h"
@ -101,7 +102,8 @@ class AppsAccessManager {
void OnSetupOperationDeleted(int operation_id);
int next_operation_id_ = 0;
base::flat_map<int, AppsAccessSetupOperation*> id_to_operation_map_;
base::flat_map<int, raw_ptr<AppsAccessSetupOperation, CtnExperimental>>
id_to_operation_map_;
base::ObserverList<Observer> observer_list_;
base::WeakPtrFactory<AppsAccessManager> weak_ptr_factory_{this};
};

@ -78,7 +78,8 @@ class SearchTagRegistry : public EnterprisePolicyDelegate::Observer {
base::ObserverList<Observer> observer_list_;
mojo::Remote<local_search_service::mojom::Index> index_remote_;
std::map<std::string, const SearchConcept*> result_id_to_search_concept_;
std::map<std::string, raw_ptr<const SearchConcept, CtnExperimental>>
result_id_to_search_concept_;
raw_ptr<PrefService> pref_service_;
std::unique_ptr<EnterprisePolicyDelegate> enterprise_policy_delegate_;
PrefChangeRegistrar pref_change_registrar_;

@ -13,6 +13,7 @@
#include "ash/wm/snap_group/snap_group_metrics.h"
#include "ash/wm/wm_metrics.h"
#include "base/containers/flat_map.h"
#include "base/memory/raw_ptr.h"
#include "base/observer_list.h"
#include "base/time/time.h"
#include "ui/aura/window.h"
@ -34,7 +35,8 @@ class ASH_EXPORT SnapGroupController : public OverviewObserver,
public display::DisplayObserver {
public:
using SnapGroups = std::vector<std::unique_ptr<SnapGroup>>;
using WindowToSnapGroupMap = base::flat_map<aura::Window*, SnapGroup*>;
using WindowToSnapGroupMap =
base::flat_map<aura::Window*, raw_ptr<SnapGroup, CtnExperimental>>;
SnapGroupController();
SnapGroupController(const SnapGroupController&) = delete;

@ -120,7 +120,8 @@ class ASH_EXPORT TabletModeWindowManager : public aura::WindowObserver,
void OnActiveUserSessionChanged(const AccountId& account_id) override;
private:
using WindowToState = std::map<aura::Window*, TabletModeWindowState*>;
using WindowToState =
std::map<aura::Window*, raw_ptr<TabletModeWindowState, CtnExperimental>>;
using WindowAndStateTypeList =
std::vector<std::pair<aura::Window*, chromeos::WindowStateType>>;

@ -178,7 +178,7 @@ void WindowPreviewView::RemoveWindow(aura::Window* window) {
if (it == mirror_views_.end())
return;
auto* view = it->second;
auto* view = it->second.get();
RemoveChildViewT(view);
it->first->RemoveObserver(this);

@ -68,7 +68,8 @@ class ASH_EXPORT WindowPreviewView
raw_ptr<aura::Window> window_;
base::flat_map<aura::Window*, WindowMirrorView*> mirror_views_;
base::flat_map<aura::Window*, raw_ptr<WindowMirrorView, CtnExperimental>>
mirror_views_;
// Transient children of |window_| may be added as transients before they're
// actually parented; i.e. `OnTransientChildWindowAdded()` is called before

@ -5,6 +5,7 @@
#include "ash/wm/window_preview_view_test_api.h"
#include "ash/wm/window_preview_view.h"
#include "base/memory/raw_ptr.h"
#include "ui/views/widget/widget.h"
namespace ash {
@ -21,7 +22,7 @@ gfx::RectF WindowPreviewViewTestApi::GetUnionRect() const {
return preview_view_->GetUnionRect();
}
const base::flat_map<aura::Window*, WindowMirrorView*>&
const base::flat_map<aura::Window*, raw_ptr<WindowMirrorView, CtnExperimental>>&
WindowPreviewViewTestApi::GetMirrorViews() const {
return preview_view_->mirror_views_;
}

@ -31,8 +31,9 @@ class WindowPreviewViewTestApi {
gfx::RectF GetUnionRect() const;
const base::flat_map<aura::Window*, WindowMirrorView*>& GetMirrorViews()
const;
const base::flat_map<aura::Window*,
raw_ptr<WindowMirrorView, CtnExperimental>>&
GetMirrorViews() const;
// Gets the mirror view in |mirror_views_| associated with |widget|. Returns
// null if |widget|'s window does not exist in |mirror_views_|.

@ -178,7 +178,8 @@ class ASH_EXPORT PieMenuView : public views::View {
const raw_ptr<views::ImageButton> back_button_;
// Maps all the buttons on all sub menu containers of this view by their IDs.
base::flat_map</*button_id=*/int, PieMenuButton*> buttons_by_id_;
base::flat_map</*button_id=*/int, raw_ptr<PieMenuButton, CtnExperimental>>
buttons_by_id_;
};
} // namespace ash

@ -25,8 +25,9 @@ std::pair<std::string_view, const Feature*> MakeNameToFeaturePair(
}
FeatureMap::FeatureMap(std::vector<const Feature*> features_exposed_to_java) {
mapping_ = MakeFlatMap<std::string_view, const Feature*>(
features_exposed_to_java, {}, &MakeNameToFeaturePair);
mapping_ =
MakeFlatMap<std::string_view, raw_ptr<const Feature, CtnExperimental>>(
features_exposed_to_java, {}, &MakeNameToFeaturePair);
}
FeatureMap::~FeatureMap() = default;

@ -10,6 +10,7 @@
#include "base/base_export.h"
#include "base/containers/flat_map.h"
#include "base/feature_list.h"
#include "base/memory/raw_ptr.h"
namespace base::android {
@ -28,7 +29,7 @@ class BASE_EXPORT FeatureMap {
const Feature* FindFeatureExposedToJava(const std::string& feature_name);
private:
flat_map<std::string_view, const Feature*> mapping_;
flat_map<std::string_view, raw_ptr<const Feature, CtnExperimental>> mapping_;
};
} // namespace base::android

@ -15,6 +15,7 @@
#include "base/check.h"
#include "base/compiler_specific.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ptr_exclusion.h"
template <class T>
@ -158,6 +159,11 @@ scoped_refptr<T> WrapRefCounted(T* t) {
return scoped_refptr<T>(t);
}
template <typename T, base::RawPtrTraits Traits = base::RawPtrTraits::kEmpty>
scoped_refptr<T> WrapRefCounted(const raw_ptr<T, Traits>& t) {
return scoped_refptr<T>(t.get());
}
} // namespace base
//

@ -800,7 +800,9 @@ class BASE_EXPORT FieldTrialList {
static void ActivateFieldTrialEntryWhileLocked(FieldTrial* field_trial);
// A map from FieldTrial names to the actual instances.
typedef std::map<std::string, FieldTrial*, std::less<>> RegistrationMap;
typedef std::
map<std::string, raw_ptr<FieldTrial, CtnExperimental>, std::less<>>
RegistrationMap;
// Helper function should be called only while holding lock_.
FieldTrial* PreLockedFind(std::string_view name)

@ -55,7 +55,9 @@ class IteratorTemplate : public SampleCountIterator {
const I end_;
};
typedef std::map<HistogramBase::Sample, HistogramBase::Count*> SampleToCountMap;
typedef std::map<HistogramBase::Sample,
raw_ptr<HistogramBase::Count, CtnExperimental>>
SampleToCountMap;
typedef IteratorTemplate<const SampleToCountMap,
SampleToCountMap::const_iterator>
PersistentSampleMapIterator;

@ -98,7 +98,9 @@ class BASE_EXPORT PersistentSampleMap : public HistogramSamples {
// All created/loaded sample values and their associated counts. The storage
// for the actual Count numbers is owned by the |records_| object and its
// underlying allocator.
std::map<HistogramBase::Sample, HistogramBase::Count*> sample_counts_;
std::map<HistogramBase::Sample,
raw_ptr<HistogramBase::Count, CtnExperimental>>
sample_counts_;
// The allocator that manages histograms inside persistent memory. This is
// owned externally and is expected to live beyond the life of this object.

@ -161,8 +161,9 @@ TEST(ScopedGenericTest, Receive) {
namespace {
struct TrackedIntTraits : public ScopedGenericOwnershipTracking {
using OwnerMap =
std::unordered_map<int, const ScopedGeneric<int, TrackedIntTraits>*>;
using OwnerMap = std::unordered_map<
int,
raw_ptr<const ScopedGeneric<int, TrackedIntTraits>, CtnExperimental>>;
TrackedIntTraits(std::unordered_set<int>* freed, OwnerMap* owners)
: freed(freed), owners(owners) {}

@ -11,6 +11,7 @@
#include "base/check_op.h"
#include "base/lazy_instance.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/ranges/algorithm.h"
#include "base/synchronization/condition_variable.h"

@ -71,7 +71,8 @@ class BASE_EXPORT ThreadIdNameManager {
ThreadIdToHandleMap;
typedef std::map<PlatformThreadHandle::Handle, std::string*>
ThreadHandleToInternedNameMap;
typedef std::map<std::string, std::string*> NameToInternedNameMap;
typedef std::map<std::string, raw_ptr<std::string, CtnExperimental>>
NameToInternedNameMap;
ThreadIdNameManager();
~ThreadIdNameManager();

@ -9,6 +9,7 @@
#include <unordered_map>
#include <vector>
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/memory/ref_counted.h"
#include "cc/cc_export.h"
@ -24,7 +25,8 @@ using OwnedLayerImplList = std::vector<std::unique_ptr<LayerImpl>>;
using LayerImplList = RAW_PTR_EXCLUSION std::vector<LayerImpl*>;
using RenderSurfaceList = RAW_PTR_EXCLUSION std::vector<RenderSurfaceImpl*>;
using OwnedLayerImplMap = std::unordered_map<int, std::unique_ptr<LayerImpl>>;
using LayerImplMap = std::unordered_map<int, LayerImpl*>;
using LayerImplMap =
std::unordered_map<int, raw_ptr<LayerImpl, CtnExperimental>>;
} // namespace cc

@ -484,7 +484,7 @@ class CC_EXPORT TileManager : CheckerImageTrackerClient,
bool use_gpu_rasterization_;
raw_ptr<RasterQueryQueue> pending_raster_queries_ = nullptr;
std::unordered_map<Tile::Id, Tile*> tiles_;
std::unordered_map<Tile::Id, raw_ptr<Tile, CtnExperimental>> tiles_;
bool all_tiles_that_need_to_be_rasterized_are_scheduled_;
MemoryHistory::Entry memory_stats_from_last_assign_;

@ -1076,10 +1076,11 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient {
scoped_refptr<HeadsUpDisplayLayer> hud_layer_;
// Layer id to Layer map.
std::unordered_map<int, Layer*> layer_id_map_;
std::unordered_map<int, raw_ptr<Layer, CtnExperimental>> layer_id_map_;
// This is for layer tree mode only.
std::unordered_map<ElementId, Layer*, ElementIdHash> element_layers_map_;
std::unordered_map<ElementId, raw_ptr<Layer, CtnExperimental>, ElementIdHash>
element_layers_map_;
bool in_paint_layer_contents_ = false;

@ -7,6 +7,7 @@
#include "base/containers/flat_map.h"
#include "base/containers/flat_set.h"
#include "base/memory/raw_ptr.h"
#include "cc/cc_export.h"
#include "components/viz/common/quads/compositor_render_pass.h"
#include "components/viz/common/surfaces/frame_sink_id.h"
@ -38,7 +39,8 @@ class CC_EXPORT ThrottleDecider {
const base::flat_set<viz::FrameSinkId>& ids() const { return ids_; }
private:
base::flat_map<viz::CompositorRenderPassId, const viz::CompositorRenderPass*>
base::flat_map<viz::CompositorRenderPassId,
raw_ptr<const viz::CompositorRenderPass, CtnExperimental>>
id_to_pass_map_;
// Ids of frame sinks that are qualified for throttling.
base::flat_set<viz::FrameSinkId> ids_;

@ -432,7 +432,7 @@ class AppServiceProxyBase : public KeyedService,
const apps::IntentFilterPtr& filter,
const apps::AppUpdate& update);
base::flat_map<AppType, AppPublisher*> publishers_;
base::flat_map<AppType, raw_ptr<AppPublisher, CtnExperimental>> publishers_;
apps::AppRegistryCache app_registry_cache_;
apps::AppCapabilityAccessCache app_capability_access_cache_;

@ -265,7 +265,8 @@ class WebsiteMetrics : public BrowserListObserver,
BrowserTabStripTracker browser_tab_strip_tracker_;
// The map from the window to the active tab contents.
base::flat_map<aura::Window*, content::WebContents*> window_to_web_contents_;
base::flat_map<aura::Window*, raw_ptr<content::WebContents, CtnExperimental>>
window_to_web_contents_;
// The map from the root window's activation client to windows.
std::map<wm::ActivationClient*,

@ -11,6 +11,7 @@
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/json/values_util.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/time/time.h"
#include "build/chromeos_buildflags.h"
@ -240,7 +241,7 @@ class WebsiteMetricsBrowserTest : public MixinBasedInProcessBrowserTest {
ASSERT_EQ(1, count);
}
base::flat_map<aura::Window*, content::WebContents*>&
base::flat_map<aura::Window*, raw_ptr<content::WebContents, CtnExperimental>>&
window_to_web_contents() {
return website_metrics()->window_to_web_contents_;
}
@ -286,7 +287,7 @@ IN_PROC_BROWSER_TEST_F(WebsiteMetricsBrowserTest, InsertAndCloseTabs) {
InsertForegroundTab(browser, "https://a.example.org");
EXPECT_EQ(1u, webcontents_to_observer_map().size());
EXPECT_TRUE(base::Contains(webcontents_to_observer_map(),
window_to_web_contents()[window]));
window_to_web_contents()[window].get()));
EXPECT_EQ(window_to_web_contents()[window]->GetVisibleURL(),
GURL("https://a.example.org"));
EXPECT_TRUE(webcontents_to_ukm_key().empty());
@ -1249,7 +1250,7 @@ IN_PROC_BROWSER_TEST_F(WebsiteMetricsObserverBrowserTest,
// Close the tab and verify observer is notified.
EXPECT_CALL(observer_,
OnUrlClosed(GURL(kUrl), window_to_web_contents()[window]))
OnUrlClosed(GURL(kUrl), window_to_web_contents()[window].get()))
.Times(1);
browser->tab_strip_model()->CloseAllTabs();
}
@ -1268,7 +1269,7 @@ IN_PROC_BROWSER_TEST_F(WebsiteMetricsObserverBrowserTest,
// Simulate window closure and verify observer is notified accordingly.
const std::string& kNewUrl = "https://b.example.org";
EXPECT_CALL(observer_,
OnUrlClosed(GURL(kUrl1), window_to_web_contents()[window]))
OnUrlClosed(GURL(kUrl1), window_to_web_contents()[window].get()))
.Times(1);
EXPECT_CALL(observer_, OnUrlClosed(GURL(kUrl2), _)).Times(1);
browser->tab_strip_model()->CloseAllTabs();

@ -215,7 +215,8 @@ class ExtensionAppsChromeOs : public ExtensionAppsBase,
// and is set by updating SystemDisabledMode policy.
bool is_disabled_apps_mode_hidden_ = false;
std::map<extensions::AppWindow*, aura::Window*> app_window_to_aura_window_;
std::map<extensions::AppWindow*, raw_ptr<aura::Window, CtnExperimental>>
app_window_to_aura_window_;
raw_ptr<ArcAppListPrefs> arc_prefs_ = nullptr;

@ -336,7 +336,7 @@ void AppListClientImpl::ActivateItem(int profile_id,
int event_flags,
ash::AppListLaunchedFrom launched_from,
bool is_above_the_fold) {
auto* requested_model_updater = profile_model_mappings_[profile_id];
auto* requested_model_updater = profile_model_mappings_[profile_id].get();
// Pointless to notify the AppListModelUpdater of the activated item if the
// |requested_model_updater| is not the current one, which means that the
@ -387,7 +387,7 @@ void AppListClientImpl::GetContextMenuModel(
const std::string& id,
ash::AppListItemContext item_context,
GetContextMenuModelCallback callback) {
auto* requested_model_updater = profile_model_mappings_[profile_id];
auto* requested_model_updater = profile_model_mappings_[profile_id].get();
if (requested_model_updater != current_model_updater_ ||
!requested_model_updater) {
std::move(callback).Run(nullptr);
@ -754,7 +754,7 @@ AppListClientImpl::CreateLauncherSearchIphSession() {
}
void AppListClientImpl::LoadIcon(int profile_id, const std::string& app_id) {
auto* requested_model_updater = profile_model_mappings_[profile_id];
auto* requested_model_updater = profile_model_mappings_[profile_id].get();
if (requested_model_updater != current_model_updater_ ||
!requested_model_updater) {
return;

@ -244,7 +244,8 @@ class AppListClientImpl
// (https://crbug.com/939755).
// TODO: Replace the mojo interface functions provided by AppListClient with
// callbacks.
std::map<int, AppListModelUpdater*> profile_model_mappings_;
std::map<int, raw_ptr<AppListModelUpdater, CtnExperimental>>
profile_model_mappings_;
std::unique_ptr<app_list::SearchController> search_controller_;
std::unique_ptr<AppSyncUIStateWatcher> app_sync_ui_state_watcher_;

@ -143,7 +143,8 @@ class ArcAccessibilityHelperBridgeTest : public ChromeViewsTestBase {
}
private:
std::map<std::string, ArcNotificationSurface*> surfaces_;
std::map<std::string, raw_ptr<ArcNotificationSurface, CtnExperimental>>
surfaces_;
base::ObserverList<Observer>::UncheckedAndDanglingUntriaged observers_;
};

@ -188,7 +188,7 @@ class ArcAccessibilityTreeTracker : public aura::EnvObserver {
// a11y window id (obtained from exo, put for each window) to task id.
std::map<int32_t, int32_t> window_id_to_task_id_;
// task id to top aura::window.
std::map<int32_t, aura::Window*> task_id_to_window_;
std::map<int32_t, raw_ptr<aura::Window, CtnExperimental>> task_id_to_window_;
ax::android::mojom::AccessibilityFilterType filter_type_ =
ax::android::mojom::AccessibilityFilterType::OFF;

@ -8,6 +8,7 @@
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/public/cpp/window_properties.h"
#include "base/memory/raw_ptr.h"
#include "base/test/task_environment.h"
#include "chrome/test/base/testing_profile.h"
#include "chromeos/ui/base/app_types.h"
@ -39,7 +40,7 @@ class FakeWMHelper : public exo::WMHelper {
}
private:
std::map<int, aura::Window*> map_;
std::map<int, raw_ptr<aura::Window, CtnExperimental>> map_;
};
} // namespace

@ -14,6 +14,7 @@
#include "base/containers/adapters.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ash/crosapi/browser_util.h"
#include "components/exo/shell_surface_util.h"
@ -75,7 +76,7 @@ class WindowList : public aura::WindowObserver {
//
// The members |id_to_window_| and |window_to_id_| must be kept in sync. The
// members exist to allow fast lookup in both directions.
std::map<uint64_t, aura::Window*> id_to_window_;
std::map<uint64_t, raw_ptr<aura::Window, CtnExperimental>> id_to_window_;
std::map<aura::Window*, uint64_t> window_to_id_;
uint64_t next_window_id_ = 0;
};

@ -157,7 +157,8 @@ class VpnServiceForExtensionAsh : public crosapi::mojom::VpnServiceForExtension,
using StringToOwnedConfigurationMap =
std::map<std::string, std::unique_ptr<VpnConfiguration>>;
using StringToConfigurationMap = std::map<std::string, VpnConfiguration*>;
using StringToConfigurationMap =
std::map<std::string, raw_ptr<VpnConfiguration, CtnExperimental>>;
const extensions::ExtensionId& extension_id() const { return extension_id_; }

@ -138,7 +138,8 @@ class AnsibleManagementService : public KeyedService,
// We don't really need to know about these, but keeping them so we can access
// for testing purposes.
std::map<guest_os::GuestId, views::Widget*> ui_elements_;
std::map<guest_os::GuestId, raw_ptr<views::Widget, CtnExperimental>>
ui_elements_;
base::WeakPtrFactory<AnsibleManagementService> weak_ptr_factory_;
};

@ -274,7 +274,8 @@ class FileManagerBrowserTestBase
void StartTest();
private:
using IdToWebContents = std::map<std::string, content::WebContents*>;
using IdToWebContents =
std::map<std::string, raw_ptr<content::WebContents, CtnExperimental>>;
class MockFileTasksObserver;

@ -323,7 +323,8 @@ class InputMethodManagerImpl : public InputMethodManager,
uint32_t features_enabled_state_;
// The engine map from extension_id to an engine.
using EngineMap = std::map<std::string, TextInputMethod*>;
using EngineMap =
std::map<std::string, raw_ptr<TextInputMethod, CtnExperimental>>;
using ProfileEngineMap = std::map<Profile*, EngineMap, ProfileCompare>;
ProfileEngineMap engine_map_;

@ -485,7 +485,8 @@ class OAuth2Test : public OobeBaseTest {
private:
base::FilePath test_data_dir_;
std::map<std::string, RequestDeferrer*> request_deferers_;
std::map<std::string, raw_ptr<RequestDeferrer, CtnExperimental>>
request_deferers_;
};
class CookieReader {

@ -3491,7 +3491,7 @@ bool WizardController::MaybeSetToPreviousScreen() {
return false;
}
auto* old_current_screen = current_screen_.get();
auto* previous_screen = previous_screens_[current_screen_];
auto* previous_screen = previous_screens_[current_screen_].get();
if (previous_screen->screen_id() == GaiaView::kScreenId) {
wizard_context_->gaia_config.gaia_path =

@ -584,7 +584,8 @@ class WizardController : public OobeUI::Observer {
// The `BaseScreen*` here point to the objects owned by the `screen_manager_`.
// So it should be safe to store the pointers.
base::flat_map<BaseScreen*, BaseScreen*> previous_screens_;
base::flat_map<BaseScreen*, raw_ptr<BaseScreen, CtnExperimental>>
previous_screens_;
raw_ptr<WizardContext> wizard_context_;

@ -8,6 +8,7 @@
#include <memory>
#include <utility>
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/test/task_environment.h"
#include "chrome/browser/ash/power/auto_screen_brightness/fake_observer.h"
@ -105,7 +106,9 @@ class LightProviderMojoTest : public testing::Test {
std::unique_ptr<AlsReader> als_reader_;
std::unique_ptr<LightProviderMojo> provider_;
std::map<int32_t, chromeos::sensors::FakeSensorDevice*> sensor_devices_;
std::map<int32_t,
raw_ptr<chromeos::sensors::FakeSensorDevice, CtnExperimental>>
sensor_devices_;
int num_samples_ = 0;

@ -212,7 +212,7 @@ class PrintingOAuth2AuthorizationZonesManagerTest : public testing::Test {
raw_ptr<testing::NiceMock<MockClientIdsDatabase>, DanglingUntriaged>
client_ids_database_;
std::map<GURL, AuthZoneMock*> auth_zones_;
std::map<GURL, raw_ptr<AuthZoneMock, CtnExperimental>> auth_zones_;
content::BrowserTaskEnvironment task_environment_;
TestingProfile profile_;
testing::NiceMock<syncer::MockDataTypeLocalChangeProcessor> mock_processor_;

@ -15,6 +15,7 @@
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
@ -59,7 +60,8 @@ class ProfileHelperImpl : public ProfileHelper {
std::unique_ptr<BrowserContextHelper> browser_context_helper_;
// Used for testing by unit tests and FakeUserManager.
std::map<const user_manager::User*, Profile*> user_to_profile_for_testing_;
std::map<const user_manager::User*, raw_ptr<Profile, CtnExperimental>>
user_to_profile_for_testing_;
};
////////////////////////////////////////////////////////////////////////////////

@ -7,6 +7,7 @@
#include <map>
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/unguessable_token.h"
#include "build/chromeos_buildflags.h"
@ -89,7 +90,9 @@ class PrintPreviewWebcontentsManager
content::WebContents* RemoveTokenMapping(const base::UnguessableToken& token);
// Mapping a unique ID to its webcontents.
std::map<base::UnguessableToken, content::WebContents*> token_to_webcontents_;
std::map<base::UnguessableToken,
raw_ptr<content::WebContents, CtnExperimental>>
token_to_webcontents_;
base::WeakPtrFactory<PrintPreviewWebcontentsManager> weak_ptr_factory_{this};
};

@ -37,7 +37,7 @@ class PortForwardingController {
private:
class Connection;
typedef std::map<std::string, Connection*> Registry;
typedef std::map<std::string, raw_ptr<Connection, CtnExperimental>> Registry;
void OnPrefsChange();

@ -15,6 +15,7 @@
#include "base/containers/queue.h"
#include "base/containers/span.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/devtools/device/usb/usb_device_manager_helper.h"
@ -146,7 +147,8 @@ class AndroidUsbDevice : public base::RefCountedThreadSafe<AndroidUsbDevice> {
// Created sockets info
uint32_t last_socket_id_;
using AndroidUsbSockets = std::map<uint32_t, AndroidUsbSocket*>;
using AndroidUsbSockets =
std::map<uint32_t, raw_ptr<AndroidUsbSocket, CtnExperimental>>;
AndroidUsbSockets sockets_;
// Outgoing bulk queue

@ -6,6 +6,7 @@
#define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_BROWSER_CONTEXT_MANAGER_H_
#include "base/containers/flat_map.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/no_destructor.h"
#include "base/scoped_multi_source_observation.h"
@ -48,7 +49,7 @@ class DevToolsBrowserContextManager : public BrowserListObserver,
base::ScopedMultiSourceObservation<Profile, ProfileObserver>
profile_observation_{this};
base::flat_map<std::string, Profile*> otr_profiles_;
base::flat_map<std::string, raw_ptr<Profile, CtnExperimental>> otr_profiles_;
base::flat_map<std::string, content::DevToolsManagerDelegate::DisposeCallback>
pending_context_disposals_;

@ -8,6 +8,7 @@
#include <map>
#include <memory>
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/browser_tab_strip_tracker.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
@ -69,7 +70,8 @@ class GlobalConfirmInfoBar : public TabStripModelObserver,
void MaybeAddInfoBar(content::WebContents* web_contents);
std::unique_ptr<ConfirmInfoBarDelegate> delegate_;
std::map<infobars::InfoBarManager*, DelegateProxy*> proxies_;
std::map<infobars::InfoBarManager*, raw_ptr<DelegateProxy, CtnExperimental>>
proxies_;
BrowserTabStripTracker browser_tab_strip_tracker_{this, nullptr};
// Indicates if the global infobar is currently in the process of shutting

@ -198,8 +198,9 @@ class DownloadManagerService
enum DownloadAction { RESUME, PAUSE, CANCEL, REMOVE, UNKNOWN };
using PendingDownloadActions = std::map<std::string, DownloadAction>;
using Coordinators =
std::map<ProfileKey*, download::SimpleDownloadManagerCoordinator*>;
using Coordinators = std::map<
ProfileKey*,
raw_ptr<download::SimpleDownloadManagerCoordinator, CtnExperimental>>;
// Helper function to start the download resumption.
void ResumeDownloadInternal(const std::string& download_guid,

@ -327,7 +327,9 @@ class DownloadRequestLimiter
// if the state is other than ALLOW_ONE_DOWNLOAD. Similarly once the state
// transitions from anything but ALLOW_ONE_DOWNLOAD back to ALLOW_ONE_DOWNLOAD
// the TabDownloadState is removed and deleted (by way of Remove).
typedef std::map<content::WebContents*, TabDownloadState*> StateMap;
typedef std::map<content::WebContents*,
raw_ptr<TabDownloadState, CtnExperimental>>
StateMap;
StateMap state_map_;
CanDownloadDecidedCallback on_can_download_decided_callback_;

@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_ENTERPRISE_CONNECTORS_REPORTING_CRASH_REPORTING_CONTEXT_H_
#define CHROME_BROWSER_ENTERPRISE_CONNECTORS_REPORTING_CRASH_REPORTING_CONTEXT_H_
#include "base/memory/raw_ptr.h"
#include "base/memory/singleton.h"
#include "base/timer/timer.h"
#include "chrome/browser/enterprise/connectors/reporting/browser_crash_event_router.h"
@ -47,7 +48,9 @@ class CrashReportingContext
CrashReportingContext();
base::RepeatingTimer repeating_crash_report_;
std::unordered_map<BrowserCrashEventRouter*, Profile*> active_profiles_;
std::unordered_map<BrowserCrashEventRouter*,
raw_ptr<Profile, CtnExperimental>>
active_profiles_;
#endif
};

@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_ENTERPRISE_CONNECTORS_TEST_FAKE_CONTENT_ANALYSIS_SDK_MANAGER_H_
#define CHROME_BROWSER_ENTERPRISE_CONNECTORS_TEST_FAKE_CONTENT_ANALYSIS_SDK_MANAGER_H_
#include "base/memory/raw_ptr.h"
#include "chrome/browser/enterprise/connectors/analysis/content_analysis_sdk_manager.h"
#include "chrome/browser/enterprise/connectors/test/fake_content_analysis_sdk_client.h"
#include "third_party/content_analysis_sdk/src/browser/include/content_analysis/sdk/analysis_client.h"
@ -57,7 +58,7 @@ class FakeContentAnalysisSdkManager final : public ContentAnalysisSdkManager {
};
std::map<content_analysis::sdk::Client::Config,
FakeContentAnalysisSdkClient*,
raw_ptr<FakeContentAnalysisSdkClient, CtnExperimental>,
decltype(CompareConfig)>
fake_clients_{CompareConfig};
};

@ -15,6 +15,7 @@
#include "base/functional/bind.h"
#include "base/json/json_string_value_serializer.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/one_shot_event.h"
#include "base/strings/string_util.h"
@ -198,7 +199,7 @@ class ApiInfoDatabase {
// The map is keyed by API name only, since API names aren't be repeated
// across multiple action types in kApiInfoTable. However, the action type
// should still be checked before returning a positive match.
std::map<std::string, const ApiInfo*> api_database_;
std::map<std::string, raw_ptr<const ApiInfo, CtnExperimental>> api_database_;
friend struct base::DefaultSingletonTraits<ApiInfoDatabase>;
};

@ -10,6 +10,7 @@
#include "base/check.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/strings/string_util.h"
#include "build/build_config.h"
@ -106,7 +107,8 @@ void ChromeExtensionsAPIClient::AddAdditionalValueStoreCaches(
content::BrowserContext* context,
const scoped_refptr<value_store::ValueStoreFactory>& factory,
SettingsChangedCallback observer,
std::map<settings_namespace::Namespace, ValueStoreCache*>* caches) {
std::map<settings_namespace::Namespace,
raw_ptr<ValueStoreCache, CtnExperimental>>* caches) {
// Add support for chrome.storage.sync.
(*caches)[settings_namespace::SYNC] =
new SyncValueStoreCache(factory, observer, context->GetPath());

@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_EXTENSIONS_API_CHROME_EXTENSIONS_API_CLIENT_H_
#define CHROME_BROWSER_EXTENSIONS_API_CHROME_EXTENSIONS_API_CLIENT_H_
#include "base/memory/raw_ptr.h"
#include "build/chromeos_buildflags.h"
#include "extensions/browser/api/extensions_api_client.h"
@ -30,8 +31,8 @@ class ChromeExtensionsAPIClient : public ExtensionsAPIClient {
content::BrowserContext* context,
const scoped_refptr<value_store::ValueStoreFactory>& factory,
SettingsChangedCallback observer,
std::map<settings_namespace::Namespace, ValueStoreCache*>* caches)
override;
std::map<settings_namespace::Namespace,
raw_ptr<ValueStoreCache, CtnExperimental>>* caches) override;
void AttachWebContentsHelpers(content::WebContents* web_contents) const
override;
bool ShouldHideResponseHeader(const GURL& url,

@ -10,6 +10,7 @@
#include <memory>
#include <string>
#include "base/memory/raw_ptr.h"
#include "base/memory/singleton.h"
#include "chrome/browser/media/webrtc/desktop_media_list.h"
#include "chrome/browser/media/webrtc/desktop_media_picker_controller.h"
@ -124,8 +125,9 @@ class DesktopCaptureRequestsRegistry {
int request_id;
};
using RequestsMap =
std::map<RequestId, DesktopCaptureChooseDesktopMediaFunctionBase*>;
using RequestsMap = std::map<
RequestId,
raw_ptr<DesktopCaptureChooseDesktopMediaFunctionBase, CtnExperimental>>;
RequestsMap requests_;
};

@ -51,7 +51,10 @@ class InputImeEventRouterFactory {
InputImeEventRouterFactory();
~InputImeEventRouterFactory();
std::map<Profile*, InputImeEventRouter*, ProfileCompare> router_map_;
std::map<Profile*,
raw_ptr<InputImeEventRouter, CtnExperimental>,
ProfileCompare>
router_map_;
};
class InputImeKeyEventHandledFunction : public ExtensionFunction {

@ -790,8 +790,8 @@ class ExtensionService : public ExtensionServiceInterface,
base::ScopedObservation<CWSInfoService, CWSInfoService::Observer>
cws_info_service_observation_{this};
using InstallGateRegistry =
std::map<ExtensionPrefs::DelayReason, InstallGate*>;
using InstallGateRegistry = std::map<ExtensionPrefs::DelayReason,
raw_ptr<InstallGate, CtnExperimental>>;
InstallGateRegistry install_delayer_registry_;
#if BUILDFLAG(IS_CHROMEOS_ASH)

@ -7,6 +7,7 @@
#include <map>
#include "base/memory/raw_ptr.h"
#include "ui/events/keycodes/keyboard_codes.h"
namespace ui {
@ -87,7 +88,8 @@ class GlobalShortcutListener {
// The map of accelerators that have been successfully registered as global
// shortcuts and their observer.
typedef std::map<ui::Accelerator, Observer*> AcceleratorMap;
typedef std::map<ui::Accelerator, raw_ptr<Observer, CtnExperimental>>
AcceleratorMap;
AcceleratorMap accelerator_map_;
// Keeps track of whether shortcut handling is currently suspended.

@ -443,7 +443,7 @@ class MenuManager : public ProfileObserver,
// This lets us make lookup by id fast. It maps id to MenuItem* for
// all items the menu manager knows about, including all children of top-level
// items.
std::map<MenuItem::Id, MenuItem*> items_by_id_;
std::map<MenuItem::Id, raw_ptr<MenuItem, CtnExperimental>> items_by_id_;
// The scheduled tasks to write the menu items to storage.
std::map<MenuItem::ExtensionKey, base::OneShotTimer> write_tasks_;

@ -15,6 +15,7 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/json/values_util.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/notreached.h"
#include "base/path_service.h"
@ -887,7 +888,8 @@ class ChromeFileSystemAccessPermissionContext::PermissionGrantImpl
}
static void UpdateGrantPath(
std::map<base::FilePath, PermissionGrantImpl*>& grants,
std::map<base::FilePath, raw_ptr<PermissionGrantImpl, CtnExperimental>>&
grants,
const base::FilePath& old_path,
const base::FilePath& new_path) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
@ -907,7 +909,7 @@ class ChromeFileSystemAccessPermissionContext::PermissionGrantImpl
DCHECK_EQ(entry_it->second->GetActivePermissionStatus(),
PermissionStatus::GRANTED);
auto* const grant_impl = entry_it->second;
auto* const grant_impl = entry_it->second.get();
grant_impl->SetPath(new_path);
// Update the permission grant's key in the map of active permissions.
@ -1134,8 +1136,10 @@ struct ChromeFileSystemAccessPermissionContext::OriginState {
// Raw pointers, owned collectively by all the handles that reference this
// grant. When last reference goes away this state is cleared as well by
// PermissionGrantDestroyed().
std::map<base::FilePath, PermissionGrantImpl*> read_grants;
std::map<base::FilePath, PermissionGrantImpl*> write_grants;
std::map<base::FilePath, raw_ptr<PermissionGrantImpl, CtnExperimental>>
read_grants;
std::map<base::FilePath, raw_ptr<PermissionGrantImpl, CtnExperimental>>
write_grants;
PersistedGrantStatus persisted_grant_status = PersistedGrantStatus::kLoaded;
@ -1289,7 +1293,7 @@ ChromeFileSystemAccessPermissionContext::GetReadPermissionGrant(
// operator[] might insert a new OriginState in |active_permissions_map_|,
// but that is exactly what we want.
auto& origin_state = active_permissions_map_[origin];
auto*& existing_grant = origin_state.read_grants[path];
auto& existing_grant = origin_state.read_grants[path];
scoped_refptr<PermissionGrantImpl> grant;
if (existing_grant && existing_grant->handle_type() != handle_type) {
@ -1383,7 +1387,7 @@ ChromeFileSystemAccessPermissionContext::GetWritePermissionGrant(
// operator[] might insert a new OriginState in |active_permissions_map_|,
// but that is exactly what we want.
auto& origin_state = active_permissions_map_[origin];
auto*& existing_grant = origin_state.write_grants[path];
auto& existing_grant = origin_state.write_grants[path];
scoped_refptr<PermissionGrantImpl> grant;
if (existing_grant && existing_grant->handle_type() != handle_type) {
@ -2498,7 +2502,7 @@ void ChromeFileSystemAccessPermissionContext::
? HandleType::kDirectory
: HandleType::kFile;
if (object_dict.FindBool(kPermissionReadableKey).value_or(false)) {
auto*& read_grant = it->second.read_grants[path];
auto& read_grant = it->second.read_grants[path];
if (read_grant && read_grant->handle_type() == handle_type) {
read_grant->SetStatus(
PermissionStatus::GRANTED,
@ -2506,7 +2510,7 @@ void ChromeFileSystemAccessPermissionContext::
}
}
if (object_dict.FindBool(kPermissionWritableKey).value_or(false)) {
auto*& write_grant = it->second.write_grants[path];
auto& write_grant = it->second.write_grants[path];
if (write_grant && write_grant->handle_type() == handle_type) {
write_grant->SetStatus(
PermissionStatus::GRANTED,

@ -118,7 +118,7 @@ class ImageDecoder {
private:
friend base::NoDestructor<ImageDecoder>;
using RequestMap = std::map<int, ImageRequest*>;
using RequestMap = std::map<int, raw_ptr<ImageRequest, CtnExperimental>>;
ImageDecoder();
~ImageDecoder() = delete;

@ -111,7 +111,8 @@ class MediaEngagementService : public KeyedService,
// engagement is only earned for HTTP and HTTPS.
bool ShouldRecordEngagement(const url::Origin& origin) const;
base::flat_map<content::WebContents*, MediaEngagementContentsObserver*>
base::flat_map<content::WebContents*,
raw_ptr<MediaEngagementContentsObserver, CtnExperimental>>
contents_observers_;
raw_ptr<Profile, DanglingUntriaged> profile_;

@ -185,7 +185,7 @@ bool DialRegistry::PruneExpiredDevices() {
bool pruned_device = false;
auto it = device_by_label_map_.begin();
while (it != device_by_label_map_.end()) {
auto* device = it->second;
auto* device = it->second.get();
if (IsDeviceExpired(*device)) {
// Make a copy of the device ID here since |device| will be destroyed
// during erase().

@ -112,7 +112,8 @@ class DialRegistry
private:
using DeviceByIdMap = std::map<std::string, std::unique_ptr<DialDeviceData>>;
using DeviceByLabelMap = std::map<std::string, DialDeviceData*>;
using DeviceByLabelMap =
std::map<std::string, raw_ptr<DialDeviceData, CtnExperimental>>;
friend class MockDialRegistry;
friend class TestDialRegistry;

@ -61,7 +61,8 @@ class TestDnsSdRegistry : public DnsSdRegistry {
}
private:
std::map<std::string, MockDnsSdDeviceLister*> listers_;
std::map<std::string, raw_ptr<MockDnsSdDeviceLister, CtnExperimental>>
listers_;
// The last delegate used or NULL.
raw_ptr<DnsSdDelegate> delegate_;
};

@ -19,6 +19,7 @@
#include "base/files/file_path.h"
#include "base/functional/callback.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/media_galleries/chromeos/mtp_device_task_helper.h"
#include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h"
@ -67,7 +68,8 @@ class MTPDeviceDelegateImplLinux : public MTPDeviceAsyncDelegate {
class MTPFileNode;
// Maps file ids to file nodes.
typedef std::map<uint32_t, MTPFileNode*> FileIdToMTPFileNodeMap;
typedef std::map<uint32_t, raw_ptr<MTPFileNode, CtnExperimental>>
FileIdToMTPFileNodeMap;
// Maps file paths to file info.
typedef std::map<base::FilePath, MTPDeviceTaskHelper::MTPEntry> FileInfoCache;

@ -118,7 +118,8 @@ class GalleryWatchManager
typedef std::map<WatchOwner, base::FilePath> WatchesMap;
typedef std::map<base::FilePath, NotificationInfo> WatchedPaths;
typedef std::map<content::BrowserContext*, GalleryWatchManagerObserver*>
typedef std::map<content::BrowserContext*,
raw_ptr<GalleryWatchManagerObserver, CtnExperimental>>
ObserverMap;
typedef std::map<content::BrowserContext*, base::CallbackListSubscription>
BrowserContextSubscriptionMap;

@ -210,7 +210,7 @@ class NotificationScheduleServiceTest : public InProcessBrowserTest {
base::ScopedTempDir tmp_dir_;
std::unique_ptr<KeyedService> service_;
raw_ptr<TestBackgroundTaskScheduler> task_scheduler_;
std::map<SchedulerClientType, TestClient*> clients_;
std::map<SchedulerClientType, raw_ptr<TestClient, CtnExperimental>> clients_;
};
// Test to schedule a notification.

@ -7,6 +7,7 @@
#include <map>
#include <memory>
#include "base/memory/raw_ptr.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/page_load_metrics/observers/page_load_metrics_observer_test_harness.h"
#include "chrome/browser/predictors/loading_data_collector.h"
@ -22,7 +23,6 @@
#include "content/public/test/prerender_test_util.h"
#include "content/public/test/test_utils.h"
#include "content/public/test/web_contents_tester.h"
#include "third_party/blink/public/mojom/lcp_critical_path_predictor/lcp_critical_path_predictor.mojom.h"
namespace predictors {
@ -231,7 +231,9 @@ class LcpCriticalPathPredictorPageLoadMetricsObserverTest
private:
page_load_metrics::mojom::PageLoadTiming timing_;
std::map<GURL, LcpCriticalPathPredictorPageLoadMetricsObserver*>
std::map<
GURL,
raw_ptr<LcpCriticalPathPredictorPageLoadMetricsObserver, CtnExperimental>>
lcpp_observers_;
int max_lcpp_histogram_buckets_;
};

@ -59,7 +59,8 @@ class MockBackgroundTabLoadingPolicy : public BackgroundTabLoadingPolicy {
return it->second;
}
std::map<const PageNode*, SiteDataReader*> site_data_readers_;
std::map<const PageNode*, raw_ptr<SiteDataReader, CtnExperimental>>
site_data_readers_;
};
} // namespace

@ -116,7 +116,8 @@ class UnitTestNoStatePrefetchManager : public NoStatePrefetchManager {
// Maintain a map from route pairs to NoStatePrefetchContents for
// GetNoStatePrefetchContentsForRoute.
using NoStatePrefetchContentsMap =
std::map<std::pair<int, int>, NoStatePrefetchContents*>;
std::map<std::pair<int, int>,
raw_ptr<NoStatePrefetchContents, CtnExperimental>>;
NoStatePrefetchContentsMap no_state_prefetch_contents_map_;
std::unique_ptr<NoStatePrefetchContents> next_no_state_prefetch_contents_;

@ -1440,7 +1440,7 @@ void PrivacySandboxServiceImpl::MaybeCloseOpenPrompts() {
// not cross task boundaries.
auto browsers_to_open_prompts_copy = browsers_to_open_prompts_;
for (const auto& browser_prompt : browsers_to_open_prompts_copy) {
auto* prompt = browser_prompt.second;
auto* prompt = browser_prompt.second.get();
CHECK(prompt);
prompt->CloseWithReason(views::Widget::ClosedReason::kUnspecified);
}

@ -368,7 +368,8 @@ class PrivacySandboxServiceImpl : public PrivacySandboxService {
#if !BUILDFLAG(IS_ANDROID)
// A map of Browser windows which have an open Privacy Sandbox prompt,
// to the Widget for that prompt.
std::map<Browser*, views::Widget*> browsers_to_open_prompts_;
std::map<Browser*, raw_ptr<views::Widget, CtnExperimental>>
browsers_to_open_prompts_;
#endif
// Fake implementation for current and blocked topics.

@ -9,6 +9,7 @@
#include <memory>
#include "base/functional/callback_forward.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "components/download/public/common/all_download_event_notifier.h"
@ -87,7 +88,8 @@ class DownloadMetadataManager
class ManagerContext;
// A mapping of DownloadManagerCoordinators to their corresponding contexts.
typedef std::map<download::SimpleDownloadManagerCoordinator*, ManagerContext*>
typedef std::map<download::SimpleDownloadManagerCoordinator*,
raw_ptr<ManagerContext, CtnExperimental>>
ManagerToContextMap;
// A task runner to which IO tasks are posted.

@ -7,6 +7,7 @@
#include <string>
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/segmentation_platform/ukm_database_client.h"
#include "components/segmentation_platform/internal/execution/mock_model_provider.h"
@ -86,7 +87,8 @@ class UkmDataManagerTestUtils {
std::unique_ptr<UkmDatabaseClient> owned_db_client_;
std::map<proto::SegmentId, MockDefaultModelProvider*> default_overrides_;
std::map<proto::SegmentId, raw_ptr<MockDefaultModelProvider, CtnExperimental>>
default_overrides_;
base::WeakPtrFactory<UkmDataManagerTestUtils> weak_factory_{this};
};

Some files were not shown because too many files have changed in this diff Show More