Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass base::TimeDelta by value #25813

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion browser/brave_shields/ad_block_service_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3077,7 +3077,7 @@ class AdBlockServiceTestJsPerformance : public AdBlockServiceTest {
target, content::JsReplace(kTemplate, start_number, end_number)));
}

void NonBlockingDelay(const base::TimeDelta& delay) {
void NonBlockingDelay(base::TimeDelta delay) {
base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed);
base::SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask(
FROM_HERE, run_loop.QuitWhenIdleClosure(), delay);
Expand Down
4 changes: 2 additions & 2 deletions browser/misc_metrics/doh_metrics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const int kAutoSecureRequestsBuckets[] = {0, 5, 50, 90};

constexpr char kDohModeAutomatic[] = "automatic";
constexpr char kDohModeSecure[] = "secure";
const base::TimeDelta kAutoSecureInitDelay = base::Seconds(6);
const base::TimeDelta kAutoSecureReportInterval = base::Seconds(20);
constexpr base::TimeDelta kAutoSecureInitDelay = base::Seconds(6);
constexpr base::TimeDelta kAutoSecureReportInterval = base::Seconds(20);

const char* GetAutoSecureRequestsHistogramName() {
std::string histogram_name = kAutoSecureRequestsHistogramName;
Expand Down
2 changes: 1 addition & 1 deletion browser/sandbox/win/module_file_name_patch_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ using sandbox::policy::features::kModuleFileNamePatch;

namespace {

void NonBlockingDelay(const base::TimeDelta& delay) {
void NonBlockingDelay(base::TimeDelta delay) {
base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed);
base::SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask(
FROM_HERE, run_loop.QuitWhenIdleClosure(), delay);
Expand Down
2 changes: 1 addition & 1 deletion browser/speedreader/speedreader_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class SpeedReaderBrowserTest : public InProcessBrowserTest {
browser()->profile());
}

void NonBlockingDelay(const base::TimeDelta& delay) {
void NonBlockingDelay(base::TimeDelta delay) {
base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed);
base::SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask(
FROM_HERE, run_loop.QuitWhenIdleClosure(), delay);
Expand Down
2 changes: 1 addition & 1 deletion browser/tor/test/brave_tor_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ bool CheckComponentExists(const std::string& component_id) {
return base::PathExists(user_data_dir.AppendASCII(component_id));
}

void NonBlockingDelay(const base::TimeDelta& delay) {
void NonBlockingDelay(base::TimeDelta delay) {
base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed);
base::SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask(
FROM_HERE, run_loop.QuitWhenIdleClosure(), delay);
Expand Down
10 changes: 2 additions & 8 deletions browser/ui/views/brave_tooltips/brave_tooltip_popup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -393,19 +393,13 @@ void BraveTooltipPopup::CloseWidgetView() {

void BraveTooltipPopup::FadeIn() {
animation_state_ = AnimationState::kFadeIn;

const base::TimeDelta fade_duration = base::Milliseconds(fade_duration_);
animation_->SetDuration(fade_duration);

animation_->SetDuration(base::Milliseconds(fade_duration_));
StartAnimation();
}

void BraveTooltipPopup::FadeOut() {
animation_state_ = AnimationState::kFadeOut;

const base::TimeDelta fade_duration = base::Milliseconds(fade_duration_);
animation_->SetDuration(fade_duration);

animation_->SetDuration(base::Milliseconds(fade_duration_));
StartAnimation();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace {

constexpr int kTopControlIconSize = 20;

std::u16string ToString(const base::TimeDelta& time) {
std::u16string ToString(base::TimeDelta time) {
const int time_in_seconds = time.InSecondsF();
const int hours = time_in_seconds / 3600;
const int minutes = (time_in_seconds % 3600) / 60;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ std::string Select(const std::string& selector1, const std::string& selector2) {
selector1.c_str(), selector2.c_str());
}

void NonBlockingDelay(const base::TimeDelta& delay) {
void NonBlockingDelay(base::TimeDelta delay) {
base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed);
base::SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask(
FROM_HERE, run_loop.QuitWhenIdleClosure(), delay);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool IsExtensionToggleEnabled(content::WebContents* web_contents) {
.value.GetBool();
}

void NonBlockingDelay(const base::TimeDelta& delay) {
void NonBlockingDelay(base::TimeDelta delay) {
base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed);
base::SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask(
FROM_HERE, run_loop.QuitWhenIdleClosure(), delay);
Expand Down
2 changes: 1 addition & 1 deletion browser/url_sanitizer/url_sanitizer_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class URLSanitizerTestBase : public InProcessBrowserTest {
loop.Run();
}

void NonBlockingDelay(const base::TimeDelta& delay) {
void NonBlockingDelay(base::TimeDelta delay) {
base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed);
base::SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask(
FROM_HERE, run_loop.QuitWhenIdleClosure(), delay);
Expand Down
4 changes: 2 additions & 2 deletions components/assist_ranker/ranker_model_loader_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class RankerModelLoaderImplTest : public ::testing::Test {
// Helper method used by InitRemoteModels()
void InitModel(const GURL& model_url,
const base::Time& last_modified,
const base::TimeDelta& cache_duration,
base::TimeDelta cache_duration,
RankerModel* model);

// Implements RankerModelLoaderImpl's ValidateModelCallback interface.
Expand Down Expand Up @@ -108,7 +108,7 @@ void RankerModelLoaderImplTest::InitRemoteModels() {

void RankerModelLoaderImplTest::InitModel(const GURL& model_url,
const base::Time& last_modified,
const base::TimeDelta& cache_duration,
base::TimeDelta cache_duration,
RankerModel* model) {
ASSERT_TRUE(model != nullptr);
model->mutable_proto()->Clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ base::TimeDelta* g_testing_subscription_retry_interval = nullptr;
namespace {

const uint16_t kSubscriptionMaxExpiresHours = 14 * 24;
constexpr base::TimeDelta kListRetryInterval = base::Hours(1);
constexpr base::TimeDelta kListCheckInitialDelay = base::Minutes(1);

bool SkipGURLField(std::string_view value, GURL* field) {
return true;
Expand Down Expand Up @@ -84,9 +86,6 @@ bool ParseExpiresWithFallback(const base::Value* value, uint16_t* field) {
}
}

const base::TimeDelta kListRetryInterval = base::Hours(1);
const base::TimeDelta kListCheckInitialDelay = base::Minutes(1);

SubscriptionInfo BuildInfoFromDict(const GURL& sub_url,
const base::Value::Dict& dict) {
SubscriptionInfo info;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class CaptivePortalServiceTest : public testing::Test,

// Changes test time for the service and service's captive portal
// detector.
void AdvanceTime(const base::TimeDelta& delta) {
void AdvanceTime(base::TimeDelta delta) {
tick_clock_->Advance(delta);
CaptivePortalDetectorTestBase::AdvanceTime(delta);
}
Expand Down
2 changes: 1 addition & 1 deletion components/misc_metrics/general_browser_usage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace misc_metrics {

namespace {

const base::TimeDelta kReportInterval = base::Minutes(10);
constexpr base::TimeDelta kReportInterval = base::Minutes(10);

#if !BUILDFLAG(IS_ANDROID)
constexpr int kProfileCountBuckets[] = {0, 1, 2, 3, 5};
Expand Down
2 changes: 1 addition & 1 deletion components/misc_metrics/privacy_hub_metrics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace misc_metrics {

namespace {
const int kViewsMonthlyBucketValues[] = {1, 10, 20};
const base::TimeDelta kReportUpdateInterval = base::Days(1);
constexpr base::TimeDelta kReportUpdateInterval = base::Days(1);
} // namespace


Expand Down
2 changes: 1 addition & 1 deletion components/misc_metrics/tab_metrics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace misc_metrics {

namespace {
const int kPercentBucketValues[] = {25, 50, 75};
const base::TimeDelta kReportUpdateInterval = base::Days(1);
constexpr base::TimeDelta kReportUpdateInterval = base::Days(1);
} // namespace

TabMetrics::TabMetrics(PrefService* local_state)
Expand Down
Loading