Skip to content

Commit

Permalink
MiraclePtr: Rewrite chromeos-ash [5/N]
Browse files Browse the repository at this point in the history
This was automated.
It rewrites chromeos-ash and annotate the dangling pointers.

This part was split out of the root CL:
https://chromium-review.googlesource.com/c/chromium/src/+/4459392

number file        selected
------ ----------- --------
  1700 chrome/
  1407 ash/        x
   626 chromeos/
   147 components/
    53 ui/
    16 extensions/
    14 media/
     9 remoting/
     8 services/
     5 content/
     3 cc/
     1 gpu/
     1 crypto/

Steps:

1. Execute the rewriter:
./tools/clang/rewrite_raw_ptr_fields/rewrite-multiple-platforms.sh chromeos-ash

2. Execute all the tests. Print the dangling pointers using
   https://godbolt.org/z/o8adYnc7a idea. Then apply the edits using:
   https://github.com/ArthurSonzogni/chrome-dangling-ptr-apply-edit

3. Apply `git cl format`

4. Add `ExperimentalAsh`. This happened using a vim macro on the root
   patch. Overall there are exactly 7461 new pointers, and 183 dangling
   pointers.

5. Apply `git cl format`

Cq-Include-Trybots:luci.chromium.try:android-pie-arm64-dbg,android-x64-Cq-Include-Trybots: luci.chromium.try:android-pie-arm64-dbg,android-x64-cast,android_compile_dbg,android_compile_x64_dbg,android_compile_x86_dbg,android_cronet,chromeos-amd64-generic-dbg,chromeos-arm-generic-rel,dawn-android-arm-deps-rel,dawn-mac-x64-deps-rel,fuchsia-arm64-rel,fuchsia-x64-cast-receiver-rel,ios-simulator,lacros-amd64-generic-rel,lacros-arm-generic-rel,linux-chromeos-compile-dbg,linux-libfuzzer-asan-rel,linux_chromium_asan_rel_ng,linux_chromium_compile_dbg_ng,linux_chromium_tsan_rel_ng,linux_vr,mac_chromium_compile_dbg_ng,win-libfuzzer-asan-rel,win_chromium_compile_dbg_ng,android-arm64-rel,android-nougat-x86-rel,android_optional_gpu_tests_rel,chromeos-amd64-generic-rel,dawn-linux-x64-deps-rel,dawn-win10-x64-deps-rel,dawn-win10-x86-deps-rel,linux-chromeos-rel,linux-lacros-rel,linux-rel,linux-wayland-rel,linux-x64-castos,linux_optional_gpu_tests_rel,mac_optional_gpu_tests_rel,win_optional_gpu_tests_rel
Include-Ci-Only-Tests: true
Bug:1430482

Change-Id: Ie1e24f40a0688c1148b27455d05aae73803c10da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4456581
Commit-Queue: Arthur Sonzogni <[email protected]>
Reviewed-by: Bartek Nowierski <[email protected]>
Owners-Override: Bartek Nowierski <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1134206}
  • Loading branch information
ArthurSonzogni authored and Chromium LUCI CQ committed Apr 22, 2023
1 parent 424369c commit 834e018
Show file tree
Hide file tree
Showing 1,406 changed files with 5,491 additions and 3,527 deletions.
7 changes: 5 additions & 2 deletions ash/accelerators/accelerator_controller_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "ash/public/cpp/accelerators.h"
#include "base/files/file_path.h"
#include "base/gtest_prod_util.h"
#include "base/memory/raw_ptr.h"
#include "base/timer/timer.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/accelerators/accelerator_map.h"
Expand Down Expand Up @@ -87,7 +88,8 @@ class ASH_EXPORT AcceleratorControllerImpl
const std::string& side);

private:
AcceleratorControllerImpl* controller_; // Not owned.
raw_ptr<AcceleratorControllerImpl, ExperimentalAsh>
controller_; // Not owned.
};

explicit AcceleratorControllerImpl(AshAcceleratorConfiguration* config);
Expand Down Expand Up @@ -223,7 +225,8 @@ class ASH_EXPORT AcceleratorControllerImpl
std::unique_ptr<AcceleratorHistoryImpl> accelerator_history_;

// Manages all accelerator mappings.
AshAcceleratorConfiguration* accelerator_configuration_;
raw_ptr<AshAcceleratorConfiguration, ExperimentalAsh>
accelerator_configuration_;

// Handles the exit accelerator which requires a double press to exit and
// shows a popup with an explanation.
Expand Down
20 changes: 13 additions & 7 deletions ash/accelerators/accelerator_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/json/json_writer.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/system/sys_info.h"
#include "base/test/bind.h"
Expand Down Expand Up @@ -429,9 +430,10 @@ class AcceleratorControllerTest : public AshTestBase {
return true;
}

AcceleratorControllerImpl* controller_ = nullptr; // Not owned.
raw_ptr<AcceleratorControllerImpl, ExperimentalAsh> controller_ =
nullptr; // Not owned.
std::unique_ptr<AcceleratorControllerImpl::TestApi> test_api_;
MockNewWindowDelegate* new_window_delegate_;
raw_ptr<MockNewWindowDelegate, ExperimentalAsh> new_window_delegate_;
std::unique_ptr<TestNewWindowDelegateProvider> delegate_provider_;
};

Expand Down Expand Up @@ -2314,19 +2316,22 @@ class AcceleratorControllerImprovedKeyboardShortcutsTest
input_method::InputMethodManager::Initialize(input_method_manager_);

AcceleratorControllerTest::SetUp();
EXPECT_TRUE(input_method_manager_->observers_.HasObserver(controller_));
EXPECT_TRUE(
input_method_manager_->observers_.HasObserver(controller_.get()));
}

void TearDown() override {
AcceleratorControllerTest::TearDown();
EXPECT_FALSE(input_method_manager_->observers_.HasObserver(controller_));
EXPECT_FALSE(
input_method_manager_->observers_.HasObserver(controller_.get()));

input_method::InputMethodManager::Shutdown();
input_method_manager_ = nullptr;
}

protected:
TestInputMethodManager* input_method_manager_ = nullptr; // Not owned.
raw_ptr<TestInputMethodManager, ExperimentalAsh> input_method_manager_ =
nullptr; // Not owned.

private:
base::test::ScopedFeatureList scoped_feature_list_;
Expand Down Expand Up @@ -2379,7 +2384,8 @@ class AcceleratorControllerInputMethodTest : public AcceleratorControllerTest {
}

protected:
AcceleratorMockInputMethod* mock_input_ = nullptr; // Not owned.
raw_ptr<AcceleratorMockInputMethod, ExperimentalAsh> mock_input_ =
nullptr; // Not owned.

private:
base::test::ScopedFeatureList scoped_feature_list_;
Expand Down Expand Up @@ -2604,7 +2610,7 @@ class FakeMagnificationManager {

private:
std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
PrefService* prefs_;
raw_ptr<PrefService, ExperimentalAsh> prefs_;
};

TEST_F(MagnifiersAcceleratorsTester, TestToggleFullscreenMagnifier) {
Expand Down
16 changes: 9 additions & 7 deletions ash/accessibility/accessibility_controller_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "ash/public/cpp/session/session_observer.h"
#include "ash/public/cpp/tablet_mode_observer.h"
#include "base/functional/callback_forward.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/time/time.h"
Expand Down Expand Up @@ -124,8 +125,8 @@ class ASH_EXPORT AccessibilityControllerImpl : public AccessibilityController,
A11yFeatureType::kNoConflictingFeature;
bool enabled_ = false;
const std::string pref_name_;
const gfx::VectorIcon* icon_;
AccessibilityControllerImpl* const owner_;
raw_ptr<const gfx::VectorIcon, ExperimentalAsh> icon_;
const raw_ptr<AccessibilityControllerImpl, ExperimentalAsh> owner_;
};

// Helper struct to store information about a11y dialog -- pref name, resource
Expand Down Expand Up @@ -536,7 +537,7 @@ class ASH_EXPORT AccessibilityControllerImpl : public AccessibilityController,
int dictation_soda_download_progress_ = 0;

// Client interface in chrome browser.
AccessibilityControllerClient* client_ = nullptr;
raw_ptr<AccessibilityControllerClient, ExperimentalAsh> client_ = nullptr;

// Features are indexed by A11yFeatureType cast to int.
std::unique_ptr<Feature> features_[kA11yFeatureTypeCount];
Expand All @@ -551,16 +552,17 @@ class ASH_EXPORT AccessibilityControllerImpl : public AccessibilityController,
SelectToSpeakState select_to_speak_state_ =
SelectToSpeakState::kSelectToSpeakStateInactive;
std::unique_ptr<SelectToSpeakEventHandler> select_to_speak_event_handler_;
SelectToSpeakEventHandlerDelegate* select_to_speak_event_handler_delegate_ =
nullptr;
raw_ptr<SelectToSpeakEventHandlerDelegate, ExperimentalAsh>
select_to_speak_event_handler_delegate_ = nullptr;
std::unique_ptr<SelectToSpeakMenuBubbleController>
select_to_speak_bubble_controller_;

// List of key codes that Switch Access should capture.
std::vector<int> switch_access_keys_to_capture_;
std::unique_ptr<SwitchAccessMenuBubbleController>
switch_access_bubble_controller_;
AccessibilityEventRewriter* accessibility_event_rewriter_ = nullptr;
raw_ptr<AccessibilityEventRewriter, ExperimentalAsh>
accessibility_event_rewriter_ = nullptr;
bool no_switch_access_disable_confirmation_dialog_for_testing_ = false;
bool switch_access_disable_dialog_showing_ = false;
bool skip_switch_access_notification_ = false;
Expand Down Expand Up @@ -599,7 +601,7 @@ class ASH_EXPORT AccessibilityControllerImpl : public AccessibilityController,

// The pref service of the currently active user or the signin profile before
// user logs in. Can be null in ash_unittests.
PrefService* active_user_prefs_ = nullptr;
raw_ptr<PrefService, ExperimentalAsh> active_user_prefs_ = nullptr;

// This has to be the first one to be destroyed so we don't get updates about
// any prefs during destruction.
Expand Down
3 changes: 2 additions & 1 deletion ash/accessibility/autoclick/autoclick_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "ash/ash_export.h"
#include "ash/constants/ash_constants.h"
#include "ash/public/cpp/ash_constants.h"
#include "base/memory/raw_ptr.h"
#include "base/time/time.h"
#include "ui/aura/client/cursor_client_observer.h"
#include "ui/aura/window_observer.h"
Expand Down Expand Up @@ -174,7 +175,7 @@ class ASH_EXPORT AutoclickController
int mouse_event_flags_ = ui::EF_NONE;
// The target window is observed by AutoclickController for the duration
// of a autoclick gesture.
aura::Window* tap_down_target_ = nullptr;
raw_ptr<aura::Window, ExperimentalAsh> tap_down_target_ = nullptr;
// The most recent mouse location.
gfx::Point last_mouse_location_{-kDefaultAutoclickMovementThreshold,
-kDefaultAutoclickMovementThreshold};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "ash/accessibility/autoclick/autoclick_drag_event_rewriter.h"
#include "ash/test/ash_test_base.h"
#include "base/memory/raw_ptr.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/events/base_event_utils.h"
Expand Down Expand Up @@ -92,7 +93,7 @@ class AutoclickDragEventRewriterTest : public AshTestBase {

protected:
// Generates ui::Events from simulated user input.
ui::test::EventGenerator* generator_ = nullptr;
raw_ptr<ui::test::EventGenerator, ExperimentalAsh> generator_ = nullptr;
// Records events delivered to the next event rewriter after
// AutoclickDragEventRewriter.
EventRecorder event_recorder_;
Expand Down
7 changes: 4 additions & 3 deletions ash/accessibility/autoclick/autoclick_ring_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "ash/accessibility/autoclick/autoclick_ring_handler.h"

#include "base/memory/raw_ptr.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkRect.h"
Expand Down Expand Up @@ -129,7 +130,7 @@ class AutoclickRingHandler::AutoclickRingView : public views::View {
canvas->Restore();
}

views::Widget* widget_;
raw_ptr<views::Widget, ExperimentalAsh> widget_;
int radius_;
int current_angle_ = kAutoclickRingAngleStartValue;
};
Expand Down Expand Up @@ -197,7 +198,7 @@ void AutoclickRingHandler::StopAutoclickRing() {
current_animation_type_ = AnimationType::NONE;
Stop();
if (view_) {
ring_widget_->GetRootView()->RemoveChildViewT(view_);
ring_widget_->GetRootView()->RemoveChildViewT(view_.get());
view_ = nullptr;
}
}
Expand All @@ -223,7 +224,7 @@ void AutoclickRingHandler::AnimationStopped() {
case AnimationType::NONE:
// Fall through to reset the view.
if (view_) {
ring_widget_->GetRootView()->RemoveChildViewT(view_);
ring_widget_->GetRootView()->RemoveChildViewT(view_.get());
view_ = nullptr;
}
break;
Expand Down
5 changes: 3 additions & 2 deletions ash/accessibility/autoclick/autoclick_ring_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef ASH_ACCESSIBILITY_AUTOCLICK_AUTOCLICK_RING_HANDLER_H_
#define ASH_ACCESSIBILITY_AUTOCLICK_AUTOCLICK_RING_HANDLER_H_

#include "base/memory/raw_ptr.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "ui/gfx/animation/linear_animation.h"
Expand Down Expand Up @@ -52,8 +53,8 @@ class AutoclickRingHandler : public gfx::LinearAnimation {
void AnimateToState(double state) override;
void AnimationStopped() override;

AutoclickRingView* view_ = nullptr;
views::Widget* ring_widget_ = nullptr;
raw_ptr<AutoclickRingView, ExperimentalAsh> view_ = nullptr;
raw_ptr<views::Widget, ExperimentalAsh> ring_widget_ = nullptr;
// Location of the simulated mouse event from auto click in screen
// coordinates.
gfx::Point tap_down_location_;
Expand Down
2 changes: 1 addition & 1 deletion ash/accessibility/autoclick/autoclick_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class AutoclickTest : public AshTestBase {
GetAutoclickController()
->GetMenuBubbleControllerForTesting()
->scroll_bubble_controller_.get();
return controller ? controller->scroll_view_ : nullptr;
return controller ? controller->scroll_view_.get() : nullptr;
}

views::Widget* GetAutoclickBubbleWidget() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/test/simple_test_tick_clock.h"
#include "ui/events/base_event_utils.h"
Expand Down Expand Up @@ -52,7 +53,7 @@ class KeyAccessibilityEnablerTest : public AshTestBase,
void OnAccessibilityStatusChanged() override { run_loop_->Quit(); }

std::unique_ptr<base::RunLoop> run_loop_;
KeyAccessibilityEnabler* key_accessibility_enabler_;
raw_ptr<KeyAccessibilityEnabler, ExperimentalAsh> key_accessibility_enabler_;
base::SimpleTestTickClock clock_;
};

Expand Down
7 changes: 4 additions & 3 deletions ash/accessibility/chromevox/touch_accessibility_enabler.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <map>

#include "ash/ash_export.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/time/tick_clock.h"
#include "base/time/time.h"
Expand Down Expand Up @@ -108,10 +109,10 @@ class ASH_EXPORT TouchAccessibilityEnabler : public ui::EventHandler {
WAIT_FOR_NO_FINGERS
};

aura::Window* root_window_;
raw_ptr<aura::Window, ExperimentalAsh> root_window_;

// Called when we detect a long-press of two fingers. Not owned.
TouchAccessibilityEnablerDelegate* delegate_;
raw_ptr<TouchAccessibilityEnablerDelegate, ExperimentalAsh> delegate_;

// The current state.
State state_;
Expand All @@ -131,7 +132,7 @@ class ASH_EXPORT TouchAccessibilityEnabler : public ui::EventHandler {

// When touch_accessibility_enabler gets time relative to real time during
// testing, this clock is set to the simulated clock and used.
const base::TickClock* tick_clock_;
raw_ptr<const base::TickClock, ExperimentalAsh> tick_clock_;

// Whether or not we currently have an event handler installed. It can
// be removed when TouchExplorationController is running.
Expand Down
5 changes: 3 additions & 2 deletions ash/accessibility/chromevox/touch_exploration_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <vector>

#include "ash/ash_export.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
Expand Down Expand Up @@ -458,10 +459,10 @@ class ASH_EXPORT TouchExplorationController

void SetAnchorPointInternal(const gfx::PointF& anchor_point);

aura::Window* root_window_;
raw_ptr<aura::Window, ExperimentalAsh> root_window_;

// Handles volume control. Not owned.
TouchExplorationControllerDelegate* delegate_;
raw_ptr<TouchExplorationControllerDelegate, ExperimentalAsh> delegate_;

// A set of touch ids for fingers currently touching the screen.
std::vector<int> current_touch_ids_;
Expand Down
7 changes: 4 additions & 3 deletions ash/accessibility/chromevox/touch_exploration_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "ash/ash_export.h"
#include "ash/public/cpp/keyboard/keyboard_controller_observer.h"
#include "ash/shell_observer.h"
#include "base/memory/raw_ptr.h"
#include "ui/aura/window_observer.h"
#include "ui/display/display_observer.h"
#include "ui/wm/public/activation_change_observer.h"
Expand Down Expand Up @@ -97,9 +98,9 @@ class ASH_EXPORT TouchExplorationManager

std::unique_ptr<TouchExplorationController> touch_exploration_controller_;
std::unique_ptr<TouchAccessibilityEnabler> touch_accessibility_enabler_;
RootWindowController* root_window_controller_;
CrasAudioHandler* audio_handler_;
aura::Window* observing_window_;
raw_ptr<RootWindowController, ExperimentalAsh> root_window_controller_;
raw_ptr<CrasAudioHandler, ExperimentalAsh> audio_handler_;
raw_ptr<aura::Window, ExperimentalAsh> observing_window_;
display::ScopedDisplayObserver display_observer_{this};
};

Expand Down
3 changes: 2 additions & 1 deletion ash/accessibility/dictation_nudge.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "ash/ash_export.h"
#include "ash/system/tray/system_nudge.h"
#include "base/memory/raw_ptr.h"

namespace ash {

Expand All @@ -34,7 +35,7 @@ class ASH_EXPORT DictationNudge : public SystemNudge {
friend class DictationNudgeControllerTest;

// Unowned. The DictationNudgeController owns |this|.
const DictationNudgeController* const controller_;
const raw_ptr<const DictationNudgeController, ExperimentalAsh> controller_;
};

} // namespace ash
Expand Down
7 changes: 4 additions & 3 deletions ash/accessibility/magnifier/docked_magnifier_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "ash/ash_export.h"
#include "ash/display/window_tree_host_manager.h"
#include "ash/public/cpp/session/session_observer.h"
#include "base/memory/raw_ptr.h"
#include "ui/base/cursor/cursor_size.h"
#include "ui/events/event_handler.h"
#include "ui/views/widget/widget_observer.h"
Expand Down Expand Up @@ -186,7 +187,7 @@ class ASH_EXPORT DockedMagnifierController
// The current root window of the source display from which we are reflecting
// and magnifying into the viewport. It is set to |nullptr| when the magnifier
// is disabled. The viewport is placed on the same display.
aura::Window* current_source_root_window_ = nullptr;
raw_ptr<aura::Window, ExperimentalAsh> current_source_root_window_ = nullptr;

// The height below which the point of interest is not allowed to go. This is
// so that we can avoid mirroring the magnifier viewport into itself.
Expand All @@ -200,7 +201,7 @@ class ASH_EXPORT DockedMagnifierController

// The viewport widget which occupies the top 1/4th of the current display on
// which it is shown. It contains all the magnifier related layer.
views::Widget* viewport_widget_ = nullptr;
raw_ptr<views::Widget, ExperimentalAsh> viewport_widget_ = nullptr;

// A solid color layer that shows a dark gray background behind the magnifier
// layer.
Expand All @@ -217,7 +218,7 @@ class ASH_EXPORT DockedMagnifierController

// The pref service of the currently active user. Can be null in
// ash_unittests.
PrefService* active_user_pref_service_ = nullptr;
raw_ptr<PrefService, ExperimentalAsh> active_user_pref_service_ = nullptr;

std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;

Expand Down
Loading

0 comments on commit 834e018

Please sign in to comment.