From 021592200e4bcc0127ad6aebcee3caa578fb77f4 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 17 Jan 2024 09:17:43 -0600 Subject: [PATCH] refactor: remove deprecated ToInternalValue() (#40980) * refactor: do not use deprecated ToInternalValue() in ElectronExtensionLoader::FinishExtensionLoad() * refactor: do not use deprecated ToInternalValue() in NotificationPresenterWin::SaveIconToFilesystem() * chore: rename temp variable to now_usec for clarity --- shell/browser/extensions/electron_extension_loader.cc | 7 ++++--- .../notifications/win/notification_presenter_win.cc | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/shell/browser/extensions/electron_extension_loader.cc b/shell/browser/extensions/electron_extension_loader.cc index d188f330e4..252b9507f8 100644 --- a/shell/browser/extensions/electron_extension_loader.cc +++ b/shell/browser/extensions/electron_extension_loader.cc @@ -148,10 +148,11 @@ void ElectronExtensionLoader::FinishExtensionLoad( ExtensionPrefs::ScopedDictionaryUpdate update( extension_prefs, extension.get()->id(), extensions::pref_names::kPrefPreferences); + auto preference = update.Create(); - const base::Time install_time = base::Time::Now(); - preference->SetString( - "install_time", base::NumberToString(install_time.ToInternalValue())); + const int64_t now_usec = + base::Time::Now().since_origin().InMicroseconds(); + preference->SetString("install_time", base::NumberToString(now_usec)); } } diff --git a/shell/browser/notifications/win/notification_presenter_win.cc b/shell/browser/notifications/win/notification_presenter_win.cc index e116ed9406..407250614d 100644 --- a/shell/browser/notifications/win/notification_presenter_win.cc +++ b/shell/browser/notifications/win/notification_presenter_win.cc @@ -14,6 +14,7 @@ #include "base/files/file_util.h" #include "base/hash/md5.h" #include "base/logging.h" +#include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" #include "base/time/time.h" #include "base/win/windows_version.h" @@ -75,8 +76,8 @@ std::wstring NotificationPresenterWin::SaveIconToFilesystem( if (origin.is_valid()) { filename = base::MD5String(origin.spec()) + ".png"; } else { - base::TimeTicks now = base::TimeTicks::Now(); - filename = std::to_string(now.ToInternalValue()) + ".png"; + const int64_t now_usec = base::Time::Now().since_origin().InMicroseconds(); + filename = base::NumberToString(now_usec) + ".png"; } ScopedAllowBlockingForElectron allow_blocking;