diff --git a/ash/accessibility/touch_accessibility_enabler.h b/ash/accessibility/touch_accessibility_enabler.h index d33ba683bfd939..b4195b4ad091cf 100644 --- a/ash/accessibility/touch_accessibility_enabler.h +++ b/ash/accessibility/touch_accessibility_enabler.h @@ -125,7 +125,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. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Whether or not we currently have an event handler installed. It can // be removed when TouchExplorationController is running. diff --git a/ash/metrics/task_switch_time_tracker.cc b/ash/metrics/task_switch_time_tracker.cc index 2c30dd086eadd3..dd5744c8e70094 100644 --- a/ash/metrics/task_switch_time_tracker.cc +++ b/ash/metrics/task_switch_time_tracker.cc @@ -30,7 +30,7 @@ TaskSwitchTimeTracker::TaskSwitchTimeTracker(const std::string& histogram_name) base::DefaultTickClock::GetInstance()) {} TaskSwitchTimeTracker::TaskSwitchTimeTracker(const std::string& histogram_name, - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : histogram_name_(histogram_name), tick_clock_(tick_clock) {} TaskSwitchTimeTracker::~TaskSwitchTimeTracker() = default; diff --git a/ash/metrics/task_switch_time_tracker.h b/ash/metrics/task_switch_time_tracker.h index 5e45d1fd28a344..e814455843b947 100644 --- a/ash/metrics/task_switch_time_tracker.h +++ b/ash/metrics/task_switch_time_tracker.h @@ -40,7 +40,7 @@ class ASH_EXPORT TaskSwitchTimeTracker { // This doesn't take the ownership of the clock. |tick_clock| must outlive // TaskSwitchTimeTracker. TaskSwitchTimeTracker(const std::string& histogram_name, - base::TickClock* tick_clock); + const base::TickClock* tick_clock); // Returns true if |last_action_time_| has a valid value. bool HasLastActionTime() const; @@ -66,7 +66,7 @@ class ASH_EXPORT TaskSwitchTimeTracker { base::TimeTicks last_action_time_ = base::TimeTicks(); // The clock used to determine the |last_action_time_|. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; DISALLOW_COPY_AND_ASSIGN(TaskSwitchTimeTracker); }; diff --git a/ash/shelf/shelf_button_pressed_metric_tracker.h b/ash/shelf/shelf_button_pressed_metric_tracker.h index 0d128862dc8ccd..6c29a1bb590e26 100644 --- a/ash/shelf/shelf_button_pressed_metric_tracker.h +++ b/ash/shelf/shelf_button_pressed_metric_tracker.h @@ -70,7 +70,7 @@ class ASH_EXPORT ShelfButtonPressedMetricTracker { void ResetMinimizedData(); // Time source for performed action times. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Stores the time of the last window minimize action. base::TimeTicks time_of_last_minimize_; diff --git a/ash/shelf/shelf_button_pressed_metric_tracker_test_api.cc b/ash/shelf/shelf_button_pressed_metric_tracker_test_api.cc index bc14b289bcbfa9..f51cc4c4497306 100644 --- a/ash/shelf/shelf_button_pressed_metric_tracker_test_api.cc +++ b/ash/shelf/shelf_button_pressed_metric_tracker_test_api.cc @@ -17,7 +17,7 @@ ShelfButtonPressedMetricTrackerTestAPI:: ~ShelfButtonPressedMetricTrackerTestAPI() = default; void ShelfButtonPressedMetricTrackerTestAPI::SetTickClock( - base::TickClock* tick_clock) { + const base::TickClock* tick_clock) { shelf_button_pressed_metric_tracker_->tick_clock_ = tick_clock; } diff --git a/ash/shelf/shelf_button_pressed_metric_tracker_test_api.h b/ash/shelf/shelf_button_pressed_metric_tracker_test_api.h index 10e8a8a10d4f11..9e9a91cf7e93bb 100644 --- a/ash/shelf/shelf_button_pressed_metric_tracker_test_api.h +++ b/ash/shelf/shelf_button_pressed_metric_tracker_test_api.h @@ -27,7 +27,7 @@ class ShelfButtonPressedMetricTrackerTestAPI { // Set's the |tick_clock_| on the internal ShelfButtonPressedMetricTracker. // This doesn't take the ownership of the clock. |tick_clock| must outlive the // ShelfButtonPressedMetricTracker instance. - void SetTickClock(base::TickClock* tick_clock); + void SetTickClock(const base::TickClock* tick_clock); private: ShelfButtonPressedMetricTracker* shelf_button_pressed_metric_tracker_; diff --git a/ash/system/power/peripheral_battery_notifier.h b/ash/system/power/peripheral_battery_notifier.h index 380dbffee46482..82e08fdbe1043f 100644 --- a/ash/system/power/peripheral_battery_notifier.h +++ b/ash/system/power/peripheral_battery_notifier.h @@ -33,7 +33,9 @@ class ASH_EXPORT PeripheralBatteryNotifier PeripheralBatteryNotifier(); ~PeripheralBatteryNotifier() override; - void set_testing_clock(base::TickClock* clock) { testing_clock_ = clock; } + void set_testing_clock(const base::TickClock* clock) { + testing_clock_ = clock; + } // chromeos::PowerManagerClient::Observer: void PeripheralBatteryStatusReceived(const std::string& path, @@ -87,7 +89,7 @@ class ASH_EXPORT PeripheralBatteryNotifier scoped_refptr bluetooth_adapter_; // Used only for helping test. Not owned and can be nullptr. - base::TickClock* testing_clock_ = nullptr; + const base::TickClock* testing_clock_ = nullptr; std::unique_ptr> weakptr_factory_; diff --git a/ash/system/power/power_button_controller.h b/ash/system/power/power_button_controller.h index 12a16dcba5d9ad..46c65b579a63c1 100644 --- a/ash/system/power/power_button_controller.h +++ b/ash/system/power/power_button_controller.h @@ -230,7 +230,7 @@ class ASH_EXPORT PowerButtonController LockStateController* lock_state_controller_; // Not owned. // Time source for performed action times. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Used to interact with the display. std::unique_ptr display_controller_; diff --git a/ash/system/power/power_button_controller_test_api.cc b/ash/system/power/power_button_controller_test_api.cc index 8a76204549cb60..c619aa4a1ffdb1 100644 --- a/ash/system/power/power_button_controller_test_api.cc +++ b/ash/system/power/power_button_controller_test_api.cc @@ -84,7 +84,8 @@ void PowerButtonControllerTestApi::SetPowerButtonType( controller_->button_type_ = button_type; } -void PowerButtonControllerTestApi::SetTickClock(base::TickClock* tick_clock) { +void PowerButtonControllerTestApi::SetTickClock( + const base::TickClock* tick_clock) { DCHECK(tick_clock); controller_->tick_clock_ = tick_clock; diff --git a/ash/system/power/power_button_controller_test_api.h b/ash/system/power/power_button_controller_test_api.h index 65c6d7031a5806..2d0942beeff953 100644 --- a/ash/system/power/power_button_controller_test_api.h +++ b/ash/system/power/power_button_controller_test_api.h @@ -65,7 +65,7 @@ class PowerButtonControllerTestApi { void SetPowerButtonType(PowerButtonController::ButtonType button_type); - void SetTickClock(base::TickClock* tick_clock); + void SetTickClock(const base::TickClock* tick_clock); void SetTurnScreenOffForTap(bool turn_screen_off_for_tap); diff --git a/ash/system/power/power_button_display_controller.cc b/ash/system/power/power_button_display_controller.cc index b02ee9915e293b..a04335327f23c0 100644 --- a/ash/system/power/power_button_display_controller.cc +++ b/ash/system/power/power_button_display_controller.cc @@ -31,7 +31,7 @@ bool IsTabletModeActive() { PowerButtonDisplayController::PowerButtonDisplayController( BacklightsForcedOffSetter* backlights_forced_off_setter, - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : backlights_forced_off_setter_(backlights_forced_off_setter), backlights_forced_off_observer_(this), tick_clock_(tick_clock), diff --git a/ash/system/power/power_button_display_controller.h b/ash/system/power/power_button_display_controller.h index b7f6c9996b54a1..88475ef8a67bc7 100644 --- a/ash/system/power/power_button_display_controller.h +++ b/ash/system/power/power_button_display_controller.h @@ -36,7 +36,7 @@ class ASH_EXPORT PowerButtonDisplayController public: PowerButtonDisplayController( BacklightsForcedOffSetter* backlights_forced_off_setter, - base::TickClock* tick_clock); + const base::TickClock* tick_clock); ~PowerButtonDisplayController() override; bool IsScreenOn() const; @@ -83,7 +83,7 @@ class ASH_EXPORT PowerButtonDisplayController bool send_accessibility_alert_on_backlights_forced_off_change_ = false; // Time source for performed action times. - base::TickClock* tick_clock_; // Not owned. + const base::TickClock* tick_clock_; // Not owned. // If set, the active request passed to |backlights_forced_off_setter_| in // order to force the backlights off. diff --git a/ash/system/power/power_button_screenshot_controller.cc b/ash/system/power/power_button_screenshot_controller.cc index 058fa260479803..8359015ca1ba77 100644 --- a/ash/system/power/power_button_screenshot_controller.cc +++ b/ash/system/power/power_button_screenshot_controller.cc @@ -29,7 +29,7 @@ constexpr base::TimeDelta PowerButtonScreenshotController::kScreenshotChordDelay; PowerButtonScreenshotController::PowerButtonScreenshotController( - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : tick_clock_(tick_clock) { DCHECK(tick_clock_); // Using prepend to make sure this event handler is put in front of diff --git a/ash/system/power/power_button_screenshot_controller.h b/ash/system/power/power_button_screenshot_controller.h index f746b801599ff2..156ed27a41829e 100644 --- a/ash/system/power/power_button_screenshot_controller.h +++ b/ash/system/power/power_button_screenshot_controller.h @@ -29,7 +29,7 @@ class ASH_EXPORT PowerButtonScreenshotController : public ui::EventHandler { static constexpr base::TimeDelta kScreenshotChordDelay = base::TimeDelta::FromMilliseconds(150); - explicit PowerButtonScreenshotController(base::TickClock* tick_clock); + explicit PowerButtonScreenshotController(const base::TickClock* tick_clock); ~PowerButtonScreenshotController() override; // Returns true if power button event is consumed by |this|, otherwise false. @@ -73,7 +73,7 @@ class ASH_EXPORT PowerButtonScreenshotController : public ui::EventHandler { base::OneShotTimer volume_down_timer_; // Time source for performed action times. - base::TickClock* tick_clock_; // Not owned. + const base::TickClock* tick_clock_; // Not owned. DISALLOW_COPY_AND_ASSIGN(PowerButtonScreenshotController); }; diff --git a/ash/system/session/logout_confirmation_controller.cc b/ash/system/session/logout_confirmation_controller.cc index 7e8f4167d9b996..1a9dcb0844886e 100644 --- a/ash/system/session/logout_confirmation_controller.cc +++ b/ash/system/session/logout_confirmation_controller.cc @@ -171,7 +171,8 @@ void LogoutConfirmationController::OnDialogClosed() { logout_timer_.Stop(); } -void LogoutConfirmationController::SetClockForTesting(base::TickClock* clock) { +void LogoutConfirmationController::SetClockForTesting( + const base::TickClock* clock) { clock_ = clock; } diff --git a/ash/system/session/logout_confirmation_controller.h b/ash/system/session/logout_confirmation_controller.h index eccb07d3fcaa1b..32d5217b60714f 100644 --- a/ash/system/session/logout_confirmation_controller.h +++ b/ash/system/session/logout_confirmation_controller.h @@ -37,7 +37,7 @@ class ASH_EXPORT LogoutConfirmationController : public SessionObserver { LogoutConfirmationController(); ~LogoutConfirmationController() override; - base::TickClock* clock() const { return clock_; } + const base::TickClock* clock() const { return clock_; } // Shows a LogoutConfirmationDialog. If a confirmation dialog is already being // shown, it is closed and a new one opened if |logout_time| is earlier than @@ -57,7 +57,7 @@ class ASH_EXPORT LogoutConfirmationController : public SessionObserver { // Overrides the internal clock for testing. This doesn't take the ownership // of the clock. |clock| must outlive the LogoutConfirmationController // instance. - void SetClockForTesting(base::TickClock* clock); + void SetClockForTesting(const base::TickClock* clock); void SetLogoutClosureForTesting(const base::Closure& logout_closure); LogoutConfirmationDialog* dialog_for_testing() const { return dialog_; } @@ -65,7 +65,7 @@ class ASH_EXPORT LogoutConfirmationController : public SessionObserver { class LastWindowClosedObserver; std::unique_ptr last_window_closed_observer_; - base::TickClock* clock_; + const base::TickClock* clock_; base::Closure logout_closure_; base::TimeTicks logout_time_; diff --git a/ash/wm/tablet_mode/tablet_mode_controller.cc b/ash/wm/tablet_mode/tablet_mode_controller.cc index cb48de13b67e97..ddc6ca3f7d5ed4 100644 --- a/ash/wm/tablet_mode/tablet_mode_controller.cc +++ b/ash/wm/tablet_mode/tablet_mode_controller.cc @@ -530,7 +530,8 @@ bool TabletModeController::CanUseUnstableLidAngle() const { return elapsed_time >= kUnstableLidAngleDuration; } -void TabletModeController::SetTickClockForTest(base::TickClock* tick_clock) { +void TabletModeController::SetTickClockForTest( + const base::TickClock* tick_clock) { DCHECK(tick_clock_); tick_clock_ = tick_clock; } diff --git a/ash/wm/tablet_mode/tablet_mode_controller.h b/ash/wm/tablet_mode/tablet_mode_controller.h index 77880c93377580..6c8913836e3c46 100644 --- a/ash/wm/tablet_mode/tablet_mode_controller.h +++ b/ash/wm/tablet_mode/tablet_mode_controller.h @@ -151,7 +151,7 @@ class ASH_EXPORT TabletModeController // artificially and deterministically control the current time. // This does not take the ownership of the tick_clock. |tick_clock| must // outlive the TabletModeController instance. - void SetTickClockForTest(base::TickClock* tick_clock); + void SetTickClockForTest(const base::TickClock* tick_clock); // Detect hinge rotation from base and lid accelerometers and automatically // start / stop tablet mode. @@ -226,7 +226,7 @@ class ASH_EXPORT TabletModeController base::TimeTicks first_unstable_lid_angle_time_; // Source for the current time in base::TimeTicks. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Set when tablet mode switch is on. This is used to force tablet mode. bool tablet_mode_switch_is_on_ = false; diff --git a/base/task_scheduler/delayed_task_manager.cc b/base/task_scheduler/delayed_task_manager.cc index eec40a88f6b30d..86a67219e46ad0 100644 --- a/base/task_scheduler/delayed_task_manager.cc +++ b/base/task_scheduler/delayed_task_manager.cc @@ -14,7 +14,8 @@ namespace base { namespace internal { -DelayedTaskManager::DelayedTaskManager(std::unique_ptr tick_clock) +DelayedTaskManager::DelayedTaskManager( + std::unique_ptr tick_clock) : tick_clock_(std::move(tick_clock)) { DCHECK(tick_clock_); } diff --git a/base/task_scheduler/delayed_task_manager.h b/base/task_scheduler/delayed_task_manager.h index 2d6babbc5a7bfd..c48aeb1e6b1647 100644 --- a/base/task_scheduler/delayed_task_manager.h +++ b/base/task_scheduler/delayed_task_manager.h @@ -36,7 +36,7 @@ class BASE_EXPORT DelayedTaskManager { using PostTaskNowCallback = OnceCallback; // |tick_clock| can be specified for testing. - DelayedTaskManager(std::unique_ptr tick_clock = + DelayedTaskManager(std::unique_ptr tick_clock = std::make_unique()); ~DelayedTaskManager(); @@ -57,7 +57,7 @@ class BASE_EXPORT DelayedTaskManager { TimeDelta delay, PostTaskNowCallback post_task_now_callback); - const std::unique_ptr tick_clock_; + const std::unique_ptr tick_clock_; AtomicFlag started_; diff --git a/base/test/scoped_task_environment.cc b/base/test/scoped_task_environment.cc index abf4f80c9bb3f1..039af6654246a1 100644 --- a/base/test/scoped_task_environment.cc +++ b/base/test/scoped_task_environment.cc @@ -244,7 +244,7 @@ void ScopedTaskEnvironment::FastForwardUntilNoTasksRemain() { mock_time_task_runner_->FastForwardUntilNoTasksRemain(); } -TickClock* ScopedTaskEnvironment::GetMockTickClock() { +const TickClock* ScopedTaskEnvironment::GetMockTickClock() { DCHECK(mock_time_task_runner_); return mock_time_task_runner_->GetMockTickClock(); } diff --git a/base/test/scoped_task_environment.h b/base/test/scoped_task_environment.h index 0afb9dfdc0f550..4a8541843c7560 100644 --- a/base/test/scoped_task_environment.h +++ b/base/test/scoped_task_environment.h @@ -116,7 +116,7 @@ class ScopedTaskEnvironment { // Returns a TickClock whose time is updated by // FastForward(By|UntilNoTasksRemain). - TickClock* GetMockTickClock(); + const TickClock* GetMockTickClock(); std::unique_ptr DeprecatedGetMockTickClock(); private: diff --git a/base/test/scoped_task_environment_unittest.cc b/base/test/scoped_task_environment_unittest.cc index ec77f6ae31cc80..4ea6d9f17d3281 100644 --- a/base/test/scoped_task_environment_unittest.cc +++ b/base/test/scoped_task_environment_unittest.cc @@ -259,7 +259,8 @@ TEST_F(ScopedTaskEnvironmentTest, FastForwardAdvanceTickClock) { ThreadTaskRunnerHandle::Get()->PostDelayedTask(FROM_HERE, base::DoNothing(), kLongTaskDelay); - base::TickClock* tick_clock = scoped_task_environment.GetMockTickClock(); + const base::TickClock* tick_clock = + scoped_task_environment.GetMockTickClock(); base::TimeTicks tick_clock_ref = tick_clock->NowTicks(); // Make sure that |FastForwardBy| advances the clock. diff --git a/base/test/test_mock_time_task_runner.cc b/base/test/test_mock_time_task_runner.cc index e22fd104b10d8b..d346ed3e718da1 100644 --- a/base/test/test_mock_time_task_runner.cc +++ b/base/test/test_mock_time_task_runner.cc @@ -239,7 +239,7 @@ std::unique_ptr TestMockTimeTaskRunner::DeprecatedGetMockTickClock() return std::make_unique(this); } -TickClock* TestMockTimeTaskRunner::GetMockTickClock() const { +const TickClock* TestMockTimeTaskRunner::GetMockTickClock() const { DCHECK(thread_checker_.CalledOnValidThread()); return &mock_clock_; } diff --git a/base/test/test_mock_time_task_runner.h b/base/test/test_mock_time_task_runner.h index 87e02c1f92eeb5..a9276c9c0bc6de 100644 --- a/base/test/test_mock_time_task_runner.h +++ b/base/test/test_mock_time_task_runner.h @@ -169,7 +169,7 @@ class TestMockTimeTaskRunner : public SingleThreadTaskRunner, // TODO(tzik): Replace Remove DeprecatedGetMockTickClock() after updating all // callers to use non-owning TickClock. std::unique_ptr DeprecatedGetMockTickClock() const; - TickClock* GetMockTickClock() const; + const TickClock* GetMockTickClock() const; base::circular_deque TakePendingTasks(); bool HasPendingTask() const; diff --git a/base/time/default_tick_clock.cc b/base/time/default_tick_clock.cc index 27b16717f805ae..188c3cf921b542 100644 --- a/base/time/default_tick_clock.cc +++ b/base/time/default_tick_clock.cc @@ -4,7 +4,7 @@ #include "base/time/default_tick_clock.h" -#include "base/lazy_instance.h" +#include "base/no_destructor.h" namespace base { @@ -15,10 +15,9 @@ TimeTicks DefaultTickClock::NowTicks() const { } // static -DefaultTickClock* DefaultTickClock::GetInstance() { - static LazyInstance::Leaky instance = - LAZY_INSTANCE_INITIALIZER; - return instance.Pointer(); +const DefaultTickClock* DefaultTickClock::GetInstance() { + static const base::NoDestructor default_tick_clock; + return default_tick_clock.get(); } } // namespace base diff --git a/base/time/default_tick_clock.h b/base/time/default_tick_clock.h index df8037fd02e4bd..78f8a997335499 100644 --- a/base/time/default_tick_clock.h +++ b/base/time/default_tick_clock.h @@ -6,7 +6,6 @@ #define BASE_TIME_DEFAULT_TICK_CLOCK_H_ #include "base/base_export.h" -#include "base/compiler_specific.h" #include "base/time/tick_clock.h" namespace base { @@ -20,7 +19,7 @@ class BASE_EXPORT DefaultTickClock : public TickClock { TimeTicks NowTicks() const override; // Returns a shared instance of DefaultTickClock. This is thread-safe. - static DefaultTickClock* GetInstance(); + static const DefaultTickClock* GetInstance(); }; } // namespace base diff --git a/base/timer/timer.cc b/base/timer/timer.cc index 5540994dcb7e35..99cd83933aa071 100644 --- a/base/timer/timer.cc +++ b/base/timer/timer.cc @@ -62,7 +62,9 @@ class BaseTimerTaskInternal { Timer::Timer(bool retain_user_task, bool is_repeating) : Timer(retain_user_task, is_repeating, nullptr) {} -Timer::Timer(bool retain_user_task, bool is_repeating, TickClock* tick_clock) +Timer::Timer(bool retain_user_task, + bool is_repeating, + const TickClock* tick_clock) : scheduled_task_(nullptr), is_repeating_(is_repeating), retain_user_task_(retain_user_task), @@ -85,7 +87,7 @@ Timer::Timer(const Location& posted_from, TimeDelta delay, const base::Closure& user_task, bool is_repeating, - TickClock* tick_clock) + const TickClock* tick_clock) : scheduled_task_(nullptr), posted_from_(posted_from), delay_(delay), diff --git a/base/timer/timer.h b/base/timer/timer.h index 99c969f997bb91..b10aca845d861b 100644 --- a/base/timer/timer.h +++ b/base/timer/timer.h @@ -89,7 +89,7 @@ class BASE_EXPORT Timer { // retained or reset when it runs or stops. If |tick_clock| is provided, it is // used instead of TimeTicks::Now() to get TimeTicks when scheduling tasks. Timer(bool retain_user_task, bool is_repeating); - Timer(bool retain_user_task, bool is_repeating, TickClock* tick_clock); + Timer(bool retain_user_task, bool is_repeating, const TickClock* tick_clock); // Construct a timer with retained task info. If |tick_clock| is provided, it // is used instead of TimeTicks::Now() to get TimeTicks when scheduling tasks. @@ -101,7 +101,7 @@ class BASE_EXPORT Timer { TimeDelta delay, const base::Closure& user_task, bool is_repeating, - TickClock* tick_clock); + const TickClock* tick_clock); virtual ~Timer(); @@ -229,7 +229,7 @@ class BASE_EXPORT Timer { const bool retain_user_task_; // The tick clock used to calculate the run time for scheduled tasks. - TickClock* const tick_clock_; + const TickClock* const tick_clock_; // If true, |user_task_| is scheduled to run sometime in the future. bool is_running_; @@ -242,7 +242,7 @@ class BASE_EXPORT Timer { class OneShotTimer : public Timer { public: OneShotTimer() : OneShotTimer(nullptr) {} - explicit OneShotTimer(TickClock* tick_clock) + explicit OneShotTimer(const TickClock* tick_clock) : Timer(false, false, tick_clock) {} }; @@ -251,7 +251,7 @@ class OneShotTimer : public Timer { class RepeatingTimer : public Timer { public: RepeatingTimer() : RepeatingTimer(nullptr) {} - explicit RepeatingTimer(TickClock* tick_clock) + explicit RepeatingTimer(const TickClock* tick_clock) : Timer(true, true, tick_clock) {} }; @@ -280,7 +280,7 @@ class DelayTimer : protected Timer { TimeDelta delay, Receiver* receiver, void (Receiver::*method)(), - TickClock* tick_clock) + const TickClock* tick_clock) : Timer(posted_from, delay, base::Bind(method, base::Unretained(receiver)), diff --git a/cc/test/scheduler_test_common.cc b/cc/test/scheduler_test_common.cc index ed87fc2912b319..436eb48351ee0f 100644 --- a/cc/test/scheduler_test_common.cc +++ b/cc/test/scheduler_test_common.cc @@ -129,7 +129,7 @@ base::TimeDelta FakeCompositorTimingHistory::DrawDurationEstimate() const { } TestScheduler::TestScheduler( - base::SimpleTestTickClock* now_src, + const base::TickClock* now_src, SchedulerClient* client, const SchedulerSettings& scheduler_settings, int layer_tree_host_id, diff --git a/cc/test/scheduler_test_common.h b/cc/test/scheduler_test_common.h index 025d228484c27c..38f07433058dec 100644 --- a/cc/test/scheduler_test_common.h +++ b/cc/test/scheduler_test_common.h @@ -76,7 +76,7 @@ class FakeCompositorTimingHistory : public CompositorTimingHistory { class TestScheduler : public Scheduler { public: TestScheduler( - base::SimpleTestTickClock* now_src, + const base::TickClock* now_src, SchedulerClient* client, const SchedulerSettings& scheduler_settings, int layer_tree_host_id, @@ -134,7 +134,7 @@ class TestScheduler : public Scheduler { base::TimeTicks Now() const override; private: - base::SimpleTestTickClock* now_src_; + const base::TickClock* now_src_; DISALLOW_COPY_AND_ASSIGN(TestScheduler); }; diff --git a/chrome/browser/android/data_usage/data_use_matcher.h b/chrome/browser/android/data_usage/data_use_matcher.h index 7aa207a91f5bcf..6d18407d395b94 100644 --- a/chrome/browser/android/data_usage/data_use_matcher.h +++ b/chrome/browser/android/data_usage/data_use_matcher.h @@ -133,7 +133,7 @@ class DataUseMatcher { const base::TimeDelta default_matching_rule_expiration_duration_; // TickClock used for obtaining the current time. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Callback to be run when a label is removed from the set of matching labels. const base::Callback diff --git a/chrome/browser/android/data_usage/data_use_tab_model.h b/chrome/browser/android/data_usage/data_use_tab_model.h index 6853d409be4d59..7b51b049745d41 100644 --- a/chrome/browser/android/data_usage/data_use_tab_model.h +++ b/chrome/browser/android/data_usage/data_use_tab_model.h @@ -297,7 +297,7 @@ class DataUseTabModel { const base::TimeDelta open_tab_expiration_duration_; // TickClock used for obtaining the current time. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Stores the matching patterns. std::unique_ptr data_use_matcher_; diff --git a/chrome/browser/captive_portal/captive_portal_service.cc b/chrome/browser/captive_portal/captive_portal_service.cc index 9521b15c4bb2c4..acae2b76fb2940 100644 --- a/chrome/browser/captive_portal/captive_portal_service.cc +++ b/chrome/browser/captive_portal/captive_portal_service.cc @@ -172,7 +172,7 @@ CaptivePortalService::RecheckPolicy::RecheckPolicy() CaptivePortalService::CaptivePortalService( Profile* profile, - base::TickClock* clock_for_testing, + const base::TickClock* clock_for_testing, network::mojom::URLLoaderFactory* loader_factory_for_testing) : profile_(profile), state_(STATE_IDLE), diff --git a/chrome/browser/captive_portal/captive_portal_service.h b/chrome/browser/captive_portal/captive_portal_service.h index 8bca1d64c7cd3d..197ef96387b359 100644 --- a/chrome/browser/captive_portal/captive_portal_service.h +++ b/chrome/browser/captive_portal/captive_portal_service.h @@ -57,7 +57,7 @@ class CaptivePortalService : public KeyedService { CaptivePortalService( Profile* profile, - base::TickClock* clock_for_testing = nullptr, + const base::TickClock* clock_for_testing = nullptr, network::mojom::URLLoaderFactory* loader_factory_for_testing = nullptr); ~CaptivePortalService() override; @@ -207,7 +207,7 @@ class CaptivePortalService : public KeyedService { static TestingState testing_state_; // Test tick clock used by unit tests. - base::TickClock* const tick_clock_for_testing_; // Not owned. + const base::TickClock* const tick_clock_for_testing_; // Not owned. DISALLOW_COPY_AND_ASSIGN(CaptivePortalService); }; diff --git a/chrome/browser/chromeos/lock_screen_apps/app_manager_impl.cc b/chrome/browser/chromeos/lock_screen_apps/app_manager_impl.cc index d593e4be324ccd..bf9b24afa4f9f4 100644 --- a/chrome/browser/chromeos/lock_screen_apps/app_manager_impl.cc +++ b/chrome/browser/chromeos/lock_screen_apps/app_manager_impl.cc @@ -164,7 +164,7 @@ void InstallExtensionCopy( } // namespace -AppManagerImpl::AppManagerImpl(base::TickClock* tick_clock) +AppManagerImpl::AppManagerImpl(const base::TickClock* tick_clock) : tick_clock_(tick_clock), extensions_observer_(this), lock_screen_profile_extensions_observer_(this), diff --git a/chrome/browser/chromeos/lock_screen_apps/app_manager_impl.h b/chrome/browser/chromeos/lock_screen_apps/app_manager_impl.h index 7ba45d7f149e6b..1f06453d4ca3bf 100644 --- a/chrome/browser/chromeos/lock_screen_apps/app_manager_impl.h +++ b/chrome/browser/chromeos/lock_screen_apps/app_manager_impl.h @@ -36,7 +36,7 @@ class AppManagerImpl : public AppManager, public chromeos::NoteTakingHelper::Observer, public extensions::ExtensionRegistryObserver { public: - explicit AppManagerImpl(base::TickClock* tick_clock); + explicit AppManagerImpl(const base::TickClock* tick_clock); ~AppManagerImpl() override; // AppManager implementation: @@ -155,7 +155,7 @@ class AppManagerImpl : public AppManager, State state_ = State::kNotInitialized; std::string lock_screen_app_id_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; ScopedObserver diff --git a/chrome/browser/chromeos/lock_screen_apps/app_window_metrics_tracker.cc b/chrome/browser/chromeos/lock_screen_apps/app_window_metrics_tracker.cc index 2f82e607231227..0f96936f05aa9c 100644 --- a/chrome/browser/chromeos/lock_screen_apps/app_window_metrics_tracker.cc +++ b/chrome/browser/chromeos/lock_screen_apps/app_window_metrics_tracker.cc @@ -57,7 +57,7 @@ const char kAppWindowStateOnRemoval[] = namespace lock_screen_apps { -AppWindowMetricsTracker::AppWindowMetricsTracker(base::TickClock* clock) +AppWindowMetricsTracker::AppWindowMetricsTracker(const base::TickClock* clock) : clock_(clock) {} AppWindowMetricsTracker::~AppWindowMetricsTracker() = default; diff --git a/chrome/browser/chromeos/lock_screen_apps/app_window_metrics_tracker.h b/chrome/browser/chromeos/lock_screen_apps/app_window_metrics_tracker.h index a5c95ab6889f2a..c8935c0925cbfe 100644 --- a/chrome/browser/chromeos/lock_screen_apps/app_window_metrics_tracker.h +++ b/chrome/browser/chromeos/lock_screen_apps/app_window_metrics_tracker.h @@ -25,7 +25,7 @@ namespace lock_screen_apps { // Helper for tracking metrics for lock screen app window launches. class AppWindowMetricsTracker : public content::WebContentsObserver { public: - explicit AppWindowMetricsTracker(base::TickClock* clock); + explicit AppWindowMetricsTracker(const base::TickClock* clock); ~AppWindowMetricsTracker() override; // Register app launch request. @@ -63,7 +63,7 @@ class AppWindowMetricsTracker : public content::WebContentsObserver { void SetState(State state); - base::TickClock* clock_; + const base::TickClock* clock_; State state_ = State::kInitial; diff --git a/chrome/browser/chromeos/lock_screen_apps/lock_screen_profile_creator_impl.cc b/chrome/browser/chromeos/lock_screen_apps/lock_screen_profile_creator_impl.cc index 3bb3de0f0dd930..6c7a08efcd8e94 100644 --- a/chrome/browser/chromeos/lock_screen_apps/lock_screen_profile_creator_impl.cc +++ b/chrome/browser/chromeos/lock_screen_apps/lock_screen_profile_creator_impl.cc @@ -25,7 +25,7 @@ namespace lock_screen_apps { LockScreenProfileCreatorImpl::LockScreenProfileCreatorImpl( Profile* primary_profile, - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : primary_profile_(primary_profile), tick_clock_(tick_clock), note_taking_helper_observer_(this), diff --git a/chrome/browser/chromeos/lock_screen_apps/lock_screen_profile_creator_impl.h b/chrome/browser/chromeos/lock_screen_apps/lock_screen_profile_creator_impl.h index 10ad14e5397d02..c0218560f7969a 100644 --- a/chrome/browser/chromeos/lock_screen_apps/lock_screen_profile_creator_impl.h +++ b/chrome/browser/chromeos/lock_screen_apps/lock_screen_profile_creator_impl.h @@ -30,7 +30,7 @@ class LockScreenProfileCreatorImpl // |primary_profile| - the primary profile - i.e. the profile which should be // used to determine lock screen note taking availability. LockScreenProfileCreatorImpl(Profile* primary_profile, - base::TickClock* tick_clock); + const base::TickClock* tick_clock); ~LockScreenProfileCreatorImpl() override; // chromeos::NoteTakingHelper::Observer: @@ -58,7 +58,7 @@ class LockScreenProfileCreatorImpl Profile::CreateStatus status); Profile* const primary_profile_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; ScopedObserver diff --git a/chrome/browser/chromeos/lock_screen_apps/state_controller.cc b/chrome/browser/chromeos/lock_screen_apps/state_controller.cc index 750044dac22b25..512c039858a283 100644 --- a/chrome/browser/chromeos/lock_screen_apps/state_controller.cc +++ b/chrome/browser/chromeos/lock_screen_apps/state_controller.cc @@ -120,7 +120,7 @@ void StateController::SetReadyCallbackForTesting( ready_callback_ = ready_callback; } -void StateController::SetTickClockForTesting(base::TickClock* clock) { +void StateController::SetTickClockForTesting(const base::TickClock* clock) { DCHECK(!tick_clock_); tick_clock_ = clock; } diff --git a/chrome/browser/chromeos/lock_screen_apps/state_controller.h b/chrome/browser/chromeos/lock_screen_apps/state_controller.h index 8938cbcc30dee5..05dd99b9432ed6 100644 --- a/chrome/browser/chromeos/lock_screen_apps/state_controller.h +++ b/chrome/browser/chromeos/lock_screen_apps/state_controller.h @@ -100,7 +100,7 @@ class StateController : public ash::mojom::TrayActionClient, // initialized and ready for action. void SetReadyCallbackForTesting(const base::Closure& ready_callback); // Sets the tick clock to be used in tests. - void SetTickClockForTesting(base::TickClock* clock); + void SetTickClockForTesting(const base::TickClock* clock); // Sets test AppManager implementation. Should be called before // |SetPrimaryProfile| void SetAppManagerForTesting(std::unique_ptr app_manager); @@ -294,7 +294,7 @@ class StateController : public ash::mojom::TrayActionClient, // The clock used to keep track of time, for example to report app window // lifetime metrics. - base::TickClock* tick_clock_ = nullptr; + const base::TickClock* tick_clock_ = nullptr; base::WeakPtrFactory weak_ptr_factory_; diff --git a/chrome/browser/chromeos/policy/off_hours/device_off_hours_controller.cc b/chrome/browser/chromeos/policy/off_hours/device_off_hours_controller.cc index b922e6ebb337d2..ecc2077a29607b 100644 --- a/chrome/browser/chromeos/policy/off_hours/device_off_hours_controller.cc +++ b/chrome/browser/chromeos/policy/off_hours/device_off_hours_controller.cc @@ -66,7 +66,7 @@ void DeviceOffHoursController::RemoveObserver(Observer* observer) { void DeviceOffHoursController::SetClockForTesting( base::Clock* clock, - base::TickClock* timer_clock) { + const base::TickClock* timer_clock) { clock_ = clock; timer_ = std::make_unique(timer_clock); } diff --git a/chrome/browser/chromeos/policy/off_hours/device_off_hours_controller.h b/chrome/browser/chromeos/policy/off_hours/device_off_hours_controller.h index 60e09b65c69c69..6ecc6c7a087db4 100644 --- a/chrome/browser/chromeos/policy/off_hours/device_off_hours_controller.h +++ b/chrome/browser/chromeos/policy/off_hours/device_off_hours_controller.h @@ -83,7 +83,8 @@ class DeviceOffHoursController : public chromeos::SystemClockClient::Observer, // |timer_clock| is not owned and its lifetime should cover lifetime of // DeviceOffHoursContoller. - void SetClockForTesting(base::Clock* clock, base::TickClock* timer_clock); + void SetClockForTesting(base::Clock* clock, + const base::TickClock* timer_clock); private: // Run OnOffHoursEndTimeChanged() for observers. diff --git a/chrome/browser/chromeos/power/power_prefs.h b/chrome/browser/chromeos/power/power_prefs.h index 369beec92b31a6..9d1b25d203d89b 100644 --- a/chrome/browser/chromeos/power/power_prefs.h +++ b/chrome/browser/chromeos/power/power_prefs.h @@ -47,7 +47,9 @@ class PowerPrefs : public PowerManagerClient::Observer, static void RegisterLoginProfilePrefs( user_prefs::PrefRegistrySyncable* registry); - void set_tick_clock_for_test(base::TickClock* clock) { tick_clock_ = clock; } + void set_tick_clock_for_test(const base::TickClock* clock) { + tick_clock_ = clock; + } // PowerManagerClient::Observer: void ScreenIdleStateChanged( @@ -79,7 +81,7 @@ class PowerPrefs : public PowerManagerClient::Observer, Profile* profile_ = nullptr; // Not owned. std::unique_ptr pref_change_registrar_; - base::TickClock* tick_clock_; // Not owned. + const base::TickClock* tick_clock_; // Not owned. // Time at which the screen was locked. Unset if the screen is unlocked. base::TimeTicks screen_lock_time_; diff --git a/chrome/browser/chromeos/system/automatic_reboot_manager.cc b/chrome/browser/chromeos/system/automatic_reboot_manager.cc index 8a3d6eee446dab..b5f1cd9eae715e 100644 --- a/chrome/browser/chromeos/system/automatic_reboot_manager.cc +++ b/chrome/browser/chromeos/system/automatic_reboot_manager.cc @@ -141,7 +141,7 @@ AutomaticRebootManager::SystemEventTimes::SystemEventTimes( has_update_reboot_needed_time = true; } -AutomaticRebootManager::AutomaticRebootManager(base::TickClock* clock) +AutomaticRebootManager::AutomaticRebootManager(const base::TickClock* clock) : initialized_(base::WaitableEvent::ResetPolicy::MANUAL, base::WaitableEvent::InitialState::NOT_SIGNALED), clock_(clock), diff --git a/chrome/browser/chromeos/system/automatic_reboot_manager.h b/chrome/browser/chromeos/system/automatic_reboot_manager.h index 7316a198fe4609..40efeb97cb9133 100644 --- a/chrome/browser/chromeos/system/automatic_reboot_manager.h +++ b/chrome/browser/chromeos/system/automatic_reboot_manager.h @@ -91,7 +91,7 @@ class AutomaticRebootManager : public PowerManagerClient::Observer, base::TimeTicks update_reboot_needed_time; }; - explicit AutomaticRebootManager(base::TickClock* clock); + explicit AutomaticRebootManager(const base::TickClock* clock); ~AutomaticRebootManager() override; AutomaticRebootManagerObserver::Reason reboot_reason() const { @@ -149,7 +149,7 @@ class AutomaticRebootManager : public PowerManagerClient::Observer, base::WaitableEvent initialized_; // A clock that can be mocked in tests to fast-forward time. - base::TickClock* const clock_; + const base::TickClock* const clock_; PrefChangeRegistrar local_state_registrar_; diff --git a/chrome/browser/chromeos/upgrade_detector_chromeos.cc b/chrome/browser/chromeos/upgrade_detector_chromeos.cc index e8d5fe5d316faf..2a3511f3a51783 100644 --- a/chrome/browser/chromeos/upgrade_detector_chromeos.cc +++ b/chrome/browser/chromeos/upgrade_detector_chromeos.cc @@ -90,7 +90,8 @@ class ChannelsRequester { } // namespace -UpgradeDetectorChromeos::UpgradeDetectorChromeos(base::TickClock* tick_clock) +UpgradeDetectorChromeos::UpgradeDetectorChromeos( + const base::TickClock* tick_clock) : UpgradeDetector(tick_clock), high_threshold_(DetermineHighThreshold()), upgrade_notification_timer_(tick_clock), diff --git a/chrome/browser/chromeos/upgrade_detector_chromeos.h b/chrome/browser/chromeos/upgrade_detector_chromeos.h index 541d0d31b4ebbe..de44d08aaabafb 100644 --- a/chrome/browser/chromeos/upgrade_detector_chromeos.h +++ b/chrome/browser/chromeos/upgrade_detector_chromeos.h @@ -42,7 +42,7 @@ class UpgradeDetectorChromeos : public UpgradeDetector, private: friend class base::NoDestructor; - explicit UpgradeDetectorChromeos(base::TickClock* tick_clock); + explicit UpgradeDetectorChromeos(const base::TickClock* tick_clock); // Returns the threshold to reach high annoyance level. static base::TimeDelta DetermineHighThreshold(); diff --git a/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc b/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc index 148b3cc4a0b4a7..40364179f40dfe 100644 --- a/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc +++ b/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc @@ -115,7 +115,7 @@ const net::BackoffEntry::Policy* BackoffPolicy::Get() { return &g_backoff_policy.Get().policy_; } -base::TickClock* g_test_clock = nullptr; +const base::TickClock* g_test_clock = nullptr; } // namespace @@ -150,7 +150,7 @@ ChromeRuntimeAPIDelegate::~ChromeRuntimeAPIDelegate() { // static void ChromeRuntimeAPIDelegate::set_tick_clock_for_tests( - base::TickClock* clock) { + const base::TickClock* clock) { g_test_clock = clock; } diff --git a/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.h b/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.h index 0a9a02e9d79879..3b1951383f0dd2 100644 --- a/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.h +++ b/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.h @@ -42,7 +42,7 @@ class ChromeRuntimeAPIDelegate : public extensions::RuntimeAPIDelegate, ~ChromeRuntimeAPIDelegate() override; // Sets a custom TickClock to use in tests. - static void set_tick_clock_for_tests(base::TickClock* clock); + static void set_tick_clock_for_tests(const base::TickClock* clock); private: friend class extensions::RuntimeAPI; diff --git a/chrome/browser/media/router/discovery/discovery_network_monitor_metric_observer.cc b/chrome/browser/media/router/discovery/discovery_network_monitor_metric_observer.cc index 033a2432873564..91ebba1db2e3a7 100644 --- a/chrome/browser/media/router/discovery/discovery_network_monitor_metric_observer.cc +++ b/chrome/browser/media/router/discovery/discovery_network_monitor_metric_observer.cc @@ -52,7 +52,7 @@ DiscoveryNetworkMonitorConnectionType ConnectionTypeFromIdAndType( } // namespace DiscoveryNetworkMonitorMetricObserver::DiscoveryNetworkMonitorMetricObserver( - base::TickClock* tick_clock, + const base::TickClock* tick_clock, std::unique_ptr metrics) : tick_clock_(tick_clock), metrics_(std::move(metrics)), diff --git a/chrome/browser/media/router/discovery/discovery_network_monitor_metric_observer.h b/chrome/browser/media/router/discovery/discovery_network_monitor_metric_observer.h index 0263b983fd667a..abd73dbaa63036 100644 --- a/chrome/browser/media/router/discovery/discovery_network_monitor_metric_observer.h +++ b/chrome/browser/media/router/discovery/discovery_network_monitor_metric_observer.h @@ -19,7 +19,7 @@ class DiscoveryNetworkMonitorMetricObserver final : public DiscoveryNetworkMonitor::Observer { public: DiscoveryNetworkMonitorMetricObserver( - base::TickClock* tick_clock, + const base::TickClock* tick_clock, std::unique_ptr metrics); ~DiscoveryNetworkMonitorMetricObserver(); @@ -36,7 +36,7 @@ class DiscoveryNetworkMonitorMetricObserver final // value instead of the time that this later check runs. void ConfirmDisconnectedToReportMetrics(base::TimeTicks disconnect_time); - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; std::unique_ptr metrics_; base::Optional last_event_time_; base::OneShotTimer disconnect_timer_; diff --git a/chrome/browser/metrics/oom/out_of_memory_reporter.cc b/chrome/browser/metrics/oom/out_of_memory_reporter.cc index b5973d2abf6b21..58f1905ee368d2 100644 --- a/chrome/browser/metrics/oom/out_of_memory_reporter.cc +++ b/chrome/browser/metrics/oom/out_of_memory_reporter.cc @@ -58,7 +58,7 @@ void OutOfMemoryReporter::OnForegroundOOMDetected(const GURL& url, } void OutOfMemoryReporter::SetTickClockForTest( - std::unique_ptr tick_clock) { + std::unique_ptr tick_clock) { DCHECK(tick_clock_); tick_clock_ = std::move(tick_clock); } diff --git a/chrome/browser/metrics/oom/out_of_memory_reporter.h b/chrome/browser/metrics/oom/out_of_memory_reporter.h index a661200224bc46..8c8127b067ce39 100644 --- a/chrome/browser/metrics/oom/out_of_memory_reporter.h +++ b/chrome/browser/metrics/oom/out_of_memory_reporter.h @@ -55,7 +55,7 @@ class OutOfMemoryReporter void OnForegroundOOMDetected(const GURL& url, ukm::SourceId source_id); // Used by tests to deterministically control time. - void SetTickClockForTest(std::unique_ptr tick_clock); + void SetTickClockForTest(std::unique_ptr tick_clock); // content::WebContentsObserver: void DidFinishNavigation(content::NavigationHandle* handle) override; @@ -71,7 +71,7 @@ class OutOfMemoryReporter base::Optional last_committed_source_id_; base::TimeTicks last_navigation_timestamp_; - std::unique_ptr tick_clock_; + std::unique_ptr tick_clock_; int crashed_render_process_id_ = content::ChildProcessHost::kInvalidUniqueID; #if defined(OS_ANDROID) diff --git a/chrome/browser/offline_pages/prefetch/prefetch_background_task_handler_impl.cc b/chrome/browser/offline_pages/prefetch/prefetch_background_task_handler_impl.cc index 889edbdcc6dfbd..320738a7694165 100644 --- a/chrome/browser/offline_pages/prefetch/prefetch_background_task_handler_impl.cc +++ b/chrome/browser/offline_pages/prefetch/prefetch_background_task_handler_impl.cc @@ -109,7 +109,7 @@ void PrefetchBackgroundTaskHandlerImpl::RemoveSuspension() { } void PrefetchBackgroundTaskHandlerImpl::SetTickClockForTesting( - base::TickClock* clock) { + const base::TickClock* clock) { clock_ = clock; } diff --git a/chrome/browser/offline_pages/prefetch/prefetch_background_task_handler_impl.h b/chrome/browser/offline_pages/prefetch/prefetch_background_task_handler_impl.h index 7f230052d89d69..004c530732c2a2 100644 --- a/chrome/browser/offline_pages/prefetch/prefetch_background_task_handler_impl.h +++ b/chrome/browser/offline_pages/prefetch/prefetch_background_task_handler_impl.h @@ -57,14 +57,14 @@ class PrefetchBackgroundTaskHandlerImpl : public PrefetchBackgroundTaskHandler { int GetAdditionalBackoffSeconds() const override; // This is used to construct the backoff value. - void SetTickClockForTesting(base::TickClock* clock); + void SetTickClockForTesting(const base::TickClock* clock); private: std::unique_ptr GetCurrentBackoff() const; void UpdateBackoff(net::BackoffEntry* backoff); PrefService* prefs_; - base::TickClock* clock_ = nullptr; + const base::TickClock* clock_ = nullptr; DISALLOW_COPY_AND_ASSIGN(PrefetchBackgroundTaskHandlerImpl); }; diff --git a/chrome/browser/prerender/prerender_manager.cc b/chrome/browser/prerender/prerender_manager.cc index cb582f2efc52c0..d741550feebf21 100644 --- a/chrome/browser/prerender/prerender_manager.cc +++ b/chrome/browser/prerender/prerender_manager.cc @@ -1024,7 +1024,7 @@ base::TimeTicks PrerenderManager::GetCurrentTimeTicks() const { } void PrerenderManager::SetTickClockForTesting( - std::unique_ptr tick_clock) { + std::unique_ptr tick_clock) { tick_clock_ = std::move(tick_clock); } diff --git a/chrome/browser/prerender/prerender_manager.h b/chrome/browser/prerender/prerender_manager.h index becd84fbb28472..7c5fbca5b16274 100644 --- a/chrome/browser/prerender/prerender_manager.h +++ b/chrome/browser/prerender/prerender_manager.h @@ -34,7 +34,6 @@ class Profile; namespace base { class DictionaryValue; class ListValue; -class SimpleTestTickClock; class TickClock; } @@ -286,7 +285,7 @@ class PrerenderManager : public content::NotificationObserver, base::Time GetCurrentTime() const; base::TimeTicks GetCurrentTimeTicks() const; void SetTickClockForTesting( - std::unique_ptr tick_clock); + std::unique_ptr tick_clock); void DisablePageLoadMetricsObserverForTesting() { page_load_metric_observer_disabled_ = true; @@ -577,7 +576,7 @@ class PrerenderManager : public content::NotificationObserver, using PrerenderProcessSet = std::set; PrerenderProcessSet prerender_process_hosts_; - std::unique_ptr tick_clock_; + std::unique_ptr tick_clock_; bool page_load_metric_observer_disabled_; diff --git a/chrome/browser/resource_coordinator/time.cc b/chrome/browser/resource_coordinator/time.cc index 0a423bc0013541..2e3def07539b5b 100644 --- a/chrome/browser/resource_coordinator/time.cc +++ b/chrome/browser/resource_coordinator/time.cc @@ -11,7 +11,7 @@ namespace resource_coordinator { namespace { -base::TickClock* g_tick_clock_for_testing = nullptr; +const base::TickClock* g_tick_clock_for_testing = nullptr; } // namespace @@ -20,12 +20,12 @@ base::TimeTicks NowTicks() { : base::TimeTicks::Now(); } -base::TickClock* GetTickClock() { +const base::TickClock* GetTickClock() { return g_tick_clock_for_testing; } ScopedSetTickClockForTesting::ScopedSetTickClockForTesting( - base::TickClock* tick_clock) { + const base::TickClock* tick_clock) { DCHECK(!g_tick_clock_for_testing); g_tick_clock_for_testing = tick_clock; } diff --git a/chrome/browser/resource_coordinator/time.h b/chrome/browser/resource_coordinator/time.h index fea1a602e7b6f9..88257762d257d9 100644 --- a/chrome/browser/resource_coordinator/time.h +++ b/chrome/browser/resource_coordinator/time.h @@ -19,12 +19,12 @@ namespace resource_coordinator { base::TimeTicks NowTicks(); // Returns the testing TickClock. -base::TickClock* GetTickClock(); +const base::TickClock* GetTickClock(); // Sets the testing TickClock within its scope. class ScopedSetTickClockForTesting { public: - explicit ScopedSetTickClockForTesting(base::TickClock* tick_clock); + explicit ScopedSetTickClockForTesting(const base::TickClock* tick_clock); ~ScopedSetTickClockForTesting(); private: diff --git a/chrome/browser/sessions/session_restore_stats_collector.h b/chrome/browser/sessions/session_restore_stats_collector.h index 2bbee066e1e9ba..6876075955c461 100644 --- a/chrome/browser/sessions/session_restore_stats_collector.h +++ b/chrome/browser/sessions/session_restore_stats_collector.h @@ -187,7 +187,7 @@ class SessionRestoreStatsCollector void ReleaseIfDoneTracking(); // Testing seam for configuring the tick clock in use. - void set_tick_clock(std::unique_ptr tick_clock) { + void set_tick_clock(std::unique_ptr tick_clock) { tick_clock_ = std::move(tick_clock); } @@ -226,7 +226,7 @@ class SessionRestoreStatsCollector // The source of ticks used for taking timing information. This is // configurable as a testing seam. Defaults to using base::DefaultTickClock, // which in turn uses base::TimeTicks. - std::unique_ptr tick_clock_; + std::unique_ptr tick_clock_; // The reporting delegate used to report gathered statistics. std::unique_ptr reporting_delegate_; diff --git a/chrome/browser/sessions/session_restore_stats_collector_unittest.cc b/chrome/browser/sessions/session_restore_stats_collector_unittest.cc index ef8a3115f53599..1a8a7d085d803e 100644 --- a/chrome/browser/sessions/session_restore_stats_collector_unittest.cc +++ b/chrome/browser/sessions/session_restore_stats_collector_unittest.cc @@ -160,7 +160,7 @@ class TestSessionRestoreStatsCollector : public SessionRestoreStatsCollector { using SessionRestoreStatsCollector::Observe; TestSessionRestoreStatsCollector( - std::unique_ptr tick_clock, + std::unique_ptr tick_clock, std::unique_ptr reporting_delegate) : SessionRestoreStatsCollector(tick_clock->NowTicks(), std::move(reporting_delegate)) { @@ -202,7 +202,7 @@ class SessionRestoreStatsCollectorTest : public testing::Test { // its job, and will clean itself up when done. scoped_refptr stats_collector = new TestSessionRestoreStatsCollector( - std::unique_ptr(test_tick_clock_), + std::unique_ptr(test_tick_clock_), std::unique_ptr( passthrough_reporting_delegate_)); stats_collector_ = stats_collector.get(); diff --git a/chrome/browser/ui/blocked_content/popup_opener_tab_helper.cc b/chrome/browser/ui/blocked_content/popup_opener_tab_helper.cc index 89705fd3f53298..410042fef707cc 100644 --- a/chrome/browser/ui/blocked_content/popup_opener_tab_helper.cc +++ b/chrome/browser/ui/blocked_content/popup_opener_tab_helper.cc @@ -18,8 +18,9 @@ DEFINE_WEB_CONTENTS_USER_DATA_KEY(PopupOpenerTabHelper); // static -void PopupOpenerTabHelper::CreateForWebContents(content::WebContents* contents, - base::TickClock* tick_clock) { +void PopupOpenerTabHelper::CreateForWebContents( + content::WebContents* contents, + const base::TickClock* tick_clock) { DCHECK(contents); if (!FromWebContents(contents)) { contents->SetUserData( @@ -61,7 +62,7 @@ void PopupOpenerTabHelper::OnDidTabUnder() { } PopupOpenerTabHelper::PopupOpenerTabHelper(content::WebContents* web_contents, - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : content::WebContentsObserver(web_contents), tick_clock_(tick_clock) { visibility_tracker_ = std::make_unique( tick_clock_, diff --git a/chrome/browser/ui/blocked_content/popup_opener_tab_helper.h b/chrome/browser/ui/blocked_content/popup_opener_tab_helper.h index 95d333a9aca400..8e85b59af3566f 100644 --- a/chrome/browser/ui/blocked_content/popup_opener_tab_helper.h +++ b/chrome/browser/ui/blocked_content/popup_opener_tab_helper.h @@ -35,7 +35,7 @@ class PopupOpenerTabHelper // ownership of the clock. |tick_clock| must outlive the PopupOpenerTabHelper // instance. static void CreateForWebContents(content::WebContents* contents, - base::TickClock* tick_clock); + const base::TickClock* tick_clock); ~PopupOpenerTabHelper() override; void OnOpenedPopup(PopupTracker* popup_tracker); @@ -53,7 +53,7 @@ class PopupOpenerTabHelper friend class content::WebContentsUserData; PopupOpenerTabHelper(content::WebContents* web_contents, - base::TickClock* tick_clock); + const base::TickClock* tick_clock); // content::WebContentsObserver: void OnVisibilityChanged(content::Visibility visibility) override; @@ -65,7 +65,7 @@ class PopupOpenerTabHelper base::Optional visible_time_before_tab_under_; // The clock which is used by the visibility trackers. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Keeps track of the total foreground time for this tab. std::unique_ptr visibility_tracker_; diff --git a/chrome/browser/ui/blocked_content/scoped_visibility_tracker.cc b/chrome/browser/ui/blocked_content/scoped_visibility_tracker.cc index 3d9924a438ef7d..64ca553e6b39c3 100644 --- a/chrome/browser/ui/blocked_content/scoped_visibility_tracker.cc +++ b/chrome/browser/ui/blocked_content/scoped_visibility_tracker.cc @@ -8,8 +8,9 @@ #include "base/time/tick_clock.h" -ScopedVisibilityTracker::ScopedVisibilityTracker(base::TickClock* tick_clock, - bool is_shown) +ScopedVisibilityTracker::ScopedVisibilityTracker( + const base::TickClock* tick_clock, + bool is_shown) : tick_clock_(tick_clock) { DCHECK(tick_clock_); if (is_shown) diff --git a/chrome/browser/ui/blocked_content/scoped_visibility_tracker.h b/chrome/browser/ui/blocked_content/scoped_visibility_tracker.h index a45e19714443a1..a84efac26cbf55 100644 --- a/chrome/browser/ui/blocked_content/scoped_visibility_tracker.h +++ b/chrome/browser/ui/blocked_content/scoped_visibility_tracker.h @@ -19,7 +19,7 @@ class TickClock; class ScopedVisibilityTracker { public: // |tick_clock| must outlive this object. - ScopedVisibilityTracker(base::TickClock* tick_clock, bool is_shown); + ScopedVisibilityTracker(const base::TickClock* tick_clock, bool is_shown); ~ScopedVisibilityTracker(); void OnShown(); @@ -30,7 +30,7 @@ class ScopedVisibilityTracker { private: void Update(bool in_foreground); - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; base::TimeTicks last_time_shown_; base::TimeDelta foreground_duration_; diff --git a/chrome/browser/ui/views/relaunch_notification/relaunch_notification_controller.cc b/chrome/browser/ui/views/relaunch_notification/relaunch_notification_controller.cc index 2ce07b52f8fd04..3696241ec3a757 100644 --- a/chrome/browser/ui/views/relaunch_notification/relaunch_notification_controller.cc +++ b/chrome/browser/ui/views/relaunch_notification/relaunch_notification_controller.cc @@ -105,7 +105,7 @@ constexpr base::TimeDelta RelaunchNotificationController::kRelaunchGracePeriod; RelaunchNotificationController::RelaunchNotificationController( UpgradeDetector* upgrade_detector, - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : upgrade_detector_(upgrade_detector), tick_clock_(tick_clock), last_notification_style_(NotificationStyle::kNone), diff --git a/chrome/browser/ui/views/relaunch_notification/relaunch_notification_controller.h b/chrome/browser/ui/views/relaunch_notification/relaunch_notification_controller.h index 603052c51b98c1..87046f51e730d2 100644 --- a/chrome/browser/ui/views/relaunch_notification/relaunch_notification_controller.h +++ b/chrome/browser/ui/views/relaunch_notification/relaunch_notification_controller.h @@ -55,7 +55,7 @@ class RelaunchNotificationController : public UpgradeObserver, base::TimeDelta::FromMinutes(3); RelaunchNotificationController(UpgradeDetector* upgrade_detector, - base::TickClock* tick_clock); + const base::TickClock* tick_clock); // UpgradeObserver: void OnUpgradeRecommended() override; @@ -136,7 +136,7 @@ class RelaunchNotificationController : public UpgradeObserver, // A provider of TimeTicks to the controller and its timer for the sake of // testability. - base::TickClock* const tick_clock_; + const base::TickClock* const tick_clock_; // Observes changes to the browser.relaunch_notification Local State pref. PrefChangeRegistrar pref_change_registrar_; diff --git a/chrome/browser/ui/views/relaunch_notification/relaunch_notification_controller_unittest.cc b/chrome/browser/ui/views/relaunch_notification/relaunch_notification_controller_unittest.cc index 6517152449acc8..f8df22fef34ff8 100644 --- a/chrome/browser/ui/views/relaunch_notification/relaunch_notification_controller_unittest.cc +++ b/chrome/browser/ui/views/relaunch_notification/relaunch_notification_controller_unittest.cc @@ -39,7 +39,7 @@ class FakeRelaunchNotificationController : public RelaunchNotificationController { public: FakeRelaunchNotificationController(UpgradeDetector* upgrade_detector, - base::TickClock* tick_clock, + const base::TickClock* tick_clock, ControllerDelegate* delegate) : RelaunchNotificationController(upgrade_detector, tick_clock), delegate_(delegate) {} @@ -78,7 +78,7 @@ class MockControllerDelegate : public ControllerDelegate { // A fake UpgradeDetector. class FakeUpgradeDetector : public UpgradeDetector { public: - explicit FakeUpgradeDetector(base::TickClock* tick_clock) + explicit FakeUpgradeDetector(const base::TickClock* tick_clock) : UpgradeDetector(tick_clock) { set_upgrade_detected_time(this->tick_clock()->NowTicks()); } @@ -140,7 +140,7 @@ class RelaunchNotificationControllerTest : public ::testing::Test { } // Returns the ScopedTaskEnvironment's MockTickClock. - base::TickClock* GetMockTickClock() { + const base::TickClock* GetMockTickClock() { return scoped_task_environment_.GetMockTickClock(); } diff --git a/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc index 3f3a9c1e27ad8c..499a1fcd2081ca 100644 --- a/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc @@ -386,7 +386,7 @@ void EncryptionMigrationScreenHandler::SetFreeDiskSpaceFetcherForTesting( } void EncryptionMigrationScreenHandler::SetTickClockForTesting( - base::TickClock* tick_clock) { + const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } diff --git a/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h b/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h index 48ce6f487b42c4..f13f58d641d860 100644 --- a/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h +++ b/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h @@ -66,7 +66,7 @@ class EncryptionMigrationScreenHandler : public EncryptionMigrationScreenView, // migration. // This doesn't toke the ownership of the clock. |tick_clock| must outlive the // EncryptionMigrationScreenHandler instance. - void SetTickClockForTesting(base::TickClock* tick_clock); + void SetTickClockForTesting(const base::TickClock* tick_clock); virtual device::mojom::WakeLock* GetWakeLock(); @@ -182,7 +182,7 @@ class EncryptionMigrationScreenHandler : public EncryptionMigrationScreenView, std::unique_ptr login_feedback_; // Used to measure elapsed time during migration. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; FreeDiskSpaceFetcher free_disk_space_fetcher_; diff --git a/chrome/browser/upgrade_detector.cc b/chrome/browser/upgrade_detector.cc index ea1fbd7d1175cf..ac99d1d339e2c6 100644 --- a/chrome/browser/upgrade_detector.cc +++ b/chrome/browser/upgrade_detector.cc @@ -60,7 +60,7 @@ gfx::Image UpgradeDetector::GetIcon() { return gfx::Image(gfx::CreateVectorIcon(kBrowserToolsUpdateIcon, color)); } -UpgradeDetector::UpgradeDetector(base::TickClock* tick_clock) +UpgradeDetector::UpgradeDetector(const base::TickClock* tick_clock) : tick_clock_(tick_clock), upgrade_available_(UPGRADE_AVAILABLE_NONE), best_effort_experiment_updates_available_(false), diff --git a/chrome/browser/upgrade_detector.h b/chrome/browser/upgrade_detector.h index bb66f6bb06e474..cfef0694b4774a 100644 --- a/chrome/browser/upgrade_detector.h +++ b/chrome/browser/upgrade_detector.h @@ -137,14 +137,14 @@ class UpgradeDetector { UPGRADE_NEEDED_OUTDATED_INSTALL_NO_AU, }; - explicit UpgradeDetector(base::TickClock* tick_clock); + explicit UpgradeDetector(const base::TickClock* tick_clock); // Returns the notification period specified via the // RelaunchNotificationPeriod policy setting, or a zero delta if unset or out // of range. static base::TimeDelta GetRelaunchNotificationPeriod(); - base::TickClock* tick_clock() { return tick_clock_; } + const base::TickClock* tick_clock() { return tick_clock_; } // Notifies that update is recommended and triggers different actions based // on the update availability. @@ -220,7 +220,7 @@ class UpgradeDetector { void IdleCallback(ui::IdleState state); // A provider of TimeTicks to the detector and its timers. - base::TickClock* const tick_clock_; + const base::TickClock* const tick_clock_; // Observes changes to the browser.relaunch_notification_period Local State // preference. diff --git a/chrome/browser/upgrade_detector_impl.cc b/chrome/browser/upgrade_detector_impl.cc index b727a32fea78e0..512048dc51458e 100644 --- a/chrome/browser/upgrade_detector_impl.cc +++ b/chrome/browser/upgrade_detector_impl.cc @@ -150,7 +150,7 @@ base::Version GetCurrentlyInstalledVersionImpl(base::Version* critical_update) { } // namespace -UpgradeDetectorImpl::UpgradeDetectorImpl(base::TickClock* tick_clock) +UpgradeDetectorImpl::UpgradeDetectorImpl(const base::TickClock* tick_clock) : UpgradeDetector(tick_clock), blocking_task_runner_(base::CreateSequencedTaskRunnerWithTraits( {base::TaskPriority::BACKGROUND, diff --git a/chrome/browser/upgrade_detector_impl.h b/chrome/browser/upgrade_detector_impl.h index d116427349a231..db24faac1ad6b9 100644 --- a/chrome/browser/upgrade_detector_impl.h +++ b/chrome/browser/upgrade_detector_impl.h @@ -43,7 +43,7 @@ class UpgradeDetectorImpl : public UpgradeDetector, base::TimeTicks GetHighAnnoyanceDeadline() override; protected: - explicit UpgradeDetectorImpl(base::TickClock* tick_clock); + explicit UpgradeDetectorImpl(const base::TickClock* tick_clock); // Sends out a notification and starts a one shot timer to wait until // notifying the user. diff --git a/chrome/browser/upgrade_detector_impl_unittest.cc b/chrome/browser/upgrade_detector_impl_unittest.cc index 14735ab3e14bbe..f71059e2556d85 100644 --- a/chrome/browser/upgrade_detector_impl_unittest.cc +++ b/chrome/browser/upgrade_detector_impl_unittest.cc @@ -17,7 +17,7 @@ namespace { class TestUpgradeDetectorImpl : public UpgradeDetectorImpl { public: - explicit TestUpgradeDetectorImpl(base::TickClock* tick_clock) + explicit TestUpgradeDetectorImpl(const base::TickClock* tick_clock) : UpgradeDetectorImpl(tick_clock) {} ~TestUpgradeDetectorImpl() override = default; @@ -98,7 +98,7 @@ class UpgradeDetectorImplTest : public ::testing::Test { base::test::ScopedTaskEnvironment::MainThreadType::MOCK_TIME), scoped_local_state_(TestingBrowserProcess::GetGlobal()) {} - base::TickClock* GetMockTickClock() { + const base::TickClock* GetMockTickClock() { return scoped_task_environment_.GetMockTickClock(); } diff --git a/chrome/renderer/media/chrome_key_systems_provider.cc b/chrome/renderer/media/chrome_key_systems_provider.cc index e2a90b796d89a1..b26acbb636fcd8 100644 --- a/chrome/renderer/media/chrome_key_systems_provider.cc +++ b/chrome/renderer/media/chrome_key_systems_provider.cc @@ -69,7 +69,7 @@ bool ChromeKeySystemsProvider::IsKeySystemsUpdateNeeded() { } void ChromeKeySystemsProvider::SetTickClockForTesting( - base::TickClock* tick_clock) { + const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } diff --git a/chrome/renderer/media/chrome_key_systems_provider.h b/chrome/renderer/media/chrome_key_systems_provider.h index 5e3eb0508f948a..48b45e5b3a03d9 100644 --- a/chrome/renderer/media/chrome_key_systems_provider.h +++ b/chrome/renderer/media/chrome_key_systems_provider.h @@ -32,7 +32,7 @@ class ChromeKeySystemsProvider { // less fragile (don't assume AddSupportedKeySystems has just one caller). bool IsKeySystemsUpdateNeeded(); - void SetTickClockForTesting(base::TickClock* tick_clock); + void SetTickClockForTesting(const base::TickClock* tick_clock); void SetProviderDelegateForTesting( const KeySystemsProviderDelegate& test_provider); @@ -49,7 +49,7 @@ class ChromeKeySystemsProvider { // Throttle how often we signal an update is needed to avoid unnecessary high // frequency of expensive IPC calls. base::TimeTicks last_update_time_ticks_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Ensure all methods are called from the same (Main) thread. base::ThreadChecker thread_checker_; diff --git a/components/cast_channel/cast_message_handler.cc b/components/cast_channel/cast_message_handler.cc index 86a154b51dec2d..b12c1b49ae961c 100644 --- a/components/cast_channel/cast_message_handler.cc +++ b/components/cast_channel/cast_message_handler.cc @@ -54,7 +54,7 @@ GetAppAvailabilityRequest::GetAppAvailabilityRequest( int channel_id, const std::string& app_id, GetAppAvailabilityCallback callback, - base::TickClock* clock) + const base::TickClock* clock) : channel_id(channel_id), app_id(app_id), callback(std::move(callback)), diff --git a/components/cast_channel/cast_message_handler.h b/components/cast_channel/cast_message_handler.h index 8c1cc334e48683..ad775ed7bfcb6b 100644 --- a/components/cast_channel/cast_message_handler.h +++ b/components/cast_channel/cast_message_handler.h @@ -31,7 +31,7 @@ struct GetAppAvailabilityRequest { GetAppAvailabilityRequest(int channel_id, const std::string& app_id, GetAppAvailabilityCallback callback, - base::TickClock* clock); + const base::TickClock* clock); ~GetAppAvailabilityRequest(); // ID of channel the request is sent over. @@ -137,7 +137,7 @@ class CastMessageHandler : public CastSocket::Observer { CastSocketService* const socket_service_; // Non-owned pointer to TickClock used for request timeouts. - base::TickClock* const clock_; + const base::TickClock* const clock_; SEQUENCE_CHECKER(sequence_checker_); base::WeakPtrFactory weak_ptr_factory_; diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.cc index b29512be2baa47..50b69ecb35f976 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.cc @@ -66,7 +66,8 @@ DataReductionProxyConfigValues* TestDataReductionProxyConfig::config_values() { return config_values_.get(); } -void TestDataReductionProxyConfig::SetTickClock(base::TickClock* tick_clock) { +void TestDataReductionProxyConfig::SetTickClock( + const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h index 84f15f895875d0..818a7e815c65df 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h @@ -70,7 +70,7 @@ class TestDataReductionProxyConfig : public DataReductionProxyConfig { // Sets the |tick_clock_| to |tick_clock|. Ownership of |tick_clock| is not // passed to the callee. - void SetTickClock(base::TickClock* tick_clock); + void SetTickClock(const base::TickClock* tick_clock); base::TimeTicks GetTicksNow() const override; @@ -128,7 +128,7 @@ class TestDataReductionProxyConfig : public DataReductionProxyConfig { private: bool GetIsCaptivePortal() const override; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; base::Optional previous_attempt_counts_; diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate.cc index 5bb99b80c8f8e3..c1d8e963e3d27d 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate.cc @@ -179,7 +179,7 @@ void DataReductionProxyDelegate::OnFallback(const net::ProxyServer& bad_proxy, } void DataReductionProxyDelegate::SetTickClockForTesting( - base::TickClock* tick_clock) { + const base::TickClock* tick_clock) { tick_clock_ = tick_clock; // Update |last_network_change_time_| to the provided tick clock's current // time for testing. diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate.h index f5adf5c608cb19..15e73f95863912 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate.h +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate.h @@ -56,7 +56,7 @@ class DataReductionProxyDelegate net::ProxyInfo* result) override; void OnFallback(const net::ProxyServer& bad_proxy, int net_error) override; - void SetTickClockForTesting(base::TickClock* tick_clock); + void SetTickClockForTesting(const base::TickClock* tick_clock); protected: // Protected so that it can be overridden during testing. @@ -92,7 +92,7 @@ class DataReductionProxyDelegate DataReductionProxyBypassStats* bypass_stats_; // Tick clock used for obtaining the current time. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // True if the metrics related to the first request whose resolved proxy was a // data saver proxy has been recorded. |first_data_saver_request_recorded_| is diff --git a/components/data_usage/android/traffic_stats_amortizer.cc b/components/data_usage/android/traffic_stats_amortizer.cc index e551eb73177b32..3a0acfc525a1c1 100644 --- a/components/data_usage/android/traffic_stats_amortizer.cc +++ b/components/data_usage/android/traffic_stats_amortizer.cc @@ -219,7 +219,7 @@ base::WeakPtr TrafficStatsAmortizer::GetWeakPtr() { } TrafficStatsAmortizer::TrafficStatsAmortizer( - base::TickClock* tick_clock, + const base::TickClock* tick_clock, std::unique_ptr traffic_stats_query_timer, const base::TimeDelta& traffic_stats_query_delay, const base::TimeDelta& max_amortization_delay, diff --git a/components/data_usage/android/traffic_stats_amortizer.h b/components/data_usage/android/traffic_stats_amortizer.h index 7dba2b1561e198..a247e65a1bb2a7 100644 --- a/components/data_usage/android/traffic_stats_amortizer.h +++ b/components/data_usage/android/traffic_stats_amortizer.h @@ -65,7 +65,7 @@ class TrafficStatsAmortizer : public DataUseAmortizer { // over the timing of the TrafficStatsAmortizer and the byte counts returned // from TrafficStats. |traffic_stats_query_timer| must not be a repeating // timer. - TrafficStatsAmortizer(base::TickClock* tick_clock, + TrafficStatsAmortizer(const base::TickClock* tick_clock, std::unique_ptr traffic_stats_query_timer, const base::TimeDelta& traffic_stats_query_delay, const base::TimeDelta& max_amortization_delay, @@ -95,7 +95,7 @@ class TrafficStatsAmortizer : public DataUseAmortizer { base::ThreadChecker thread_checker_; // TickClock for determining the current time tick. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // One-shot timer used to wait a short time after receiving DataUse before // querying TrafficStats, to give TrafficStats time to update and give the diff --git a/components/data_usage/android/traffic_stats_amortizer_unittest.cc b/components/data_usage/android/traffic_stats_amortizer_unittest.cc index 8d80e5b85cc8d2..462400c8956cd7 100644 --- a/components/data_usage/android/traffic_stats_amortizer_unittest.cc +++ b/components/data_usage/android/traffic_stats_amortizer_unittest.cc @@ -123,7 +123,7 @@ class MockTimerWithTickClock : public base::MockTimer { public: MockTimerWithTickClock(bool retain_user_task, bool is_repeating, - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : base::MockTimer(retain_user_task, is_repeating), tick_clock_(tick_clock) {} @@ -135,7 +135,7 @@ class MockTimerWithTickClock : public base::MockTimer { } private: - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; DISALLOW_COPY_AND_ASSIGN(MockTimerWithTickClock); }; @@ -145,7 +145,7 @@ class MockTimerWithTickClock : public base::MockTimer { class TestTrafficStatsAmortizer : public TrafficStatsAmortizer { public: TestTrafficStatsAmortizer( - base::TickClock* tick_clock, + const base::TickClock* tick_clock, std::unique_ptr traffic_stats_query_timer) : TrafficStatsAmortizer(tick_clock, std::move(traffic_stats_query_timer), diff --git a/components/mirroring/browser/cast_remoting_sender.h b/components/mirroring/browser/cast_remoting_sender.h index 1dd2718601f4f4..de017a08e26e90 100644 --- a/components/mirroring/browser/cast_remoting_sender.h +++ b/components/mirroring/browser/cast_remoting_sender.h @@ -152,7 +152,7 @@ class CastRemotingSender : public media::mojom::RemotingDataStreamSender { // The callback to send frame events to renderer process for logging. const FrameEventCallback frame_event_cb_; - base::TickClock* clock_; + const base::TickClock* clock_; // Callback that is run to notify when a fatal error occurs. base::OnceClosure error_callback_; diff --git a/components/network_time/network_time_tracker.cc b/components/network_time/network_time_tracker.cc index 20205d4349fcb4..b9581ce9d78cd1 100644 --- a/components/network_time/network_time_tracker.cc +++ b/components/network_time/network_time_tracker.cc @@ -203,7 +203,7 @@ void NetworkTimeTracker::RegisterPrefs(PrefRegistrySimple* registry) { NetworkTimeTracker::NetworkTimeTracker( std::unique_ptr clock, - std::unique_ptr tick_clock, + std::unique_ptr tick_clock, PrefService* pref_service, scoped_refptr getter) : server_url_(kTimeServiceURL), diff --git a/components/network_time/network_time_tracker.h b/components/network_time/network_time_tracker.h index 923364736780e5..edc2cd4a5410bb 100644 --- a/components/network_time/network_time_tracker.h +++ b/components/network_time/network_time_tracker.h @@ -96,7 +96,7 @@ class NetworkTimeTracker : public net::URLFetcherDelegate { // null, will cause automatic queries to a time server. Otherwise, time is // available only if |UpdateNetworkTime| is called. NetworkTimeTracker(std::unique_ptr clock, - std::unique_ptr tick_clock, + std::unique_ptr tick_clock, PrefService* pref_service, scoped_refptr getter); ~NetworkTimeTracker() override; @@ -194,7 +194,7 @@ class NetworkTimeTracker : public net::URLFetcherDelegate { // the NetworkTimeTracker to notice e.g. suspend/resume events and clock // resets. std::unique_ptr clock_; - std::unique_ptr tick_clock_; + std::unique_ptr tick_clock_; PrefService* pref_service_; diff --git a/components/network_time/network_time_tracker_unittest.cc b/components/network_time/network_time_tracker_unittest.cc index c29c92c3c1526d..78d7fa656d313f 100644 --- a/components/network_time/network_time_tracker_unittest.cc +++ b/components/network_time/network_time_tracker_unittest.cc @@ -64,7 +64,7 @@ class NetworkTimeTrackerTest : public ::testing::Test { tracker_.reset(new NetworkTimeTracker( std::unique_ptr(clock_), - std::unique_ptr(tick_clock_), &pref_service_, + std::unique_ptr(tick_clock_), &pref_service_, new net::TestURLRequestContextGetter(io_thread_.task_runner()))); // Do this to be sure that |is_null| returns false. @@ -90,7 +90,7 @@ class NetworkTimeTrackerTest : public ::testing::Test { tick_clock_ = new_tick_clock; tracker_.reset(new NetworkTimeTracker( std::unique_ptr(clock_), - std::unique_ptr(tick_clock_), &pref_service_, + std::unique_ptr(tick_clock_), &pref_service_, new net::TestURLRequestContextGetter(io_thread_.task_runner()))); } diff --git a/components/password_manager/core/browser/android_affiliation/affiliation_backend.cc b/components/password_manager/core/browser/android_affiliation/affiliation_backend.cc index 9e74c3474493e8..8e86a50dea3c4d 100644 --- a/components/password_manager/core/browser/android_affiliation/affiliation_backend.cc +++ b/components/password_manager/core/browser/android_affiliation/affiliation_backend.cc @@ -28,7 +28,7 @@ AffiliationBackend::AffiliationBackend( const scoped_refptr& request_context_getter, const scoped_refptr& task_runner, base::Clock* time_source, - base::TickClock* time_tick_source) + const base::TickClock* time_tick_source) : request_context_getter_(request_context_getter), task_runner_(task_runner), clock_(time_source), diff --git a/components/password_manager/core/browser/android_affiliation/affiliation_backend.h b/components/password_manager/core/browser/android_affiliation/affiliation_backend.h index bce8b24db6ec4d..79c17d65b8eeb6 100644 --- a/components/password_manager/core/browser/android_affiliation/affiliation_backend.h +++ b/components/password_manager/core/browser/android_affiliation/affiliation_backend.h @@ -65,7 +65,7 @@ class AffiliationBackend : public FacetManagerHost, const scoped_refptr& request_context_getter, const scoped_refptr& task_runner, base::Clock* time_source, - base::TickClock* time_tick_source); + const base::TickClock* time_tick_source); ~AffiliationBackend() override; // Performs the I/O-heavy part of initialization. The database used to cache @@ -143,7 +143,7 @@ class AffiliationBackend : public FacetManagerHost, scoped_refptr request_context_getter_; scoped_refptr task_runner_; base::Clock* clock_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; std::unique_ptr cache_; std::unique_ptr fetcher_; diff --git a/components/password_manager/core/browser/android_affiliation/affiliation_fetch_throttler.cc b/components/password_manager/core/browser/android_affiliation/affiliation_fetch_throttler.cc index 9721b726b1b4d9..edeae34993f717 100644 --- a/components/password_manager/core/browser/android_affiliation/affiliation_fetch_throttler.cc +++ b/components/password_manager/core/browser/android_affiliation/affiliation_fetch_throttler.cc @@ -52,7 +52,7 @@ const int64_t AffiliationFetchThrottler::kGracePeriodAfterReconnectMs = AffiliationFetchThrottler::AffiliationFetchThrottler( AffiliationFetchThrottlerDelegate* delegate, const scoped_refptr& task_runner, - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : delegate_(delegate), task_runner_(task_runner), tick_clock_(tick_clock), diff --git a/components/password_manager/core/browser/android_affiliation/affiliation_fetch_throttler.h b/components/password_manager/core/browser/android_affiliation/affiliation_fetch_throttler.h index d9a3cbadd95a31..3cf52739426ac3 100644 --- a/components/password_manager/core/browser/android_affiliation/affiliation_fetch_throttler.h +++ b/components/password_manager/core/browser/android_affiliation/affiliation_fetch_throttler.h @@ -58,7 +58,7 @@ class AffiliationFetchThrottler AffiliationFetchThrottler( AffiliationFetchThrottlerDelegate* delegate, const scoped_refptr& task_runner, - base::TickClock* tick_clock); + const base::TickClock* tick_clock); ~AffiliationFetchThrottler() override; // Signals to the throttling logic that a network request is needed, and that @@ -119,7 +119,7 @@ class AffiliationFetchThrottler net::NetworkChangeNotifier::ConnectionType type) override; scoped_refptr task_runner_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; State state_; bool has_network_connectivity_; bool is_fetch_scheduled_; diff --git a/components/password_manager/core/browser/android_affiliation/affiliation_fetch_throttler_unittest.cc b/components/password_manager/core/browser/android_affiliation/affiliation_fetch_throttler_unittest.cc index 43082316c42cc0..016b37842a88f1 100644 --- a/components/password_manager/core/browser/android_affiliation/affiliation_fetch_throttler_unittest.cc +++ b/components/password_manager/core/browser/android_affiliation/affiliation_fetch_throttler_unittest.cc @@ -29,7 +29,8 @@ class MockAffiliationFetchThrottlerDelegate : public AffiliationFetchThrottlerDelegate { public: // The |tick_clock| should outlive this instance. - explicit MockAffiliationFetchThrottlerDelegate(base::TickClock* tick_clock) + explicit MockAffiliationFetchThrottlerDelegate( + const base::TickClock* tick_clock) : tick_clock_(tick_clock), emulated_return_value_(true), can_send_count_(0u) {} @@ -50,7 +51,7 @@ class MockAffiliationFetchThrottlerDelegate } private: - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; bool emulated_return_value_; size_t can_send_count_; base::TimeTicks last_can_send_time_; diff --git a/components/policy/core/common/remote_commands/remote_commands_queue.cc b/components/policy/core/common/remote_commands/remote_commands_queue.cc index cdced061030e3a..df32ecab440813 100644 --- a/components/policy/core/common/remote_commands/remote_commands_queue.cc +++ b/components/policy/core/common/remote_commands/remote_commands_queue.cc @@ -41,7 +41,7 @@ void RemoteCommandsQueue::AddJob(std::unique_ptr job) { ScheduleNextJob(); } -void RemoteCommandsQueue::SetClockForTesting(base::TickClock* clock) { +void RemoteCommandsQueue::SetClockForTesting(const base::TickClock* clock) { clock_ = clock; } diff --git a/components/policy/core/common/remote_commands/remote_commands_queue.h b/components/policy/core/common/remote_commands/remote_commands_queue.h index c4f6a18d00c332..909600098573d8 100644 --- a/components/policy/core/common/remote_commands/remote_commands_queue.h +++ b/components/policy/core/common/remote_commands/remote_commands_queue.h @@ -55,7 +55,7 @@ class POLICY_EXPORT RemoteCommandsQueue { void AddJob(std::unique_ptr job); // Set an alternative clock for testing. - void SetClockForTesting(base::TickClock* clock); + void SetClockForTesting(const base::TickClock* clock); // Helper function to get the current time. base::TimeTicks GetNowTicks(); @@ -76,7 +76,7 @@ class POLICY_EXPORT RemoteCommandsQueue { std::unique_ptr running_command_; - base::TickClock* clock_; + const base::TickClock* clock_; base::OneShotTimer execution_timeout_timer_; base::ObserverList observer_list_; diff --git a/components/policy/core/common/remote_commands/remote_commands_queue_unittest.cc b/components/policy/core/common/remote_commands/remote_commands_queue_unittest.cc index 3f64c776ef34f1..ef8ccb5b3d8907 100644 --- a/components/policy/core/common/remote_commands/remote_commands_queue_unittest.cc +++ b/components/policy/core/common/remote_commands/remote_commands_queue_unittest.cc @@ -89,7 +89,7 @@ class RemoteCommandsQueueTest : public testing::Test { RemoteCommandsQueue queue_; StrictMock observer_; base::TimeTicks test_start_time_; - base::TickClock* clock_; + const base::TickClock* clock_; private: void VerifyCommandIssuedTime(RemoteCommandJob* job, diff --git a/components/policy/core/common/remote_commands/remote_commands_service.cc b/components/policy/core/common/remote_commands/remote_commands_service.cc index abe84760f05324..c9ca0ae9bf830f 100644 --- a/components/policy/core/common/remote_commands/remote_commands_service.cc +++ b/components/policy/core/common/remote_commands/remote_commands_service.cc @@ -76,7 +76,7 @@ bool RemoteCommandsService::FetchRemoteCommands() { return true; } -void RemoteCommandsService::SetClockForTesting(base::TickClock* clock) { +void RemoteCommandsService::SetClockForTesting(const base::TickClock* clock) { queue_.SetClockForTesting(clock); } diff --git a/components/policy/core/common/remote_commands/remote_commands_service.h b/components/policy/core/common/remote_commands/remote_commands_service.h index 5ce2cbfb93afdf..774ae9b9a5ed0b 100644 --- a/components/policy/core/common/remote_commands/remote_commands_service.h +++ b/components/policy/core/common/remote_commands/remote_commands_service.h @@ -51,7 +51,7 @@ class POLICY_EXPORT RemoteCommandsService } // Set an alternative clock for testing. - void SetClockForTesting(base::TickClock* clock); + void SetClockForTesting(const base::TickClock* clock); private: // Helper function to enqueue a command which we get from server. diff --git a/components/policy/core/common/remote_commands/testing_remote_commands_server.cc b/components/policy/core/common/remote_commands/testing_remote_commands_server.cc index d48ae5d6b4068a..7690d6affa145f 100644 --- a/components/policy/core/common/remote_commands/testing_remote_commands_server.cc +++ b/components/policy/core/common/remote_commands/testing_remote_commands_server.cc @@ -135,7 +135,7 @@ TestingRemoteCommandsServer::FetchCommands( return fetched_commands; } -void TestingRemoteCommandsServer::SetClock(base::TickClock* clock) { +void TestingRemoteCommandsServer::SetClock(const base::TickClock* clock) { DCHECK(thread_checker_.CalledOnValidThread()); clock_ = clock; } diff --git a/components/policy/core/common/remote_commands/testing_remote_commands_server.h b/components/policy/core/common/remote_commands/testing_remote_commands_server.h index acffdb915ed1da..b12ae422fc4208 100644 --- a/components/policy/core/common/remote_commands/testing_remote_commands_server.h +++ b/components/policy/core/common/remote_commands/testing_remote_commands_server.h @@ -80,7 +80,7 @@ class TestingRemoteCommandsServer { // Set alternative clock for obtaining the command issue time. The default // clock uses the system clock. - void SetClock(base::TickClock* clock); + void SetClock(const base::TickClock* clock); // Get the number of commands for which no results have been reported yet. // This number also includes commands which have not been fetched yet. @@ -104,7 +104,7 @@ class TestingRemoteCommandsServer { RemoteCommandJob::UniqueIDType last_generated_unique_id_ = 0; // Clock used to generate command issue time when IssueCommand() is called. - base::TickClock* clock_; + const base::TickClock* clock_; // A lock protecting the command queues, as well as generated and acknowledged // IDs. diff --git a/components/ssl_errors/error_classification_unittest.cc b/components/ssl_errors/error_classification_unittest.cc index 9f96ea36b02273..f73cd636827730 100644 --- a/components/ssl_errors/error_classification_unittest.cc +++ b/components/ssl_errors/error_classification_unittest.cc @@ -380,7 +380,7 @@ TEST_F(SSLErrorClassificationTest, NetworkClockStateHistogram) { base::MessageLoop loop; network_time::NetworkTimeTracker network_time_tracker( std::unique_ptr(clock), - std::unique_ptr(tick_clock), &pref_service, + std::unique_ptr(tick_clock), &pref_service, new net::TestURLRequestContextGetter(io_thread.task_runner())); network_time_tracker.SetTimeServerURLForTesting(test_server.GetURL("/")); field_trial_test()->SetNetworkQueriesWithVariationsService( diff --git a/components/suggestions/suggestions_service_impl.cc b/components/suggestions/suggestions_service_impl.cc index 1946552852532e..f8ad6b3203ac43 100644 --- a/components/suggestions/suggestions_service_impl.cc +++ b/components/suggestions/suggestions_service_impl.cc @@ -123,7 +123,7 @@ SuggestionsServiceImpl::SuggestionsServiceImpl( std::unique_ptr suggestions_store, std::unique_ptr thumbnail_manager, std::unique_ptr blacklist_store, - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : identity_manager_(identity_manager), sync_service_(sync_service), sync_service_observer_(this), diff --git a/components/suggestions/suggestions_service_impl.h b/components/suggestions/suggestions_service_impl.h index 5a84eef5403c78..3d64716e342051 100644 --- a/components/suggestions/suggestions_service_impl.h +++ b/components/suggestions/suggestions_service_impl.h @@ -64,7 +64,7 @@ class SuggestionsServiceImpl : public SuggestionsService, std::unique_ptr suggestions_store, std::unique_ptr thumbnail_manager, std::unique_ptr blacklist_store, - base::TickClock* tick_clock); + const base::TickClock* tick_clock); ~SuggestionsServiceImpl() override; // SuggestionsService implementation. @@ -195,7 +195,7 @@ class SuggestionsServiceImpl : public SuggestionsService, // The local cache for temporary blacklist, until uploaded to the server. std::unique_ptr blacklist_store_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Backoff for scheduling blacklist upload tasks. net::BackoffEntry blacklist_upload_backoff_; diff --git a/components/viz/common/frame_sinks/begin_frame_source_unittest.cc b/components/viz/common/frame_sinks/begin_frame_source_unittest.cc index 40044a81928167..984977ef2a3a1c 100644 --- a/components/viz/common/frame_sinks/begin_frame_source_unittest.cc +++ b/components/viz/common/frame_sinks/begin_frame_source_unittest.cc @@ -7,6 +7,7 @@ #include #include "base/memory/ptr_util.h" +#include "base/test/simple_test_tick_clock.h" #include "base/test/test_simple_task_runner.h" #include "components/viz/test/begin_frame_args_test.h" #include "components/viz/test/begin_frame_source_test.h" diff --git a/components/viz/common/frame_sinks/delay_based_time_source_unittest.cc b/components/viz/common/frame_sinks/delay_based_time_source_unittest.cc index 47744c917cd249..eb5977897e8eb3 100644 --- a/components/viz/common/frame_sinks/delay_based_time_source_unittest.cc +++ b/components/viz/common/frame_sinks/delay_based_time_source_unittest.cc @@ -6,6 +6,7 @@ #include +#include "base/test/simple_test_tick_clock.h" #include "base/test/test_simple_task_runner.h" #include "components/viz/test/fake_delay_based_time_source.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/components/viz/service/frame_sinks/direct_layer_tree_frame_sink_unittest.cc b/components/viz/service/frame_sinks/direct_layer_tree_frame_sink_unittest.cc index abdf1f90ca7516..2ab44fe66c1ee1 100644 --- a/components/viz/service/frame_sinks/direct_layer_tree_frame_sink_unittest.cc +++ b/components/viz/service/frame_sinks/direct_layer_tree_frame_sink_unittest.cc @@ -6,6 +6,7 @@ #include +#include "base/test/simple_test_tick_clock.h" #include "cc/test/fake_layer_tree_frame_sink_client.h" #include "components/viz/common/display/renderer_settings.h" #include "components/viz/common/frame_sinks/begin_frame_source.h" diff --git a/components/viz/service/frame_sinks/surface_synchronization_unittest.cc b/components/viz/service/frame_sinks/surface_synchronization_unittest.cc index d125b45e1d038e..77797c9c831a7f 100644 --- a/components/viz/service/frame_sinks/surface_synchronization_unittest.cc +++ b/components/viz/service/frame_sinks/surface_synchronization_unittest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/containers/flat_set.h" +#include "base/test/simple_test_tick_clock.h" #include "components/viz/common/surfaces/surface_id.h" #include "components/viz/service/frame_sinks/compositor_frame_sink_support.h" #include "components/viz/service/frame_sinks/frame_sink_manager_impl.h" diff --git a/components/viz/service/frame_sinks/video_capture/frame_sink_video_capturer_impl.h b/components/viz/service/frame_sinks/video_capture/frame_sink_video_capturer_impl.h index cc1e20df503907..8dbfb0525ee48b 100644 --- a/components/viz/service/frame_sinks/video_capture/frame_sink_video_capturer_impl.h +++ b/components/viz/service/frame_sinks/video_capture/frame_sink_video_capturer_impl.h @@ -207,7 +207,7 @@ class VIZ_SERVICE_EXPORT FrameSinkVideoCapturerImpl final // Use the default base::TimeTicks clock; but allow unit tests to provide a // replacement. - base::TickClock* clock_; + const base::TickClock* clock_; // Current image format. media::VideoPixelFormat pixel_format_ = kDefaultPixelFormat; diff --git a/components/viz/service/frame_sinks/video_detector.cc b/components/viz/service/frame_sinks/video_detector.cc index 6bf93c22b3b3f2..c6762e62e2d5bf 100644 --- a/components/viz/service/frame_sinks/video_detector.cc +++ b/components/viz/service/frame_sinks/video_detector.cc @@ -89,7 +89,7 @@ class VideoDetector::ClientInfo { VideoDetector::VideoDetector( SurfaceManager* surface_manager, - std::unique_ptr tick_clock, + std::unique_ptr tick_clock, scoped_refptr task_runner) : tick_clock_(std::move(tick_clock)), video_inactive_timer_(tick_clock_.get()), diff --git a/components/viz/service/frame_sinks/video_detector.h b/components/viz/service/frame_sinks/video_detector.h index 319a6790667fea..de32e6bf201ec2 100644 --- a/components/viz/service/frame_sinks/video_detector.h +++ b/components/viz/service/frame_sinks/video_detector.h @@ -29,7 +29,7 @@ class VideoDetectorTest; class VIZ_SERVICE_EXPORT VideoDetector : public SurfaceObserver { public: VideoDetector(SurfaceManager* surface_manager, - std::unique_ptr tick_clock = + std::unique_ptr tick_clock = std::make_unique(), scoped_refptr task_runner = nullptr); virtual ~VideoDetector(); @@ -87,7 +87,7 @@ class VIZ_SERVICE_EXPORT VideoDetector : public SurfaceObserver { bool video_is_playing_ = false; // Provides the current time. - std::unique_ptr tick_clock_; + std::unique_ptr tick_clock_; // Calls OnVideoActivityEnded() after |kVideoTimeout|. Uses |tick_clock_| to // measure time. diff --git a/components/viz/service/surfaces/surface_dependency_deadline.cc b/components/viz/service/surfaces/surface_dependency_deadline.cc index 14678e8ab19458..f60a39b08afe42 100644 --- a/components/viz/service/surfaces/surface_dependency_deadline.cc +++ b/components/viz/service/surfaces/surface_dependency_deadline.cc @@ -14,7 +14,7 @@ namespace viz { SurfaceDependencyDeadline::SurfaceDependencyDeadline( SurfaceDeadlineClient* client, BeginFrameSource* begin_frame_source, - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : client_(client), begin_frame_source_(begin_frame_source), tick_clock_(tick_clock) { diff --git a/components/viz/service/surfaces/surface_dependency_deadline.h b/components/viz/service/surfaces/surface_dependency_deadline.h index 6bc6902595ff13..bc5913b7ed3e6b 100644 --- a/components/viz/service/surfaces/surface_dependency_deadline.h +++ b/components/viz/service/surfaces/surface_dependency_deadline.h @@ -22,7 +22,7 @@ class VIZ_SERVICE_EXPORT SurfaceDependencyDeadline : public BeginFrameObserver { public: SurfaceDependencyDeadline(SurfaceDeadlineClient* client, BeginFrameSource* begin_frame_source, - base::TickClock* tick_clock); + const base::TickClock* tick_clock); ~SurfaceDependencyDeadline() override; // Sets up a deadline in wall time where @@ -61,7 +61,7 @@ class VIZ_SERVICE_EXPORT SurfaceDependencyDeadline : public BeginFrameObserver { SurfaceDeadlineClient* const client_; BeginFrameSource* begin_frame_source_ = nullptr; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; base::TimeTicks start_time_; base::Optional deadline_; diff --git a/components/viz/service/surfaces/surface_dependency_deadline_unittest.cc b/components/viz/service/surfaces/surface_dependency_deadline_unittest.cc index 98bb7b3998fed8..1769edbe881bda 100644 --- a/components/viz/service/surfaces/surface_dependency_deadline_unittest.cc +++ b/components/viz/service/surfaces/surface_dependency_deadline_unittest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "components/viz/service/surfaces/surface_dependency_deadline.h" +#include "base/test/simple_test_tick_clock.h" #include "components/viz/common/quads/frame_deadline.h" #include "components/viz/service/surfaces/surface_deadline_client.h" #include "components/viz/test/begin_frame_args_test.h" diff --git a/components/viz/service/surfaces/surface_manager.cc b/components/viz/service/surfaces/surface_manager.cc index 67d1d6b4794588..7cff2021294c41 100644 --- a/components/viz/service/surfaces/surface_manager.cc +++ b/components/viz/service/surfaces/surface_manager.cc @@ -96,7 +96,7 @@ void SurfaceManager::SetActivationDeadlineInFramesForTesting( activation_deadline_in_frames_ = activation_deadline_in_frames; } -void SurfaceManager::SetTickClockForTesting(base::TickClock* tick_clock) { +void SurfaceManager::SetTickClockForTesting(const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } diff --git a/components/viz/service/surfaces/surface_manager.h b/components/viz/service/surfaces/surface_manager.h index 11bf3d3077d4dc..238e2093fc6dcd 100644 --- a/components/viz/service/surfaces/surface_manager.h +++ b/components/viz/service/surfaces/surface_manager.h @@ -73,10 +73,10 @@ class VIZ_SERVICE_EXPORT SurfaceManager { // Sets an alternative base::TickClock to pass into surfaces for surface // synchronization deadlines. This allows unit tests to mock the wall clock. - void SetTickClockForTesting(base::TickClock* tick_clock); + void SetTickClockForTesting(const base::TickClock* tick_clock); // Returns the base::TickClock used to set surface synchronization deadlines. - base::TickClock* tick_clock() { return tick_clock_; } + const base::TickClock* tick_clock() { return tick_clock_; } // Creates a Surface for the given SurfaceClient. The surface will be // destroyed when DestroySurface is called, all of its destruction @@ -325,7 +325,7 @@ class VIZ_SERVICE_EXPORT SurfaceManager { const base::flat_set empty_surface_id_set_; // Used for setting deadlines for surface synchronization. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Keeps track of surface references for a surface. The graph of references is // stored in both directions, so we know the parents and children for each diff --git a/components/viz/test/begin_frame_args_test.cc b/components/viz/test/begin_frame_args_test.cc index 9ada3f30fc2293..5f7c777be4f689 100644 --- a/components/viz/test/begin_frame_args_test.cc +++ b/components/viz/test/begin_frame_args_test.cc @@ -6,6 +6,7 @@ #include +#include "base/time/tick_clock.h" #include "base/time/time.h" #include "components/viz/common/frame_sinks/begin_frame_args.h" @@ -64,7 +65,7 @@ BeginFrameArgs CreateBeginFrameArgsForTesting( BeginFrameArgs::CreationLocation location, uint64_t source_id, uint64_t sequence_number, - base::SimpleTestTickClock* now_src) { + const base::TickClock* now_src) { base::TimeTicks now = now_src->NowTicks(); return BeginFrameArgs::Create( location, source_id, sequence_number, now, diff --git a/components/viz/test/begin_frame_args_test.h b/components/viz/test/begin_frame_args_test.h index f0584efc9f5e32..23cfae2a85c807 100644 --- a/components/viz/test/begin_frame_args_test.h +++ b/components/viz/test/begin_frame_args_test.h @@ -9,10 +9,13 @@ #include -#include "base/test/simple_test_tick_clock.h" #include "base/time/time.h" #include "components/viz/common/frame_sinks/begin_frame_args.h" +namespace base { +class TickClock; +} + namespace viz { // Functions for quickly creating BeginFrameArgs @@ -50,7 +53,7 @@ BeginFrameArgs CreateBeginFrameArgsForTesting( BeginFrameArgs::CreationLocation location, uint64_t source_id, uint64_t sequence_number, - base::SimpleTestTickClock* now_src); + const base::TickClock* now_src); // gtest helpers -- these *must* be in the same namespace as the types they // operate on. diff --git a/components/viz/test/fake_delay_based_time_source.cc b/components/viz/test/fake_delay_based_time_source.cc index 8e9647be5c5109..b39f4f11f0a6e5 100644 --- a/components/viz/test/fake_delay_based_time_source.cc +++ b/components/viz/test/fake_delay_based_time_source.cc @@ -4,6 +4,8 @@ #include "components/viz/test/fake_delay_based_time_source.h" +#include "base/time/tick_clock.h" + namespace viz { void FakeDelayBasedTimeSourceClient::OnTimerTick() { @@ -11,7 +13,7 @@ void FakeDelayBasedTimeSourceClient::OnTimerTick() { } FakeDelayBasedTimeSource::FakeDelayBasedTimeSource( - base::SimpleTestTickClock* now_src, + const base::TickClock* now_src, base::SingleThreadTaskRunner* task_runner) : DelayBasedTimeSource(task_runner), now_src_(now_src) {} diff --git a/components/viz/test/fake_delay_based_time_source.h b/components/viz/test/fake_delay_based_time_source.h index ce76ed6cedabdc..a8edd32b205803 100644 --- a/components/viz/test/fake_delay_based_time_source.h +++ b/components/viz/test/fake_delay_based_time_source.h @@ -5,10 +5,13 @@ #ifndef COMPONENTS_VIZ_TEST_FAKE_DELAY_BASED_TIME_SOURCE_H_ #define COMPONENTS_VIZ_TEST_FAKE_DELAY_BASED_TIME_SOURCE_H_ -#include "base/test/simple_test_tick_clock.h" #include "base/time/time.h" #include "components/viz/common/frame_sinks/delay_based_time_source.h" +namespace base { +class TickClock; +} + namespace viz { class FakeDelayBasedTimeSourceClient : public DelayBasedTimeSourceClient { @@ -29,7 +32,7 @@ class FakeDelayBasedTimeSourceClient : public DelayBasedTimeSourceClient { class FakeDelayBasedTimeSource : public DelayBasedTimeSource { public: - FakeDelayBasedTimeSource(base::SimpleTestTickClock* now_src, + FakeDelayBasedTimeSource(const base::TickClock* now_src, base::SingleThreadTaskRunner* task_runner); ~FakeDelayBasedTimeSource() override; @@ -39,7 +42,7 @@ class FakeDelayBasedTimeSource : public DelayBasedTimeSource { private: // Not owned. - base::SimpleTestTickClock* now_src_; + const base::TickClock* now_src_; DISALLOW_COPY_AND_ASSIGN(FakeDelayBasedTimeSource); }; diff --git a/components/viz/test/fake_external_begin_frame_source.cc b/components/viz/test/fake_external_begin_frame_source.cc index 3ec06760bee5bf..75a0b0d36889f4 100644 --- a/components/viz/test/fake_external_begin_frame_source.cc +++ b/components/viz/test/fake_external_begin_frame_source.cc @@ -75,7 +75,7 @@ bool FakeExternalBeginFrameSource::IsThrottled() const { BeginFrameArgs FakeExternalBeginFrameSource::CreateBeginFrameArgs( BeginFrameArgs::CreationLocation location, - base::SimpleTestTickClock* now_src) { + const base::TickClock* now_src) { return CreateBeginFrameArgsForTesting(location, source_id(), next_begin_frame_number_++, now_src); } diff --git a/components/viz/test/fake_external_begin_frame_source.h b/components/viz/test/fake_external_begin_frame_source.h index 0233238461decb..957067c5b7b3f0 100644 --- a/components/viz/test/fake_external_begin_frame_source.h +++ b/components/viz/test/fake_external_begin_frame_source.h @@ -14,7 +14,7 @@ #include "components/viz/common/frame_sinks/begin_frame_source.h" namespace base { -class SimpleTestTickClock; +class TickClock; } // namespace base namespace viz { @@ -43,7 +43,7 @@ class FakeExternalBeginFrameSource : public BeginFrameSource { BeginFrameArgs CreateBeginFrameArgs( BeginFrameArgs::CreationLocation location); BeginFrameArgs CreateBeginFrameArgs(BeginFrameArgs::CreationLocation location, - base::SimpleTestTickClock* now_src); + const base::TickClock* now_src); uint64_t next_begin_frame_number() const { return next_begin_frame_number_; } void TestOnBeginFrame(const BeginFrameArgs& args); diff --git a/content/browser/indexed_db/indexed_db_tombstone_sweeper.h b/content/browser/indexed_db/indexed_db_tombstone_sweeper.h index 5ce9f30aa1ddc6..ef335a71440fe4 100644 --- a/content/browser/indexed_db/indexed_db_tombstone_sweeper.h +++ b/content/browser/indexed_db/indexed_db_tombstone_sweeper.h @@ -140,7 +140,7 @@ class CONTENT_EXPORT IndexedDBTombstoneSweeper sweep_state_.start_index_seed = index_seed; } - void SetClockForTesting(base::TickClock* clock) { + void SetClockForTesting(const base::TickClock* clock) { clock_for_testing_ = clock; } @@ -177,7 +177,7 @@ class CONTENT_EXPORT IndexedDBTombstoneSweeper int total_indices_ = 0; // Used to measure total time of the task. - base::TickClock* clock_for_testing_ = nullptr; + const base::TickClock* clock_for_testing_ = nullptr; base::Optional start_time_; leveldb::DB* database_ = nullptr; diff --git a/content/browser/media/audible_metrics.cc b/content/browser/media/audible_metrics.cc index b02977ca954b44..8244c11ad92906 100644 --- a/content/browser/media/audible_metrics.cc +++ b/content/browser/media/audible_metrics.cc @@ -31,7 +31,7 @@ void AudibleMetrics::UpdateAudibleWebContentsState( RemoveAudibleWebContents(web_contents); } -void AudibleMetrics::SetClockForTest(base::TickClock* test_clock) { +void AudibleMetrics::SetClockForTest(const base::TickClock* test_clock) { clock_ = test_clock; } diff --git a/content/browser/media/audible_metrics.h b/content/browser/media/audible_metrics.h index 3c90da942d4fbf..02d98671223203 100644 --- a/content/browser/media/audible_metrics.h +++ b/content/browser/media/audible_metrics.h @@ -29,7 +29,7 @@ class CONTENT_EXPORT AudibleMetrics { void UpdateAudibleWebContentsState(const WebContents* web_contents, bool audible); - void SetClockForTest(base::TickClock* test_clock); + void SetClockForTest(const base::TickClock* test_clock); private: void AddAudibleWebContents(const WebContents* web_contents); @@ -37,7 +37,7 @@ class CONTENT_EXPORT AudibleMetrics { base::TimeTicks concurrent_web_contents_start_time_; size_t max_concurrent_audible_web_contents_in_session_; - base::TickClock* clock_; + const base::TickClock* clock_; std::set audible_web_contents_; diff --git a/content/browser/media/audio_stream_monitor.h b/content/browser/media/audio_stream_monitor.h index febec7c5a56fee..84a1a706e5118b 100644 --- a/content/browser/media/audio_stream_monitor.h +++ b/content/browser/media/audio_stream_monitor.h @@ -126,7 +126,7 @@ class CONTENT_EXPORT AudioStreamMonitor : public WebContentsObserver { // Note: |clock_| is always a DefaultTickClock, except during unit // testing. - base::TickClock* const clock_; + const base::TickClock* const clock_; // Confirms single-threaded access in debug builds. base::ThreadChecker thread_checker_; diff --git a/content/browser/media/audio_stream_monitor_unittest.cc b/content/browser/media/audio_stream_monitor_unittest.cc index 4b9dc715be9011..ffdea7dd6d85ed 100644 --- a/content/browser/media/audio_stream_monitor_unittest.cc +++ b/content/browser/media/audio_stream_monitor_unittest.cc @@ -58,7 +58,7 @@ class AudioStreamMonitorTest : public RenderViewHostTestHarness { web_contents->SetDelegate(&mock_web_contents_delegate_); monitor_ = web_contents->audio_stream_monitor(); - const_cast(monitor_->clock_) = &clock_; + const_cast(monitor_->clock_) = &clock_; } base::TimeTicks GetTestClockTime() { return clock_.NowTicks(); } diff --git a/content/browser/media/capture/desktop_capture_device.cc b/content/browser/media/capture/desktop_capture_device.cc index 25f88391161a20..81f5b5f88742f1 100644 --- a/content/browser/media/capture/desktop_capture_device.cc +++ b/content/browser/media/capture/desktop_capture_device.cc @@ -117,7 +117,7 @@ class DesktopCaptureDevice::Core : public webrtc::DesktopCapturer::Callback { void SetMockTimeForTesting( scoped_refptr task_runner, - base::TickClock* tick_clock); + const base::TickClock* tick_clock); private: // webrtc::DesktopCapturer::Callback interface. @@ -166,7 +166,7 @@ class DesktopCaptureDevice::Core : public webrtc::DesktopCapturer::Callback { // be returned to the caller directly then this is NULL. std::unique_ptr output_frame_; - base::TickClock* tick_clock_ = nullptr; + const base::TickClock* tick_clock_ = nullptr; // Timer used to capture the frame. std::unique_ptr capture_timer_; @@ -271,7 +271,7 @@ void DesktopCaptureDevice::Core::SetNotificationWindowId( void DesktopCaptureDevice::Core::SetMockTimeForTesting( scoped_refptr task_runner, - base::TickClock* tick_clock) { + const base::TickClock* tick_clock) { tick_clock_ = tick_clock; capture_timer_.reset(new base::OneShotTimer(tick_clock_)); capture_timer_->SetTaskRunner(task_runner); @@ -578,7 +578,7 @@ DesktopCaptureDevice::DesktopCaptureDevice( void DesktopCaptureDevice::SetMockTimeForTesting( scoped_refptr task_runner, - base::TickClock* tick_clock) { + const base::TickClock* tick_clock) { core_->SetMockTimeForTesting(task_runner, tick_clock); } diff --git a/content/browser/media/capture/desktop_capture_device.h b/content/browser/media/capture/desktop_capture_device.h index 2c1b9e8f753942..07719176eeaea7 100644 --- a/content/browser/media/capture/desktop_capture_device.h +++ b/content/browser/media/capture/desktop_capture_device.h @@ -63,7 +63,7 @@ class CONTENT_EXPORT DesktopCaptureDevice : public media::VideoCaptureDevice { // other testing entities inheriting the common runner and tick interfaces. void SetMockTimeForTesting( scoped_refptr task_runner, - base::TickClock* tick_clock); + const base::TickClock* tick_clock); base::Thread thread_; std::unique_ptr core_; diff --git a/content/browser/media/session/media_session_uma_helper.cc b/content/browser/media/session/media_session_uma_helper.cc index 10073466529667..32195e450cb3d7 100644 --- a/content/browser/media/session/media_session_uma_helper.cc +++ b/content/browser/media/session/media_session_uma_helper.cc @@ -65,7 +65,8 @@ void MediaSessionUmaHelper::OnSessionInactive() { total_active_time_ = base::TimeDelta(); } -void MediaSessionUmaHelper::SetClockForTest(base::TickClock* testing_clock) { +void MediaSessionUmaHelper::SetClockForTest( + const base::TickClock* testing_clock) { clock_ = testing_clock; } diff --git a/content/browser/media/session/media_session_uma_helper.h b/content/browser/media/session/media_session_uma_helper.h index bd928c3e016cae..99f40c552e9dc4 100644 --- a/content/browser/media/session/media_session_uma_helper.h +++ b/content/browser/media/session/media_session_uma_helper.h @@ -58,12 +58,12 @@ class CONTENT_EXPORT MediaSessionUmaHelper { void OnSessionSuspended(); void OnSessionInactive(); - void SetClockForTest(base::TickClock* testing_clock); + void SetClockForTest(const base::TickClock* testing_clock); private: base::TimeDelta total_active_time_; base::TimeTicks current_active_time_; - base::TickClock* clock_; + const base::TickClock* clock_; }; } // namespace content diff --git a/content/browser/memory/memory_coordinator_impl.cc b/content/browser/memory/memory_coordinator_impl.cc index bcae711ddd8dec..c5a1eb246bd2a5 100644 --- a/content/browser/memory/memory_coordinator_impl.cc +++ b/content/browser/memory/memory_coordinator_impl.cc @@ -335,7 +335,7 @@ void MemoryCoordinatorImpl::AddChildForTesting( } void MemoryCoordinatorImpl::SetTickClockForTesting( - base::TickClock* tick_clock) { + const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } diff --git a/content/browser/memory/memory_coordinator_impl.h b/content/browser/memory/memory_coordinator_impl.h index 48de5510b6b755..7291b1e03b31f1 100644 --- a/content/browser/memory/memory_coordinator_impl.h +++ b/content/browser/memory/memory_coordinator_impl.h @@ -166,7 +166,7 @@ class CONTENT_EXPORT MemoryCoordinatorImpl : public base::MemoryCoordinator, mojom::ChildMemoryCoordinatorPtr child); // Sets a TickClock for testing. - void SetTickClockForTesting(base::TickClock* tick_clock); + void SetTickClockForTesting(const base::TickClock* tick_clock); // Callback invoked by mojo when the child connection goes down. Exposed // for testing. @@ -204,7 +204,7 @@ class CONTENT_EXPORT MemoryCoordinatorImpl : public base::MemoryCoordinator, std::unique_ptr delegate_; std::unique_ptr memory_monitor_; std::unique_ptr condition_observer_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; NotificationRegistrar notification_registrar_; // The current memory condition. diff --git a/content/browser/renderer_host/delegated_frame_host.h b/content/browser/renderer_host/delegated_frame_host.h index 5e6c05d572e771..1047ecd63cfadd 100644 --- a/content/browser/renderer_host/delegated_frame_host.h +++ b/content/browser/renderer_host/delegated_frame_host.h @@ -256,7 +256,7 @@ class CONTENT_EXPORT DelegatedFrameHost gfx::Size current_frame_size_in_dip_; // Overridable tick clock used for testing functions using current time. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // True after a delegated frame has been skipped, until a frame is not // skipped. diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h index 71d6cd0f0ed49f..fe65b5363f59d8 100644 --- a/content/browser/renderer_host/render_widget_host_impl.h +++ b/content/browser/renderer_host/render_widget_host_impl.h @@ -167,7 +167,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl RenderWidgetHostOwnerDelegate* owner_delegate() { return owner_delegate_; } - void set_clock_for_testing(base::TickClock* clock) { clock_ = clock; } + void set_clock_for_testing(const base::TickClock* clock) { clock_ = clock; } // Returns the viz::FrameSinkId that this object uses to put things on screen. // This value is constant throughout the lifetime of this object. Note that @@ -904,7 +904,7 @@ class CONTENT_EXPORT RenderWidgetHostImpl const int routing_id_; // The clock used; overridable for tests. - base::TickClock* clock_; + const base::TickClock* clock_; // Indicates whether a page is loading or not. bool is_loading_; diff --git a/content/browser/service_worker/service_worker_lifetime_tracker.cc b/content/browser/service_worker/service_worker_lifetime_tracker.cc index 6a6d28cf06201d..9cb281539724ed 100644 --- a/content/browser/service_worker/service_worker_lifetime_tracker.cc +++ b/content/browser/service_worker/service_worker_lifetime_tracker.cc @@ -15,7 +15,7 @@ ServiceWorkerLifetimeTracker::ServiceWorkerLifetimeTracker() : ServiceWorkerLifetimeTracker(base::DefaultTickClock::GetInstance()) {} ServiceWorkerLifetimeTracker::ServiceWorkerLifetimeTracker( - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : tick_clock_(tick_clock) {} ServiceWorkerLifetimeTracker::~ServiceWorkerLifetimeTracker() = default; diff --git a/content/browser/service_worker/service_worker_lifetime_tracker.h b/content/browser/service_worker/service_worker_lifetime_tracker.h index 12b0eb16c23963..39a82aacf3373d 100644 --- a/content/browser/service_worker/service_worker_lifetime_tracker.h +++ b/content/browser/service_worker/service_worker_lifetime_tracker.h @@ -22,7 +22,7 @@ namespace content { class CONTENT_EXPORT ServiceWorkerLifetimeTracker { public: ServiceWorkerLifetimeTracker(); - explicit ServiceWorkerLifetimeTracker(base::TickClock* tick_clock); + explicit ServiceWorkerLifetimeTracker(const base::TickClock* tick_clock); virtual ~ServiceWorkerLifetimeTracker(); // Called when the worker started running. @@ -38,7 +38,7 @@ class CONTENT_EXPORT ServiceWorkerLifetimeTracker { void RecordHistograms(); - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; std::map running_workers_; diff --git a/content/browser/service_worker/service_worker_version.cc b/content/browser/service_worker/service_worker_version.cc index de4158fb160fd2..c1d31cab6fe53e 100644 --- a/content/browser/service_worker/service_worker_version.cc +++ b/content/browser/service_worker/service_worker_version.cc @@ -887,7 +887,8 @@ void ServiceWorkerVersion::SimulatePingTimeoutForTesting() { ping_controller_->SimulateTimeoutForTesting(); } -void ServiceWorkerVersion::SetTickClockForTesting(base::TickClock* tick_clock) { +void ServiceWorkerVersion::SetTickClockForTesting( + const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } diff --git a/content/browser/service_worker/service_worker_version.h b/content/browser/service_worker/service_worker_version.h index bc89aadc9dd751..62964bc6799962 100644 --- a/content/browser/service_worker/service_worker_version.h +++ b/content/browser/service_worker/service_worker_version.h @@ -438,7 +438,7 @@ class CONTENT_EXPORT ServiceWorkerVersion void SimulatePingTimeoutForTesting(); // Used to allow tests to change time for testing. - void SetTickClockForTesting(base::TickClock* tick_clock); + void SetTickClockForTesting(const base::TickClock* tick_clock); // Used to allow tests to change wall clock for testing. void SetClockForTesting(base::Clock* clock); @@ -835,7 +835,7 @@ class CONTENT_EXPORT ServiceWorkerVersion ServiceWorkerStatusCode start_worker_status_ = SERVICE_WORKER_OK; // The clock used to vend tick time. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // The clock used for actual (wall clock) time base::Clock* clock_; diff --git a/content/renderer/media/render_media_log.cc b/content/renderer/media/render_media_log.cc index 6d85af8ac0a6e4..380f66397c5a8f 100644 --- a/content/renderer/media/render_media_log.cc +++ b/content/renderer/media/render_media_log.cc @@ -184,7 +184,7 @@ void RenderMediaLog::SendQueuedMediaEvents() { RenderThread::Get()->Send(new ViewHostMsg_MediaLogEvents(events_to_send)); } -void RenderMediaLog::SetTickClockForTesting(base::TickClock* tick_clock) { +void RenderMediaLog::SetTickClockForTesting(const base::TickClock* tick_clock) { base::AutoLock auto_lock(lock_); tick_clock_ = tick_clock; last_ipc_send_time_ = tick_clock_->NowTicks(); diff --git a/content/renderer/media/render_media_log.h b/content/renderer/media/render_media_log.h index e964388a903bcf..e3110a8a5a3ad9 100644 --- a/content/renderer/media/render_media_log.h +++ b/content/renderer/media/render_media_log.h @@ -44,7 +44,7 @@ class CONTENT_EXPORT RenderMediaLog : public media::MediaLog { void RecordRapporWithSecurityOrigin(const std::string& metric) override; // Will reset |last_ipc_send_time_| with the value of NowTicks(). - void SetTickClockForTesting(base::TickClock* tick_clock); + void SetTickClockForTesting(const base::TickClock* tick_clock); void SetTaskRunnerForTesting( const scoped_refptr& task_runner); @@ -63,7 +63,7 @@ class CONTENT_EXPORT RenderMediaLog : public media::MediaLog { // sequence for throttled send on |task_runner_| and coherent retrieval by // GetErrorMessage(). mutable base::Lock lock_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; base::TimeTicks last_ipc_send_time_; std::vector queued_media_events_; diff --git a/content/renderer/media/renderer_webmediaplayer_delegate.cc b/content/renderer/media/renderer_webmediaplayer_delegate.cc index 9830f92f1b0f6a..7adf82dab767ed 100644 --- a/content/renderer/media/renderer_webmediaplayer_delegate.cc +++ b/content/renderer/media/renderer_webmediaplayer_delegate.cc @@ -255,7 +255,7 @@ bool RendererWebMediaPlayerDelegate::OnMessageReceived( void RendererWebMediaPlayerDelegate::SetIdleCleanupParamsForTesting( base::TimeDelta idle_timeout, base::TimeDelta idle_cleanup_interval, - base::TickClock* tick_clock, + const base::TickClock* tick_clock, bool is_jelly_bean) { idle_cleanup_interval_ = idle_cleanup_interval; idle_timeout_ = idle_timeout; diff --git a/content/renderer/media/renderer_webmediaplayer_delegate.h b/content/renderer/media/renderer_webmediaplayer_delegate.h index a0c5bf8edc96a9..913e1444e0b640 100644 --- a/content/renderer/media/renderer_webmediaplayer_delegate.h +++ b/content/renderer/media/renderer_webmediaplayer_delegate.h @@ -79,7 +79,7 @@ class CONTENT_EXPORT RendererWebMediaPlayerDelegate // will cause the idle timer to run with each run of the message loop. void SetIdleCleanupParamsForTesting(base::TimeDelta idle_timeout, base::TimeDelta idle_cleanup_interval, - base::TickClock* tick_clock, + const base::TickClock* tick_clock, bool is_jelly_bean); bool IsIdleCleanupTimerRunningForTesting() const; @@ -144,7 +144,7 @@ class CONTENT_EXPORT RendererWebMediaPlayerDelegate // Clock used for calculating when players have become stale. May be // overridden for testing. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; #if defined(OS_ANDROID) bool was_playing_background_video_ = false; diff --git a/content/renderer/service_worker/service_worker_timeout_timer.cc b/content/renderer/service_worker/service_worker_timeout_timer.cc index 003961c0aaa009..83b78f2fb59bf9 100644 --- a/content/renderer/service_worker/service_worker_timeout_timer.cc +++ b/content/renderer/service_worker/service_worker_timeout_timer.cc @@ -36,7 +36,7 @@ ServiceWorkerTimeoutTimer::ServiceWorkerTimeoutTimer( ServiceWorkerTimeoutTimer::ServiceWorkerTimeoutTimer( base::RepeatingClosure idle_callback, - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : idle_callback_(std::move(idle_callback)), tick_clock_(tick_clock) { // |idle_callback_| will be invoked if no event happens in |kIdleDelay|. idle_time_ = tick_clock_->NowTicks() + kIdleDelay; diff --git a/content/renderer/service_worker/service_worker_timeout_timer.h b/content/renderer/service_worker/service_worker_timeout_timer.h index 787a7b4f405ad8..484f7e156f5e84 100644 --- a/content/renderer/service_worker/service_worker_timeout_timer.h +++ b/content/renderer/service_worker/service_worker_timeout_timer.h @@ -47,7 +47,7 @@ class CONTENT_EXPORT ServiceWorkerTimeoutTimer { explicit ServiceWorkerTimeoutTimer(base::RepeatingClosure idle_callback); // For testing. ServiceWorkerTimeoutTimer(base::RepeatingClosure idle_callback, - base::TickClock* tick_clock); + const base::TickClock* tick_clock); ~ServiceWorkerTimeoutTimer(); // StartEvent() should be called at the beginning of an event. It returns an @@ -143,7 +143,7 @@ class CONTENT_EXPORT ServiceWorkerTimeoutTimer { base::RepeatingTimer timer_; // |tick_clock_| outlives |this|. - base::TickClock* const tick_clock_; + const base::TickClock* const tick_clock_; }; } // namespace content diff --git a/extensions/browser/api/feedback_private/access_rate_limiter.cc b/extensions/browser/api/feedback_private/access_rate_limiter.cc index e13c5508856f32..6d3a2fa26f1b9b 100644 --- a/extensions/browser/api/feedback_private/access_rate_limiter.cc +++ b/extensions/browser/api/feedback_private/access_rate_limiter.cc @@ -8,7 +8,7 @@ namespace extensions { AccessRateLimiter::AccessRateLimiter(size_t max_num_accesses, const base::TimeDelta& recharge_period, - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : max_num_accesses_(max_num_accesses), recharge_period_(recharge_period), counter_(recharge_period * max_num_accesses), diff --git a/extensions/browser/api/feedback_private/access_rate_limiter.h b/extensions/browser/api/feedback_private/access_rate_limiter.h index d04067082c1738..e8153bc688973e 100644 --- a/extensions/browser/api/feedback_private/access_rate_limiter.h +++ b/extensions/browser/api/feedback_private/access_rate_limiter.h @@ -49,7 +49,7 @@ class AccessRateLimiter { public: AccessRateLimiter(size_t max_num_accesses, const base::TimeDelta& recharge_period, - base::TickClock* tick_clock); + const base::TickClock* tick_clock); ~AccessRateLimiter(); // Attempt to access a resource. Will update |counter_| based on how much time @@ -76,7 +76,7 @@ class AccessRateLimiter { base::TimeDelta counter_; // Points to a timer clock implementation for keeping track of access times. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; DISALLOW_COPY_AND_ASSIGN(AccessRateLimiter); }; diff --git a/extensions/browser/api/feedback_private/log_source_access_manager.h b/extensions/browser/api/feedback_private/log_source_access_manager.h index 86ac1e5f67acb5..56d409a9734c4c 100644 --- a/extensions/browser/api/feedback_private/log_source_access_manager.h +++ b/extensions/browser/api/feedback_private/log_source_access_manager.h @@ -47,7 +47,9 @@ class LogSourceAccessManager { static void SetRateLimitingTimeoutForTesting(const base::TimeDelta* timeout); // Override the default base::Time clock with a custom clock for testing. - void SetTickClockForTesting(base::TickClock* clock) { tick_clock_ = clock; } + void SetTickClockForTesting(const base::TickClock* clock) { + tick_clock_ = clock; + } // Initiates a fetch from a log source, as specified in |params|. See // feedback_private.idl for more info about the actual parameters. @@ -151,7 +153,7 @@ class LogSourceAccessManager { // Provides a timer clock implementation for keeping track of access times. // Can override the default clock for testing. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // For removing PII from log strings from log sources. scoped_refptr task_runner_for_anonymizer_; diff --git a/extensions/browser/api/lock_screen_data/lock_screen_item_storage.h b/extensions/browser/api/lock_screen_data/lock_screen_item_storage.h index db64decc80995f..e1c5361d26dca9 100644 --- a/extensions/browser/api/lock_screen_data/lock_screen_item_storage.h +++ b/extensions/browser/api/lock_screen_data/lock_screen_item_storage.h @@ -305,7 +305,7 @@ class LockScreenItemStorage : public ExtensionRegistryObserver { const std::string crypto_key_; PrefService* local_state_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; SessionLockedState session_locked_state_ = SessionLockedState::kUnknown; diff --git a/extensions/test/logging_timer.cc b/extensions/test/logging_timer.cc index e8169d0841aa96..7713152dc83123 100644 --- a/extensions/test/logging_timer.cc +++ b/extensions/test/logging_timer.cc @@ -14,7 +14,7 @@ namespace extensions { namespace { -base::TickClock* g_clock_for_testing = nullptr; +const base::TickClock* g_clock_for_testing = nullptr; // A global record of all tracked times. class TimeTracker { @@ -89,7 +89,7 @@ void LoggingTimer::Print() { } // static -void LoggingTimer::set_clock_for_testing(base::TickClock* clock) { +void LoggingTimer::set_clock_for_testing(const base::TickClock* clock) { g_clock_for_testing = clock; } diff --git a/extensions/test/logging_timer.h b/extensions/test/logging_timer.h index 1b6e1fce481800..660eef8328a0df 100644 --- a/extensions/test/logging_timer.h +++ b/extensions/test/logging_timer.h @@ -70,7 +70,7 @@ class LoggingTimer { // Allows for setting a test clock. Otherwise, defaults to using // base::TimeTicks::Now(). - static void set_clock_for_testing(base::TickClock* clock); + static void set_clock_for_testing(const base::TickClock* clock); private: // When the timer started. We don't use base::ElapsedTimer so that we can diff --git a/media/audio/alsa/alsa_output.cc b/media/audio/alsa/alsa_output.cc index 830d25bf5ad3a2..02ac80e2b981af 100644 --- a/media/audio/alsa/alsa_output.cc +++ b/media/audio/alsa/alsa_output.cc @@ -351,7 +351,8 @@ void AlsaPcmOutputStream::GetVolume(double* volume) { *volume = volume_; } -void AlsaPcmOutputStream::SetTickClockForTesting(base::TickClock* tick_clock) { +void AlsaPcmOutputStream::SetTickClockForTesting( + const base::TickClock* tick_clock) { DCHECK(tick_clock); tick_clock_ = tick_clock; } diff --git a/media/audio/alsa/alsa_output.h b/media/audio/alsa/alsa_output.h index 7c2cd1b9ab6fd9..000807d6963d41 100644 --- a/media/audio/alsa/alsa_output.h +++ b/media/audio/alsa/alsa_output.h @@ -84,7 +84,7 @@ class MEDIA_EXPORT AlsaPcmOutputStream : public AudioOutputStream { void SetVolume(double volume) override; void GetVolume(double* volume) override; - void SetTickClockForTesting(base::TickClock* tick_clock); + void SetTickClockForTesting(const base::TickClock* tick_clock); private: friend class AlsaPcmOutputStreamTest; @@ -211,7 +211,7 @@ class MEDIA_EXPORT AlsaPcmOutputStream : public AudioOutputStream { std::unique_ptr channel_mixer_; std::unique_ptr mixed_audio_bus_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; SEQUENCE_CHECKER(sequence_checker_); diff --git a/media/audio/android/audio_track_output_stream.h b/media/audio/android/audio_track_output_stream.h index 926f7d123c553c..8cb2ba0e73deed 100644 --- a/media/audio/android/audio_track_output_stream.h +++ b/media/audio/android/audio_track_output_stream.h @@ -54,7 +54,7 @@ class MEDIA_EXPORT AudioTrackOutputStream : public MuteableAudioOutputStream { // Extra buffer for PCM format. std::unique_ptr audio_bus_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Java AudioTrackOutputStream instance. base::android::ScopedJavaGlobalRef j_audio_output_stream_; diff --git a/media/audio/win/audio_device_listener_win.h b/media/audio/win/audio_device_listener_win.h index e82162ed0d7fdd..ae933eff8ec5c3 100644 --- a/media/audio/win/audio_device_listener_win.h +++ b/media/audio/win/audio_device_listener_win.h @@ -65,7 +65,7 @@ class MEDIA_EXPORT AudioDeviceListenerWin : public IMMNotificationClient { // AudioDeviceListenerWin must be constructed and destructed on one thread. base::ThreadChecker thread_checker_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; DISALLOW_COPY_AND_ASSIGN(AudioDeviceListenerWin); }; diff --git a/media/base/android/media_codec_loop.cc b/media/base/android/media_codec_loop.cc index 4d2213914c0375..21c98d2323d411 100644 --- a/media/base/android/media_codec_loop.cc +++ b/media/base/android/media_codec_loop.cc @@ -58,7 +58,7 @@ MediaCodecLoop::~MediaCodecLoop() { io_timer_.Stop(); } -void MediaCodecLoop::SetTestTickClock(base::TickClock* test_tick_clock) { +void MediaCodecLoop::SetTestTickClock(const base::TickClock* test_tick_clock) { test_tick_clock_ = test_tick_clock; } diff --git a/media/base/android/media_codec_loop.h b/media/base/android/media_codec_loop.h index df2654c7e666d8..539cb241f45b49 100644 --- a/media/base/android/media_codec_loop.h +++ b/media/base/android/media_codec_loop.h @@ -209,7 +209,7 @@ class MEDIA_EXPORT MediaCodecLoop { // Optionally set the tick clock used for testing. It is our caller's // responsibility to maintain ownership of this, since // FakeSingleThreadTaskRunner maintains a raw ptr to it also. - void SetTestTickClock(base::TickClock* test_tick_clock); + void SetTestTickClock(const base::TickClock* test_tick_clock); // Does the MediaCodec processing cycle: enqueues an input buffer, then // dequeues output buffers. This should be called by the client when more @@ -313,7 +313,7 @@ class MEDIA_EXPORT MediaCodecLoop { // Optional clock for use during testing. It may be null. We do not maintain // ownership of it. - base::TickClock* test_tick_clock_ = nullptr; + const base::TickClock* test_tick_clock_ = nullptr; // Has the value of BuildInfo::sdk_int(), except in tests where it // might be set to other values. Will not be needed when there is a diff --git a/media/base/android/media_service_throttler.cc b/media/base/android/media_service_throttler.cc index 74817eb80f4395..2d69884be8718d 100644 --- a/media/base/android/media_service_throttler.cc +++ b/media/base/android/media_service_throttler.cc @@ -94,7 +94,8 @@ MediaServiceThrottler::MediaServiceThrottler() EnsureCrashListenerStarted(); } -void MediaServiceThrottler::SetTickClockForTesting(base::TickClock* clock) { +void MediaServiceThrottler::SetTickClockForTesting( + const base::TickClock* clock) { clock_ = clock; } diff --git a/media/base/android/media_service_throttler.h b/media/base/android/media_service_throttler.h index ed42b8e0547b05..3c7c34b7c53d4a 100644 --- a/media/base/android/media_service_throttler.h +++ b/media/base/android/media_service_throttler.h @@ -49,7 +49,7 @@ class MEDIA_EXPORT MediaServiceThrottler { base::TimeDelta GetDelayForClientCreation(); // Test only methods. - void SetTickClockForTesting(base::TickClock* clock); + void SetTickClockForTesting(const base::TickClock* clock); void ResetInternalStateForTesting(); base::TimeDelta GetBaseThrottlingRateForTesting(); bool IsCrashListenerAliveForTesting(); @@ -79,7 +79,7 @@ class MEDIA_EXPORT MediaServiceThrottler { // based on |current_crashes_|. base::TimeDelta GetThrottlingDelayFromServerCrashes(); - base::TickClock* clock_; + const base::TickClock* clock_; // Effective number of media server crashes. // NOTE: This is of type double because we decay the number of crashes at a diff --git a/media/base/null_video_sink.h b/media/base/null_video_sink.h index 763602b38ab8b0..54cd9549e627be 100644 --- a/media/base/null_video_sink.h +++ b/media/base/null_video_sink.h @@ -38,7 +38,7 @@ class MEDIA_EXPORT NullVideoSink : public VideoRendererSink { void PaintSingleFrame(const scoped_refptr& frame, bool repaint_duplicate_frame) override; - void set_tick_clock_for_testing(base::TickClock* tick_clock) { + void set_tick_clock_for_testing(const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } @@ -81,7 +81,7 @@ class MEDIA_EXPORT NullVideoSink : public VideoRendererSink { base::TimeTicks last_now_; // If specified, used instead of a DefaultTickClock. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // If set, called when Stop() is called. base::Closure stop_cb_; diff --git a/media/base/time_delta_interpolator.cc b/media/base/time_delta_interpolator.cc index 2385e501296b9d..cbfe38d8765c86 100644 --- a/media/base/time_delta_interpolator.cc +++ b/media/base/time_delta_interpolator.cc @@ -14,7 +14,7 @@ namespace media { -TimeDeltaInterpolator::TimeDeltaInterpolator(base::TickClock* tick_clock) +TimeDeltaInterpolator::TimeDeltaInterpolator(const base::TickClock* tick_clock) : tick_clock_(tick_clock), interpolating_(false), upper_bound_(kNoTimestamp), diff --git a/media/base/time_delta_interpolator.h b/media/base/time_delta_interpolator.h index a2e306402c98ec..9a02eada2e53a3 100644 --- a/media/base/time_delta_interpolator.h +++ b/media/base/time_delta_interpolator.h @@ -24,7 +24,7 @@ class MEDIA_EXPORT TimeDeltaInterpolator { // Constructs an interpolator initialized to zero with a rate of 1.0. // // |tick_clock| is used for sampling wall clock time for interpolating. - explicit TimeDeltaInterpolator(base::TickClock* tick_clock); + explicit TimeDeltaInterpolator(const base::TickClock* tick_clock); ~TimeDeltaInterpolator(); bool interpolating() { return interpolating_; } @@ -63,7 +63,7 @@ class MEDIA_EXPORT TimeDeltaInterpolator { base::TimeDelta GetInterpolatedTime(); private: - base::TickClock* const tick_clock_; + const base::TickClock* const tick_clock_; bool interpolating_; diff --git a/media/base/video_frame_pool.cc b/media/base/video_frame_pool.cc index ccc63cfc9f853d..a58fcf6fd0edae 100644 --- a/media/base/video_frame_pool.cc +++ b/media/base/video_frame_pool.cc @@ -33,7 +33,7 @@ class VideoFramePool::PoolImpl size_t get_pool_size_for_testing() const { return frames_.size(); } - void set_tick_clock_for_testing(base::TickClock* tick_clock) { + void set_tick_clock_for_testing(const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } @@ -59,7 +59,7 @@ class VideoFramePool::PoolImpl base::circular_deque frames_; // |tick_clock_| is always a DefaultTickClock outside of testing. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; DISALLOW_COPY_AND_ASSIGN(PoolImpl); }; @@ -160,7 +160,7 @@ size_t VideoFramePool::GetPoolSizeForTesting() const { return pool_->get_pool_size_for_testing(); } -void VideoFramePool::SetTickClockForTesting(base::TickClock* tick_clock) { +void VideoFramePool::SetTickClockForTesting(const base::TickClock* tick_clock) { pool_->set_tick_clock_for_testing(tick_clock); } diff --git a/media/base/video_frame_pool.h b/media/base/video_frame_pool.h index 54631b1998bbbb..e6532b4bf41f4d 100644 --- a/media/base/video_frame_pool.h +++ b/media/base/video_frame_pool.h @@ -48,7 +48,7 @@ class MEDIA_EXPORT VideoFramePool { size_t GetPoolSizeForTesting() const; // Allows injection of a base::SimpleTestClock for testing. - void SetTickClockForTesting(base::TickClock* tick_clock); + void SetTickClockForTesting(const base::TickClock* tick_clock); private: class PoolImpl; diff --git a/media/base/wall_clock_time_source.h b/media/base/wall_clock_time_source.h index b32da4fd4d06ec..1e4ddaa3d700be 100644 --- a/media/base/wall_clock_time_source.h +++ b/media/base/wall_clock_time_source.h @@ -29,7 +29,7 @@ class MEDIA_EXPORT WallClockTimeSource : public TimeSource { const std::vector& media_timestamps, std::vector* wall_clock_times) override; - void set_tick_clock_for_testing(base::TickClock* tick_clock) { + void set_tick_clock_for_testing(const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } @@ -37,7 +37,7 @@ class MEDIA_EXPORT WallClockTimeSource : public TimeSource { base::TimeDelta CurrentMediaTime_Locked(); // Allow for an injectable tick clock for testing. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; bool ticking_; diff --git a/media/blink/buffered_data_source_host_impl.cc b/media/blink/buffered_data_source_host_impl.cc index 15fa194ef10f3c..2c111cc96836da 100644 --- a/media/blink/buffered_data_source_host_impl.cc +++ b/media/blink/buffered_data_source_host_impl.cc @@ -25,7 +25,7 @@ constexpr int64_t kDownloadHistoryMinBytesPerEntry = 1000; BufferedDataSourceHostImpl::BufferedDataSourceHostImpl( base::RepeatingClosure progress_cb, - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : total_bytes_(0), did_loading_progress_(false), progress_cb_(std::move(progress_cb)), @@ -180,7 +180,7 @@ bool BufferedDataSourceHostImpl::CanPlayThrough( } void BufferedDataSourceHostImpl::SetTickClockForTest( - base::TickClock* tick_clock) { + const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } diff --git a/media/blink/buffered_data_source_host_impl.h b/media/blink/buffered_data_source_host_impl.h index 5dd0c003e2d2e1..fbcaa207cc4841 100644 --- a/media/blink/buffered_data_source_host_impl.h +++ b/media/blink/buffered_data_source_host_impl.h @@ -40,7 +40,7 @@ class MEDIA_BLINK_EXPORT BufferedDataSourceHostImpl : public BufferedDataSourceHost { public: BufferedDataSourceHostImpl(base::Closure progress_cb, - base::TickClock* tick_clock); + const base::TickClock* tick_clock); ~BufferedDataSourceHostImpl() override; // BufferedDataSourceHost implementation. @@ -62,7 +62,7 @@ class MEDIA_BLINK_EXPORT BufferedDataSourceHostImpl double playback_rate) const; // Caller must make sure |tick_clock| is valid for lifetime of this object. - void SetTickClockForTest(base::TickClock* tick_clock); + void SetTickClockForTest(const base::TickClock* tick_clock); private: // Returns number of bytes not yet loaded in the given interval. @@ -88,7 +88,7 @@ class MEDIA_BLINK_EXPORT BufferedDataSourceHostImpl base::circular_deque> download_history_; base::Closure progress_cb_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; FRIEND_TEST_ALL_PREFIXES(BufferedDataSourceHostImplTest, CanPlayThrough); FRIEND_TEST_ALL_PREFIXES(BufferedDataSourceHostImplTest, diff --git a/media/blink/video_decode_stats_reporter.cc b/media/blink/video_decode_stats_reporter.cc index 9d445a7433b931..e760d47c9c6e5a 100644 --- a/media/blink/video_decode_stats_reporter.cc +++ b/media/blink/video_decode_stats_reporter.cc @@ -18,7 +18,7 @@ VideoDecodeStatsReporter::VideoDecodeStatsReporter( GetPipelineStatsCB get_pipeline_stats_cb, const VideoDecoderConfig& video_config, scoped_refptr task_runner, - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : kRecordingInterval( base::TimeDelta::FromMilliseconds(kRecordingIntervalMs)), kTinyFpsWindowDuration( diff --git a/media/blink/video_decode_stats_reporter.h b/media/blink/video_decode_stats_reporter.h index ac3d12614ad76d..e8fd8937dd9397 100644 --- a/media/blink/video_decode_stats_reporter.h +++ b/media/blink/video_decode_stats_reporter.h @@ -33,7 +33,8 @@ class MEDIA_BLINK_EXPORT VideoDecodeStatsReporter { GetPipelineStatsCB get_pipeline_stats_cb, const VideoDecoderConfig& video_config, scoped_refptr task_runner, - base::TickClock* tick_clock = base::DefaultTickClock::GetInstance()); + const base::TickClock* tick_clock = + base::DefaultTickClock::GetInstance()); ~VideoDecodeStatsReporter(); void OnPlaying(); @@ -152,7 +153,7 @@ class MEDIA_BLINK_EXPORT VideoDecodeStatsReporter { // Clock for |stats_cb_timer_| and getting current tick count (NowTicks()). // Tests may supply a mock clock via the constructor. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Timer for all stats callbacks. Timer interval will be dynamically set based // on state of reporter. See calls to RunStatsTimerAtIntervalMs(). diff --git a/media/blink/video_frame_compositor.h b/media/blink/video_frame_compositor.h index d86ad95a737c23..5c920fd49887e5 100644 --- a/media/blink/video_frame_compositor.h +++ b/media/blink/video_frame_compositor.h @@ -127,7 +127,7 @@ class MEDIA_BLINK_EXPORT VideoFrameCompositor : public VideoRendererSink, // Updates the rotation information for frames given to |submitter_|. void UpdateRotation(media::VideoRotation rotation); - void set_tick_clock_for_testing(base::TickClock* tick_clock) { + void set_tick_clock_for_testing(const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } @@ -182,7 +182,7 @@ class MEDIA_BLINK_EXPORT VideoFrameCompositor : public VideoRendererSink, // media thread. scoped_refptr task_runner_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Allows tests to disable the background rendering task. bool background_rendering_enabled_; diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc index 8c1056dca1587c..4405bb78fa00df 100644 --- a/media/blink/webmediaplayer_impl.cc +++ b/media/blink/webmediaplayer_impl.cc @@ -3113,7 +3113,8 @@ void WebMediaPlayerImpl::RecordVideoNaturalSize(const gfx::Size& natural_size) { #undef UMA_HISTOGRAM_VIDEO_HEIGHT -void WebMediaPlayerImpl::SetTickClockForTest(base::TickClock* tick_clock) { +void WebMediaPlayerImpl::SetTickClockForTest( + const base::TickClock* tick_clock) { tick_clock_ = tick_clock; buffered_data_source_host_.SetTickClockForTest(tick_clock); } diff --git a/media/blink/webmediaplayer_impl.h b/media/blink/webmediaplayer_impl.h index dd8a150f19ec43..5ae1817b7678bc 100644 --- a/media/blink/webmediaplayer_impl.h +++ b/media/blink/webmediaplayer_impl.h @@ -542,7 +542,7 @@ class MEDIA_BLINK_EXPORT WebMediaPlayerImpl // Records |natural_size| to MediaLog and video height to UMA. void RecordVideoNaturalSize(const gfx::Size& natural_size); - void SetTickClockForTest(base::TickClock* tick_clock); + void SetTickClockForTest(const base::TickClock* tick_clock); // Returns the current time without clamping to Duration() as required by // HTMLMediaElement for handling ended. This method will never return a @@ -687,7 +687,7 @@ class MEDIA_BLINK_EXPORT WebMediaPlayerImpl std::unique_ptr memory_pressure_listener_; - base::TickClock* tick_clock_ = nullptr; + const base::TickClock* tick_clock_ = nullptr; BufferedDataSourceHostImpl buffered_data_source_host_; UrlIndex* const url_index_; diff --git a/media/blink/webmediaplayer_impl_unittest.cc b/media/blink/webmediaplayer_impl_unittest.cc index 8412f650f5ae4b..722e9def0a1ee8 100644 --- a/media/blink/webmediaplayer_impl_unittest.cc +++ b/media/blink/webmediaplayer_impl_unittest.cc @@ -373,7 +373,7 @@ class WebMediaPlayerImplTest : public testing::Test { void SetPaused(bool is_paused) { wmpi_->paused_ = is_paused; } void SetSeeking(bool is_seeking) { wmpi_->seeking_ = is_seeking; } void SetEnded(bool is_ended) { wmpi_->ended_ = is_ended; } - void SetTickClock(base::TickClock* clock) { + void SetTickClock(const base::TickClock* clock) { wmpi_->SetTickClockForTest(clock); } diff --git a/media/cast/cast_environment.cc b/media/cast/cast_environment.cc index 680c97b8b6e39b..0a60aa2ff64928 100644 --- a/media/cast/cast_environment.cc +++ b/media/cast/cast_environment.cc @@ -16,7 +16,7 @@ namespace media { namespace cast { CastEnvironment::CastEnvironment( - base::TickClock* clock, + const base::TickClock* clock, scoped_refptr main_thread_proxy, scoped_refptr audio_thread_proxy, scoped_refptr video_thread_proxy) diff --git a/media/cast/cast_environment.h b/media/cast/cast_environment.h index 731f9c3efd8171..45c95f4cfb8be8 100644 --- a/media/cast/cast_environment.h +++ b/media/cast/cast_environment.h @@ -32,7 +32,7 @@ class CastEnvironment : public base::RefCountedThreadSafe { }; CastEnvironment( - base::TickClock* clock, + const base::TickClock* clock, scoped_refptr main_thread_proxy, scoped_refptr audio_thread_proxy, scoped_refptr video_thread_proxy); @@ -54,7 +54,7 @@ class CastEnvironment : public base::RefCountedThreadSafe { bool CurrentlyOn(ThreadId identifier); // All of the media::cast implementation must use this TickClock. - base::TickClock* Clock() const { return clock_; } + const base::TickClock* Clock() const { return clock_; } // Thread-safe log event dispatcher. LogEventDispatcher* logger() { return &logger_; } @@ -73,7 +73,7 @@ class CastEnvironment : public base::RefCountedThreadSafe { scoped_refptr main_thread_proxy_; scoped_refptr audio_thread_proxy_; scoped_refptr video_thread_proxy_; - base::TickClock* clock_; + const base::TickClock* clock_; LogEventDispatcher logger_; private: diff --git a/media/cast/logging/stats_event_subscriber.cc b/media/cast/logging/stats_event_subscriber.cc index 26033edde93229..a877cc099d8885 100644 --- a/media/cast/logging/stats_event_subscriber.cc +++ b/media/cast/logging/stats_event_subscriber.cc @@ -98,7 +98,7 @@ StatsEventSubscriber::SimpleHistogram::GetHistogram() const { StatsEventSubscriber::StatsEventSubscriber( EventMediaType event_media_type, - base::TickClock* clock, + const base::TickClock* clock, ReceiverTimeOffsetEstimator* offset_estimator) : event_media_type_(event_media_type), clock_(clock), diff --git a/media/cast/logging/stats_event_subscriber.h b/media/cast/logging/stats_event_subscriber.h index 735695bfe7973f..4313436162bb8a 100644 --- a/media/cast/logging/stats_event_subscriber.h +++ b/media/cast/logging/stats_event_subscriber.h @@ -34,7 +34,7 @@ class StatsEventSubscriberTest; class StatsEventSubscriber : public RawEventSubscriber { public: StatsEventSubscriber(EventMediaType event_media_type, - base::TickClock* clock, + const base::TickClock* clock, ReceiverTimeOffsetEstimator* offset_estimator); ~StatsEventSubscriber() final; @@ -238,7 +238,7 @@ class StatsEventSubscriber : public RawEventSubscriber { const EventMediaType event_media_type_; // Not owned by this class. - base::TickClock* const clock_; + const base::TickClock* const clock_; // Not owned by this class. ReceiverTimeOffsetEstimator* const offset_estimator_; diff --git a/media/cast/net/cast_transport.h b/media/cast/net/cast_transport.h index bfae9fc4840745..e65a6ebddfbdc6 100644 --- a/media/cast/net/cast_transport.h +++ b/media/cast/net/cast_transport.h @@ -93,7 +93,7 @@ class CastTransport { }; static std::unique_ptr Create( - base::TickClock* clock, // Owned by the caller. + const base::TickClock* clock, // Owned by the caller. base::TimeDelta logging_flush_interval, std::unique_ptr client, std::unique_ptr transport, diff --git a/media/cast/net/cast_transport_impl.cc b/media/cast/net/cast_transport_impl.cc index 63a6f71da7b5ff..5bbbbbe09f4b2b 100644 --- a/media/cast/net/cast_transport_impl.cc +++ b/media/cast/net/cast_transport_impl.cc @@ -42,7 +42,7 @@ int LookupOptionWithDefault(const base::DictionaryValue& options, } // namespace std::unique_ptr CastTransport::Create( - base::TickClock* clock, // Owned by the caller. + const base::TickClock* clock, // Owned by the caller. base::TimeDelta logging_flush_interval, std::unique_ptr client, std::unique_ptr transport, @@ -113,7 +113,7 @@ struct CastTransportImpl::RtpStreamSession { }; CastTransportImpl::CastTransportImpl( - base::TickClock* clock, + const base::TickClock* clock, base::TimeDelta logging_flush_interval, std::unique_ptr client, std::unique_ptr transport, diff --git a/media/cast/net/cast_transport_impl.h b/media/cast/net/cast_transport_impl.h index 28f1a4753ca2df..49184655b28170 100644 --- a/media/cast/net/cast_transport_impl.h +++ b/media/cast/net/cast_transport_impl.h @@ -54,7 +54,7 @@ namespace cast { class CastTransportImpl final : public CastTransport { public: CastTransportImpl( - base::TickClock* clock, // Owned by the caller. + const base::TickClock* clock, // Owned by the caller. base::TimeDelta logging_flush_interval, std::unique_ptr client, std::unique_ptr transport, @@ -143,7 +143,7 @@ class CastTransportImpl final : public CastTransport { void OnReceivedCastMessage(uint32_t ssrc, const RtcpCastMessage& cast_message); - base::TickClock* const clock_; // Not owned by this class. + const base::TickClock* const clock_; // Not owned by this class. const base::TimeDelta logging_flush_interval_; const std::unique_ptr transport_client_; const std::unique_ptr transport_; diff --git a/media/cast/net/pacing/paced_sender.cc b/media/cast/net/pacing/paced_sender.cc index d673cad86e9417..4129778a0971ac 100644 --- a/media/cast/net/pacing/paced_sender.cc +++ b/media/cast/net/pacing/paced_sender.cc @@ -66,7 +66,7 @@ struct PacedSender::RtpSession { PacedSender::PacedSender( size_t target_burst_size, size_t max_burst_size, - base::TickClock* clock, + const base::TickClock* clock, std::vector* recent_packet_events, PacketTransport* transport, const scoped_refptr& transport_task_runner) diff --git a/media/cast/net/pacing/paced_sender.h b/media/cast/net/pacing/paced_sender.h index 9dc7e344bd8715..af8815cdd95378 100644 --- a/media/cast/net/pacing/paced_sender.h +++ b/media/cast/net/pacing/paced_sender.h @@ -104,7 +104,7 @@ class PacedSender : public PacedPacketSender { PacedSender( size_t target_burst_size, // Should normally be kTargetBurstSize. size_t max_burst_size, // Should normally be kMaxBurstSize. - base::TickClock* clock, + const base::TickClock* clock, std::vector* recent_packet_events, PacketTransport* external_transport, const scoped_refptr& transport_task_runner); @@ -198,7 +198,7 @@ class PacedSender : public PacedPacketSender { bool IsHighPriority(const PacketKey& packet_key) const; // These are externally-owned objects injected via the constructor. - base::TickClock* const clock_; + const base::TickClock* const clock_; std::vector* const recent_packet_events_; PacketTransport* const transport_; diff --git a/media/cast/net/rtcp/receiver_rtcp_session.cc b/media/cast/net/rtcp/receiver_rtcp_session.cc index 71c0988fe35dde..aec48b7841c690 100644 --- a/media/cast/net/rtcp/receiver_rtcp_session.cc +++ b/media/cast/net/rtcp/receiver_rtcp_session.cc @@ -12,7 +12,7 @@ namespace media { namespace cast { -ReceiverRtcpSession::ReceiverRtcpSession(base::TickClock* clock, +ReceiverRtcpSession::ReceiverRtcpSession(const base::TickClock* clock, uint32_t local_ssrc, uint32_t remote_ssrc) : clock_(clock), diff --git a/media/cast/net/rtcp/receiver_rtcp_session.h b/media/cast/net/rtcp/receiver_rtcp_session.h index 66960f2df84879..5b95a87973f57b 100644 --- a/media/cast/net/rtcp/receiver_rtcp_session.h +++ b/media/cast/net/rtcp/receiver_rtcp_session.h @@ -22,7 +22,7 @@ namespace cast { // & NTP timestamps). class ReceiverRtcpSession : public RtcpSession { public: - ReceiverRtcpSession(base::TickClock* clock, // Not owned. + ReceiverRtcpSession(const base::TickClock* clock, // Not owned. uint32_t local_ssrc, uint32_t remote_ssrc); @@ -61,7 +61,7 @@ class ReceiverRtcpSession : public RtcpSession { uint32_t ntp_seconds, uint32_t ntp_fraction); - base::TickClock* const clock_; // Not owned. + const base::TickClock* const clock_; // Not owned. const uint32_t local_ssrc_; const uint32_t remote_ssrc_; diff --git a/media/cast/net/rtcp/sender_rtcp_session.cc b/media/cast/net/rtcp/sender_rtcp_session.cc index 091cf96b95eadd..0e61b04f483756 100644 --- a/media/cast/net/rtcp/sender_rtcp_session.cc +++ b/media/cast/net/rtcp/sender_rtcp_session.cc @@ -68,7 +68,7 @@ std::pair GetReceiverEventKey( } // namespace -SenderRtcpSession::SenderRtcpSession(base::TickClock* clock, +SenderRtcpSession::SenderRtcpSession(const base::TickClock* clock, PacedPacketSender* packet_sender, RtcpObserver* observer, uint32_t local_ssrc, diff --git a/media/cast/net/rtcp/sender_rtcp_session.h b/media/cast/net/rtcp/sender_rtcp_session.h index ff40acbdfc5e41..0131bc3086b4fc 100644 --- a/media/cast/net/rtcp/sender_rtcp_session.h +++ b/media/cast/net/rtcp/sender_rtcp_session.h @@ -42,7 +42,7 @@ using RtcpSendTimeQueue = base::queue; // applications. class SenderRtcpSession : public RtcpSession { public: - SenderRtcpSession(base::TickClock* clock, // Not owned. + SenderRtcpSession(const base::TickClock* clock, // Not owned. PacedPacketSender* packet_sender, // Not owned. RtcpObserver* observer, // Not owned. uint32_t local_ssrc, @@ -99,8 +99,8 @@ class SenderRtcpSession : public RtcpSession { uint32_t last_ntp_seconds, uint32_t last_ntp_fraction); - base::TickClock* const clock_; // Not owned. - PacedPacketSender* packet_sender_; // Not owned. + const base::TickClock* const clock_; // Not owned. + PacedPacketSender* packet_sender_; // Not owned. const uint32_t local_ssrc_; const uint32_t remote_ssrc_; RtcpObserver* const rtcp_observer_; // Owned by |CastTransportImpl|. diff --git a/media/cast/net/rtp/cast_message_builder.cc b/media/cast/net/rtp/cast_message_builder.cc index 9f3720a90ddae9..1376061153c963 100644 --- a/media/cast/net/rtp/cast_message_builder.cc +++ b/media/cast/net/rtp/cast_message_builder.cc @@ -27,7 +27,7 @@ enum { } // namespace CastMessageBuilder::CastMessageBuilder( - base::TickClock* clock, + const base::TickClock* clock, RtpPayloadFeedback* incoming_payload_feedback, const Framer* framer, uint32_t media_ssrc, diff --git a/media/cast/net/rtp/cast_message_builder.h b/media/cast/net/rtp/cast_message_builder.h index fbbd0ae91fdb3c..9afd8c197522af 100644 --- a/media/cast/net/rtp/cast_message_builder.h +++ b/media/cast/net/rtp/cast_message_builder.h @@ -23,7 +23,7 @@ class RtpPayloadFeedback; class CastMessageBuilder { public: - CastMessageBuilder(base::TickClock* clock, + CastMessageBuilder(const base::TickClock* clock, RtpPayloadFeedback* incoming_payload_feedback, const Framer* framer, uint32_t media_ssrc, @@ -42,7 +42,7 @@ class CastMessageBuilder { FrameId last_acked_frame_id() const { return cast_msg_.ack_frame_id; } - base::TickClock* const clock_; // Not owned by this class. + const base::TickClock* const clock_; // Not owned by this class. RtpPayloadFeedback* const cast_feedback_; // CastMessageBuilder has only const access to the framer. diff --git a/media/cast/net/rtp/framer.cc b/media/cast/net/rtp/framer.cc index c59f677ad15b2c..369c9db7a3550e 100644 --- a/media/cast/net/rtp/framer.cc +++ b/media/cast/net/rtp/framer.cc @@ -10,7 +10,7 @@ namespace media { namespace cast { -Framer::Framer(base::TickClock* clock, +Framer::Framer(const base::TickClock* clock, RtpPayloadFeedback* incoming_payload_feedback, uint32_t ssrc, bool decoder_faster_than_max_frame_rate, diff --git a/media/cast/net/rtp/framer.h b/media/cast/net/rtp/framer.h index 51ea1b30a5e467..1d0160a500b368 100644 --- a/media/cast/net/rtp/framer.h +++ b/media/cast/net/rtp/framer.h @@ -23,7 +23,7 @@ namespace cast { class Framer { public: - Framer(base::TickClock* clock, + Framer(const base::TickClock* clock, RtpPayloadFeedback* incoming_payload_feedback, uint32_t ssrc, bool decoder_faster_than_max_frame_rate, diff --git a/media/cast/net/rtp/receiver_stats.cc b/media/cast/net/rtp/receiver_stats.cc index 3ea81a97b31470..5c7b4295d9c19b 100644 --- a/media/cast/net/rtp/receiver_stats.cc +++ b/media/cast/net/rtp/receiver_stats.cc @@ -25,7 +25,7 @@ bool IsNewerSequenceNumber(uint16_t sequence_number, } // namespace -ReceiverStats::ReceiverStats(base::TickClock* clock) +ReceiverStats::ReceiverStats(const base::TickClock* clock) : clock_(clock), min_sequence_number_(0), max_sequence_number_(0), diff --git a/media/cast/net/rtp/receiver_stats.h b/media/cast/net/rtp/receiver_stats.h index bd364c46076912..a1cd9039714548 100644 --- a/media/cast/net/rtp/receiver_stats.h +++ b/media/cast/net/rtp/receiver_stats.h @@ -19,13 +19,13 @@ namespace cast { // TODO(miu): Document this class. class ReceiverStats { public: - explicit ReceiverStats(base::TickClock* clock); + explicit ReceiverStats(const base::TickClock* clock); RtpReceiverStatistics GetStatistics(); void UpdateStatistics(const RtpCastHeader& header, int rtp_timebase); private: - base::TickClock* const clock_; // Not owned by this class. + const base::TickClock* const clock_; // Not owned by this class. // Global metrics. uint16_t min_sequence_number_; diff --git a/media/cast/sender/congestion_control.cc b/media/cast/sender/congestion_control.cc index 34894fbf82ff1c..d956c471eb5ffd 100644 --- a/media/cast/sender/congestion_control.cc +++ b/media/cast/sender/congestion_control.cc @@ -28,7 +28,7 @@ namespace cast { class AdaptiveCongestionControl : public CongestionControl { public: - AdaptiveCongestionControl(base::TickClock* clock, + AdaptiveCongestionControl(const base::TickClock* clock, int max_bitrate_configured, int min_bitrate_configured, double max_frame_rate); @@ -78,7 +78,7 @@ class AdaptiveCongestionControl : public CongestionControl { base::TimeTicks EstimatedSendingTime(FrameId frame_id, double estimated_bitrate); - base::TickClock* const clock_; // Not owned by this class. + const base::TickClock* const clock_; // Not owned by this class. const int max_bitrate_configured_; const int min_bitrate_configured_; const double max_frame_rate_; @@ -127,12 +127,10 @@ class FixedCongestionControl : public CongestionControl { DISALLOW_COPY_AND_ASSIGN(FixedCongestionControl); }; - -CongestionControl* NewAdaptiveCongestionControl( - base::TickClock* clock, - int max_bitrate_configured, - int min_bitrate_configured, - double max_frame_rate) { +CongestionControl* NewAdaptiveCongestionControl(const base::TickClock* clock, + int max_bitrate_configured, + int min_bitrate_configured, + double max_frame_rate) { return new AdaptiveCongestionControl(clock, max_bitrate_configured, min_bitrate_configured, @@ -156,10 +154,11 @@ static const size_t kHistorySize = 100; AdaptiveCongestionControl::FrameStats::FrameStats() : frame_size_in_bits(0) { } -AdaptiveCongestionControl::AdaptiveCongestionControl(base::TickClock* clock, - int max_bitrate_configured, - int min_bitrate_configured, - double max_frame_rate) +AdaptiveCongestionControl::AdaptiveCongestionControl( + const base::TickClock* clock, + int max_bitrate_configured, + int min_bitrate_configured, + double max_frame_rate) : clock_(clock), max_bitrate_configured_(max_bitrate_configured), min_bitrate_configured_(min_bitrate_configured), diff --git a/media/cast/sender/congestion_control.h b/media/cast/sender/congestion_control.h index 2cebb24ff1ec90..e63bbff8b2078d 100644 --- a/media/cast/sender/congestion_control.h +++ b/media/cast/sender/congestion_control.h @@ -46,11 +46,10 @@ class CongestionControl { base::TimeDelta playout_delay) = 0; }; -CongestionControl* NewAdaptiveCongestionControl( - base::TickClock* clock, - int max_bitrate_configured, - int min_bitrate_configured, - double max_frame_rate); +CongestionControl* NewAdaptiveCongestionControl(const base::TickClock* clock, + int max_bitrate_configured, + int min_bitrate_configured, + double max_frame_rate); CongestionControl* NewFixedCongestionControl(int bitrate); diff --git a/media/cast/test/end2end_unittest.cc b/media/cast/test/end2end_unittest.cc index fd0531f6ce9d16..1075ee2e2b15d5 100644 --- a/media/cast/test/end2end_unittest.cc +++ b/media/cast/test/end2end_unittest.cc @@ -180,7 +180,7 @@ class LoopBackTransport : public PacketTransport { void SetPacketReceiver( const PacketReceiverCallback& packet_receiver, const scoped_refptr& task_runner, - base::TickClock* clock) { + const base::TickClock* clock) { std::unique_ptr loopback_pipe( new LoopBackPacketPipe(packet_receiver)); if (packet_pipe_) { diff --git a/media/cast/test/fake_media_source.cc b/media/cast/test/fake_media_source.cc index 6ab8938bc349cc..679c7cb09e453c 100644 --- a/media/cast/test/fake_media_source.cc +++ b/media/cast/test/fake_media_source.cc @@ -71,7 +71,7 @@ namespace cast { FakeMediaSource::FakeMediaSource( scoped_refptr task_runner, - base::TickClock* clock, + const base::TickClock* clock, const FrameSenderConfig& audio_config, const FrameSenderConfig& video_config, bool keep_frames) diff --git a/media/cast/test/fake_media_source.h b/media/cast/test/fake_media_source.h index c0c800214a938b..ad5e6b2ca673a0 100644 --- a/media/cast/test/fake_media_source.h +++ b/media/cast/test/fake_media_source.h @@ -57,7 +57,7 @@ class FakeMediaSource : public media::AudioConverter::InputCallback { // |video_config| is the desired video config. // |keep_frames| is true if all VideoFrames are saved in a queue. FakeMediaSource(scoped_refptr task_runner, - base::TickClock* clock, + const base::TickClock* clock, const FrameSenderConfig& audio_config, const FrameSenderConfig& video_config, bool keep_frames); @@ -129,7 +129,7 @@ class FakeMediaSource : public media::AudioConverter::InputCallback { scoped_refptr audio_frame_input_; scoped_refptr video_frame_input_; uint8_t synthetic_count_; - base::TickClock* const clock_; // Not owned by this class. + const base::TickClock* const clock_; // Not owned by this class. // Time when the stream starts. base::TimeTicks start_time_; diff --git a/media/cast/test/loopback_transport.cc b/media/cast/test/loopback_transport.cc index 84603d65e2c5e5..1d2cac3b988b7d 100644 --- a/media/cast/test/loopback_transport.cc +++ b/media/cast/test/loopback_transport.cc @@ -63,7 +63,7 @@ void LoopBackTransport::Initialize( std::unique_ptr pipe, const PacketReceiverCallback& packet_receiver, const scoped_refptr& task_runner, - base::TickClock* clock) { + const base::TickClock* clock) { std::unique_ptr loopback_pipe( new LoopBackPacketPipe(packet_receiver)); if (pipe) { diff --git a/media/cast/test/loopback_transport.h b/media/cast/test/loopback_transport.h index 130d34fc284336..4280ee67bc5727 100644 --- a/media/cast/test/loopback_transport.h +++ b/media/cast/test/loopback_transport.h @@ -54,7 +54,7 @@ class LoopBackTransport : public PacketTransport { std::unique_ptr pipe, const PacketReceiverCallback& packet_receiver, const scoped_refptr& task_runner, - base::TickClock* clock); + const base::TickClock* clock); private: const scoped_refptr cast_environment_; diff --git a/media/cast/test/skewed_tick_clock.cc b/media/cast/test/skewed_tick_clock.cc index 04383203968fad..4a69a4d6d9f142 100644 --- a/media/cast/test/skewed_tick_clock.cc +++ b/media/cast/test/skewed_tick_clock.cc @@ -10,12 +10,11 @@ namespace media { namespace cast { namespace test { -SkewedTickClock::SkewedTickClock(base::TickClock* clock) +SkewedTickClock::SkewedTickClock(const base::TickClock* clock) : clock_(clock), skew_(1.0), last_skew_set_time_(clock_->NowTicks()), - skew_clock_at_last_set_(last_skew_set_time_) { -} + skew_clock_at_last_set_(last_skew_set_time_) {} base::TimeTicks SkewedTickClock::SkewTicks(base::TimeTicks now) const { return base::TimeDelta::FromMicroseconds( diff --git a/media/cast/test/skewed_tick_clock.h b/media/cast/test/skewed_tick_clock.h index 532a866518c0f8..6a5c2499d35282 100644 --- a/media/cast/test/skewed_tick_clock.h +++ b/media/cast/test/skewed_tick_clock.h @@ -18,7 +18,7 @@ namespace test { class SkewedTickClock : public base::TickClock { public: // Does not take ownership of |clock_|. - explicit SkewedTickClock(base::TickClock* clock_); + explicit SkewedTickClock(const base::TickClock* clock_); // |skew| > 1.0 means clock runs faster. // |offset| > 0 means clock returns times from the future. // Note, |offset| is cumulative. @@ -30,7 +30,7 @@ class SkewedTickClock : public base::TickClock { private: base::TimeTicks SkewTicks(base::TimeTicks now) const; - base::TickClock* clock_; // Not owned. + const base::TickClock* clock_; // Not owned. double skew_; base::TimeTicks last_skew_set_time_; base::TimeTicks skew_clock_at_last_set_; diff --git a/media/cast/test/utility/udp_proxy.cc b/media/cast/test/utility/udp_proxy.cc index 1a3f64fc6d57d6..47c3dbfb070079 100644 --- a/media/cast/test/utility/udp_proxy.cc +++ b/media/cast/test/utility/udp_proxy.cc @@ -33,7 +33,7 @@ PacketPipe::PacketPipe() = default; PacketPipe::~PacketPipe() = default; void PacketPipe::InitOnIOThread( const scoped_refptr& task_runner, - base::TickClock* clock) { + const base::TickClock* clock) { task_runner_ = task_runner; clock_ = clock; if (pipe_) { @@ -233,7 +233,7 @@ class RandomSortedDelay : public PacketPipe { } void InitOnIOThread( const scoped_refptr& task_runner, - base::TickClock* clock) final { + const base::TickClock* clock) final { PacketPipe::InitOnIOThread(task_runner, clock); // As we start the stream, assume that we are in a random // place between two extra delays, thus multiplier = 1.0; @@ -309,7 +309,7 @@ class NetworkGlitchPipe : public PacketPipe { void InitOnIOThread( const scoped_refptr& task_runner, - base::TickClock* clock) final { + const base::TickClock* clock) final { PacketPipe::InitOnIOThread(task_runner, clock); Flip(); } @@ -369,7 +369,7 @@ class InterruptedPoissonProcess::InternalBuffer : public PacketPipe { void InitOnIOThread( const scoped_refptr& task_runner, - base::TickClock* clock) final { + const base::TickClock* clock) final { clock_ = clock; if (ipp_) ipp_->InitOnIOThread(task_runner, clock); @@ -405,7 +405,7 @@ class InterruptedPoissonProcess::InternalBuffer : public PacketPipe { const size_t stored_limit_; base::circular_deque> buffer_; base::circular_deque buffer_time_; - base::TickClock* clock_; + const base::TickClock* clock_; base::WeakPtrFactory weak_factory_; DISALLOW_COPY_AND_ASSIGN(InternalBuffer); @@ -432,7 +432,7 @@ InterruptedPoissonProcess::~InterruptedPoissonProcess() = default; void InterruptedPoissonProcess::InitOnIOThread( const scoped_refptr& task_runner, - base::TickClock* clock) { + const base::TickClock* clock) { // Already initialized and started. if (task_runner_.get() && clock_) return; diff --git a/media/cast/test/utility/udp_proxy.h b/media/cast/test/utility/udp_proxy.h index dc5810849169e9..93f4e3954f339d 100644 --- a/media/cast/test/utility/udp_proxy.h +++ b/media/cast/test/utility/udp_proxy.h @@ -40,14 +40,14 @@ class PacketPipe { // Allows injection of fake test runner for testing. virtual void InitOnIOThread( const scoped_refptr& task_runner, - base::TickClock* clock); + const base::TickClock* clock); virtual void AppendToPipe(std::unique_ptr pipe); protected: std::unique_ptr pipe_; // Allows injection of fake task runner for testing. scoped_refptr task_runner_; - base::TickClock* clock_; + const base::TickClock* clock_; }; // Implements a Interrupted Poisson Process for packet delivery. @@ -73,7 +73,7 @@ class InterruptedPoissonProcess { // |clock| is the system clock. void InitOnIOThread( const scoped_refptr& task_runner, - base::TickClock* clock); + const base::TickClock* clock); base::TimeDelta NextEvent(double rate); double RandDouble(); @@ -84,7 +84,7 @@ class InterruptedPoissonProcess { void SendPacket(); scoped_refptr task_runner_; - base::TickClock* clock_; + const base::TickClock* clock_; const std::vector average_rates_; const double coef_burstiness_; const double coef_variance_; diff --git a/media/filters/frame_buffer_pool.h b/media/filters/frame_buffer_pool.h index 444691f04dd1da..b108dd24baff50 100644 --- a/media/filters/frame_buffer_pool.h +++ b/media/filters/frame_buffer_pool.h @@ -51,7 +51,7 @@ class MEDIA_EXPORT FrameBufferPool size_t get_pool_size_for_testing() const { return frame_buffers_.size(); } - void set_tick_clock_for_testing(base::TickClock* tick_clock) { + void set_tick_clock_for_testing(const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } @@ -93,7 +93,7 @@ class MEDIA_EXPORT FrameBufferPool bool registered_dump_provider_ = false; // |tick_clock_| is always a DefaultTickClock outside of testing. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; SEQUENCE_CHECKER(sequence_checker_); diff --git a/media/gpu/android/android_video_surface_chooser_impl.cc b/media/gpu/android/android_video_surface_chooser_impl.cc index 120f5c746890f4..f1faaa4e2aa7cc 100644 --- a/media/gpu/android/android_video_surface_chooser_impl.cc +++ b/media/gpu/android/android_video_surface_chooser_impl.cc @@ -17,7 +17,7 @@ constexpr base::TimeDelta MinimumDelayAfterFailedOverlay = AndroidVideoSurfaceChooserImpl::AndroidVideoSurfaceChooserImpl( bool allow_dynamic, - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : allow_dynamic_(allow_dynamic), tick_clock_(tick_clock), weak_factory_(this) { diff --git a/media/gpu/android/android_video_surface_chooser_impl.h b/media/gpu/android/android_video_surface_chooser_impl.h index 1f19a37bfcac4b..e3b1a21277da70 100644 --- a/media/gpu/android/android_video_surface_chooser_impl.h +++ b/media/gpu/android/android_video_surface_chooser_impl.h @@ -25,7 +25,7 @@ class MEDIA_GPU_EXPORT AndroidVideoSurfaceChooserImpl // will be used as our time source. Otherwise, we'll use wall clock. If // provided, then it must outlast |this|. AndroidVideoSurfaceChooserImpl(bool allow_dynamic, - base::TickClock* tick_clock = nullptr); + const base::TickClock* tick_clock = nullptr); ~AndroidVideoSurfaceChooserImpl() override; // AndroidVideoSurfaceChooser @@ -84,7 +84,7 @@ class MEDIA_GPU_EXPORT AndroidVideoSurfaceChooserImpl bool initial_state_received_ = false; // Not owned by us. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Time at which we most recently got a failed overlay request. base::TimeTicks most_recent_overlay_failure_; diff --git a/media/gpu/android/avda_codec_allocator.cc b/media/gpu/android/avda_codec_allocator.cc index a5f728cae29b2c..8f7a74653a7a15 100644 --- a/media/gpu/android/avda_codec_allocator.cc +++ b/media/gpu/android/avda_codec_allocator.cc @@ -81,7 +81,8 @@ void DeleteMediaCodecAndSignal(std::unique_ptr codec, CodecConfig::CodecConfig() {} CodecConfig::~CodecConfig() {} -AVDACodecAllocator::HangDetector::HangDetector(base::TickClock* tick_clock) +AVDACodecAllocator::HangDetector::HangDetector( + const base::TickClock* tick_clock) : tick_clock_(tick_clock) {} void AVDACodecAllocator::HangDetector::WillProcessTask( @@ -448,7 +449,7 @@ bool AVDACodecAllocator::WaitForPendingRelease(AndroidOverlay* overlay) { AVDACodecAllocator::AVDACodecAllocator( AVDACodecAllocator::CodecFactoryCB factory_cb, scoped_refptr task_runner, - base::TickClock* tick_clock, + const base::TickClock* tick_clock, base::WaitableEvent* stop_event) : task_runner_(task_runner), stop_event_for_testing_(stop_event), diff --git a/media/gpu/android/avda_codec_allocator.h b/media/gpu/android/avda_codec_allocator.h index 1d5f68018e65c6..db83c84e098a24 100644 --- a/media/gpu/android/avda_codec_allocator.h +++ b/media/gpu/android/avda_codec_allocator.h @@ -176,7 +176,7 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator { // |tick_clock| and |stop_event| are for tests only. AVDACodecAllocator(AVDACodecAllocator::CodecFactoryCB factory_cb, scoped_refptr task_runner, - base::TickClock* tick_clock = nullptr, + const base::TickClock* tick_clock = nullptr, base::WaitableEvent* stop_event = nullptr); virtual ~AVDACodecAllocator(); @@ -217,7 +217,7 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator { class HangDetector : public base::MessageLoop::TaskObserver { public: - HangDetector(base::TickClock* tick_clock); + HangDetector(const base::TickClock* tick_clock); void WillProcessTask(const base::PendingTask& pending_task) override; void DidProcessTask(const base::PendingTask& pending_task) override; bool IsThreadLikelyHung(); @@ -228,14 +228,15 @@ class MEDIA_GPU_EXPORT AVDACodecAllocator { // Non-null when a task is currently running. base::TimeTicks task_start_time_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; DISALLOW_COPY_AND_ASSIGN(HangDetector); }; // Handy combination of a thread and hang detector for it. struct ThreadAndHangDetector { - ThreadAndHangDetector(const std::string& name, base::TickClock* tick_clock) + ThreadAndHangDetector(const std::string& name, + const base::TickClock* tick_clock) : thread(name), hang_detector(tick_clock) {} base::Thread thread; HangDetector hang_detector; diff --git a/media/gpu/android/avda_codec_allocator_unittest.cc b/media/gpu/android/avda_codec_allocator_unittest.cc index 2de118aa196278..0887042fab0efd 100644 --- a/media/gpu/android/avda_codec_allocator_unittest.cc +++ b/media/gpu/android/avda_codec_allocator_unittest.cc @@ -155,7 +155,8 @@ class AVDACodecAllocatorTest : public testing::Test { FROM_HERE, base::Bind( [](AVDACodecAllocator::CodecFactoryCB factory_cb, scoped_refptr task_runner, - base::TickClock* clock, base::WaitableEvent* event) { + const base::TickClock* clock, + base::WaitableEvent* event) { return new AVDACodecAllocator(factory_cb, task_runner, clock, event); }, diff --git a/media/gpu/android/promotion_hint_aggregator_impl.cc b/media/gpu/android/promotion_hint_aggregator_impl.cc index c2dc6d3f54f0e6..880bce817cb35f 100644 --- a/media/gpu/android/promotion_hint_aggregator_impl.cc +++ b/media/gpu/android/promotion_hint_aggregator_impl.cc @@ -28,7 +28,7 @@ constexpr base::TimeDelta MinimumUnpromotableFrameTime = base::TimeDelta::FromMilliseconds(2000); PromotionHintAggregatorImpl::PromotionHintAggregatorImpl( - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : weak_ptr_factory_(this) { if (!tick_clock) tick_clock = base::DefaultTickClock::GetInstance(); diff --git a/media/gpu/android/promotion_hint_aggregator_impl.h b/media/gpu/android/promotion_hint_aggregator_impl.h index ac2e000ccef68b..6fb8a26f2f4091 100644 --- a/media/gpu/android/promotion_hint_aggregator_impl.h +++ b/media/gpu/android/promotion_hint_aggregator_impl.h @@ -22,7 +22,7 @@ class MEDIA_GPU_EXPORT PromotionHintAggregatorImpl public: // |tick_clock| may be null, in which case we will use wall clock. If it is // not null, then it must outlive |this|. It is provided for tests. - PromotionHintAggregatorImpl(base::TickClock* tick_clock = nullptr); + PromotionHintAggregatorImpl(const base::TickClock* tick_clock = nullptr); ~PromotionHintAggregatorImpl() override; void NotifyPromotionHint(const Hint& hint) override; @@ -30,7 +30,7 @@ class MEDIA_GPU_EXPORT PromotionHintAggregatorImpl private: // Clock, which we might not own, that we'll use. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // When did we receive the most recent "not promotable" frame? base::TimeTicks most_recent_unpromotable_; diff --git a/media/gpu/android/surface_chooser_helper.cc b/media/gpu/android/surface_chooser_helper.cc index c186475fc75d55..1704289671b944 100644 --- a/media/gpu/android/surface_chooser_helper.cc +++ b/media/gpu/android/surface_chooser_helper.cc @@ -34,7 +34,7 @@ SurfaceChooserHelper::SurfaceChooserHelper( bool is_overlay_required, bool promote_aggressively, std::unique_ptr promotion_hint_aggregator, - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : surface_chooser_(std::move(surface_chooser)), is_overlay_required_(is_overlay_required), promotion_hint_aggregator_( diff --git a/media/gpu/android/surface_chooser_helper.h b/media/gpu/android/surface_chooser_helper.h index b7557500954563..2bfaddf9ee0c80 100644 --- a/media/gpu/android/surface_chooser_helper.h +++ b/media/gpu/android/surface_chooser_helper.h @@ -34,7 +34,7 @@ class MEDIA_GPU_EXPORT SurfaceChooserHelper { bool promote_aggressively, std::unique_ptr promotion_hint_aggregator = nullptr, - base::TickClock* tick_clock = nullptr); + const base::TickClock* tick_clock = nullptr); ~SurfaceChooserHelper(); enum class SecureSurfaceMode { @@ -105,7 +105,7 @@ class MEDIA_GPU_EXPORT SurfaceChooserHelper { // Time since we last updated the chooser state. base::TimeTicks most_recent_chooser_retry_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Number of promotion hints that we need to receive before clearing the // "delay overlay promotion" flag in |surface_chooser_state_|. We do this so diff --git a/media/remoting/courier_renderer.h b/media/remoting/courier_renderer.h index 51197e921d9e67..df01dfd4474f83 100644 --- a/media/remoting/courier_renderer.h +++ b/media/remoting/courier_renderer.h @@ -211,7 +211,7 @@ class CourierRenderer : public Renderer { // Records events and measurements of interest. RendererMetricsRecorder metrics_recorder_; - base::TickClock* clock_; + const base::TickClock* clock_; // A timer that polls the DemuxerStreamAdapters periodically to measure // the data flow rates for metrics. diff --git a/media/remoting/renderer_controller.h b/media/remoting/renderer_controller.h index 75a1c7345c9bbf..ed0ba9b46e4e18 100644 --- a/media/remoting/renderer_controller.h +++ b/media/remoting/renderer_controller.h @@ -214,7 +214,7 @@ class RendererController final : public mojom::RemotingSource, // remote the content while this timer is running. base::OneShotTimer delayed_start_stability_timer_; - base::TickClock* clock_; + const base::TickClock* clock_; base::WeakPtrFactory weak_factory_; diff --git a/media/renderers/audio_renderer_impl.h b/media/renderers/audio_renderer_impl.h index ca04dc3cb766d1..c23f7bd6f2526c 100644 --- a/media/renderers/audio_renderer_impl.h +++ b/media/renderers/audio_renderer_impl.h @@ -242,7 +242,7 @@ class MEDIA_EXPORT AudioRendererImpl base::Closure flush_cb_; // Overridable tick clock for testing. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Memory usage of |algorithm_| recorded during the last // HandleDecodedBuffer_Locked() call. diff --git a/media/renderers/video_renderer_impl.cc b/media/renderers/video_renderer_impl.cc index d712937e5fcf95..443ea3045e0aa7 100644 --- a/media/renderers/video_renderer_impl.cc +++ b/media/renderers/video_renderer_impl.cc @@ -379,7 +379,8 @@ void VideoRendererImpl::OnConfigChange(const VideoDecoderConfig& config) { } } -void VideoRendererImpl::SetTickClockForTesting(base::TickClock* tick_clock) { +void VideoRendererImpl::SetTickClockForTesting( + const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } diff --git a/media/renderers/video_renderer_impl.h b/media/renderers/video_renderer_impl.h index 62f9d3f540bc6e..49cc84d392e3a8 100644 --- a/media/renderers/video_renderer_impl.h +++ b/media/renderers/video_renderer_impl.h @@ -71,7 +71,7 @@ class MEDIA_EXPORT VideoRendererImpl void OnTimeProgressing() override; void OnTimeStopped() override; - void SetTickClockForTesting(base::TickClock* tick_clock); + void SetTickClockForTesting(const base::TickClock* tick_clock); size_t frames_queued_for_testing() const { return algorithm_->frames_queued(); } @@ -263,7 +263,7 @@ class MEDIA_EXPORT VideoRendererImpl // last call to |statistics_cb_|. These must be accessed under lock. PipelineStatistics stats_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Algorithm for selecting which frame to render; manages frames and all // timing related information. Ensure this is destructed before diff --git a/media/video/gpu_memory_buffer_video_frame_pool.cc b/media/video/gpu_memory_buffer_video_frame_pool.cc index 4efa4b549e6776..42ef94eb27c366 100644 --- a/media/video/gpu_memory_buffer_video_frame_pool.cc +++ b/media/video/gpu_memory_buffer_video_frame_pool.cc @@ -80,7 +80,7 @@ class GpuMemoryBufferVideoFramePool::PoolImpl // |frames_|. void Shutdown(); - void SetTickClockForTesting(base::TickClock* tick_clock); + void SetTickClockForTesting(const base::TickClock* tick_clock); private: friend class base::RefCountedThreadSafe< @@ -203,7 +203,7 @@ class GpuMemoryBufferVideoFramePool::PoolImpl GpuVideoAcceleratorFactories::OutputFormat output_format_; // |tick_clock_| is always a DefaultTickClock outside of testing. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Queued up video frames for copies. The front is the currently // in-flight copy, new copies are added at the end. @@ -948,7 +948,7 @@ void GpuMemoryBufferVideoFramePool::PoolImpl::Shutdown() { } void GpuMemoryBufferVideoFramePool::PoolImpl::SetTickClockForTesting( - base::TickClock* tick_clock) { + const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } @@ -1113,7 +1113,7 @@ void GpuMemoryBufferVideoFramePool::Abort() { } void GpuMemoryBufferVideoFramePool::SetTickClockForTesting( - base::TickClock* tick_clock) { + const base::TickClock* tick_clock) { pool_impl_->SetTickClockForTesting(tick_clock); } diff --git a/media/video/gpu_memory_buffer_video_frame_pool.h b/media/video/gpu_memory_buffer_video_frame_pool.h index d48d4cbde03f78..7b86cedc6ae4be 100644 --- a/media/video/gpu_memory_buffer_video_frame_pool.h +++ b/media/video/gpu_memory_buffer_video_frame_pool.h @@ -61,7 +61,7 @@ class MEDIA_EXPORT GpuMemoryBufferVideoFramePool { virtual void Abort(); // Allows injection of a base::SimpleTestClock for testing. - void SetTickClockForTesting(base::TickClock* tick_clock); + void SetTickClockForTesting(const base::TickClock* tick_clock); private: class PoolImpl; diff --git a/net/base/backoff_entry.cc b/net/base/backoff_entry.cc index 5914711a288fda..db70d42726e785 100644 --- a/net/base/backoff_entry.cc +++ b/net/base/backoff_entry.cc @@ -19,7 +19,7 @@ BackoffEntry::BackoffEntry(const BackoffEntry::Policy* policy) : BackoffEntry(policy, nullptr) {} BackoffEntry::BackoffEntry(const BackoffEntry::Policy* policy, - base::TickClock* clock) + const base::TickClock* clock) : policy_(policy), clock_(clock) { DCHECK(policy_); Reset(); diff --git a/net/base/backoff_entry.h b/net/base/backoff_entry.h index db440207213243..2c4cd180665121 100644 --- a/net/base/backoff_entry.h +++ b/net/base/backoff_entry.h @@ -69,7 +69,7 @@ class NET_EXPORT BackoffEntry { // Lifetime of policy and clock must enclose lifetime of BackoffEntry. // |policy| pointer must be valid but isn't dereferenced during construction. // |clock| pointer may be null. - BackoffEntry(const Policy* policy, base::TickClock* clock); + BackoffEntry(const Policy* policy, const base::TickClock* clock); virtual ~BackoffEntry(); // Inform this item that a request for the network resource it is @@ -124,7 +124,7 @@ class NET_EXPORT BackoffEntry { const Policy* const policy_; // Not owned. - base::TickClock* const clock_; // Not owned. + const base::TickClock* const clock_; // Not owned. THREAD_CHECKER(thread_checker_); diff --git a/net/base/backoff_entry_serializer.cc b/net/base/backoff_entry_serializer.cc index f2cbec753e0928..57f5a3ee213f1c 100644 --- a/net/base/backoff_entry_serializer.cc +++ b/net/base/backoff_entry_serializer.cc @@ -43,7 +43,7 @@ std::unique_ptr BackoffEntrySerializer::SerializeToValue( std::unique_ptr BackoffEntrySerializer::DeserializeFromValue( const base::Value& serialized, const BackoffEntry::Policy* policy, - base::TickClock* tick_clock, + const base::TickClock* tick_clock, base::Time time_now) { const base::ListValue* serialized_list = nullptr; if (!serialized.GetAsList(&serialized_list)) diff --git a/net/base/backoff_entry_serializer.h b/net/base/backoff_entry_serializer.h index 1ecaf015d704c9..d5fde2c768dc29 100644 --- a/net/base/backoff_entry_serializer.h +++ b/net/base/backoff_entry_serializer.h @@ -45,7 +45,7 @@ class NET_EXPORT BackoffEntrySerializer { static std::unique_ptr DeserializeFromValue( const base::Value& serialized, const BackoffEntry::Policy* policy, - base::TickClock* clock, + const base::TickClock* clock, base::Time time_now); private: diff --git a/net/base/network_throttle_manager_impl.cc b/net/base/network_throttle_manager_impl.cc new file mode 100644 index 00000000000000..cd62444c522c89 --- /dev/null +++ b/net/base/network_throttle_manager_impl.cc @@ -0,0 +1,326 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "net/base/network_throttle_manager_impl.h" + +#include "base/logging.h" +#include "base/stl_util.h" +#include "base/threading/thread_task_runner_handle.h" +#include "base/time/default_tick_clock.h" + +namespace net { + +const size_t NetworkThrottleManagerImpl::kActiveRequestThrottlingLimit = 2; +const int NetworkThrottleManagerImpl::kMedianLifetimeMultiple = 5; + +// Initial estimate based on the median in the +// Net.RequestTime2.Success histogram, excluding cached results by eye. +const int NetworkThrottleManagerImpl::kInitialMedianInMs = 400; + +// Set timers slightly further into the future than they need to be set, so +// that the algorithm isn't vulnerable to timer round off errors triggering +// the callback before the throttle would be considered aged out of the set. +// Set to 17 to hanlde systems with |!base::TimeTicks::IsHighResolution()|. +// Note that even if the timer goes off before it should, all that should cost +// is a second task; this class does not rely on timer accuracy for its +// correctness. +const int kTimerFudgeInMs = 17; + +class NetworkThrottleManagerImpl::ThrottleImpl + : public NetworkThrottleManager::Throttle { + public: + // Allowed state transitions are BLOCKED -> OUTSTANDING -> AGED. + // Throttles may be created in the BLOCKED or OUTSTANDING states. + enum class State { + // Not allowed to proceed by manager. + BLOCKED, + + // Allowed to proceed, counts as an "outstanding" request for + // manager accounting purposes. + OUTSTANDING, + + // Old enough to not count as "outstanding" anymore for + // manager accounting purposes. + AGED + }; + + using ThrottleListQueuePointer = + NetworkThrottleManagerImpl::ThrottleList::iterator; + + // Caller must arrange that |*delegate| and |*manager| outlive + // the ThrottleImpl class. + ThrottleImpl(bool blocked, + RequestPriority priority, + ThrottleDelegate* delegate, + NetworkThrottleManagerImpl* manager, + ThrottleListQueuePointer queue_pointer); + + ~ThrottleImpl() override; + + // Throttle: + bool IsBlocked() const override; + RequestPriority Priority() const override; + void SetPriority(RequestPriority priority) override; + + State state() const { return state_; } + + ThrottleListQueuePointer queue_pointer() const { return queue_pointer_; } + void set_queue_pointer(const ThrottleListQueuePointer& pointer) { + if (state_ != State::AGED) + DCHECK_EQ(this, *pointer); + queue_pointer_ = pointer; + } + + void set_start_time(base::TimeTicks start_time) { start_time_ = start_time; } + base::TimeTicks start_time() const { return start_time_; } + + // Change the throttle's state to AGED. The previous + // state must be OUTSTANDING. + void SetAged(); + + // Note that this call calls the delegate, and hence may result in + // re-entrant calls into the manager or ThrottleImpl. The manager should + // not rely on any state other than its own existence being persistent + // across this call. + void NotifyUnblocked(); + + private: + State state_; + RequestPriority priority_; + ThrottleDelegate* const delegate_; + NetworkThrottleManagerImpl* const manager_; + + base::TimeTicks start_time_; + + // To allow deletion from the blocked queue (when the throttle is in the + // blocked queue). + ThrottleListQueuePointer queue_pointer_; + + DISALLOW_COPY_AND_ASSIGN(ThrottleImpl); +}; + +NetworkThrottleManagerImpl::ThrottleImpl::ThrottleImpl( + bool blocked, + RequestPriority priority, + NetworkThrottleManager::ThrottleDelegate* delegate, + NetworkThrottleManagerImpl* manager, + ThrottleListQueuePointer queue_pointer) + : state_(blocked ? State::BLOCKED : State::OUTSTANDING), + priority_(priority), + delegate_(delegate), + manager_(manager), + queue_pointer_(queue_pointer) { + DCHECK(delegate); + if (!blocked) + start_time_ = manager->tick_clock_->NowTicks(); +} + +NetworkThrottleManagerImpl::ThrottleImpl::~ThrottleImpl() { + manager_->OnThrottleDestroyed(this); +} + +bool NetworkThrottleManagerImpl::ThrottleImpl::IsBlocked() const { + return state_ == State::BLOCKED; +} + +RequestPriority NetworkThrottleManagerImpl::ThrottleImpl::Priority() const { + return priority_; +} + +void NetworkThrottleManagerImpl::ThrottleImpl::SetPriority( + RequestPriority new_priority) { + RequestPriority old_priority(priority_); + if (old_priority == new_priority) + return; + priority_ = new_priority; + manager_->OnThrottlePriorityChanged(this, old_priority, new_priority); +} + +void NetworkThrottleManagerImpl::ThrottleImpl::SetAged() { + DCHECK_EQ(State::OUTSTANDING, state_); + state_ = State::AGED; +} + +void NetworkThrottleManagerImpl::ThrottleImpl::NotifyUnblocked() { + // This method should only be called once, and only if the + // current state is blocked. + DCHECK_EQ(State::BLOCKED, state_); + state_ = State::OUTSTANDING; + delegate_->OnThrottleUnblocked(this); +} + +NetworkThrottleManagerImpl::NetworkThrottleManagerImpl() + : lifetime_median_estimate_(PercentileEstimator::kMedianPercentile, + kInitialMedianInMs), + outstanding_recomputation_timer_( + std::make_unique(false /* retain_user_task */, + false /* is_repeating */)), + tick_clock_(base::DefaultTickClock::GetInstance()), + weak_ptr_factory_(this) {} + +NetworkThrottleManagerImpl::~NetworkThrottleManagerImpl() = default; + +std::unique_ptr +NetworkThrottleManagerImpl::CreateThrottle( + NetworkThrottleManager::ThrottleDelegate* delegate, + RequestPriority priority, + bool ignore_limits) { + bool blocked = + (!ignore_limits && priority == THROTTLED && + outstanding_throttles_.size() >= kActiveRequestThrottlingLimit); + + std::unique_ptr throttle( + new ThrottleImpl(blocked, priority, delegate, this, + blocked_throttles_.end())); + + ThrottleList& insert_list(blocked ? blocked_throttles_ + : outstanding_throttles_); + + throttle->set_queue_pointer( + insert_list.insert(insert_list.end(), throttle.get())); + + // In case oustanding_throttles_ was empty, set up timer. + if (!blocked) + RecomputeOutstanding(); + + return std::move(throttle); +} + +void NetworkThrottleManagerImpl::SetTickClockForTesting( + const base::TickClock* tick_clock) { + tick_clock_ = tick_clock; + DCHECK(!outstanding_recomputation_timer_->IsRunning()); + outstanding_recomputation_timer_ = std::make_unique( + false /* retain_user_task */, false /* is_repeating */, tick_clock_); +} + +bool NetworkThrottleManagerImpl::ConditionallyTriggerTimerForTesting() { + if (!outstanding_recomputation_timer_->IsRunning() || + (tick_clock_->NowTicks() < + outstanding_recomputation_timer_->desired_run_time())) { + return false; + } + + base::Closure timer_callback(outstanding_recomputation_timer_->user_task()); + outstanding_recomputation_timer_->Stop(); + timer_callback.Run(); + return true; +} + +void NetworkThrottleManagerImpl::OnThrottlePriorityChanged( + NetworkThrottleManagerImpl::ThrottleImpl* throttle, + RequestPriority old_priority, + RequestPriority new_priority) { + // The only case requiring a state change is if the priority change + // implies unblocking, which can only happen on a transition from blocked + // (implies THROTTLED) to non-THROTTLED. + if (throttle->IsBlocked() && new_priority != THROTTLED) { + // May result in re-entrant calls into this class. + UnblockThrottle(throttle); + } +} + +void NetworkThrottleManagerImpl::OnThrottleDestroyed(ThrottleImpl* throttle) { + switch (throttle->state()) { + case ThrottleImpl::State::BLOCKED: + DCHECK(throttle->queue_pointer() != blocked_throttles_.end()); + DCHECK_EQ(throttle, *(throttle->queue_pointer())); + blocked_throttles_.erase(throttle->queue_pointer()); + break; + case ThrottleImpl::State::OUTSTANDING: + DCHECK(throttle->queue_pointer() != outstanding_throttles_.end()); + DCHECK_EQ(throttle, *(throttle->queue_pointer())); + outstanding_throttles_.erase(throttle->queue_pointer()); + FALLTHROUGH; + case ThrottleImpl::State::AGED: + DCHECK(!throttle->start_time().is_null()); + lifetime_median_estimate_.AddSample( + (tick_clock_->NowTicks() - throttle->start_time()) + .InMillisecondsRoundedUp()); + break; + } + + DCHECK(!base::ContainsValue(blocked_throttles_, throttle)); + DCHECK(!base::ContainsValue(outstanding_throttles_, throttle)); + + // Unblock the throttles if there's some chance there's a throttle to + // unblock. + if (outstanding_throttles_.size() < kActiveRequestThrottlingLimit && + !blocked_throttles_.empty()) { + // Via PostTask so there aren't upcalls from within destructors. + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, + base::Bind(&NetworkThrottleManagerImpl::MaybeUnblockThrottles, + weak_ptr_factory_.GetWeakPtr())); + } +} + +void NetworkThrottleManagerImpl::RecomputeOutstanding() { + // Remove all throttles that have aged out of the outstanding set. + base::TimeTicks now(tick_clock_->NowTicks()); + base::TimeDelta age_horizon(base::TimeDelta::FromMilliseconds(( + kMedianLifetimeMultiple * lifetime_median_estimate_.current_estimate()))); + while (!outstanding_throttles_.empty()) { + ThrottleImpl* throttle = *outstanding_throttles_.begin(); + if (throttle->start_time() + age_horizon >= now) + break; + + outstanding_throttles_.erase(outstanding_throttles_.begin()); + throttle->SetAged(); + throttle->set_queue_pointer(outstanding_throttles_.end()); + } + + if (outstanding_throttles_.empty()) + return; + + // If the timer is already running, be conservative and leave it alone; + // the time for which it would be set will only be later than when it's + // currently set. + // This addresses, e.g., situations where a RecomputeOutstanding() races + // with a running timer which would unblock blocked throttles. + if (outstanding_recomputation_timer_->IsRunning()) + return; + + ThrottleImpl* first_throttle(*outstanding_throttles_.begin()); + DCHECK_GE(first_throttle->start_time() + age_horizon, now); + + outstanding_recomputation_timer_->Start( + FROM_HERE, + ((first_throttle->start_time() + age_horizon) - now + + base::TimeDelta::FromMilliseconds(kTimerFudgeInMs)), + // Unretained use of |this| is safe because the timer is + // owned by this object, and will be torn down if this object + // is destroyed. + base::Bind(&NetworkThrottleManagerImpl::MaybeUnblockThrottles, + base::Unretained(this))); +} + +void NetworkThrottleManagerImpl::UnblockThrottle(ThrottleImpl* throttle) { + DCHECK(throttle->IsBlocked()); + + blocked_throttles_.erase(throttle->queue_pointer()); + throttle->set_start_time(tick_clock_->NowTicks()); + throttle->set_queue_pointer( + outstanding_throttles_.insert(outstanding_throttles_.end(), throttle)); + + // Called in case |*throttle| was added to a null set. + RecomputeOutstanding(); + + // May result in re-entrant calls into this class. + throttle->NotifyUnblocked(); +} + +void NetworkThrottleManagerImpl::MaybeUnblockThrottles() { + RecomputeOutstanding(); + + while (outstanding_throttles_.size() < kActiveRequestThrottlingLimit && + !blocked_throttles_.empty()) { + // NOTE: This call may result in reentrant calls into + // NetworkThrottleManagerImpl; no state should be assumed to be + // persistent across this call. + UnblockThrottle(blocked_throttles_.front()); + } +} + +} // namespace net diff --git a/net/base/network_throttle_manager_impl.h b/net/base/network_throttle_manager_impl.h new file mode 100644 index 00000000000000..cb1bfe4be7b709 --- /dev/null +++ b/net/base/network_throttle_manager_impl.h @@ -0,0 +1,152 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef NET_BASE_NETWORK_THROTTLE_MANAGER_IMPL_H_ +#define NET_BASE_NETWORK_THROTTLE_MANAGER_IMPL_H_ + +#include +#include +#include + +#include "base/memory/weak_ptr.h" +#include "base/time/tick_clock.h" +#include "base/time/time.h" +#include "base/timer/timer.h" +#include "net/base/network_throttle_manager.h" +#include "net/base/percentile_estimator.h" + +namespace net { + +// The NetworkThrottleManagerImpl implements the following semantics: +// * All throttles of priority above THROTTLED are created unblocked. +// * Throttles of priority THROTTLED are created unblocked, unless +// there are |kActiveRequestThrottlingLimit| or more throttles active, +// in which case they are created blocked. +// When that condition is no longer true, throttles of priority +// THROTTLED are unblocked, in FIFO order. +// * Throttles that have been alive for more than |kMedianLifetimeMultiple| +// times the current estimate of the throttle median lifetime do +// not count against the |kActiveRequestThrottlingLimit| limit. +class NET_EXPORT NetworkThrottleManagerImpl : public NetworkThrottleManager { + public: + // Maximum number of active requests before new THROTTLED throttles + // are created blocked. Throttles are unblocked as the active requests + // fall below this limit. + static const size_t kActiveRequestThrottlingLimit; + + // Note that the following constants are implementation details exposed in the + // header file only for testing, and should not be relied on by consumers. + + // Constants used for the running estimate of the median lifetime + // for throttles created by this class. That estimate is used to detect + // throttles that are "unusually old" and hence may represent hanging GETs + // or long-running streams. Such throttles should not be considered + // "active" for the purposes of determining whether THROTTLED throttles + // should be created in a blocked state. + // Note that the precise details of this algorithm aren't very important; + // specifically, if it takes a while for the median estimate to reach the + // "actual" median of a request stream, the consequence is either a bit more + // of a delay in unblocking THROTTLED requests or more THROTTLED requests + // being unblocked than would be ideal (i.e. performance tweaks at + // the margins). + + // Multiple of the current median lifetime beyond which a throttle is + // considered "unusually old" and not considered in counting active + // requests. This is used instead of a percentile estimate because the goal + // is eliminating requests that are qualitatively different + // (e.g. hanging gets, streams), and the percentage of all requests + // that are in that category can vary greatly. + static const int kMedianLifetimeMultiple; + + // The median lifetime estimate starts at class creation at + // |kInitialMedianInMs|. + static const int kInitialMedianInMs; + + NetworkThrottleManagerImpl(); + ~NetworkThrottleManagerImpl() override; + + // NetworkThrottleManager: + std::unique_ptr CreateThrottle(ThrottleDelegate* delegate, + RequestPriority priority, + bool ignore_limits) override; + + void SetTickClockForTesting(const base::TickClock* tick_clock); + + // If the |NowTicks()| value of |tick_clock_| is greater than the + // time the outstanding_recomputation_timer_ has set to go off, Stop() + // the timer and manually run the associated user task. This is to allow + // "fast-forwarding" of the clock for testing by working around + // base::Timer's direct use of base::TimeTicks rather than a base::TickClock. + // + // Note specifically that base::Timer::Start takes a time delta into the + // future and adds it to base::TimeTicks::Now() to get + // base::Timer::desired_run_time(), which is what this method compares + // |tick_clock_->NowTicks()| against. So tests should be written so that + // the timer Start() routine whose callback should be run is called + // with |tick_clock_| in accord with wallclock time. This routine can then + // be called with |tick_clock_| set into the future. + // + // Returns true if there was a timer running and it was triggerred + // (|tick_clock_->NowTicks() > + // outstanding_recomputation_timer_.desired_run_time()|). + bool ConditionallyTriggerTimerForTesting(); + + private: + class ThrottleImpl; + using ThrottleList = std::list; + + void OnThrottlePriorityChanged(ThrottleImpl* throttle, + RequestPriority old_priority, + RequestPriority new_priority); + void OnThrottleDestroyed(ThrottleImpl* throttle); + + // Recompute how many requests count as outstanding (i.e. + // are not older than kMedianLifetimeMultiple * MedianThrottleLifetime()). + // If outstanding_recomputation_timer_ is not set, it will be set + // to the earliest a throttle might "age out" of the outstanding list. + void RecomputeOutstanding(); + + // Unblock the specified throttle. May result in re-entrant calls + // into NetworkThrottleManagerImpl. + void UnblockThrottle(ThrottleImpl* throttle); + + // Recomputes how many requests count as outstanding, checks to see + // if any currently blocked throttles should be unblocked, + // and unblock them if so. Note that unblocking may result in + // re-entrant calls to this class, so no assumptions about state persistence + // should be made across this call. + void MaybeUnblockThrottles(); + + PercentileEstimator lifetime_median_estimate_; + + // base::Timer controlling outstanding request recomputation. + // + // This is started whenever it is not running and a new throttle is + // added to |outstanding_throttles_|, and is never cleared except by + // execution, which re-starts it if there are any + // outstanding_throttles_. So it should always be running if any + // throttles are outstanding. This guarantees that the class will + // eventually detect aging out of outstanding throttles and unblock + // throttles blocked on those outstanding throttles. + std::unique_ptr outstanding_recomputation_timer_; + + // FIFO of OUTSTANDING throttles (ordered by time of entry into the + // OUTSTANDING state). + ThrottleList outstanding_throttles_; + + // FIFO list of BLOCKED throttles. This is a list so that the + // throttles can store iterators to themselves. + ThrottleList blocked_throttles_; + + // For testing. + const base::TickClock* tick_clock_; + + base::WeakPtrFactory weak_ptr_factory_; + + DISALLOW_COPY_AND_ASSIGN(NetworkThrottleManagerImpl); +}; + +} // namespace net + +#endif // NET_BASE_NETWORK_THROTTLE_MANAGER_IMPL_H_ diff --git a/net/http/broken_alternative_services.cc b/net/http/broken_alternative_services.cc index 04e541f575affe..6c57a23af7f002 100644 --- a/net/http/broken_alternative_services.cc +++ b/net/http/broken_alternative_services.cc @@ -30,11 +30,10 @@ base::TimeDelta ComputeBrokenAlternativeServiceExpirationDelay( } // namespace -BrokenAlternativeServices::BrokenAlternativeServices(Delegate* delegate, - base::TickClock* clock) - : delegate_(delegate), - clock_(clock), - weak_ptr_factory_(this) { +BrokenAlternativeServices::BrokenAlternativeServices( + Delegate* delegate, + const base::TickClock* clock) + : delegate_(delegate), clock_(clock), weak_ptr_factory_(this) { DCHECK(delegate_); DCHECK(clock_); } @@ -297,4 +296,4 @@ void BrokenAlternativeServices :: weak_ptr_factory_.GetWeakPtr())); } -} // namespace net \ No newline at end of file +} // namespace net diff --git a/net/http/broken_alternative_services.h b/net/http/broken_alternative_services.h index f60b6c298a5639..16e20ea2ba30b7 100644 --- a/net/http/broken_alternative_services.h +++ b/net/http/broken_alternative_services.h @@ -41,7 +41,7 @@ class NET_EXPORT_PRIVATE BrokenAlternativeServices { // |clock| is used for setting expiration times and scheduling the // expiration of broken alternative services. It must not be null. // |delegate| and |clock| are both unowned and must outlive this. - BrokenAlternativeServices(Delegate* delegate, base::TickClock* clock); + BrokenAlternativeServices(Delegate* delegate, const base::TickClock* clock); BrokenAlternativeServices(const BrokenAlternativeServices&) = delete; void operator=(const BrokenAlternativeServices&) = delete; @@ -135,8 +135,8 @@ class NET_EXPORT_PRIVATE BrokenAlternativeServices { void ExpireBrokenAlternateProtocolMappings(); void ScheduleBrokenAlternateProtocolMappingsExpiration(); - Delegate* delegate_; // Unowned - base::TickClock* clock_; // Unowned + Delegate* delegate_; // Unowned + const base::TickClock* clock_; // Unowned // List of pairs sorted by expiration time. BrokenAlternativeServiceList broken_alternative_service_list_; diff --git a/net/http/broken_alternative_services_unittest.cc b/net/http/broken_alternative_services_unittest.cc index aac8f64f206c76..05bce72cb7a788 100644 --- a/net/http/broken_alternative_services_unittest.cc +++ b/net/http/broken_alternative_services_unittest.cc @@ -37,7 +37,7 @@ class BrokenAlternativeServicesTest scoped_refptr test_task_runner_; base::TestMockTimeTaskRunner::ScopedContext test_task_runner_context_; - base::TickClock* broken_services_clock_; + const base::TickClock* broken_services_clock_; BrokenAlternativeServices broken_services_; std::vector expired_alt_svcs_; diff --git a/net/http/http_server_properties_impl.cc b/net/http/http_server_properties_impl.cc index 14e8ad677ba4c5..6e915cf25950d3 100644 --- a/net/http/http_server_properties_impl.cc +++ b/net/http/http_server_properties_impl.cc @@ -22,8 +22,9 @@ namespace net { -HttpServerPropertiesImpl::HttpServerPropertiesImpl(base::TickClock* tick_clock, - base::Clock* clock) +HttpServerPropertiesImpl::HttpServerPropertiesImpl( + const base::TickClock* tick_clock, + base::Clock* clock) : tick_clock_(tick_clock ? tick_clock : base::DefaultTickClock::GetInstance()), clock_(clock ? clock : base::DefaultClock::GetInstance()), diff --git a/net/http/http_server_properties_impl.h b/net/http/http_server_properties_impl.h index e3d15e98aa24cf..ce89063a38bec4 100644 --- a/net/http/http_server_properties_impl.h +++ b/net/http/http_server_properties_impl.h @@ -43,7 +43,8 @@ class NET_EXPORT HttpServerPropertiesImpl // used. // |clock| is used for converting base::TimeTicks to base::Time for // wherever base::Time is preferable. - HttpServerPropertiesImpl(base::TickClock* tick_clock, base::Clock* clock); + HttpServerPropertiesImpl(const base::TickClock* tick_clock, + base::Clock* clock); // Default clock will be used. HttpServerPropertiesImpl(); @@ -180,8 +181,8 @@ class NET_EXPORT HttpServerPropertiesImpl // have an entry associated with |server|, the method will add one. void UpdateCanonicalServerInfoMap(const QuicServerId& server); - base::TickClock* tick_clock_; // Unowned - base::Clock* clock_; // Unowned + const base::TickClock* tick_clock_; // Unowned + base::Clock* clock_; // Unowned SpdyServersMap spdy_servers_map_; Http11ServerHostPortSet http11_servers_; diff --git a/net/http/http_server_properties_impl_unittest.cc b/net/http/http_server_properties_impl_unittest.cc index 4c460bbc7d6bae..1b244b28d522f7 100644 --- a/net/http/http_server_properties_impl_unittest.cc +++ b/net/http/http_server_properties_impl_unittest.cc @@ -98,7 +98,7 @@ class HttpServerPropertiesImplTest : public testing::Test { scoped_refptr test_task_runner_; - base::TickClock* test_tick_clock_; + const base::TickClock* test_tick_clock_; base::SimpleTestClock test_clock_; HttpServerPropertiesImpl impl_; diff --git a/net/http/http_server_properties_manager.cc b/net/http/http_server_properties_manager.cc index 4dbb45771891a7..5bacee1d02eacf 100644 --- a/net/http/http_server_properties_manager.cc +++ b/net/http/http_server_properties_manager.cc @@ -106,7 +106,7 @@ HttpServerPropertiesManager::PrefDelegate::~PrefDelegate() = default; HttpServerPropertiesManager::HttpServerPropertiesManager( std::unique_ptr pref_delegate, NetLog* net_log, - base::TickClock* clock) + const base::TickClock* clock) : pref_delegate_(std::move(pref_delegate)), clock_(clock ? clock : base::DefaultTickClock::GetInstance()), net_log_( diff --git a/net/http/http_server_properties_manager.h b/net/http/http_server_properties_manager.h index 5f346262100721..001392041c97fb 100644 --- a/net/http/http_server_properties_manager.h +++ b/net/http/http_server_properties_manager.h @@ -76,7 +76,7 @@ class NET_EXPORT HttpServerPropertiesManager : public HttpServerProperties { // be used. HttpServerPropertiesManager(std::unique_ptr pref_delegate, NetLog* net_log, - base::TickClock* clock = nullptr); + const base::TickClock* clock = nullptr); ~HttpServerPropertiesManager() override; @@ -267,7 +267,7 @@ class NET_EXPORT HttpServerPropertiesManager : public HttpServerProperties { // result of them being changed by the changes just made by this class. bool setting_prefs_ = false; - base::TickClock* clock_; // Unowned + const base::TickClock* clock_; // Unowned // Set to true once the initial prefs have been loaded. bool is_initialized_ = false; diff --git a/net/http/http_server_properties_manager_unittest.cc b/net/http/http_server_properties_manager_unittest.cc index 5e44a1fd6b7732..30f9fe0afc83ee 100644 --- a/net/http/http_server_properties_manager_unittest.cc +++ b/net/http/http_server_properties_manager_unittest.cc @@ -150,7 +150,7 @@ class HttpServerPropertiesManagerTest : public testing::TestWithParam { // Overrides the main thread's message loop with a mock tick clock. base::ScopedMockTimeMessageLoopTaskRunner test_task_runner_; - base::TickClock* net_test_task_runner_clock_; + const base::TickClock* net_test_task_runner_clock_; private: DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManagerTest); diff --git a/net/network_error_logging/network_error_logging_service.cc b/net/network_error_logging/network_error_logging_service.cc index 6fdbcceb505a3d..82f508ea2565d4 100644 --- a/net/network_error_logging/network_error_logging_service.cc +++ b/net/network_error_logging/network_error_logging_service.cc @@ -560,7 +560,7 @@ void NetworkErrorLoggingService::SetReportingService( } void NetworkErrorLoggingService::SetTickClockForTesting( - base::TickClock* tick_clock) { + const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } diff --git a/net/network_error_logging/network_error_logging_service.h b/net/network_error_logging/network_error_logging_service.h index e63ece2f8474ec..7fd8b20eb39b25 100644 --- a/net/network_error_logging/network_error_logging_service.h +++ b/net/network_error_logging/network_error_logging_service.h @@ -119,13 +119,13 @@ class NET_EXPORT NetworkErrorLoggingService { // Sets a base::TickClock (used to track policy expiration) for tests. // |tick_clock| must outlive the NetworkErrorLoggingService, and cannot be // nullptr. - void SetTickClockForTesting(base::TickClock* tick_clock); + void SetTickClockForTesting(const base::TickClock* tick_clock); protected: NetworkErrorLoggingService(); // Unowned: - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; ReportingService* reporting_service_; private: diff --git a/net/nqe/network_quality_estimator.cc b/net/nqe/network_quality_estimator.cc index 2b5440878d4342..18f9dfee2be7fe 100644 --- a/net/nqe/network_quality_estimator.cc +++ b/net/nqe/network_quality_estimator.cc @@ -1440,7 +1440,7 @@ bool NetworkQualityEstimator::ReadCachedNetworkQualityEstimate() { } void NetworkQualityEstimator::SetTickClockForTesting( - base::TickClock* tick_clock) { + const base::TickClock* tick_clock) { DCHECK(thread_checker_.CalledOnValidThread()); tick_clock_ = tick_clock; http_rtt_ms_observations_.SetTickClockForTesting(tick_clock_); diff --git a/net/nqe/network_quality_estimator.h b/net/nqe/network_quality_estimator.h index 5c63cdf023f564..11e901250c39b6 100644 --- a/net/nqe/network_quality_estimator.h +++ b/net/nqe/network_quality_estimator.h @@ -267,7 +267,7 @@ class NET_EXPORT NetworkQualityEstimator const; // Overrides the tick clock used by |this| for testing. - void SetTickClockForTesting(base::TickClock* tick_clock); + void SetTickClockForTesting(const base::TickClock* tick_clock); // Returns the effective type of the current connection based on only the // observations received after |start_time|. |http_rtt|, |transport_rtt| and @@ -532,7 +532,7 @@ class NET_EXPORT NetworkQualityEstimator bool disable_offline_check_; // Tick clock used by the network quality estimator. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Intervals after the main frame request arrives at which accuracy of network // quality prediction is recorded. diff --git a/net/nqe/observation_buffer.cc b/net/nqe/observation_buffer.cc index beb93590e0f34a..84796058adac6d 100644 --- a/net/nqe/observation_buffer.cc +++ b/net/nqe/observation_buffer.cc @@ -23,7 +23,7 @@ namespace internal { ObservationBuffer::ObservationBuffer( const NetworkQualityEstimatorParams* params, - base::TickClock* tick_clock, + const base::TickClock* tick_clock, double weight_multiplier_per_second, double weight_multiplier_per_signal_level) : params_(params), diff --git a/net/nqe/observation_buffer.h b/net/nqe/observation_buffer.h index 4c4bc510531ee7..3d59ea19f8137d 100644 --- a/net/nqe/observation_buffer.h +++ b/net/nqe/observation_buffer.h @@ -41,7 +41,7 @@ struct WeightedObservation; class NET_EXPORT_PRIVATE ObservationBuffer { public: ObservationBuffer(const NetworkQualityEstimatorParams* params, - base::TickClock* tick_clock, + const base::TickClock* tick_clock, double weight_multiplier_per_second, double weight_multiplier_per_signal_level); @@ -75,7 +75,7 @@ class NET_EXPORT_PRIVATE ObservationBuffer { int percentile, size_t* observations_count) const; - void SetTickClockForTesting(base::TickClock* tick_clock) { + void SetTickClockForTesting(const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } @@ -134,7 +134,7 @@ class NET_EXPORT_PRIVATE ObservationBuffer { // |weight_multiplier_per_signal_level_| ^ 3. const double weight_multiplier_per_signal_level_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; DISALLOW_COPY_AND_ASSIGN(ObservationBuffer); }; diff --git a/net/nqe/socket_watcher.cc b/net/nqe/socket_watcher.cc index d10508bfea90f9..26ca08c505860c 100644 --- a/net/nqe/socket_watcher.cc +++ b/net/nqe/socket_watcher.cc @@ -61,7 +61,7 @@ SocketWatcher::SocketWatcher( scoped_refptr task_runner, OnUpdatedRTTAvailableCallback updated_rtt_observation_callback, ShouldNotifyRTTCallback should_notify_rtt_callback, - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : protocol_(protocol), task_runner_(std::move(task_runner)), updated_rtt_observation_callback_(updated_rtt_observation_callback), diff --git a/net/nqe/socket_watcher.h b/net/nqe/socket_watcher.h index 52b1d73a10feaf..a383dadd082cd9 100644 --- a/net/nqe/socket_watcher.h +++ b/net/nqe/socket_watcher.h @@ -65,7 +65,7 @@ class NET_EXPORT_PRIVATE SocketWatcher : public SocketPerformanceWatcher { scoped_refptr task_runner, OnUpdatedRTTAvailableCallback updated_rtt_observation_callback, ShouldNotifyRTTCallback should_notify_rtt_callback, - base::TickClock* tick_clock); + const base::TickClock* tick_clock); ~SocketWatcher() override; @@ -97,7 +97,7 @@ class NET_EXPORT_PRIVATE SocketWatcher : public SocketPerformanceWatcher { // Time when this was last notified of updated RTT. base::TimeTicks last_rtt_notification_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; base::ThreadChecker thread_checker_; diff --git a/net/nqe/socket_watcher_factory.cc b/net/nqe/socket_watcher_factory.cc index e20cb0c7d27f78..884ea770345bdb 100644 --- a/net/nqe/socket_watcher_factory.cc +++ b/net/nqe/socket_watcher_factory.cc @@ -18,7 +18,7 @@ SocketWatcherFactory::SocketWatcherFactory( base::TimeDelta min_notification_interval, OnUpdatedRTTAvailableCallback updated_rtt_observation_callback, ShouldNotifyRTTCallback should_notify_rtt_callback, - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : task_runner_(std::move(task_runner)), min_notification_interval_(min_notification_interval), allow_rtt_private_address_(false), @@ -41,7 +41,8 @@ SocketWatcherFactory::CreateSocketPerformanceWatcher( tick_clock_); } -void SocketWatcherFactory::SetTickClockForTesting(base::TickClock* tick_clock) { +void SocketWatcherFactory::SetTickClockForTesting( + const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } diff --git a/net/nqe/socket_watcher_factory.h b/net/nqe/socket_watcher_factory.h index 7634d6fc0b076d..58d613338aaa99 100644 --- a/net/nqe/socket_watcher_factory.h +++ b/net/nqe/socket_watcher_factory.h @@ -57,7 +57,7 @@ class SocketWatcherFactory : public SocketPerformanceWatcherFactory { base::TimeDelta min_notification_interval, OnUpdatedRTTAvailableCallback updated_rtt_observation_callback, ShouldNotifyRTTCallback should_notify_rtt_callback, - base::TickClock* tick_clock); + const base::TickClock* tick_clock); ~SocketWatcherFactory() override; @@ -71,7 +71,7 @@ class SocketWatcherFactory : public SocketPerformanceWatcherFactory { } // Overrides the tick clock used by |this| for testing. - void SetTickClockForTesting(base::TickClock* tick_clock); + void SetTickClockForTesting(const base::TickClock* tick_clock); private: scoped_refptr task_runner_; @@ -91,7 +91,7 @@ class SocketWatcherFactory : public SocketPerformanceWatcherFactory { // notification should be notified using |updated_rtt_observation_callback_|. ShouldNotifyRTTCallback should_notify_rtt_callback_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; DISALLOW_COPY_AND_ASSIGN(SocketWatcherFactory); }; diff --git a/net/nqe/throughput_analyzer.cc b/net/nqe/throughput_analyzer.cc index d8f84cc00f416d..9dfc9ab26e6d0c 100644 --- a/net/nqe/throughput_analyzer.cc +++ b/net/nqe/throughput_analyzer.cc @@ -46,7 +46,7 @@ ThroughputAnalyzer::ThroughputAnalyzer( const NetworkQualityEstimatorParams* params, scoped_refptr task_runner, ThroughputObservationCallback throughput_observation_callback, - base::TickClock* tick_clock, + const base::TickClock* tick_clock, const NetLogWithSource& net_log) : network_quality_provider_(network_quality_provider), params_(params), @@ -118,7 +118,8 @@ bool ThroughputAnalyzer::IsCurrentlyTrackingThroughput() const { return true; } -void ThroughputAnalyzer::SetTickClockForTesting(base::TickClock* tick_clock) { +void ThroughputAnalyzer::SetTickClockForTesting( + const base::TickClock* tick_clock) { DCHECK(thread_checker_.CalledOnValidThread()); tick_clock_ = tick_clock; DCHECK(tick_clock_); diff --git a/net/nqe/throughput_analyzer.h b/net/nqe/throughput_analyzer.h index 77350017b3a265..446a9022164ed6 100644 --- a/net/nqe/throughput_analyzer.h +++ b/net/nqe/throughput_analyzer.h @@ -63,7 +63,7 @@ class NET_EXPORT_PRIVATE ThroughputAnalyzer { const NetworkQualityEstimatorParams* params, scoped_refptr task_runner, ThroughputObservationCallback throughput_observation_callback, - base::TickClock* tick_clock, + const base::TickClock* tick_clock, const NetLogWithSource& net_log); virtual ~ThroughputAnalyzer(); @@ -89,7 +89,7 @@ class NET_EXPORT_PRIVATE ThroughputAnalyzer { bool IsCurrentlyTrackingThroughput() const; // Overrides the tick clock used by |this| for testing. - void SetTickClockForTesting(base::TickClock* tick_clock); + void SetTickClockForTesting(const base::TickClock* tick_clock); protected: // Exposed for testing. @@ -173,7 +173,7 @@ class NET_EXPORT_PRIVATE ThroughputAnalyzer { ThroughputObservationCallback throughput_observation_callback_; // Guaranteed to be non-null during the lifetime of |this|. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Time when last connection change was observed. base::TimeTicks last_connection_change_; diff --git a/net/nqe/throughput_analyzer_unittest.cc b/net/nqe/throughput_analyzer_unittest.cc index 0b164dfeb07944..11ea27d957fe9b 100644 --- a/net/nqe/throughput_analyzer_unittest.cc +++ b/net/nqe/throughput_analyzer_unittest.cc @@ -61,7 +61,7 @@ class TestThroughputAnalyzer : public internal::ThroughputAnalyzer { public: TestThroughputAnalyzer(NetworkQualityProvider* network_quality_provider, NetworkQualityEstimatorParams* params, - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : internal::ThroughputAnalyzer( network_quality_provider, params, @@ -127,7 +127,7 @@ TEST(ThroughputAnalyzerTest, MaximumRequests) { }}; for (const auto& test : tests) { - base::DefaultTickClock* tick_clock = base::DefaultTickClock::GetInstance(); + const base::TickClock* tick_clock = base::DefaultTickClock::GetInstance(); TestNetworkQualityProvider network_quality_provider; std::map variation_params; NetworkQualityEstimatorParams params(variation_params); @@ -169,7 +169,7 @@ TEST(ThroughputAnalyzerTest, MaximumRequests) { // Tests that the throughput observation is taken only if there are sufficient // number of requests in-flight. TEST(ThroughputAnalyzerTest, TestMinRequestsForThroughputSample) { - base::DefaultTickClock* tick_clock = base::DefaultTickClock::GetInstance(); + const base::TickClock* tick_clock = base::DefaultTickClock::GetInstance(); TestNetworkQualityProvider network_quality_provider; std::map variation_params; variation_params["throughput_hanging_requests_cwnd_size_multiplier"] = "-1"; @@ -276,7 +276,7 @@ TEST(ThroughputAnalyzerTest, TestHangingRequests) { for (const auto& test : tests) { base::HistogramTester histogram_tester; - base::DefaultTickClock* tick_clock = base::DefaultTickClock::GetInstance(); + const base::TickClock* tick_clock = base::DefaultTickClock::GetInstance(); TestNetworkQualityProvider network_quality_provider; if (test.http_rtt >= base::TimeDelta()) network_quality_provider.SetHttpRtt(test.http_rtt); @@ -569,7 +569,7 @@ TEST(ThroughputAnalyzerTest, TestThroughputWithMultipleRequestsOverlap) { }; for (const auto& test : tests) { - base::DefaultTickClock* tick_clock = base::DefaultTickClock::GetInstance(); + const base::TickClock* tick_clock = base::DefaultTickClock::GetInstance(); TestNetworkQualityProvider network_quality_provider; // Localhost requests are not allowed for estimation purposes. std::map variation_params; @@ -672,7 +672,7 @@ TEST(ThroughputAnalyzerTest, TestThroughputWithNetworkRequestsOverlap) { }; for (const auto& test : tests) { - base::DefaultTickClock* tick_clock = base::DefaultTickClock::GetInstance(); + const base::TickClock* tick_clock = base::DefaultTickClock::GetInstance(); TestNetworkQualityProvider network_quality_provider; // Localhost requests are not allowed for estimation purposes. std::map variation_params; @@ -736,7 +736,7 @@ TEST(ThroughputAnalyzerTest, TestThroughputWithNetworkRequestsOverlap) { // of network requests overlap, and the minimum number of in flight requests // when taking an observation is more than 1. TEST(ThroughputAnalyzerTest, TestThroughputWithMultipleNetworkRequests) { - base::DefaultTickClock* tick_clock = base::DefaultTickClock::GetInstance(); + const base::TickClock* tick_clock = base::DefaultTickClock::GetInstance(); TestNetworkQualityProvider network_quality_provider; std::map variation_params; variation_params["throughput_min_requests_in_flight"] = "3"; diff --git a/net/reporting/reporting_cache.cc b/net/reporting/reporting_cache.cc index 4d4a1d01cfa88d..76dbd348576429 100644 --- a/net/reporting/reporting_cache.cc +++ b/net/reporting/reporting_cache.cc @@ -453,7 +453,7 @@ class ReportingCacheImpl : public ReportingCache { return earliest_used; } - base::TickClock* tick_clock() { return context_->tick_clock(); } + const base::TickClock* tick_clock() { return context_->tick_clock(); } ReportingContext* context_; diff --git a/net/reporting/reporting_context.cc b/net/reporting/reporting_context.cc index 8f2a280e5b200f..04ee3b5d2bbaac 100644 --- a/net/reporting/reporting_context.cc +++ b/net/reporting/reporting_context.cc @@ -72,7 +72,7 @@ void ReportingContext::NotifyCacheUpdated() { ReportingContext::ReportingContext(const ReportingPolicy& policy, base::Clock* clock, - base::TickClock* tick_clock, + const base::TickClock* tick_clock, const RandIntCallback& rand_callback, std::unique_ptr uploader, std::unique_ptr delegate) diff --git a/net/reporting/reporting_context.h b/net/reporting/reporting_context.h index 9b4a602127995f..8fff426c2c0a0d 100644 --- a/net/reporting/reporting_context.h +++ b/net/reporting/reporting_context.h @@ -44,7 +44,7 @@ class NET_EXPORT ReportingContext { const ReportingPolicy& policy() { return policy_; } base::Clock* clock() { return clock_; } - base::TickClock* tick_clock() { return tick_clock_; } + const base::TickClock* tick_clock() { return tick_clock_; } ReportingUploader* uploader() { return uploader_.get(); } ReportingDelegate* delegate() { return delegate_.get(); } @@ -65,7 +65,7 @@ class NET_EXPORT ReportingContext { protected: ReportingContext(const ReportingPolicy& policy, base::Clock* clock, - base::TickClock* tick_clock, + const base::TickClock* tick_clock, const RandIntCallback& rand_callback, std::unique_ptr uploader, std::unique_ptr delegate); @@ -74,7 +74,7 @@ class NET_EXPORT ReportingContext { ReportingPolicy policy_; base::Clock* clock_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; std::unique_ptr uploader_; base::ObserverList observers_; diff --git a/net/reporting/reporting_delivery_agent.cc b/net/reporting/reporting_delivery_agent.cc index 741943027652e9..5f7e415d7f26d3 100644 --- a/net/reporting/reporting_delivery_agent.cc +++ b/net/reporting/reporting_delivery_agent.cc @@ -224,7 +224,7 @@ class ReportingDeliveryAgentImpl : public ReportingDeliveryAgent, } const ReportingPolicy& policy() { return context_->policy(); } - base::TickClock* tick_clock() { return context_->tick_clock(); } + const base::TickClock* tick_clock() { return context_->tick_clock(); } ReportingDelegate* delegate() { return context_->delegate(); } ReportingCache* cache() { return context_->cache(); } ReportingUploader* uploader() { return context_->uploader(); } diff --git a/net/reporting/reporting_endpoint_manager.cc b/net/reporting/reporting_endpoint_manager.cc index 6a4c6c126a50ce..b5aec562ec5306 100644 --- a/net/reporting/reporting_endpoint_manager.cc +++ b/net/reporting/reporting_endpoint_manager.cc @@ -119,7 +119,7 @@ class ReportingEndpointManagerImpl : public ReportingEndpointManager { private: const ReportingPolicy& policy() { return context_->policy(); } - base::TickClock* tick_clock() { return context_->tick_clock(); } + const base::TickClock* tick_clock() { return context_->tick_clock(); } ReportingDelegate* delegate() { return context_->delegate(); } ReportingCache* cache() { return context_->cache(); } diff --git a/net/reporting/reporting_test_util.cc b/net/reporting/reporting_test_util.cc index e87f8893943d38..a23535f7572584 100644 --- a/net/reporting/reporting_test_util.cc +++ b/net/reporting/reporting_test_util.cc @@ -164,7 +164,7 @@ void TestReportingDelegate::ParseJson( } TestReportingContext::TestReportingContext(base::Clock* clock, - base::TickClock* tick_clock, + const base::TickClock* tick_clock, const ReportingPolicy& policy) : ReportingContext( policy, diff --git a/net/reporting/reporting_test_util.h b/net/reporting/reporting_test_util.h index 296827b134814d..239a2f42a83c2d 100644 --- a/net/reporting/reporting_test_util.h +++ b/net/reporting/reporting_test_util.h @@ -140,7 +140,7 @@ class TestReportingDelegate : public ReportingDelegate { class TestReportingContext : public ReportingContext { public: TestReportingContext(base::Clock* clock, - base::TickClock* tick_clock, + const base::TickClock* tick_clock, const ReportingPolicy& policy); ~TestReportingContext(); diff --git a/remoting/base/rate_counter.h b/remoting/base/rate_counter.h index c7e08a1ec15983..8367a3fe6b9b2c 100644 --- a/remoting/base/rate_counter.h +++ b/remoting/base/rate_counter.h @@ -34,7 +34,7 @@ class RateCounter { // Note that rates reported before |time_window| has elapsed are not accurate. double Rate() const; - void set_tick_clock_for_tests(base::TickClock* tick_clock) { + void set_tick_clock_for_tests(const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } @@ -54,7 +54,7 @@ class RateCounter { // Sum of values in |data_points_|. int64_t sum_; - base::TickClock* tick_clock_ = base::DefaultTickClock::GetInstance(); + const base::TickClock* tick_clock_ = base::DefaultTickClock::GetInstance(); SEQUENCE_CHECKER(sequence_checker_); diff --git a/remoting/client/ui/fling_animation.cc b/remoting/client/ui/fling_animation.cc index efde8691d0994f..b91d8b8851e100 100644 --- a/remoting/client/ui/fling_animation.cc +++ b/remoting/client/ui/fling_animation.cc @@ -42,7 +42,7 @@ void FlingAnimation::Abort() { fling_tracker_.StopFling(); } -void FlingAnimation::SetTickClockForTest(base::TickClock* clock) { +void FlingAnimation::SetTickClockForTest(const base::TickClock* clock) { clock_ = clock; } diff --git a/remoting/client/ui/fling_animation.h b/remoting/client/ui/fling_animation.h index 19ec7a3f850e77..ecd44b3f6411b7 100644 --- a/remoting/client/ui/fling_animation.h +++ b/remoting/client/ui/fling_animation.h @@ -37,7 +37,7 @@ class FlingAnimation { // Aborts the animation. void Abort(); - void SetTickClockForTest(base::TickClock* clock); + void SetTickClockForTest(const base::TickClock* clock); private: FlingTracker fling_tracker_; @@ -45,7 +45,7 @@ class FlingAnimation { base::TimeTicks fling_start_time_; - base::TickClock* clock_; + const base::TickClock* clock_; // FlingAnimation is neither copyable nor movable. FlingAnimation(const FlingAnimation&) = delete; diff --git a/remoting/codec/video_encoder_vpx.cc b/remoting/codec/video_encoder_vpx.cc index 37d4bf5758807d..bd4740052c1df7 100644 --- a/remoting/codec/video_encoder_vpx.cc +++ b/remoting/codec/video_encoder_vpx.cc @@ -239,7 +239,7 @@ std::unique_ptr VideoEncoderVpx::CreateForVP9() { VideoEncoderVpx::~VideoEncoderVpx() = default; -void VideoEncoderVpx::SetTickClockForTests(base::TickClock* tick_clock) { +void VideoEncoderVpx::SetTickClockForTests(const base::TickClock* tick_clock) { clock_ = tick_clock; } diff --git a/remoting/codec/video_encoder_vpx.h b/remoting/codec/video_encoder_vpx.h index d7d84b432479a5..3ad6084554b678 100644 --- a/remoting/codec/video_encoder_vpx.h +++ b/remoting/codec/video_encoder_vpx.h @@ -32,7 +32,7 @@ class VideoEncoderVpx : public VideoEncoder { ~VideoEncoderVpx() override; - void SetTickClockForTests(base::TickClock* tick_clock); + void SetTickClockForTests(const base::TickClock* tick_clock); // VideoEncoder interface. void SetLosslessEncode(bool want_lossless) override; @@ -88,7 +88,7 @@ class VideoEncoderVpx : public VideoEncoder { // Used to help initialize VideoPackets from DesktopFrames. VideoEncoderHelper helper_; - base::TickClock* clock_; + const base::TickClock* clock_; DISALLOW_COPY_AND_ASSIGN(VideoEncoderVpx); }; diff --git a/remoting/codec/webrtc_video_encoder_vpx.cc b/remoting/codec/webrtc_video_encoder_vpx.cc index 8a1f3ca1ef4d55..20a5930de8134a 100644 --- a/remoting/codec/webrtc_video_encoder_vpx.cc +++ b/remoting/codec/webrtc_video_encoder_vpx.cc @@ -270,7 +270,8 @@ bool WebrtcVideoEncoderVpx::IsSupportedByVP9( WebrtcVideoEncoderVpx::~WebrtcVideoEncoderVpx() = default; -void WebrtcVideoEncoderVpx::SetTickClockForTests(base::TickClock* tick_clock) { +void WebrtcVideoEncoderVpx::SetTickClockForTests( + const base::TickClock* tick_clock) { clock_ = tick_clock; } diff --git a/remoting/codec/webrtc_video_encoder_vpx.h b/remoting/codec/webrtc_video_encoder_vpx.h index 1cce3fa1771d96..0ff9a708f67637 100644 --- a/remoting/codec/webrtc_video_encoder_vpx.h +++ b/remoting/codec/webrtc_video_encoder_vpx.h @@ -43,7 +43,7 @@ class WebrtcVideoEncoderVpx : public WebrtcVideoEncoder { ~WebrtcVideoEncoderVpx() override; - void SetTickClockForTests(base::TickClock* tick_clock); + void SetTickClockForTests(const base::TickClock* tick_clock); void SetLosslessEncode(bool want_lossless); void SetLosslessColor(bool want_lossless); @@ -103,7 +103,7 @@ class WebrtcVideoEncoderVpx : public WebrtcVideoEncoder { std::unique_ptr active_map_; webrtc::DesktopSize active_map_size_; - base::TickClock* clock_; + const base::TickClock* clock_; EncoderBitrateFilter bitrate_filter_; diff --git a/remoting/protocol/capture_scheduler.cc b/remoting/protocol/capture_scheduler.cc index e4aeddb361adaf..38e3c737f411eb 100644 --- a/remoting/protocol/capture_scheduler.cc +++ b/remoting/protocol/capture_scheduler.cc @@ -127,7 +127,7 @@ void CaptureScheduler::ProcessVideoAck(std::unique_ptr video_ack) { ScheduleNextCapture(); } -void CaptureScheduler::SetTickClockForTest(base::TickClock* tick_clock) { +void CaptureScheduler::SetTickClockForTest(const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } diff --git a/remoting/protocol/capture_scheduler.h b/remoting/protocol/capture_scheduler.h index cabd26d3562dc8..119235bcc76981 100644 --- a/remoting/protocol/capture_scheduler.h +++ b/remoting/protocol/capture_scheduler.h @@ -62,7 +62,7 @@ class CaptureScheduler : public VideoFeedbackStub { } // Helper functions for tests. - void SetTickClockForTest(base::TickClock* tick_clock); + void SetTickClockForTest(const base::TickClock* tick_clock); void SetTimerForTest(std::unique_ptr timer); void SetNumOfProcessorsForTest(int num_of_processors); @@ -78,7 +78,7 @@ class CaptureScheduler : public VideoFeedbackStub { base::Closure capture_closure_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Timer used to schedule CaptureNextFrame(). std::unique_ptr capture_timer_; diff --git a/remoting/protocol/webrtc_frame_scheduler_simple.cc b/remoting/protocol/webrtc_frame_scheduler_simple.cc index be4b61f39beedf..799a90b8f9f98d 100644 --- a/remoting/protocol/webrtc_frame_scheduler_simple.cc +++ b/remoting/protocol/webrtc_frame_scheduler_simple.cc @@ -240,7 +240,7 @@ void WebrtcFrameSchedulerSimple::OnFrameEncoded( } void WebrtcFrameSchedulerSimple::SetTickClockForTest( - base::TickClock* tick_clock) { + const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } diff --git a/remoting/protocol/webrtc_frame_scheduler_simple.h b/remoting/protocol/webrtc_frame_scheduler_simple.h index fea084ff7a77b4..a32fb316c72252 100644 --- a/remoting/protocol/webrtc_frame_scheduler_simple.h +++ b/remoting/protocol/webrtc_frame_scheduler_simple.h @@ -49,7 +49,7 @@ class WebrtcFrameSchedulerSimple : public VideoChannelStateObserver, HostFrameStats* frame_stats) override; // Allows unit-tests to provide a mock clock. - void SetTickClockForTest(base::TickClock* tick_clock); + void SetTickClockForTest(const base::TickClock* tick_clock); private: void ScheduleNextFrame(); @@ -57,7 +57,7 @@ class WebrtcFrameSchedulerSimple : public VideoChannelStateObserver, // A TimeTicks provider which defaults to using a real system clock, but can // be replaced for unittests. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; base::Closure capture_callback_; bool paused_ = false; diff --git a/remoting/test/cyclic_frame_generator.cc b/remoting/test/cyclic_frame_generator.cc index 648a551001806e..21dae071d29a58 100644 --- a/remoting/test/cyclic_frame_generator.cc +++ b/remoting/test/cyclic_frame_generator.cc @@ -40,7 +40,7 @@ CyclicFrameGenerator::CyclicFrameGenerator( CyclicFrameGenerator::~CyclicFrameGenerator() = default; -void CyclicFrameGenerator::SetTickClock(base::TickClock* tick_clock) { +void CyclicFrameGenerator::SetTickClock(const base::TickClock* tick_clock) { clock_ = tick_clock; started_time_ = clock_->NowTicks(); } diff --git a/remoting/test/cyclic_frame_generator.h b/remoting/test/cyclic_frame_generator.h index 90d8d6c226e2ad..e802c70451c9bf 100644 --- a/remoting/test/cyclic_frame_generator.h +++ b/remoting/test/cyclic_frame_generator.h @@ -59,7 +59,7 @@ class CyclicFrameGenerator : public protocol::InputEventTimestampsSource { cursor_blink_period_ = cursor_blink_period; } - void SetTickClock(base::TickClock* tick_clock); + void SetTickClock(const base::TickClock* tick_clock); std::unique_ptr GenerateFrame( webrtc::SharedMemoryFactory* shared_memory_factory); @@ -80,7 +80,7 @@ class CyclicFrameGenerator : public protocol::InputEventTimestampsSource { friend class base::RefCountedThreadSafe; std::vector> reference_frames_; - base::TickClock* clock_; + const base::TickClock* clock_; webrtc::DesktopSize screen_size_; // By default switch between reference frames every 2 seconds. diff --git a/services/network/public/cpp/cors/preflight_result.cc b/services/network/public/cpp/cors/preflight_result.cc index 63e30ad8a71eba..17f936ac37635b 100644 --- a/services/network/public/cpp/cors/preflight_result.cc +++ b/services/network/public/cpp/cors/preflight_result.cc @@ -36,7 +36,7 @@ constexpr base::TimeDelta kDefaultTimeout = base::TimeDelta::FromSeconds(5); constexpr base::TimeDelta kMaxTimeout = base::TimeDelta::FromSeconds(600); // Holds TickClock instance to overwrite TimeTicks::Now() for testing. -base::TickClock* tick_clock_for_testing = nullptr; +const base::TickClock* tick_clock_for_testing = nullptr; base::TimeTicks Now() { if (tick_clock_for_testing) @@ -82,7 +82,8 @@ bool ParseAccessControlAllowList(const base::Optional& string, } // namespace // static -void PreflightResult::SetTickClockForTesting(base::TickClock* tick_clock) { +void PreflightResult::SetTickClockForTesting( + const base::TickClock* tick_clock) { tick_clock_for_testing = tick_clock; } diff --git a/services/network/public/cpp/cors/preflight_result.h b/services/network/public/cpp/cors/preflight_result.h index 52b30fdf1a27f5..4916ca2dc19c13 100644 --- a/services/network/public/cpp/cors/preflight_result.h +++ b/services/network/public/cpp/cors/preflight_result.h @@ -31,7 +31,7 @@ namespace cors { // See https://fetch.spec.whatwg.org/#concept-cache. class COMPONENT_EXPORT(NETWORK_CPP) PreflightResult final { public: - static void SetTickClockForTesting(base::TickClock* tick_clock); + static void SetTickClockForTesting(const base::TickClock* tick_clock); // Creates a PreflightResult instance from a CORS-preflight result. Returns // nullptr and |detected_error| is populated with the failed reason if the diff --git a/services/resource_coordinator/resource_coordinator_clock.cc b/services/resource_coordinator/resource_coordinator_clock.cc index cf7371040da4a1..7856f26ff1df24 100644 --- a/services/resource_coordinator/resource_coordinator_clock.cc +++ b/services/resource_coordinator/resource_coordinator_clock.cc @@ -10,8 +10,8 @@ namespace resource_coordinator { namespace { -base::TickClock*& g_tick_clock_for_testing() { - static base::TickClock* tick_clock_for_testing = nullptr; +const base::TickClock*& g_tick_clock_for_testing() { + static const base::TickClock* tick_clock_for_testing = nullptr; return tick_clock_for_testing; } @@ -22,7 +22,7 @@ base::TimeTicks ResourceCoordinatorClock::NowTicks() { : base::TimeTicks::Now(); } -base::TickClock* ResourceCoordinatorClock::GetClockForTesting() { +const base::TickClock* ResourceCoordinatorClock::GetClockForTesting() { return g_tick_clock_for_testing(); } @@ -30,7 +30,8 @@ void ResourceCoordinatorClock::ResetClockForTesting() { g_tick_clock_for_testing() = nullptr; } -void ResourceCoordinatorClock::SetClockForTesting(base::TickClock* tick_clock) { +void ResourceCoordinatorClock::SetClockForTesting( + const base::TickClock* tick_clock) { DCHECK(!g_tick_clock_for_testing()); g_tick_clock_for_testing() = tick_clock; } diff --git a/services/resource_coordinator/resource_coordinator_clock.h b/services/resource_coordinator/resource_coordinator_clock.h index 60d6408cdb724e..622dae72512c41 100644 --- a/services/resource_coordinator/resource_coordinator_clock.h +++ b/services/resource_coordinator/resource_coordinator_clock.h @@ -25,10 +25,10 @@ class ResourceCoordinatorClock { // TimeTicks::Now(). static base::TimeTicks NowTicks(); - static base::TickClock* GetClockForTesting(); + static const base::TickClock* GetClockForTesting(); // Sets a TickClock for testing. - static void SetClockForTesting(base::TickClock* tick_clock); + static void SetClockForTesting(const base::TickClock* tick_clock); static void ResetClockForTesting(); diff --git a/services/ui/ws/user_activity_monitor.cc b/services/ui/ws/user_activity_monitor.cc index d036530b94993a..8e22d445407eea 100644 --- a/services/ui/ws/user_activity_monitor.cc +++ b/services/ui/ws/user_activity_monitor.cc @@ -11,7 +11,8 @@ namespace ui { namespace ws { -UserActivityMonitor::UserActivityMonitor(std::unique_ptr clock) +UserActivityMonitor::UserActivityMonitor( + std::unique_ptr clock) : now_clock_(std::move(clock)) { if (!now_clock_) now_clock_ = base::WrapUnique(new base::DefaultTickClock); diff --git a/services/ui/ws/user_activity_monitor.h b/services/ui/ws/user_activity_monitor.h index 2354504beb5bc3..c892af2257c018 100644 --- a/services/ui/ws/user_activity_monitor.h +++ b/services/ui/ws/user_activity_monitor.h @@ -23,7 +23,8 @@ class UserActivityMonitor : public mojom::UserActivityMonitor { public: // |now_clock| is used to get the timestamp. If |now_clock| is nullptr, then // DefaultTickClock is used. - explicit UserActivityMonitor(std::unique_ptr now_clock); + explicit UserActivityMonitor( + std::unique_ptr now_clock); ~UserActivityMonitor() override; // Should be called whenever some input event is received from the user. @@ -52,7 +53,7 @@ class UserActivityMonitor : public mojom::UserActivityMonitor { void OnIdleObserverDisconnected(mojom::UserIdleObserver* observer); mojo::BindingSet bindings_; - std::unique_ptr now_clock_; + std::unique_ptr now_clock_; struct ActivityObserverInfo { base::TimeTicks last_activity_notification; diff --git a/third_party/WebKit/Source/platform/bindings/RuntimeCallStats.cpp b/third_party/WebKit/Source/platform/bindings/RuntimeCallStats.cpp index 34a4bccac273ac..911a383215918d 100644 --- a/third_party/WebKit/Source/platform/bindings/RuntimeCallStats.cpp +++ b/third_party/WebKit/Source/platform/bindings/RuntimeCallStats.cpp @@ -52,7 +52,8 @@ RuntimeCallTimer* RuntimeCallTimer::Stop() { return parent_; } -RuntimeCallStats::RuntimeCallStats(base::TickClock* clock) : clock_(clock) { +RuntimeCallStats::RuntimeCallStats(const base::TickClock* clock) + : clock_(clock) { static const char* const names[] = { #define BINDINGS_COUNTER_NAME(name) "Blink_Bindings_" #name, BINDINGS_COUNTERS(BINDINGS_COUNTER_NAME) // diff --git a/third_party/WebKit/Source/platform/bindings/RuntimeCallStats.h b/third_party/WebKit/Source/platform/bindings/RuntimeCallStats.h index 33b1cb75ab0517..b7f648f2a7ff9d 100644 --- a/third_party/WebKit/Source/platform/bindings/RuntimeCallStats.h +++ b/third_party/WebKit/Source/platform/bindings/RuntimeCallStats.h @@ -62,7 +62,7 @@ class PLATFORM_EXPORT RuntimeCallCounter { // with the macros below. class PLATFORM_EXPORT RuntimeCallTimer { public: - explicit RuntimeCallTimer(base::TickClock* clock) : clock_(clock) {} + explicit RuntimeCallTimer(const base::TickClock* clock) : clock_(clock) {} ~RuntimeCallTimer() { DCHECK(!IsRunning()); }; // Starts recording time for , and pauses (if non-null). @@ -97,7 +97,7 @@ class PLATFORM_EXPORT RuntimeCallTimer { RuntimeCallTimer* parent_; TimeTicks start_ticks_; TimeDelta elapsed_time_; - base::TickClock* clock_ = nullptr; + const base::TickClock* clock_ = nullptr; }; // Macros that take RuntimeCallStats as a parameter; used only in @@ -162,7 +162,7 @@ class PLATFORM_EXPORT RuntimeCallTimer { // scope. class PLATFORM_EXPORT RuntimeCallStats { public: - explicit RuntimeCallStats(base::TickClock*); + explicit RuntimeCallStats(const base::TickClock*); // Get RuntimeCallStats object associated with the given isolate. static RuntimeCallStats* From(v8::Isolate*); @@ -305,7 +305,7 @@ class PLATFORM_EXPORT RuntimeCallStats { RuntimeCallCounter* GetCounter(const char* name); #endif - base::TickClock* clock() const { return clock_; } + const base::TickClock* clock() const { return clock_; } private: RuntimeCallTimer* current_timer_ = nullptr; @@ -313,7 +313,7 @@ class PLATFORM_EXPORT RuntimeCallStats { RuntimeCallCounter counters_[static_cast(CounterId::kNumberOfCounters)]; static const int number_of_counters_ = static_cast(CounterId::kNumberOfCounters); - base::TickClock* clock_ = nullptr; + const base::TickClock* clock_ = nullptr; #if BUILDFLAG(RCS_COUNT_EVERYTHING) typedef HashMap> CounterMap; diff --git a/third_party/WebKit/Source/platform/bindings/RuntimeCallStatsTest.cpp b/third_party/WebKit/Source/platform/bindings/RuntimeCallStatsTest.cpp index f8402e80487079..0bc780569c2227 100644 --- a/third_party/WebKit/Source/platform/bindings/RuntimeCallStatsTest.cpp +++ b/third_party/WebKit/Source/platform/bindings/RuntimeCallStatsTest.cpp @@ -36,7 +36,7 @@ class RuntimeCallStatsTest : public testing::Test { clock_.Advance(TimeDelta::FromMilliseconds(milliseconds)); } - base::TickClock* clock() { return &clock_; } + const base::TickClock* clock() { return &clock_; } private: RuntimeEnabledFeatures::Backup features_backup_; diff --git a/third_party/WebKit/Source/platform/scheduler/base/lazy_now.h b/third_party/WebKit/Source/platform/scheduler/base/lazy_now.h index ab9eb2bfdf14be..17938456d3ec32 100644 --- a/third_party/WebKit/Source/platform/scheduler/base/lazy_now.h +++ b/third_party/WebKit/Source/platform/scheduler/base/lazy_now.h @@ -23,13 +23,14 @@ class PLATFORM_EXPORT LazyNow { explicit LazyNow(base::TimeTicks now) : tick_clock_(nullptr), now_(now) { } - explicit LazyNow(base::TickClock* tick_clock) : tick_clock_(tick_clock) {} + explicit LazyNow(const base::TickClock* tick_clock) + : tick_clock_(tick_clock) {} // Result will not be updated on any subsesequent calls. base::TimeTicks Now(); private: - base::TickClock* tick_clock_; // NOT OWNED + const base::TickClock* tick_clock_; // NOT OWNED base::Optional now_; }; diff --git a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.h b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.h index 4808a2a1122549..9b83a6e2f93b3e 100644 --- a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.h +++ b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.h @@ -56,7 +56,7 @@ class PLATFORM_EXPORT TaskQueueManager { virtual void UnregisterTimeDomain(TimeDomain* time_domain) = 0; virtual RealTimeDomain* GetRealTimeDomain() const = 0; - virtual base::TickClock* GetClock() const = 0; + virtual const base::TickClock* GetClock() const = 0; virtual base::TimeTicks NowTicks() const = 0; // Sets the SingleThreadTaskRunner that will be returned by diff --git a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_delegate_for_test.cc b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_delegate_for_test.cc index ca8c081c26433e..57004b39c33553 100644 --- a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_delegate_for_test.cc +++ b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_delegate_for_test.cc @@ -16,14 +16,14 @@ namespace scheduler { scoped_refptr TaskQueueManagerDelegateForTest::Create( scoped_refptr task_runner, - base::TickClock* time_source) { + const base::TickClock* time_source) { return base::WrapRefCounted( new TaskQueueManagerDelegateForTest(task_runner, time_source)); } TaskQueueManagerDelegateForTest::TaskQueueManagerDelegateForTest( scoped_refptr task_runner, - base::TickClock* time_source) + const base::TickClock* time_source) : task_runner_(task_runner), time_source_(time_source) {} TaskQueueManagerDelegateForTest::~TaskQueueManagerDelegateForTest() {} diff --git a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_delegate_for_test.h b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_delegate_for_test.h index 449e443bc910cc..bc5a7cf3ef3fbd 100644 --- a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_delegate_for_test.h +++ b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_delegate_for_test.h @@ -21,7 +21,7 @@ class TaskQueueManagerDelegateForTest : public TaskQueueManagerDelegate { public: static scoped_refptr Create( scoped_refptr task_runner, - base::TickClock* time_source); + const base::TickClock* time_source); // SingleThreadTaskRunner: bool PostDelayedTask(const base::Location& from_here, @@ -44,11 +44,11 @@ class TaskQueueManagerDelegateForTest : public TaskQueueManagerDelegate { ~TaskQueueManagerDelegateForTest() override; TaskQueueManagerDelegateForTest( scoped_refptr task_runner, - base::TickClock* time_source); + const base::TickClock* time_source); private: scoped_refptr task_runner_; - base::TickClock* time_source_; + const base::TickClock* time_source_; DISALLOW_COPY_AND_ASSIGN(TaskQueueManagerDelegateForTest); }; diff --git a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_impl.cc b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_impl.cc index 053ffeffb3a98c..00d6981f032437 100644 --- a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_impl.cc +++ b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_impl.cc @@ -625,7 +625,7 @@ void TaskQueueManagerImpl::SetDefaultTaskRunner( controller_->SetDefaultTaskRunner(task_runner); } -base::TickClock* TaskQueueManagerImpl::GetClock() const { +const base::TickClock* TaskQueueManagerImpl::GetClock() const { return controller_->GetClock(); } diff --git a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_impl.h b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_impl.h index 4b3a9a0965434f..4bd2f383e5a161 100644 --- a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_impl.h +++ b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_impl.h @@ -93,7 +93,7 @@ class PLATFORM_EXPORT TaskQueueManagerImpl void RegisterTimeDomain(TimeDomain* time_domain) override; void UnregisterTimeDomain(TimeDomain* time_domain) override; RealTimeDomain* GetRealTimeDomain() const override; - base::TickClock* GetClock() const override; + const base::TickClock* GetClock() const override; base::TimeTicks NowTicks() const override; void SetDefaultTaskRunner( scoped_refptr task_runner) override; diff --git a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_impl_unittest.cc b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_impl_unittest.cc index 532b0e5bc877a2..86c0ee959b9c67 100644 --- a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_impl_unittest.cc +++ b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager_impl_unittest.cc @@ -1976,14 +1976,14 @@ TEST_F(TaskQueueManagerTest, TaskQueueObserver_DelayedWorkWhichCanRunNow) { class CancelableTask { public: - explicit CancelableTask(base::TickClock* clock) + explicit CancelableTask(const base::TickClock* clock) : clock_(clock), weak_factory_(this) {} void RecordTimeTask(std::vector* run_times) { run_times->push_back(clock_->NowTicks()); } - base::TickClock* clock_; + const base::TickClock* clock_; base::WeakPtrFactory weak_factory_; }; diff --git a/third_party/WebKit/Source/platform/scheduler/base/thread_controller.h b/third_party/WebKit/Source/platform/scheduler/base/thread_controller.h index 20279c44c47a67..36d373b9bb2c12 100644 --- a/third_party/WebKit/Source/platform/scheduler/base/thread_controller.h +++ b/third_party/WebKit/Source/platform/scheduler/base/thread_controller.h @@ -74,7 +74,7 @@ class PLATFORM_EXPORT ThreadController { virtual bool RunsTasksInCurrentSequence() = 0; - virtual base::TickClock* GetClock() = 0; + virtual const base::TickClock* GetClock() = 0; virtual void SetDefaultTaskRunner( scoped_refptr) = 0; diff --git a/third_party/WebKit/Source/platform/scheduler/base/thread_controller_impl.cc b/third_party/WebKit/Source/platform/scheduler/base/thread_controller_impl.cc index a4004787d2038e..c0d6e2190653f1 100644 --- a/third_party/WebKit/Source/platform/scheduler/base/thread_controller_impl.cc +++ b/third_party/WebKit/Source/platform/scheduler/base/thread_controller_impl.cc @@ -19,7 +19,7 @@ namespace internal { ThreadControllerImpl::ThreadControllerImpl( base::MessageLoop* message_loop, scoped_refptr task_runner, - base::TickClock* time_source) + const base::TickClock* time_source) : message_loop_(message_loop), task_runner_(task_runner), message_loop_task_runner_(message_loop ? message_loop->task_runner() @@ -38,7 +38,7 @@ ThreadControllerImpl::~ThreadControllerImpl() = default; std::unique_ptr ThreadControllerImpl::Create( base::MessageLoop* message_loop, - base::TickClock* time_source) { + const base::TickClock* time_source) { return base::WrapUnique(new ThreadControllerImpl( message_loop, message_loop->task_runner(), time_source)); } @@ -117,7 +117,7 @@ bool ThreadControllerImpl::RunsTasksInCurrentSequence() { return task_runner_->RunsTasksInCurrentSequence(); } -base::TickClock* ThreadControllerImpl::GetClock() { +const base::TickClock* ThreadControllerImpl::GetClock() { return time_source_; } diff --git a/third_party/WebKit/Source/platform/scheduler/base/thread_controller_impl.h b/third_party/WebKit/Source/platform/scheduler/base/thread_controller_impl.h index 095d20c1790aea..77d16782121630 100644 --- a/third_party/WebKit/Source/platform/scheduler/base/thread_controller_impl.h +++ b/third_party/WebKit/Source/platform/scheduler/base/thread_controller_impl.h @@ -34,7 +34,7 @@ class PLATFORM_EXPORT ThreadControllerImpl static std::unique_ptr Create( base::MessageLoop* message_loop, - base::TickClock* time_source); + const base::TickClock* time_source); // ThreadController: void SetWorkBatchSize(int work_batch_size) override; @@ -45,7 +45,7 @@ class PLATFORM_EXPORT ThreadControllerImpl void CancelDelayedWork(base::TimeTicks run_time) override; void SetSequencedTaskSource(SequencedTaskSource* sequence) override; bool RunsTasksInCurrentSequence() override; - base::TickClock* GetClock() override; + const base::TickClock* GetClock() override; void SetDefaultTaskRunner( scoped_refptr) override; void RestoreDefaultTaskRunner() override; @@ -59,7 +59,7 @@ class PLATFORM_EXPORT ThreadControllerImpl protected: ThreadControllerImpl(base::MessageLoop* message_loop, scoped_refptr task_runner, - base::TickClock* time_source); + const base::TickClock* time_source); // TODO(altimin): Make these const. Blocked on removing // lazy initialisation support. @@ -113,7 +113,7 @@ class PLATFORM_EXPORT ThreadControllerImpl } scoped_refptr message_loop_task_runner_; - base::TickClock* time_source_; + const base::TickClock* time_source_; base::RepeatingClosure immediate_do_work_closure_; base::RepeatingClosure delayed_do_work_closure_; base::CancelableClosure cancelable_delayed_do_work_closure_; diff --git a/third_party/WebKit/Source/platform/scheduler/child/scheduler_helper.cc b/third_party/WebKit/Source/platform/scheduler/child/scheduler_helper.cc index 6eedcf628ae760..35ef8dbf93fc51 100644 --- a/third_party/WebKit/Source/platform/scheduler/child/scheduler_helper.cc +++ b/third_party/WebKit/Source/platform/scheduler/child/scheduler_helper.cc @@ -118,7 +118,7 @@ void SchedulerHelper::OnExitNestedRunLoop() { observer_->OnExitNestedRunLoop(); } -base::TickClock* SchedulerHelper::GetClock() const { +const base::TickClock* SchedulerHelper::GetClock() const { return task_queue_manager_->GetClock(); } diff --git a/third_party/WebKit/Source/platform/scheduler/child/scheduler_helper.h b/third_party/WebKit/Source/platform/scheduler/child/scheduler_helper.h index 03ccc0ef49ebce..17309947b47cd5 100644 --- a/third_party/WebKit/Source/platform/scheduler/child/scheduler_helper.h +++ b/third_party/WebKit/Source/platform/scheduler/child/scheduler_helper.h @@ -27,7 +27,7 @@ class PLATFORM_EXPORT SchedulerHelper : public TaskQueueManager::Observer { void OnBeginNestedRunLoop() override; void OnExitNestedRunLoop() override; - base::TickClock* GetClock() const; + const base::TickClock* GetClock() const; base::TimeTicks NowTicks() const; // Returns the default task queue. diff --git a/third_party/WebKit/Source/platform/scheduler/common/throttling/task_queue_throttler.h b/third_party/WebKit/Source/platform/scheduler/common/throttling/task_queue_throttler.h index 81a178f71ce63e..7861066008bb8a 100644 --- a/third_party/WebKit/Source/platform/scheduler/common/throttling/task_queue_throttler.h +++ b/third_party/WebKit/Source/platform/scheduler/common/throttling/task_queue_throttler.h @@ -202,7 +202,7 @@ class PLATFORM_EXPORT TaskQueueThrottler : public TaskQueue::Observer, scoped_refptr control_task_queue_; RendererSchedulerImpl* renderer_scheduler_; // NOT OWNED TraceableVariableController* tracing_controller_; // NOT OWNED - base::TickClock* tick_clock_; // NOT OWNED + const base::TickClock* tick_clock_; // NOT OWNED std::unique_ptr time_domain_; CancelableClosureHolder pump_throttled_tasks_closure_; diff --git a/third_party/WebKit/Source/platform/scheduler/main_thread/main_thread_scheduler.cc b/third_party/WebKit/Source/platform/scheduler/main_thread/main_thread_scheduler.cc index 667be81d92c822..3aa1abfecf36d8 100644 --- a/third_party/WebKit/Source/platform/scheduler/main_thread/main_thread_scheduler.cc +++ b/third_party/WebKit/Source/platform/scheduler/main_thread/main_thread_scheduler.cc @@ -342,7 +342,7 @@ RendererSchedulerImpl::~RendererSchedulerImpl() { RendererSchedulerImpl::MainThreadOnly::MainThreadOnly( RendererSchedulerImpl* renderer_scheduler_impl, const scoped_refptr& compositor_task_runner, - base::TickClock* time_source, + const base::TickClock* time_source, base::TimeTicks now) : loading_task_cost_estimator(time_source, kLoadingTaskEstimationSampleCount, @@ -2429,7 +2429,7 @@ void RendererSchedulerImpl::UnregisterTimeDomain(TimeDomain* time_domain) { helper_.UnregisterTimeDomain(time_domain); } -base::TickClock* RendererSchedulerImpl::tick_clock() const { +const base::TickClock* RendererSchedulerImpl::tick_clock() const { return helper_.GetClock(); } diff --git a/third_party/WebKit/Source/platform/scheduler/main_thread/main_thread_scheduler.h b/third_party/WebKit/Source/platform/scheduler/main_thread/main_thread_scheduler.h index a6a0f17f68cd3a..1ca3c149a818b8 100644 --- a/third_party/WebKit/Source/platform/scheduler/main_thread/main_thread_scheduler.h +++ b/third_party/WebKit/Source/platform/scheduler/main_thread/main_thread_scheduler.h @@ -248,7 +248,7 @@ class PLATFORM_EXPORT RendererSchedulerImpl bool PolicyNeedsUpdateForTesting(); WakeUpBudgetPool* GetWakeUpBudgetPoolForTesting(); - base::TickClock* tick_clock() const; + const base::TickClock* tick_clock() const; RealTimeDomain* real_time_domain() const { return helper_.real_time_domain(); @@ -631,7 +631,7 @@ class PLATFORM_EXPORT RendererSchedulerImpl MainThreadOnly( RendererSchedulerImpl* renderer_scheduler_impl, const scoped_refptr& compositor_task_runner, - base::TickClock* time_source, + const base::TickClock* time_source, base::TimeTicks now); ~MainThreadOnly(); diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/idle_time_estimator.cc b/third_party/WebKit/Source/platform/scheduler/renderer/idle_time_estimator.cc index d3d5a8d91e161b..a738e8a8615933 100644 --- a/third_party/WebKit/Source/platform/scheduler/renderer/idle_time_estimator.cc +++ b/third_party/WebKit/Source/platform/scheduler/renderer/idle_time_estimator.cc @@ -11,7 +11,7 @@ namespace scheduler { IdleTimeEstimator::IdleTimeEstimator( const scoped_refptr& compositor_task_runner, - base::TickClock* time_source, + const base::TickClock* time_source, int sample_count, double estimation_percentile) : compositor_task_queue_(compositor_task_runner), diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/idle_time_estimator.h b/third_party/WebKit/Source/platform/scheduler/renderer/idle_time_estimator.h index bfd43af146d1a3..00dc0fba06e8f5 100644 --- a/third_party/WebKit/Source/platform/scheduler/renderer/idle_time_estimator.h +++ b/third_party/WebKit/Source/platform/scheduler/renderer/idle_time_estimator.h @@ -20,7 +20,7 @@ class PLATFORM_EXPORT IdleTimeEstimator : public base::MessageLoop::TaskObserver { public: IdleTimeEstimator(const scoped_refptr& compositor_task_runner, - base::TickClock* time_source, + const base::TickClock* time_source, int sample_count, double estimation_percentile); @@ -42,7 +42,7 @@ class PLATFORM_EXPORT IdleTimeEstimator private: scoped_refptr compositor_task_queue_; cc::RollingTimeDeltaHistory per_frame_compositor_task_runtime_; - base::TickClock* time_source_; // NOT OWNED + const base::TickClock* time_source_; // NOT OWNED double estimation_percentile_; base::TimeTicks task_start_time_; diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/idle_time_estimator_unittest.cc b/third_party/WebKit/Source/platform/scheduler/renderer/idle_time_estimator_unittest.cc index 3993017e62c167..68968e05f7b0a1 100644 --- a/third_party/WebKit/Source/platform/scheduler/renderer/idle_time_estimator_unittest.cc +++ b/third_party/WebKit/Source/platform/scheduler/renderer/idle_time_estimator_unittest.cc @@ -23,7 +23,7 @@ class IdleTimeEstimatorForTest : public IdleTimeEstimator { public: IdleTimeEstimatorForTest( const scoped_refptr& compositor_task_runner, - base::TickClock* clock, + const base::TickClock* clock, int sample_count, double estimation_percentile) : IdleTimeEstimator(compositor_task_runner, diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/task_cost_estimator.cc b/third_party/WebKit/Source/platform/scheduler/renderer/task_cost_estimator.cc index df69a1f49c531e..9dea1c78ce31f9 100644 --- a/third_party/WebKit/Source/platform/scheduler/renderer/task_cost_estimator.cc +++ b/third_party/WebKit/Source/platform/scheduler/renderer/task_cost_estimator.cc @@ -9,7 +9,7 @@ namespace blink { namespace scheduler { -TaskCostEstimator::TaskCostEstimator(base::TickClock* time_source, +TaskCostEstimator::TaskCostEstimator(const base::TickClock* time_source, int sample_count, double estimation_percentile) : rolling_time_delta_history_(sample_count), diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/task_cost_estimator.h b/third_party/WebKit/Source/platform/scheduler/renderer/task_cost_estimator.h index 3f0631e9e32f5f..9e34a267a943e4 100644 --- a/third_party/WebKit/Source/platform/scheduler/renderer/task_cost_estimator.h +++ b/third_party/WebKit/Source/platform/scheduler/renderer/task_cost_estimator.h @@ -22,7 +22,7 @@ namespace scheduler { class PLATFORM_EXPORT TaskCostEstimator : public base::MessageLoop::TaskObserver { public: - TaskCostEstimator(base::TickClock* time_source, + TaskCostEstimator(const base::TickClock* time_source, int sample_count, double estimation_percentile); ~TaskCostEstimator() override; @@ -37,7 +37,7 @@ class PLATFORM_EXPORT TaskCostEstimator private: cc::RollingTimeDeltaHistory rolling_time_delta_history_; - base::TickClock* time_source_; // NOT OWNED + const base::TickClock* time_source_; // NOT OWNED int outstanding_task_count_; double estimation_percentile_; base::TimeTicks task_start_time_; diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/task_cost_estimator_unittest.cc b/third_party/WebKit/Source/platform/scheduler/renderer/task_cost_estimator_unittest.cc index 0fed209795d4e7..79ff46dc920756 100644 --- a/third_party/WebKit/Source/platform/scheduler/renderer/task_cost_estimator_unittest.cc +++ b/third_party/WebKit/Source/platform/scheduler/renderer/task_cost_estimator_unittest.cc @@ -23,7 +23,7 @@ class TaskCostEstimatorTest : public testing::Test { class TaskCostEstimatorForTest : public TaskCostEstimator { public: - TaskCostEstimatorForTest(base::TickClock* clock, + TaskCostEstimatorForTest(const base::TickClock* clock, int sample_count, double estimation_percentile) : TaskCostEstimator(clock, sample_count, estimation_percentile) {} diff --git a/third_party/WebKit/Source/platform/scheduler/test/task_queue_manager_for_test.cc b/third_party/WebKit/Source/platform/scheduler/test/task_queue_manager_for_test.cc index f835e0443d313a..98a2013301418a 100644 --- a/third_party/WebKit/Source/platform/scheduler/test/task_queue_manager_for_test.cc +++ b/third_party/WebKit/Source/platform/scheduler/test/task_queue_manager_for_test.cc @@ -16,7 +16,7 @@ class ThreadControllerForTest : public internal::ThreadControllerImpl { ThreadControllerForTest( base::MessageLoop* message_loop, scoped_refptr task_runner, - base::TickClock* time_source) + const base::TickClock* time_source) : ThreadControllerImpl(message_loop, std::move(task_runner), time_source) {} @@ -47,7 +47,7 @@ TaskQueueManagerForTest::TaskQueueManagerForTest( std::unique_ptr TaskQueueManagerForTest::Create( base::MessageLoop* message_loop, scoped_refptr task_runner, - base::TickClock* clock) { + const base::TickClock* clock) { return std::make_unique( std::make_unique(message_loop, std::move(task_runner), clock)); diff --git a/third_party/WebKit/Source/platform/scheduler/test/task_queue_manager_for_test.h b/third_party/WebKit/Source/platform/scheduler/test/task_queue_manager_for_test.h index 98fa34e76be73f..6e6a5c72cc2d23 100644 --- a/third_party/WebKit/Source/platform/scheduler/test/task_queue_manager_for_test.h +++ b/third_party/WebKit/Source/platform/scheduler/test/task_queue_manager_for_test.h @@ -29,7 +29,7 @@ class TaskQueueManagerForTest : public TaskQueueManagerImpl { static std::unique_ptr Create( base::MessageLoop* message_loop, scoped_refptr task_runner, - base::TickClock* clock); + const base::TickClock* clock); size_t ActiveQueuesCount() const; bool HasImmediateWork() const; diff --git a/tools/battor_agent/battor_agent.h b/tools/battor_agent/battor_agent.h index 0c956645ef61c5..d33b8e0fb5fb90 100644 --- a/tools/battor_agent/battor_agent.h +++ b/tools/battor_agent/battor_agent.h @@ -103,7 +103,7 @@ class BattOrAgent : public BattOrConnection::Listener, std::unique_ptr connection_; // A source of TimeTicks. Protected so that it can be faked in testing. - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; // Timeout for when an action isn't completed within the allotted time. This // is virtual and protected so that timeouts can be disabled in testing. The diff --git a/tools/battor_agent/battor_agent_unittest.cc b/tools/battor_agent/battor_agent_unittest.cc index c6550fab009714..d952fc313942b6 100644 --- a/tools/battor_agent/battor_agent_unittest.cc +++ b/tools/battor_agent/battor_agent_unittest.cc @@ -84,7 +84,7 @@ class MockBattOrConnection : public BattOrConnection { class TestableBattOrAgent : public BattOrAgent { public: TestableBattOrAgent(BattOrAgent::Listener* listener, - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : BattOrAgent("/dev/test", listener, nullptr) { connection_ = std::unique_ptr(new MockBattOrConnection(this)); diff --git a/tools/battor_agent/battor_connection_impl.h b/tools/battor_agent/battor_connection_impl.h index a2db3b0c3c045c..ee2cc39c325080 100644 --- a/tools/battor_agent/battor_connection_impl.h +++ b/tools/battor_agent/battor_connection_impl.h @@ -64,7 +64,7 @@ class BattOrConnectionImpl // IO handler capable of reading and writing from the serial connection. scoped_refptr io_handler_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; private: void OnOpened(bool success); diff --git a/tools/battor_agent/battor_connection_impl_unittest.cc b/tools/battor_agent/battor_connection_impl_unittest.cc index f78e6fc2e8434f..2ce35ca9cb4960 100644 --- a/tools/battor_agent/battor_connection_impl_unittest.cc +++ b/tools/battor_agent/battor_connection_impl_unittest.cc @@ -31,7 +31,7 @@ namespace battor { class TestableBattOrConnection : public BattOrConnectionImpl { public: TestableBattOrConnection(BattOrConnection::Listener* listener, - base::TickClock* tick_clock) + const base::TickClock* tick_clock) : BattOrConnectionImpl("/dev/test", listener, nullptr) { tick_clock_ = tick_clock; } diff --git a/ui/events/base_event_utils.cc b/ui/events/base_event_utils.cc index 20bbed9d18f6f8..21dc226e9ff32a 100644 --- a/ui/events/base_event_utils.cc +++ b/ui/events/base_event_utils.cc @@ -47,7 +47,7 @@ bool IsSystemKeyModifier(int flags) { (EF_ALTGR_DOWN & flags) == 0; } -base::LazyInstance::Leaky g_tick_clock = +base::LazyInstance::Leaky g_tick_clock = LAZY_INSTANCE_INITIALIZER; base::TimeTicks EventTimeForNow() { @@ -55,7 +55,7 @@ base::TimeTicks EventTimeForNow() { : base::TimeTicks::Now(); } -void SetEventTickClockForTesting(base::TickClock* tick_clock) { +void SetEventTickClockForTesting(const base::TickClock* tick_clock) { g_tick_clock.Get() = tick_clock; } diff --git a/ui/events/base_event_utils.h b/ui/events/base_event_utils.h index d030fd15b8dc61..c75509fd171531 100644 --- a/ui/events/base_event_utils.h +++ b/ui/events/base_event_utils.h @@ -30,7 +30,7 @@ EVENTS_BASE_EXPORT base::TimeTicks EventTimeForNow(); // Overrides the clock used by EventTimeForNow for testing. // This doesn't take the ownership of the clock. EVENTS_BASE_EXPORT void SetEventTickClockForTesting( - base::TickClock* tick_clock); + const base::TickClock* tick_clock); // Converts an event timestamp ticks to seconds (floating point representation). // WARNING: This should only be used when interfacing with platform code that diff --git a/ui/events/blink/input_handler_proxy.cc b/ui/events/blink/input_handler_proxy.cc index 126f75c6518d80..90ebc4ea0af44e 100644 --- a/ui/events/blink/input_handler_proxy.cc +++ b/ui/events/blink/input_handler_proxy.cc @@ -1400,7 +1400,8 @@ void InputHandlerProxy::HandleScrollElasticityOverscroll( scroll_result)); } -void InputHandlerProxy::SetTickClockForTesting(base::TickClock* tick_clock) { +void InputHandlerProxy::SetTickClockForTesting( + const base::TickClock* tick_clock) { tick_clock_ = tick_clock; } diff --git a/ui/events/blink/input_handler_proxy.h b/ui/events/blink/input_handler_proxy.h index f39f3a7403f411..8ade9f5388fe9d 100644 --- a/ui/events/blink/input_handler_proxy.h +++ b/ui/events/blink/input_handler_proxy.h @@ -189,7 +189,7 @@ class InputHandlerProxy : public cc::InputHandlerClient, // Overrides the internal clock for testing. // This doesn't take the ownership of the clock. |tick_clock| must outlive the // InputHandlerProxy instance. - void SetTickClockForTesting(base::TickClock* tick_clock); + void SetTickClockForTesting(const base::TickClock* tick_clock); // |is_touching_scrolling_layer| indicates if one of the points that has // been touched hits a currently scrolling layer. @@ -270,7 +270,7 @@ class InputHandlerProxy : public cc::InputHandlerClient, bool has_ongoing_compositor_scroll_fling_pinch_; bool is_first_gesture_scroll_update_; - base::TickClock* tick_clock_; + const base::TickClock* tick_clock_; std::unique_ptr fling_booster_; diff --git a/ui/events/blink/input_handler_proxy_unittest.cc b/ui/events/blink/input_handler_proxy_unittest.cc index 1f8734cc3a79ca..ff87840d3c8bed 100644 --- a/ui/events/blink/input_handler_proxy_unittest.cc +++ b/ui/events/blink/input_handler_proxy_unittest.cc @@ -558,7 +558,8 @@ class InputHandlerProxyEventQueueTest : public testing::TestWithParam { return input_handler_proxy_->compositor_event_queue_->queue_; } - void SetInputHandlerProxyTickClockForTesting(base::TickClock* tick_clock) { + void SetInputHandlerProxyTickClockForTesting( + const base::TickClock* tick_clock) { input_handler_proxy_->SetTickClockForTesting(tick_clock); }