Skip to content

Commit

Permalink
Migrate "base::TimeDelta::FromX" to "base:X".
Browse files Browse the repository at this point in the history
All changes were done automatically with git grep, sed, xargs, etc.

No-Presubmit: true
No-Try: true
Bug: 1243777
Change-Id: I7cc197e9027f7837cd36afc67a209079f85ec364
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3198824
Commit-Queue: Peter Kasting <[email protected]>
Owners-Override: Peter Kasting <[email protected]>
Reviewed-by: Peter Boström <[email protected]>
Cr-Commit-Position: refs/heads/main@{#927512}
  • Loading branch information
pkasting authored and Chromium LUCI CQ committed Oct 2, 2021
1 parent 1931425 commit e5a38ed
Show file tree
Hide file tree
Showing 5,638 changed files with 27,018 additions and 33,440 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
8 changes: 3 additions & 5 deletions android_webview/browser/aw_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1146,8 +1146,7 @@ void AwContents::OnComputeScroll(JNIEnv* env,
jlong animation_time_millis) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
browser_view_renderer_.OnComputeScroll(
base::TimeTicks() +
base::TimeDelta::FromMilliseconds(animation_time_millis));
base::TimeTicks() + base::Milliseconds(animation_time_millis));
}

jlong AwContents::ReleasePopupAwContents(JNIEnv* env,
Expand Down Expand Up @@ -1263,9 +1262,8 @@ void AwContents::SmoothScroll(JNIEnv* env,
scale *= browser_view_renderer_.dip_scale();

DCHECK_GE(duration_ms, 0);
render_view_host_ext_->SmoothScroll(
target_x / scale, target_y / scale,
base::TimeDelta::FromMilliseconds(duration_ms));
render_view_host_ext_->SmoothScroll(target_x / scale, target_y / scale,
base::Milliseconds(duration_ms));
}

void AwContents::OnWebLayoutPageScaleFactorChanged(float page_scale_factor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,8 @@ void AwAppsPackageNamesAllowlistComponentLoaderPolicy::ComponentLoaded(
return;
}

base::Time expiry_date =
base::Time::UnixEpoch() +
base::TimeDelta::FromMillisecondsD(expiry_date_ms.value_or(0.0));
base::Time expiry_date = base::Time::UnixEpoch() +
base::Milliseconds(expiry_date_ms.value_or(0.0));
if (expiry_date <= base::Time::Now()) {
RecordAndReportResult(std::move(lookup_callback_),
{AllowlistPraseStatus::kExpiredAllowlist});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ std::unique_ptr<base::Value> BuildTestManifest() {
auto manifest = std::make_unique<base::Value>(base::Value::Type::DICTIONARY);
manifest->SetKey(kBloomFilterNumHashKey, base::Value(kNumHash));
manifest->SetKey(kBloomFilterNumBitsKey, base::Value(3 * kNumBitsPerEntry));
manifest->SetKey(kExpiryDateKey,
base::Value(MillisFromUnixEpoch(
base::Time::Now() + base::TimeDelta::FromDays(1))));
manifest->SetKey(
kExpiryDateKey,
base::Value(MillisFromUnixEpoch(base::Time::Now() + base::Days(1))));

return manifest;
}
Expand Down Expand Up @@ -116,8 +116,7 @@ TEST_F(AwAppsPackageNamesAllowlistComponentLoaderPolicyTest,
base::flat_map<std::string, base::ScopedFD> fd_map;
fd_map[kAllowlistBloomFilterFileName] = OpenAndGetAllowlistFd();
std::unique_ptr<base::Value> manifest = BuildTestManifest();
base::Time one_day_from_now =
base::Time::Now() + base::TimeDelta::FromDays(1);
base::Time one_day_from_now = base::Time::Now() + base::Days(1);
manifest->SetDoubleKey(kExpiryDateKey, MillisFromUnixEpoch(one_day_from_now));
base::Version new_version(kTestAllowlistVersion);

Expand Down Expand Up @@ -148,8 +147,7 @@ TEST_F(AwAppsPackageNamesAllowlistComponentLoaderPolicyTest,
TestSameVersionAsCache) {
base::flat_map<std::string, base::ScopedFD> fd_map;
std::unique_ptr<base::Value> manifest = BuildTestManifest();
base::Time one_day_from_now =
base::Time::Now() + base::TimeDelta::FromDays(1);
base::Time one_day_from_now = base::Time::Now() + base::Days(1);
base::Version version(kTestAllowlistVersion);

AppPackageNameLoggingRule expected_record(version, one_day_from_now);
Expand Down Expand Up @@ -304,9 +302,9 @@ TEST_F(AwAppsPackageNamesAllowlistComponentLoaderPolicyTest,
base::flat_map<std::string, base::ScopedFD> fd_map;
fd_map[kAllowlistBloomFilterFileName] = OpenAndGetAllowlistFd();
std::unique_ptr<base::Value> manifest = BuildTestManifest();
manifest->SetKey(kExpiryDateKey,
base::Value(MillisFromUnixEpoch(
base::Time::Now() - base::TimeDelta::FromDays(1))));
manifest->SetKey(
kExpiryDateKey,
base::Value(MillisFromUnixEpoch(base::Time::Now() - base::Days(1))));

auto policy =
std::make_unique<AwAppsPackageNamesAllowlistComponentLoaderPolicy>(
Expand Down
2 changes: 1 addition & 1 deletion android_webview/browser/gfx/test/invalidate_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class VizClient : public viz::mojom::CompositorFrameSinkClient {
int max_pending_frames,
int frame_rate)
: max_pending_frames_(max_pending_frames),
frame_interval_(base::TimeDelta::FromSeconds(1) / frame_rate) {
frame_interval_(base::Seconds(1) / frame_rate) {
support_ = std::make_unique<viz::CompositorFrameSinkSupport>(
this,
VizCompositorThreadRunnerWebView::GetInstance()->GetFrameSinkManager(),
Expand Down
5 changes: 2 additions & 3 deletions android_webview/browser/metrics/aw_metrics_service_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void JNI_AwMetricsServiceClient_SetUploadIntervalForTesting(
JNIEnv* env,
jlong upload_interval_ms) {
AwMetricsServiceClient::GetInstance()->SetUploadIntervalForTesting(
base::TimeDelta::FromMilliseconds(upload_interval_ms));
base::Milliseconds(upload_interval_ms));
}

// static
Expand All @@ -263,8 +263,7 @@ void JNI_AwMetricsServiceClient_SetAppPackageNameLoggingRuleForTesting(
AwMetricsServiceClient::GetInstance()->SetAppPackageNameLoggingRule(
AppPackageNameLoggingRule(
base::Version(base::android::ConvertJavaStringToUTF8(env, version)),
base::Time::UnixEpoch() +
base::TimeDelta::FromMilliseconds(expiry_date_ms)));
base::Time::UnixEpoch() + base::Milliseconds(expiry_date_ms)));
}

} // namespace android_webview
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ TEST_F(AwMetricsServiceClientTest, TestShouldRecordPackageName_WithCache) {
AwMetricsServiceClient* client = GetClient();
TestingPrefServiceSimple* prefs = GetPrefs();

auto one_day_from_now = base::Time::Now() + base::TimeDelta::FromDays(1);
auto one_day_from_now = base::Time::Now() + base::Days(1);
AppPackageNameLoggingRule expected_record(
base::Version(kTestAllowlistVersion), one_day_from_now);
prefs->Set(prefs::kMetricsAppPackageNameLoggingRule,
Expand Down Expand Up @@ -146,7 +146,7 @@ TEST_F(AwMetricsServiceClientTest,
scoped_list.InitAndEnableFeature(
android_webview::features::kWebViewAppsPackageNamesAllowlist);

auto one_day_from_now = base::Time::Now() + base::TimeDelta::FromDays(1);
auto one_day_from_now = base::Time::Now() + base::Days(1);

AwMetricsServiceClient* client = GetClient();
AppPackageNameLoggingRule expected_record(
Expand Down Expand Up @@ -175,7 +175,7 @@ TEST_F(AwMetricsServiceClientTest,
scoped_list.InitAndEnableFeature(
android_webview::features::kWebViewAppsPackageNamesAllowlist);

auto one_day_from_now = base::Time::Now() + base::TimeDelta::FromDays(1);
auto one_day_from_now = base::Time::Now() + base::Days(1);

AwMetricsServiceClient* client = GetClient();
AppPackageNameLoggingRule expected_record(
Expand Down Expand Up @@ -229,9 +229,8 @@ TEST_F(AwMetricsServiceClientTest, TestShouldRecordPackageName_SameAsCache) {
AwMetricsServiceClient* client = GetClient();
TestingPrefServiceSimple* prefs = GetPrefs();

AppPackageNameLoggingRule record(
base::Version(kTestAllowlistVersion),
base::Time::Now() + base::TimeDelta::FromDays(1));
AppPackageNameLoggingRule record(base::Version(kTestAllowlistVersion),
base::Time::Now() + base::Days(1));
prefs->Set(prefs::kMetricsAppPackageNameLoggingRule, record.ToDictionary());
client->SetAppPackageNameLoggingRule(record);

Expand Down
18 changes: 9 additions & 9 deletions android_webview/browser/metrics/visibility_metrics_logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,20 +222,20 @@ void VisibilityMetricsLogger::RecordVisibilityMetrics() {
any_webview_visible_seconds =
visible_duration_tracker_.any_webview_tracked_duration_.InSeconds();
visible_duration_tracker_.any_webview_tracked_duration_ -=
base::TimeDelta::FromSeconds(any_webview_visible_seconds);
base::Seconds(any_webview_visible_seconds);
no_webview_visible_seconds =
visible_duration_tracker_.no_webview_tracked_duration_.InSeconds();
visible_duration_tracker_.no_webview_tracked_duration_ -=
base::TimeDelta::FromSeconds(no_webview_visible_seconds);
base::Seconds(no_webview_visible_seconds);

total_webview_visible_seconds =
visible_duration_tracker_.per_webview_duration_.InSeconds();
visible_duration_tracker_.per_webview_duration_ -=
base::TimeDelta::FromSeconds(total_webview_visible_seconds);
base::Seconds(total_webview_visible_seconds);
total_no_webview_visible_seconds =
visible_duration_tracker_.per_webview_untracked_duration_.InSeconds();
visible_duration_tracker_.per_webview_untracked_duration_ -=
base::TimeDelta::FromSeconds(total_no_webview_visible_seconds);
base::Seconds(total_no_webview_visible_seconds);

if (any_webview_visible_seconds) {
GetGlobalVisibilityHistogram()->AddCount(
Expand Down Expand Up @@ -266,20 +266,20 @@ void VisibilityMetricsLogger::RecordOpenWebDisplayMetrics() {
any_webcontent_visible_seconds =
webcontent_visible_tracker_.any_webview_tracked_duration_.InSeconds();
webcontent_visible_tracker_.any_webview_tracked_duration_ -=
base::TimeDelta::FromSeconds(any_webcontent_visible_seconds);
base::Seconds(any_webcontent_visible_seconds);
no_webcontent_visible_seconds =
webcontent_visible_tracker_.no_webview_tracked_duration_.InSeconds();
webcontent_visible_tracker_.no_webview_tracked_duration_ -=
base::TimeDelta::FromSeconds(no_webcontent_visible_seconds);
base::Seconds(no_webcontent_visible_seconds);

total_webcontent_isible_seconds =
webcontent_visible_tracker_.per_webview_duration_.InSeconds();
webcontent_visible_tracker_.per_webview_duration_ -=
base::TimeDelta::FromSeconds(total_webcontent_isible_seconds);
base::Seconds(total_webcontent_isible_seconds);
total_not_webcontent_or_not_visible_seconds =
webcontent_visible_tracker_.per_webview_untracked_duration_.InSeconds();
webcontent_visible_tracker_.per_webview_untracked_duration_ -=
base::TimeDelta::FromSeconds(total_not_webcontent_or_not_visible_seconds);
base::Seconds(total_not_webcontent_or_not_visible_seconds);

if (any_webcontent_visible_seconds) {
GetGlobalOpenWebVisibilityHistogram()->AddCount(
Expand Down Expand Up @@ -313,7 +313,7 @@ void VisibilityMetricsLogger::RecordScreenPortionMetrics() {
continue;

open_web_screen_portion_tracked_duration_[i] -=
base::TimeDelta::FromSeconds(elapsed_seconds);
base::Seconds(elapsed_seconds);
GetOpenWebVisibileScreenPortionHistogram()->AddCount(i, elapsed_seconds);
}
}
Expand Down
11 changes: 4 additions & 7 deletions android_webview/browser/metrics/visibility_metrics_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,14 @@ class VisibilityMetricsLogger {

struct WebViewDurationTracker {
// Duration any WebView meets the tracking criteria
base::TimeDelta any_webview_tracked_duration_ =
base::TimeDelta::FromSeconds(0);
base::TimeDelta any_webview_tracked_duration_ = base::Seconds(0);
// Duration no WebViews meet the tracking criteria
base::TimeDelta no_webview_tracked_duration_ =
base::TimeDelta::FromSeconds(0);
base::TimeDelta no_webview_tracked_duration_ = base::Seconds(0);
// Total duration that WebViews meet the tracking criteria (i.e. if
// 2x WebViews meet the criteria for 1 second then increment by 2 seconds)
base::TimeDelta per_webview_duration_ = base::TimeDelta::FromSeconds(0);
base::TimeDelta per_webview_duration_ = base::Seconds(0);
// Total duration that WebViews exist but do not meet the tracking criteria
base::TimeDelta per_webview_untracked_duration_ =
base::TimeDelta::FromSeconds(0);
base::TimeDelta per_webview_untracked_duration_ = base::Seconds(0);
};

WebViewDurationTracker visible_duration_tracker_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ TEST_F(VisibilityMetricsLoggerTest, TestFractionalSecondAccumulation) {
client->SetViewAttached(true);
client->SetWindowVisible(true);

task_environment().FastForwardBy(base::TimeDelta::FromMilliseconds(500));
task_environment().FastForwardBy(base::Milliseconds(500));

logger()->RecordMetrics();
histogram_tester.ExpectBucketCount(
"Android.WebView.Visibility.Global",
VisibilityMetricsLogger::Visibility::kVisible, 0);

task_environment().FastForwardBy(base::TimeDelta::FromMilliseconds(500));
task_environment().FastForwardBy(base::Milliseconds(500));

logger()->RecordMetrics();
histogram_tester.ExpectBucketCount(
Expand All @@ -109,16 +109,16 @@ TEST_F(VisibilityMetricsLoggerTest, TestFractionalSecondAccumulation) {
TEST_F(VisibilityMetricsLoggerTest, TestSingleVisibleClient) {
base::HistogramTester histogram_tester;

task_environment().FastForwardBy(base::TimeDelta::FromSeconds(10));
task_environment().FastForwardBy(base::Seconds(10));
std::unique_ptr<TestClient> client = std::make_unique<TestClient>(logger());

task_environment().FastForwardBy(base::TimeDelta::FromSeconds(30));
task_environment().FastForwardBy(base::Seconds(30));
client->SetViewVisible(true);
client->SetViewAttached(true);
client->SetWindowVisible(true);
client->SetSchemeHttpOrHttps(true);

task_environment().FastForwardBy(base::TimeDelta::FromSeconds(10));
task_environment().FastForwardBy(base::Seconds(10));
client->SetWindowVisible(false);

logger()->RecordMetrics();
Expand All @@ -143,7 +143,7 @@ TEST_F(VisibilityMetricsLoggerTest, TestSingleVisibleClient) {
client->SetViewAttached(true);
client->SetWindowVisible(true);
client->SetSchemeHttpOrHttps(false);
task_environment().FastForwardBy(base::TimeDelta::FromSeconds(90));
task_environment().FastForwardBy(base::Seconds(90));

logger()->RecordMetrics();
histogram_tester.ExpectBucketCount(
Expand All @@ -170,20 +170,20 @@ TEST_F(VisibilityMetricsLoggerTest, TestLongDurationVisibleClient) {
std::unique_ptr<TestClient> client1 = std::make_unique<TestClient>(logger());
std::unique_ptr<TestClient> client2 = std::make_unique<TestClient>(logger());

task_environment().FastForwardBy(base::TimeDelta::FromSeconds(300));
task_environment().FastForwardBy(base::Seconds(300));
client1->SetViewVisible(true);
client1->SetViewAttached(true);
client1->SetWindowVisible(true);

task_environment().FastForwardBy(base::TimeDelta::FromSeconds(50));
task_environment().FastForwardBy(base::Seconds(50));
client2->SetViewVisible(true);
client2->SetViewAttached(true);
client2->SetWindowVisible(true);

task_environment().FastForwardBy(base::TimeDelta::FromSeconds(50));
task_environment().FastForwardBy(base::Seconds(50));
client2.reset();

task_environment().FastForwardBy(base::TimeDelta::FromSeconds(50));
task_environment().FastForwardBy(base::Seconds(50));
client1.reset();

logger()->RecordMetrics();
Expand Down Expand Up @@ -217,32 +217,32 @@ TEST_F(VisibilityMetricsLoggerTest, TestTwoVisibleClients) {
base::HistogramTester histogram_tester;
std::unique_ptr<TestClient> client1 = std::make_unique<TestClient>(logger());

task_environment().FastForwardBy(base::TimeDelta::FromSeconds(10));
task_environment().FastForwardBy(base::Seconds(10));
std::unique_ptr<TestClient> client2 = std::make_unique<TestClient>(logger());

task_environment().FastForwardBy(base::TimeDelta::FromSeconds(30));
task_environment().FastForwardBy(base::Seconds(30));
// This queues delayed recording after 60 seconds (test-defined)
client1->SetViewVisible(true);
client1->SetViewAttached(true);
client1->SetWindowVisible(true);

task_environment().FastForwardBy(base::TimeDelta::FromSeconds(10));
task_environment().FastForwardBy(base::Seconds(10));
// No additional task is queued
client2->SetViewVisible(true);
client2->SetViewAttached(true);
client2->SetWindowVisible(true);

task_environment().FastForwardBy(base::TimeDelta::FromSeconds(10));
task_environment().FastForwardBy(base::Seconds(10));
// This does not cause metrics to be recorded because one client remains
// visible.
client1->SetWindowVisible(false);

task_environment().FastForwardBy(base::TimeDelta::FromSeconds(10));
task_environment().FastForwardBy(base::Seconds(10));
// The last client becoming invisible triggers immediate recording and the
// cancellation of the queued task.
client2->SetWindowVisible(false);

task_environment().FastForwardBy(base::TimeDelta::FromSeconds(30));
task_environment().FastForwardBy(base::Seconds(30));
client1.reset();
client2.reset();

Expand Down Expand Up @@ -284,36 +284,36 @@ TEST_F(VisibilityMetricsLoggerTest, TestTwoVisibleWebContentClients) {
base::HistogramTester histogram_tester;
std::unique_ptr<TestClient> client1 = std::make_unique<TestClient>(logger());

task_environment().FastForwardBy(base::TimeDelta::FromSeconds(10));
task_environment().FastForwardBy(base::Seconds(10));
std::unique_ptr<TestClient> client2 = std::make_unique<TestClient>(logger());

task_environment().FastForwardBy(base::TimeDelta::FromSeconds(30));
task_environment().FastForwardBy(base::Seconds(30));
// This queues delayed recording after 60 seconds (test-defined)
client1->SetViewVisible(true);
client1->SetViewAttached(true);
client1->SetWindowVisible(true);

task_environment().FastForwardBy(base::TimeDelta::FromSeconds(10));
task_environment().FastForwardBy(base::Seconds(10));
// No additional task is queued
client1->SetSchemeHttpOrHttps(true);

task_environment().FastForwardBy(base::TimeDelta::FromSeconds(10));
task_environment().FastForwardBy(base::Seconds(10));
// No additional task is queued
client2->SetViewVisible(true);
client2->SetViewAttached(true);
client2->SetWindowVisible(true);

task_environment().FastForwardBy(base::TimeDelta::FromSeconds(10));
task_environment().FastForwardBy(base::Seconds(10));
// This does not cause metrics to be recorded because one client remains
// visible.
client1->SetWindowVisible(false);

task_environment().FastForwardBy(base::TimeDelta::FromSeconds(10));
task_environment().FastForwardBy(base::Seconds(10));
// The last client becoming invisible triggers immediate recording and the
// cancellation of the queued task.
client2->SetWindowVisible(false);

task_environment().FastForwardBy(base::TimeDelta::FromSeconds(20));
task_environment().FastForwardBy(base::Seconds(20));
client1.reset();
client2.reset();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ net::NetworkChangeNotifier::NetworkChangeCalculatorParams
AwNetworkChangeNotifier::DefaultNetworkChangeCalculatorParams() {
net::NetworkChangeNotifier::NetworkChangeCalculatorParams params;
// Use defaults as in network_change_notifier_android.cc
params.ip_address_offline_delay_ = base::TimeDelta::FromSeconds(1);
params.ip_address_online_delay_ = base::TimeDelta::FromSeconds(1);
params.connection_type_offline_delay_ = base::TimeDelta::FromSeconds(0);
params.connection_type_online_delay_ = base::TimeDelta::FromSeconds(0);
params.ip_address_offline_delay_ = base::Seconds(1);
params.ip_address_online_delay_ = base::Seconds(1);
params.connection_type_offline_delay_ = base::Seconds(0);
params.connection_type_online_delay_ = base::Seconds(0);
return params;
}

Expand Down
Loading

0 comments on commit e5a38ed

Please sign in to comment.