updater: use std::optional everywhere in place of absl::optional.
This is because https://crrev.com/c/4469528.
This change is mechanical and trivial but it fails the code coverage
test in a couple of macOS files. Currently, because of
infra reasons, it is not possible to get macOS coverage for
per-system code because such code requires passwordless sudo,
which is not available in the general bot pool where coverage is
collected from.
Fixed: 1501379
Low-Coverage-Reason:TRIVIAL_CHANGE large but mechanical find and replace
Change-Id: I1f6792c95a9a80f8af1c1b3de3f89d9870071c88
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5021148
Reviewed-by: Joshua Pawlicki <waffles@chromium.org>
Commit-Queue: Sorin Jianu <sorin@chromium.org>
Auto-Submit: Sorin Jianu <sorin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1223097}
diff --git a/chrome/updater/app/app_install.cc b/chrome/updater/app/app_install.cc
index 3524860..9885050 100644
--- a/chrome/updater/app/app_install.cc
+++ b/chrome/updater/app/app_install.cc
@@ -4,6 +4,7 @@
#include "chrome/updater/app/app_install.h"
+#include <optional>
#include <utility>
#include <vector>
@@ -30,7 +31,6 @@
#include "chrome/updater/updater_version.h"
#include "chrome/updater/util/util.h"
#include "components/prefs/pref_service.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -59,8 +59,8 @@
RegistrationRequest request;
request.app_id = app_id;
request.version = base::Version(kNullVersion);
- absl::optional<tagging::AppArgs> app_args = GetAppArgs(app_id);
- absl::optional<tagging::TagArgs> tag_args = GetTagArgs().tag_args;
+ std::optional<tagging::AppArgs> app_args = GetAppArgs(app_id);
+ std::optional<tagging::TagArgs> tag_args = GetTagArgs().tag_args;
if (app_args) {
request.ap = app_args->ap;
}
diff --git a/chrome/updater/app/app_install_win.cc b/chrome/updater/app/app_install_win.cc
index 13a3fc6..1e714a48 100644
--- a/chrome/updater/app/app_install_win.cc
+++ b/chrome/updater/app/app_install_win.cc
@@ -5,6 +5,7 @@
#include "chrome/updater/app/app_install.h"
#include <memory>
+#include <optional>
#include <string>
#include <tuple>
#include <vector>
@@ -65,7 +66,6 @@
#pragma clang diagnostic pop
#include "components/update_client/protocol_parser.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace {
@@ -299,7 +299,7 @@
void SetUsageStats(UpdaterScope scope,
const std::string& app_id,
- absl::optional<bool> usage_stats) {
+ std::optional<bool> usage_stats) {
if (!usage_stats) {
return;
}
@@ -445,7 +445,7 @@
// Contains the result of installing the application. This is populated
// by the `StateChangeCallback` or the completion callback, if the
// former callback was not posted.
- absl::optional<ObserverCompletionInfo> observer_completion_info_;
+ std::optional<ObserverCompletionInfo> observer_completion_info_;
// Called when InstallApp is done.
base::OnceCallback<void(int)> callback_;
@@ -497,8 +497,8 @@
RegistrationRequest request;
request.app_id = app_id_;
request.version = base::Version(kNullVersion);
- absl::optional<tagging::AppArgs> app_args = GetAppArgs(app_id_);
- absl::optional<tagging::TagArgs> tag_args = GetTagArgs().tag_args;
+ std::optional<tagging::AppArgs> app_args = GetAppArgs(app_id_);
+ std::optional<tagging::TagArgs> tag_args = GetTagArgs().tag_args;
if (app_args) {
request.ap = app_args->ap;
}
@@ -509,7 +509,7 @@
base::ThreadPool::PostTaskAndReply(
FROM_HERE,
base::BindOnce(&SetUsageStats, GetUpdaterScope(), app_id_,
- tag_args ? tag_args->usage_stats_enable : absl::nullopt),
+ tag_args ? tag_args->usage_stats_enable : std::nullopt),
base::BindOnce(
&UpdateService::Install, update_service_, request,
GetDecodedInstallDataFromAppArgs(app_id_),
@@ -616,12 +616,12 @@
VLOG(1) << "Failed to serialize install settings.";
}
- absl::optional<tagging::TagArgs> tag_args = GetTagArgs().tag_args;
+ std::optional<tagging::TagArgs> tag_args = GetTagArgs().tag_args;
RegistrationRequest request;
request.app_id = app_id_;
request.version = base::Version(kNullVersion);
- absl::optional<tagging::AppArgs> app_args = GetAppArgs(app_id_);
+ std::optional<tagging::AppArgs> app_args = GetAppArgs(app_id_);
if (app_args) {
request.ap = app_args->ap;
}
@@ -635,7 +635,7 @@
base::ThreadPool::PostTaskAndReply(
FROM_HERE,
base::BindOnce(&SetUsageStats, GetUpdaterScope(), app_id_,
- tag_args ? tag_args->usage_stats_enable : absl::nullopt),
+ tag_args ? tag_args->usage_stats_enable : std::nullopt),
base::BindOnce(
&UpdateService::RegisterApp, update_service_, request,
base::BindOnce(
diff --git a/chrome/updater/app/app_server.cc b/chrome/updater/app/app_server.cc
index f65c4dc..5ee4df67 100644
--- a/chrome/updater/app/app_server.cc
+++ b/chrome/updater/app/app_server.cc
@@ -4,6 +4,7 @@
#include "chrome/updater/app/app_server.h"
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -34,7 +35,6 @@
#include "chrome/updater/updater_version.h"
#include "chrome/updater/util/util.h"
#include "components/prefs/pref_service.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#if BUILDFLAG(IS_WIN)
#include "base/win/registry.h"
@@ -214,7 +214,7 @@
updater_scope(), prefs_->GetPrefService());
if (ShouldUninstall(persisted_data->GetAppIds(), server_starts_,
persisted_data->GetHadApps())) {
- absl::optional<base::FilePath> executable =
+ std::optional<base::FilePath> executable =
GetUpdaterExecutablePath(updater_scope());
if (executable) {
base::CommandLine command_line(*executable);
diff --git a/chrome/updater/app/app_server_unittest.cc b/chrome/updater/app/app_server_unittest.cc
index 97f82c0..ca9f12bf 100644
--- a/chrome/updater/app/app_server_unittest.cc
+++ b/chrome/updater/app/app_server_unittest.cc
@@ -4,6 +4,7 @@
#include "chrome/updater/app/app_server.h"
+#include <optional>
#include <string>
#include "base/files/file_path.h"
@@ -24,7 +25,6 @@
#include "components/prefs/pref_service.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#if BUILDFLAG(IS_WIN)
#include <shlobj.h>
@@ -74,7 +74,7 @@
void ClearPrefs() {
const UpdaterScope updater_scope = GetTestScope();
- for (const absl::optional<base::FilePath>& path :
+ for (const std::optional<base::FilePath>& path :
{GetInstallDirectory(updater_scope),
GetVersionedInstallDirectory(updater_scope)}) {
ASSERT_TRUE(path);
diff --git a/chrome/updater/app/app_server_win.cc b/chrome/updater/app/app_server_win.cc
index fc6556e..75967ed 100644
--- a/chrome/updater/app/app_server_win.cc
+++ b/chrome/updater/app/app_server_win.cc
@@ -8,6 +8,7 @@
#include <wrl/module.h>
#include <memory>
+#include <optional>
#include <string>
#include <tuple>
#include <utility>
@@ -46,7 +47,6 @@
#include "chrome/updater/win/setup/uninstall.h"
#include "chrome/updater/win/task_scheduler.h"
#include "chrome/updater/win/win_constants.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace {
@@ -128,7 +128,7 @@
WorkItemList* list) {
CHECK(list);
- const absl::optional<base::FilePath> target_path =
+ const std::optional<base::FilePath> target_path =
GetGoogleUpdateExePath(scope);
if (!target_path || !base::CreateDirectory(target_path->DirName())) {
return false;
@@ -215,7 +215,7 @@
return DeleteExcept(GetGoogleUpdateExePath(scope));
}
-absl::optional<int> DaynumFromDWORD(DWORD value) {
+std::optional<int> DaynumFromDWORD(DWORD value) {
const int daynum = static_cast<int>(value);
// When daynum is positive, it is the number of days since January 1, 2007.
@@ -223,8 +223,8 @@
// and 50000 (maps to Nov 24, 2143).
// -1 is special value for first install.
return daynum == -1 || (daynum >= 3000 && daynum <= 50000)
- ? absl::make_optional(daynum)
- : absl::nullopt;
+ ? std::make_optional(daynum)
+ : std::nullopt;
}
} // namespace
@@ -360,7 +360,7 @@
bool AppServerWin::SwapInNewVersion() {
std::unique_ptr<WorkItemList> list(WorkItem::CreateWorkItemList());
- const absl::optional<base::FilePath> versioned_directory =
+ const std::optional<base::FilePath> versioned_directory =
GetVersionedInstallDirectory(updater_scope());
if (!versioned_directory) {
return false;
@@ -373,7 +373,7 @@
return false;
}
- absl::optional<base::ScopedTempDir> temp_dir = CreateSecureTempDir();
+ std::optional<base::ScopedTempDir> temp_dir = CreateSecureTempDir();
if (!temp_dir) {
return false;
}
@@ -392,7 +392,7 @@
const base::ScopedClosureRunner reset_shutdown_event(
SignalShutdownEvent(updater_scope()));
- absl::optional<base::FilePath> target =
+ std::optional<base::FilePath> target =
GetGoogleUpdateExePath(updater_scope());
if (target) {
StopProcessesUnderPath(target->DirName(), base::Seconds(45));
diff --git a/chrome/updater/app/app_uninstall.cc b/chrome/updater/app/app_uninstall.cc
index 616112d..5e037d8 100644
--- a/chrome/updater/app/app_uninstall.cc
+++ b/chrome/updater/app/app_uninstall.cc
@@ -4,6 +4,7 @@
#include "chrome/updater/app/app_uninstall.h"
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -33,7 +34,6 @@
#include "chrome/updater/updater_version.h"
#include "chrome/updater/util/util.h"
#include "components/update_client/update_client.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#if BUILDFLAG(IS_WIN)
#include "chrome/updater/win/setup/uninstall.h"
@@ -44,7 +44,7 @@
namespace updater {
std::vector<base::FilePath> GetVersionExecutablePaths(UpdaterScope scope) {
- const absl::optional<base::FilePath> updater_folder_path =
+ const std::optional<base::FilePath> updater_folder_path =
GetInstallDirectory(scope);
if (!updater_folder_path) {
LOG(ERROR) << __func__ << ": failed to get the updater install directory.";
diff --git a/chrome/updater/app/app_uninstall_unittest.cc b/chrome/updater/app/app_uninstall_unittest.cc
index bcc7562..74896f0 100644
--- a/chrome/updater/app/app_uninstall_unittest.cc
+++ b/chrome/updater/app/app_uninstall_unittest.cc
@@ -4,6 +4,8 @@
#include "chrome/updater/app/app_uninstall.h"
+#include <optional>
+
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/test/task_environment.h"
@@ -16,7 +18,6 @@
#include "chrome/updater/util/util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -47,7 +48,7 @@
ASSERT_EQ(GetVersionExecutablePaths(GetTestScope()).size(), 3u);
- const absl::optional<base::FilePath> path =
+ const std::optional<base::FilePath> path =
GetInstallDirectory(GetTestScope());
ASSERT_TRUE(path);
ASSERT_TRUE(base::DeletePathRecursively(*path));
diff --git a/chrome/updater/app/app_wakeall.cc b/chrome/updater/app/app_wakeall.cc
index 289fa4c..f773218 100644
--- a/chrome/updater/app/app_wakeall.cc
+++ b/chrome/updater/app/app_wakeall.cc
@@ -4,6 +4,8 @@
#include "chrome/updater/app/app_wakeall.h"
+#include <optional>
+
#include "base/command_line.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
@@ -17,7 +19,6 @@
#include "chrome/updater/app/app.h"
#include "chrome/updater/constants.h"
#include "chrome/updater/util/util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -39,7 +40,7 @@
FROM_HERE, {base::MayBlock(), base::WithBaseSyncPrimitives()},
base::BindOnce(
[](UpdaterScope scope) {
- absl::optional<base::FilePath> base = GetInstallDirectory(scope);
+ std::optional<base::FilePath> base = GetInstallDirectory(scope);
if (!base) {
return kErrorNoBaseDirectory;
}
diff --git a/chrome/updater/app/server/win/com_classes.cc b/chrome/updater/app/server/win/com_classes.cc
index 9f87b4b..f4efdb9 100644
--- a/chrome/updater/app/server/win/com_classes.cc
+++ b/chrome/updater/app/server/win/com_classes.cc
@@ -8,6 +8,7 @@
#include <wrl/client.h>
#include <wrl/implements.h>
+#include <optional>
#include <string>
#include <utility>
@@ -32,7 +33,6 @@
#include "chrome/updater/update_service.h"
#include "chrome/updater/updater_version.h"
#include "chrome/updater/util/win_util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace {
@@ -266,35 +266,35 @@
}
// Validates that string parameters are not longer than 16K characters.
- absl::optional<RegistrationRequest> request =
+ std::optional<RegistrationRequest> request =
[app_id, brand_code, brand_path, ap, version,
existence_checker_path]() -> decltype(request) {
for (const auto* str : {app_id, brand_code, brand_path, ap, version,
existence_checker_path}) {
if (wcsnlen_s(str, kMaxStringLen) == kMaxStringLen) {
- return absl::nullopt;
+ return std::nullopt;
}
}
RegistrationRequest request;
if (!app_id || !base::WideToUTF8(app_id, wcslen(app_id), &request.app_id)) {
- return absl::nullopt;
+ return std::nullopt;
}
if (!brand_code || !base::WideToUTF8(brand_code, wcslen(brand_code),
&request.brand_code)) {
- return absl::nullopt;
+ return std::nullopt;
}
request.brand_path = base::FilePath(brand_path);
if (!ap || !base::WideToUTF8(ap, wcslen(ap), &request.ap)) {
- return absl::nullopt;
+ return std::nullopt;
}
std::string version_str;
if (!version || !base::WideToUTF8(version, wcslen(version), &version_str)) {
- return absl::nullopt;
+ return std::nullopt;
}
request.version = base::Version(version_str);
if (!request.version.IsValid()) {
- return absl::nullopt;
+ return std::nullopt;
}
request.existence_checker_path = base::FilePath(existence_checker_path);
@@ -401,7 +401,7 @@
Microsoft::WRL::ComPtr<IUpdaterObserver> observer_;
// Most recent download progress value the client has been notified about.
- absl::optional<int> progress_seen_;
+ std::optional<int> progress_seen_;
};
} // namespace
@@ -572,36 +572,36 @@
}
// Validates that string parameters are not longer than 16K characters.
- absl::optional<RegistrationRequest> request =
+ std::optional<RegistrationRequest> request =
[app_id, brand_code, brand_path, ap, version, existence_checker_path,
client_install_data, install_data_index]() -> decltype(request) {
for (const auto* str :
{app_id, brand_code, brand_path, ap, version, existence_checker_path,
client_install_data, install_data_index}) {
if (wcsnlen_s(str, kMaxStringLen) == kMaxStringLen) {
- return absl::nullopt;
+ return std::nullopt;
}
}
RegistrationRequest request;
if (!app_id || !base::WideToUTF8(app_id, wcslen(app_id), &request.app_id)) {
- return absl::nullopt;
+ return std::nullopt;
}
if (!brand_code || !base::WideToUTF8(brand_code, wcslen(brand_code),
&request.brand_code)) {
- return absl::nullopt;
+ return std::nullopt;
}
request.brand_path = base::FilePath(brand_path);
if (!ap || !base::WideToUTF8(ap, wcslen(ap), &request.ap)) {
- return absl::nullopt;
+ return std::nullopt;
}
std::string version_str;
if (!version || !base::WideToUTF8(version, wcslen(version), &version_str)) {
- return absl::nullopt;
+ return std::nullopt;
}
request.version = base::Version(version_str);
if (!request.version.IsValid()) {
- return absl::nullopt;
+ return std::nullopt;
}
request.existence_checker_path = base::FilePath(existence_checker_path);
diff --git a/chrome/updater/app/server/win/com_classes_legacy.cc b/chrome/updater/app/server/win/com_classes_legacy.cc
index 44de8ec..d641ab6 100644
--- a/chrome/updater/app/server/win/com_classes_legacy.cc
+++ b/chrome/updater/app/server/win/com_classes_legacy.cc
@@ -9,6 +9,7 @@
#include <windows.h>
#include <wrl/client.h>
+#include <optional>
#include <string>
#include <vector>
@@ -48,7 +49,6 @@
#include "chrome/updater/win/setup/setup_util.h"
#include "chrome/updater/win/ui/l10n_util.h"
#include "chrome/updater/win/ui/resources/updater_installer_strings.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace {
@@ -59,8 +59,8 @@
}
// Extracts a string from a VARIANT if the VARIANT is VT_BSTR or VT_BSTR |
-// VT_BYREF. Returns absl::nullopt if the VARIANT is not a BSTR.
-absl::optional<std::wstring> StringFromVariant(const VARIANT& source) {
+// VT_BYREF. Returns std::nullopt if the VARIANT is not a BSTR.
+std::optional<std::wstring> StringFromVariant(const VARIANT& source) {
if (V_VT(&source) == VT_BSTR) {
return V_BSTR(&source);
}
@@ -441,7 +441,7 @@
// Holds the result of the IPC to retrieve the current version.
struct CurrentVersionResult
: public base::RefCountedThreadSafe<CurrentVersionResult> {
- absl::optional<base::Version> current_version;
+ std::optional<base::Version> current_version;
base::WaitableEvent completion_event;
private:
@@ -635,8 +635,8 @@
// Access to `state_update_` and `result_` must be serialized by using the
// lock.
mutable base::Lock lock_;
- absl::optional<UpdateService::UpdateState> state_update_;
- absl::optional<UpdateService::Result> result_;
+ std::optional<UpdateService::UpdateState> state_update_;
+ std::optional<UpdateService::Result> result_;
};
// This class implements the legacy Omaha3 IAppBundleWeb interface as expected
@@ -908,7 +908,7 @@
{substitution1, substitution2, substitution3, substitution4,
substitution5, substitution6, substitution7, substitution8,
substitution9}) {
- const absl::optional<std::wstring> substitution_string =
+ const std::optional<std::wstring> substitution_string =
StringFromVariant(substitution);
if (!substitution_string) {
break;
@@ -1090,7 +1090,7 @@
// Holds the result of the IPC to retrieve `last checked time`.
struct LastCheckedTimeResult
: public base::RefCountedThreadSafe<LastCheckedTimeResult> {
- absl::optional<DATE> last_checked_time;
+ std::optional<DATE> last_checked_time;
base::WaitableEvent completion_event;
private:
@@ -1129,7 +1129,7 @@
}
ValueGetter value_getter;
- absl::optional<PolicyStatus<T>> value;
+ std::optional<PolicyStatus<T>> value;
base::WaitableEvent completion_event;
};
@@ -1378,7 +1378,7 @@
value.effective_policy()
? GetStringFromValue(value.effective_policy()->policy)
: "",
- value.conflict_policy() != absl::nullopt,
+ value.conflict_policy() != std::nullopt,
value.conflict_policy() ? value.conflict_policy()->source : "",
value.conflict_policy()
? GetStringFromValue(value.conflict_policy()->policy)
diff --git a/chrome/updater/app/server/win/com_classes_legacy.h b/chrome/updater/app/server/win/com_classes_legacy.h
index 77cafbda..90cd340 100644
--- a/chrome/updater/app/server/win/com_classes_legacy.h
+++ b/chrome/updater/app/server/win/com_classes_legacy.h
@@ -8,6 +8,7 @@
#include <windows.h>
#include <wrl/implements.h>
+#include <optional>
#include <string>
#include <vector>
diff --git a/chrome/updater/auto_run_on_os_upgrade_task.cc b/chrome/updater/auto_run_on_os_upgrade_task.cc
index ed4ac79908..9a25fd7 100644
--- a/chrome/updater/auto_run_on_os_upgrade_task.cc
+++ b/chrome/updater/auto_run_on_os_upgrade_task.cc
@@ -4,6 +4,7 @@
#include "chrome/updater/auto_run_on_os_upgrade_task.h"
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -23,7 +24,6 @@
#include "chrome/updater/constants.h"
#include "chrome/updater/persisted_data.h"
#include "chrome/updater/util/util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
@@ -108,7 +108,7 @@
bool AutoRunOnOsUpgradeTask::HasOSUpgraded() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
- const absl::optional<OSVERSIONINFOEX> previous_os_version =
+ const std::optional<OSVERSIONINFOEX> previous_os_version =
persisted_data_->GetLastOSVersion();
if (!previous_os_version) {
// Initialize the OS version.
@@ -119,7 +119,7 @@
if (!CompareOSVersions(previous_os_version.value(), VER_GREATER))
return false;
- if (const absl::optional<OSVERSIONINFOEX> current_os_version = GetOSVersion();
+ if (const std::optional<OSVERSIONINFOEX> current_os_version = GetOSVersion();
current_os_version) {
os_upgrade_string_ = GetOSUpgradeVersionsString(previous_os_version.value(),
current_os_version.value());
diff --git a/chrome/updater/auto_run_on_os_upgrade_task_unittest.cc b/chrome/updater/auto_run_on_os_upgrade_task_unittest.cc
index 5433309..5a70284 100644
--- a/chrome/updater/auto_run_on_os_upgrade_task_unittest.cc
+++ b/chrome/updater/auto_run_on_os_upgrade_task_unittest.cc
@@ -5,6 +5,7 @@
#include "chrome/updater/auto_run_on_os_upgrade_task.h"
#include <memory>
+#include <optional>
#include <string>
#include "base/base64.h"
@@ -76,8 +77,8 @@
};
TEST_F(AutoRunOnOsUpgradeTaskTest, RunOnOsUpgradeForApp) {
- const absl::optional<OSVERSIONINFOEX> current_os_version = GetOSVersion();
- ASSERT_NE(current_os_version, absl::nullopt);
+ const std::optional<OSVERSIONINFOEX> current_os_version = GetOSVersion();
+ ASSERT_NE(current_os_version, std::nullopt);
OSVERSIONINFOEX last_os_version = current_os_version.value();
--last_os_version.dwMajorVersion;
diff --git a/chrome/updater/certificate_tag.cc b/chrome/updater/certificate_tag.cc
index 2753b563..327fe43 100644
--- a/chrome/updater/certificate_tag.cc
+++ b/chrome/updater/certificate_tag.cc
@@ -4,6 +4,8 @@
#include "chrome/updater/certificate_tag.h"
+#include <optional>
+
#include "base/notreached.h"
#include "third_party/boringssl/src/include/openssl/bytestring.h"
#include "third_party/boringssl/src/include/openssl/crypto.h"
@@ -41,7 +43,7 @@
static constexpr uint16_t kAttributeCertificateTypePKCS7SignedData = 2;
// static
-absl::optional<Binary> Binary::Parse(base::span<const uint8_t> binary) {
+std::optional<Binary> Binary::Parse(base::span<const uint8_t> binary) {
// Parse establishes some offsets into |binary| for structures that |GetTag|
// and |SetTag| will both need.
@@ -83,7 +85,7 @@
!CBS_get_bytes(&bin_for_header, &optional_header,
size_of_optional_header) ||
!CBS_get_u16le(&optional_header, &optional_header_magic)) {
- return absl::nullopt;
+ return std::nullopt;
}
size_t address_size = 0, extra_header_bytes = 0;
@@ -97,7 +99,7 @@
extra_header_bytes = 4;
break;
default:
- return absl::nullopt;
+ return std::nullopt;
}
// Skip the Windows-specific header section up until the number of data
@@ -119,14 +121,14 @@
!CBS_get_u32le(&optional_header, &cert_entry_size) ||
size_t{cert_entry_virtual_addr} + cert_entry_size < cert_entry_size ||
size_t{cert_entry_virtual_addr} + cert_entry_size != CBS_len(&bin)) {
- return absl::nullopt;
+ return std::nullopt;
}
CBS bin_for_certs = bin;
CBS certs;
if (!CBS_skip(&bin_for_certs, cert_entry_virtual_addr) ||
!CBS_get_bytes(&bin_for_certs, &certs, cert_entry_size)) {
- return absl::nullopt;
+ return std::nullopt;
}
// See the WIN_CERTIFICATE structure from
@@ -141,7 +143,7 @@
!CBS_get_u16le(&certs, &certs_type) ||
certs_type != kAttributeCertificateTypePKCS7SignedData ||
!CBS_get_asn1_element(&certs, &signed_data, CBS_ASN1_SEQUENCE)) {
- return absl::nullopt;
+ return std::nullopt;
}
Binary ret;
@@ -157,7 +159,7 @@
!CBS_get_u32le(&bin_for_check, &cert_entry_size_duplicate) ||
cert_entry_size_duplicate != cert_entry_size) {
NOTREACHED();
- return absl::nullopt;
+ return std::nullopt;
}
ret.binary_ = binary;
@@ -165,13 +167,13 @@
ret.attr_cert_offset_ = cert_entry_virtual_addr;
if (!ret.ParseTag()) {
- return absl::nullopt;
+ return std::nullopt;
}
return ret;
}
-const absl::optional<base::span<const uint8_t>>& Binary::tag() const {
+const std::optional<base::span<const uint8_t>>& Binary::tag() const {
return tag_;
}
@@ -204,7 +206,7 @@
CBB_add_bytes(out, CBS_data(&element), CBS_len(&element)) == 1;
}
-absl::optional<std::vector<uint8_t>> Binary::SetTag(
+std::optional<std::vector<uint8_t>> Binary::SetTag(
base::span<const uint8_t> tag) const {
bssl::ScopedCBB cbb;
if (!CBB_init(cbb.get(), binary_.size() + 1024) ||
@@ -216,7 +218,7 @@
!CBB_add_u32(cbb.get(), 0 /* Length. Filled in later. */) ||
!CBB_add_u16le(cbb.get(), kAttributeCertificateRevision) ||
!CBB_add_u16le(cbb.get(), kAttributeCertificateTypePKCS7SignedData)) {
- return absl::nullopt;
+ return std::nullopt;
}
// Walk the PKCS SignedData structure from the input and copy elements to the
@@ -246,7 +248,7 @@
0 | CBS_ASN1_CONSTRUCTED | CBS_ASN1_CONTEXT_SPECIFIC) ||
!CBB_add_asn1(&pkcs7_cbb, &certs_cbb,
0 | CBS_ASN1_CONSTRUCTED | CBS_ASN1_CONTEXT_SPECIFIC)) {
- return absl::nullopt;
+ return std::nullopt;
}
// Copy the certificates from the input to the output, potentially omitting
@@ -258,7 +260,7 @@
if ((have_last_cert && !CBB_add_bytes(&certs_cbb, CBS_data(&last_cert),
CBS_len(&last_cert))) ||
!CBS_get_asn1_element(&certs, &last_cert, CBS_ASN1_SEQUENCE)) {
- return absl::nullopt;
+ return std::nullopt;
}
have_last_cert = true;
}
@@ -268,7 +270,7 @@
// it.
if (!tag_.has_value() &&
!CBB_add_bytes(&certs_cbb, CBS_data(&last_cert), CBS_len(&last_cert))) {
- return absl::nullopt;
+ return std::nullopt;
}
// These values are DER-encoded OIDs needed in the X.509 certificate that's
@@ -359,7 +361,7 @@
// Copy signerInfos from the input PKCS#7 structure.
!CopyASN1(&pkcs7_cbb, &pkcs7) || CBS_len(&pkcs7) != 0 ||
!CBB_finish(cbb.get(), &cbb_data, &cbb_len)) {
- return absl::nullopt;
+ return std::nullopt;
}
// Copy the CBB result into a std::vector, padding to 8-byte alignment.
diff --git a/chrome/updater/certificate_tag.h b/chrome/updater/certificate_tag.h
index 6e50763..a2afb094 100644
--- a/chrome/updater/certificate_tag.h
+++ b/chrome/updater/certificate_tag.h
@@ -6,10 +6,10 @@
#define CHROME_UPDATER_CERTIFICATE_TAG_H_
#include <cstdint>
+#include <optional>
#include <vector>
#include "base/containers/span.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace tagging {
@@ -24,15 +24,15 @@
// Parse a signed, Windows PE binary. Note that the returned structure
// contains pointers into the given data.
- static absl::optional<Binary> Parse(base::span<const uint8_t> binary);
+ static std::optional<Binary> Parse(base::span<const uint8_t> binary);
// tag returns the embedded tag, if any.
- const absl::optional<base::span<const uint8_t>>& tag() const;
+ const std::optional<base::span<const uint8_t>>& tag() const;
// SetTag returns an updated version of the binary that contains the given
// tag, or |nullopt| on error. If the binary already contains a tag then it
// will be replaced.
- absl::optional<std::vector<uint8_t>> SetTag(
+ std::optional<std::vector<uint8_t>> SetTag(
base::span<const uint8_t> tag) const;
private:
@@ -49,7 +49,7 @@
base::span<const uint8_t> content_info_;
// tag_ contains the embedded tag, or |nullopt| if there isn't one.
- absl::optional<base::span<const uint8_t>> tag_;
+ std::optional<base::span<const uint8_t>> tag_;
// attr_cert_offset_ is the offset in the file where the |WIN_CERTIFICATE|
// structure appears. (This is the last structure in the file.)
diff --git a/chrome/updater/certificate_tag_unittest.cc b/chrome/updater/certificate_tag_unittest.cc
index f756a8f..268a70c3 100644
--- a/chrome/updater/certificate_tag_unittest.cc
+++ b/chrome/updater/certificate_tag_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <cstdint>
+#include <optional>
#include <vector>
#include "base/containers/span.h"
@@ -11,7 +12,6 @@
#include "chrome/updater/certificate_tag.h"
#include "chrome/updater/util/unit_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/zlib/google/compression_utils.h"
namespace updater::tagging {
@@ -24,32 +24,32 @@
const base::span<const uint8_t> exe_span(
reinterpret_cast<const uint8_t*>(exe.data()), exe.size());
- absl::optional<Binary> bin(Binary::Parse(exe_span));
+ std::optional<Binary> bin(Binary::Parse(exe_span));
ASSERT_TRUE(bin);
// Binary should be untagged on disk.
- absl::optional<base::span<const uint8_t>> orig_tag(bin->tag());
+ std::optional<base::span<const uint8_t>> orig_tag(bin->tag());
EXPECT_FALSE(orig_tag);
constexpr uint8_t kTag[] = {1, 2, 3, 4, 5};
- absl::optional<std::vector<uint8_t>> updated_exe(bin->SetTag(kTag));
+ std::optional<std::vector<uint8_t>> updated_exe(bin->SetTag(kTag));
ASSERT_TRUE(updated_exe);
- absl::optional<Binary> bin2(Binary::Parse(*updated_exe));
+ std::optional<Binary> bin2(Binary::Parse(*updated_exe));
ASSERT_TRUE(bin2);
- absl::optional<base::span<const uint8_t>> parsed_tag(bin2->tag());
+ std::optional<base::span<const uint8_t>> parsed_tag(bin2->tag());
ASSERT_TRUE(parsed_tag);
EXPECT_TRUE(parsed_tag->size() == sizeof(kTag) &&
memcmp(kTag, parsed_tag->data(), sizeof(kTag)) == 0);
// Update an existing tag.
constexpr uint8_t kTag2[] = {1, 2, 3, 4, 6};
- absl::optional<std::vector<uint8_t>> updated_again_exe(bin2->SetTag(kTag2));
+ std::optional<std::vector<uint8_t>> updated_again_exe(bin2->SetTag(kTag2));
ASSERT_TRUE(updated_again_exe);
- absl::optional<Binary> bin3(Binary::Parse(*updated_again_exe));
+ std::optional<Binary> bin3(Binary::Parse(*updated_again_exe));
ASSERT_TRUE(bin3);
- absl::optional<base::span<const uint8_t>> parsed_tag2(bin3->tag());
+ std::optional<base::span<const uint8_t>> parsed_tag2(bin3->tag());
ASSERT_TRUE(parsed_tag2);
EXPECT_TRUE(parsed_tag2->size() == sizeof(kTag2) &&
memcmp(kTag2, parsed_tag2->data(), sizeof(kTag2)) == 0);
diff --git a/chrome/updater/cleanup_task.cc b/chrome/updater/cleanup_task.cc
index 62d947b..e4405ab 100644
--- a/chrome/updater/cleanup_task.cc
+++ b/chrome/updater/cleanup_task.cc
@@ -4,6 +4,8 @@
#include "chrome/updater/cleanup_task.h"
+#include <optional>
+
#include "base/files/file_enumerator.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
@@ -18,7 +20,6 @@
#include "chrome/updater/app/app_uninstall.h"
#include "chrome/updater/updater_version.h"
#include "chrome/updater/util/util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#if BUILDFLAG(IS_WIN)
#include "chrome/updater/util/win_util.h"
@@ -34,7 +35,7 @@
// TODO(crbug/5002644): we should remove this once we believe the cache has
// been deleted by the majority of clients.
void TempCleanupCache(UpdaterScope scope) {
- absl::optional<base::FilePath> cache_dir = GetCrxDiffCacheDirectory(scope);
+ std::optional<base::FilePath> cache_dir = GetCrxDiffCacheDirectory(scope);
if (cache_dir.has_value()) {
base::DeletePathRecursively(cache_dir.value());
}
@@ -53,7 +54,7 @@
CHECK(base::Version(kCleanupVersionMax).IsValid());
CHECK(base::Version(kUpdaterVersion)
.CompareTo(base::Version(kCleanupVersionMax)) > 0);
- absl::optional<base::FilePath> dir = GetInstallDirectory(scope);
+ std::optional<base::FilePath> dir = GetInstallDirectory(scope);
if (!dir) {
return;
}
diff --git a/chrome/updater/cleanup_task_unittest.cc b/chrome/updater/cleanup_task_unittest.cc
index 88d7fc8..e94a96a 100644
--- a/chrome/updater/cleanup_task_unittest.cc
+++ b/chrome/updater/cleanup_task_unittest.cc
@@ -4,6 +4,8 @@
#include "chrome/updater/cleanup_task.h"
+#include <optional>
+
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/memory/scoped_refptr.h"
@@ -14,7 +16,6 @@
#include "chrome/updater/util/unit_test_util.h"
#include "chrome/updater/util/util.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#if BUILDFLAG(IS_WIN)
#include "chrome/updater/util/win_util.h"
@@ -36,13 +37,13 @@
#if BUILDFLAG(IS_WIN)
// Set up a mock `GoogleUpdate.exe`, and the following mock directories:
// `Download`, `Install`, and a versioned `1.2.3.4` directory.
- const absl::optional<base::FilePath> google_update_exe =
+ const std::optional<base::FilePath> google_update_exe =
GetGoogleUpdateExePath(GetTestScope());
ASSERT_TRUE(google_update_exe.has_value());
test::SetupMockUpdater(google_update_exe.value());
#endif // BUILDFLAG(IS_WIN)
- absl::optional<base::FilePath> folder_path =
+ std::optional<base::FilePath> folder_path =
GetVersionedInstallDirectory(GetTestScope(), base::Version("100"));
ASSERT_TRUE(folder_path);
ASSERT_TRUE(base::CreateDirectory(*folder_path));
diff --git a/chrome/updater/configurator.cc b/chrome/updater/configurator.cc
index 4177b41..02ae692 100644
--- a/chrome/updater/configurator.cc
+++ b/chrome/updater/configurator.cc
@@ -6,6 +6,7 @@
#include <algorithm>
#include <memory>
+#include <optional>
#include <string>
#include <vector>
@@ -36,7 +37,6 @@
#include "components/update_client/unzip/in_process_unzipper.h"
#include "components/update_client/unzipper.h"
#include "components/version_info/version_info.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
#if BUILDFLAG(IS_WIN)
@@ -60,7 +60,7 @@
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
return base::IsManagedOrEnterpriseDevice();
#else
- return absl::nullopt;
+ return std::nullopt;
#endif
}()) {
#if BUILDFLAG(IS_LINUX)
@@ -199,8 +199,8 @@
return std::make_unique<update_client::ProtocolHandlerFactoryJSON>();
}
-absl::optional<bool> Configurator::IsMachineExternallyManaged() const {
- const absl::optional<bool> is_managed_overridden =
+std::optional<bool> Configurator::IsMachineExternallyManaged() const {
+ const std::optional<bool> is_managed_overridden =
external_constants_->IsMachineManaged();
return is_managed_overridden.has_value() ? is_managed_overridden
: is_managed_device_;
@@ -221,7 +221,7 @@
});
}
-absl::optional<base::FilePath> Configurator::GetCrxCachePath() const {
+std::optional<base::FilePath> Configurator::GetCrxCachePath() const {
return updater::GetCrxDiffCacheDirectory(GetUpdaterScope());
}
diff --git a/chrome/updater/configurator.h b/chrome/updater/configurator.h
index 4bea420b..d4c4552d 100644
--- a/chrome/updater/configurator.h
+++ b/chrome/updater/configurator.h
@@ -6,6 +6,7 @@
#define CHROME_UPDATER_CONFIGURATOR_H_
#include <memory>
+#include <optional>
#include <string>
#include <vector>
@@ -13,7 +14,6 @@
#include "base/memory/scoped_refptr.h"
#include "base/time/time.h"
#include "components/update_client/configurator.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
class GURL;
class PrefService;
@@ -78,9 +78,9 @@
bool IsPerUserInstall() const override;
std::unique_ptr<update_client::ProtocolHandlerFactory>
GetProtocolHandlerFactory() const override;
- absl::optional<bool> IsMachineExternallyManaged() const override;
+ std::optional<bool> IsMachineExternallyManaged() const override;
update_client::UpdaterStateProvider GetUpdaterStateProvider() const override;
- absl::optional<base::FilePath> GetCrxCachePath() const override;
+ std::optional<base::FilePath> GetCrxCachePath() const override;
virtual GURL CrashUploadURL() const;
virtual GURL DeviceManagementURL() const;
@@ -101,7 +101,7 @@
scoped_refptr<update_client::CrxDownloaderFactory> crx_downloader_factory_;
scoped_refptr<update_client::UnzipperFactory> unzip_factory_;
scoped_refptr<update_client::PatcherFactory> patch_factory_;
- const absl::optional<bool> is_managed_device_;
+ const std::optional<bool> is_managed_device_;
};
} // namespace updater
diff --git a/chrome/updater/crash_client.cc b/chrome/updater/crash_client.cc
index 373a2a5..d6bf4084 100644
--- a/chrome/updater/crash_client.cc
+++ b/chrome/updater/crash_client.cc
@@ -4,6 +4,7 @@
#include "chrome/updater/crash_client.h"
+#include <optional>
#include <vector>
#include "base/check.h"
@@ -21,7 +22,6 @@
#include "chrome/updater/updater_branding.h"
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/util/util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/crashpad/crashpad/client/crash_report_database.h"
#include "third_party/crashpad/crashpad/client/crashpad_client.h"
#include "third_party/crashpad/crashpad/client/prune_crash_reports.h"
@@ -57,7 +57,7 @@
bool CrashClient::InitializeDatabaseOnly(UpdaterScope updater_scope) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
- const absl::optional<base::FilePath> database_path =
+ const std::optional<base::FilePath> database_path =
EnsureCrashDatabasePath(updater_scope);
if (!database_path) {
LOG(ERROR) << "Failed to get the database path.";
@@ -126,7 +126,7 @@
LOG(ERROR) << "Failed to fetch pending crash reports: " << status_pending;
}
- absl::optional<tagging::TagArgs> tag_args = GetTagArgs().tag_args;
+ std::optional<tagging::TagArgs> tag_args = GetTagArgs().tag_args;
std::string env_usage_stats;
if ((tag_args && tag_args->usage_stats_enable &&
*tag_args->usage_stats_enable) ||
diff --git a/chrome/updater/crash_reporter.cc b/chrome/updater/crash_reporter.cc
index 413a713b..bb001fa06 100644
--- a/chrome/updater/crash_reporter.cc
+++ b/chrome/updater/crash_reporter.cc
@@ -7,6 +7,7 @@
#include <iterator>
#include <map>
#include <memory>
+#include <optional>
#include <string>
#include <vector>
@@ -26,7 +27,6 @@
#include "chrome/updater/updater_branding.h"
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/util/util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/crashpad/crashpad/client/crashpad_client.h"
#include "third_party/crashpad/crashpad/client/crashpad_info.h"
#include "third_party/crashpad/crashpad/handler/handler_main.h"
@@ -77,7 +77,7 @@
base::FilePath handler_path;
base::PathService::Get(base::FILE_EXE, &handler_path);
- const absl::optional<base::FilePath> database_path =
+ const std::optional<base::FilePath> database_path =
EnsureCrashDatabasePath(updater_scope);
if (!database_path) {
LOG(ERROR) << "Failed to get the database path.";
@@ -98,7 +98,7 @@
crashpad::CrashpadClient& client = GetCrashpadClient();
std::vector<base::FilePath> attachments;
#if !BUILDFLAG(IS_MAC) // Crashpad does not support attachments on macOS.
- absl::optional<base::FilePath> log_file = GetLogFilePath(updater_scope);
+ std::optional<base::FilePath> log_file = GetLogFilePath(updater_scope);
if (log_file) {
attachments.push_back(*log_file);
}
diff --git a/chrome/updater/device_management/dm_client.cc b/chrome/updater/device_management/dm_client.cc
index fd76407..8e54fdb 100644
--- a/chrome/updater/device_management/dm_client.cc
+++ b/chrome/updater/device_management/dm_client.cc
@@ -7,6 +7,7 @@
#include <stdint.h>
#include <memory>
+#include <optional>
#include <ostream>
#include <string>
#include <utility>
@@ -31,7 +32,6 @@
#include "chrome/updater/updater_version.h"
#include "chrome/updater/util/util.h"
#include "components/update_client/network.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
namespace updater {
@@ -68,7 +68,7 @@
class DefaultConfigurator : public DMClient::Configurator {
public:
DefaultConfigurator(const GURL& server_url,
- absl::optional<PolicyServiceProxyConfiguration>
+ std::optional<PolicyServiceProxyConfiguration>
policy_service_proxy_configuration);
~DefaultConfigurator() override = default;
@@ -92,7 +92,7 @@
DefaultConfigurator::DefaultConfigurator(
const GURL& server_url,
- absl::optional<PolicyServiceProxyConfiguration>
+ std::optional<PolicyServiceProxyConfiguration>
policy_service_proxy_configuration)
: server_url_(server_url),
network_fetcher_factory_(base::MakeRefCounted<NetworkFetcherFactory>(
@@ -414,7 +414,7 @@
std::unique_ptr<DMClient::Configurator> DMClient::CreateDefaultConfigurator(
const GURL& server_url,
- absl::optional<PolicyServiceProxyConfiguration>
+ std::optional<PolicyServiceProxyConfiguration>
policy_service_proxy_configuration) {
return std::make_unique<DefaultConfigurator>(
server_url, policy_service_proxy_configuration);
diff --git a/chrome/updater/device_management/dm_client.h b/chrome/updater/device_management/dm_client.h
index 33a3a18..1b7f7e5 100644
--- a/chrome/updater/device_management/dm_client.h
+++ b/chrome/updater/device_management/dm_client.h
@@ -6,13 +6,13 @@
#define CHROME_UPDATER_DEVICE_MANAGEMENT_DM_CLIENT_H_
#include <memory>
+#include <optional>
#include <ostream>
#include <string>
#include <vector>
#include "base/functional/callback.h"
#include "base/memory/scoped_refptr.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
class GURL;
@@ -138,7 +138,7 @@
static std::unique_ptr<Configurator> CreateDefaultConfigurator(
const GURL& server_url,
- absl::optional<PolicyServiceProxyConfiguration>
+ std::optional<PolicyServiceProxyConfiguration>
policy_service_proxy_configuration);
};
diff --git a/chrome/updater/device_management/dm_policy_builder_for_testing.h b/chrome/updater/device_management/dm_policy_builder_for_testing.h
index e3bedd1d..27ac2d6 100644
--- a/chrome/updater/device_management/dm_policy_builder_for_testing.h
+++ b/chrome/updater/device_management/dm_policy_builder_for_testing.h
@@ -6,7 +6,9 @@
#define CHROME_UPDATER_DEVICE_MANAGEMENT_DM_POLICY_BUILDER_FOR_TESTING_H_
#include <stdint.h>
+
#include <memory>
+#include <optional>
#include <string>
#include <vector>
diff --git a/chrome/updater/device_management/dm_storage_mac.mm b/chrome/updater/device_management/dm_storage_mac.mm
index 3b9dff7..d1e875c 100644
--- a/chrome/updater/device_management/dm_storage_mac.mm
+++ b/chrome/updater/device_management/dm_storage_mac.mm
@@ -6,6 +6,7 @@
#import <Foundation/Foundation.h>
+#include <optional>
#include <string>
#include "base/apple/foundation_util.h"
@@ -189,7 +190,7 @@
dm_token_path)) {}
scoped_refptr<DMStorage> GetDefaultDMStorage() {
- absl::optional<base::FilePath> keystone_path =
+ std::optional<base::FilePath> keystone_path =
GetKeystoneFolderPath(UpdaterScope::kSystem);
return keystone_path ? base::MakeRefCounted<DMStorage>(
keystone_path->AppendASCII("DeviceManagement"))
diff --git a/chrome/updater/enum_traits.h b/chrome/updater/enum_traits.h
index 581acf7..9d10cfc1 100644
--- a/chrome/updater/enum_traits.h
+++ b/chrome/updater/enum_traits.h
@@ -5,11 +5,10 @@
#ifndef CHROME_UPDATER_ENUM_TRAITS_H_
#define CHROME_UPDATER_ENUM_TRAITS_H_
+#include <optional>
#include <ostream>
#include <type_traits>
-#include "third_party/abseil-cpp/absl/types/optional.h"
-
namespace updater {
// Provides a way to safely convert numeric types to enumerated values.
@@ -42,14 +41,14 @@
// The enum type must be annotated with traits to specify the lower and upper
// bounds of the enum values.
template <typename T, typename V>
-absl::optional<T> CheckedCastToEnum(V v) {
+std::optional<T> CheckedCastToEnum(V v) {
static_assert(std::is_enum<T>::value, "T must be an enum type.");
static_assert(std::is_integral<V>::value, "V must be an integral type.");
using Traits = EnumTraits<T>;
return (static_cast<V>(Traits::first_elem) <= v &&
v <= static_cast<V>(Traits::last_elem))
- ? absl::make_optional(static_cast<T>(v))
- : absl::nullopt;
+ ? std::make_optional(static_cast<T>(v))
+ : std::nullopt;
}
} // namespace updater
diff --git a/chrome/updater/enum_traits_unittest.cc b/chrome/updater/enum_traits_unittest.cc
index def0b499..e53f0e5 100644
--- a/chrome/updater/enum_traits_unittest.cc
+++ b/chrome/updater/enum_traits_unittest.cc
@@ -7,7 +7,6 @@
#include <ostream>
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -27,8 +26,8 @@
EXPECT_EQ(MyEnum::kVal1, *CheckedCastToEnum<MyEnum>(-1));
EXPECT_EQ(MyEnum::kVal2, *CheckedCastToEnum<MyEnum>(0));
EXPECT_EQ(MyEnum::kVal3, *CheckedCastToEnum<MyEnum>(1));
- EXPECT_EQ(CheckedCastToEnum<MyEnum>(-2), absl::nullopt);
- EXPECT_EQ(CheckedCastToEnum<MyEnum>(2), absl::nullopt);
+ EXPECT_EQ(CheckedCastToEnum<MyEnum>(-2), std::nullopt);
+ EXPECT_EQ(CheckedCastToEnum<MyEnum>(2), std::nullopt);
}
} // namespace updater
diff --git a/chrome/updater/external_constants.h b/chrome/updater/external_constants.h
index 841b9f6..0b27953 100644
--- a/chrome/updater/external_constants.h
+++ b/chrome/updater/external_constants.h
@@ -5,13 +5,13 @@
#ifndef CHROME_UPDATER_EXTERNAL_CONSTANTS_H_
#define CHROME_UPDATER_EXTERNAL_CONSTANTS_H_
+#include <optional>
#include <vector>
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_refptr.h"
#include "base/time/time.h"
#include "base/values.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
class GURL;
@@ -65,7 +65,7 @@
virtual base::TimeDelta IdleCheckPeriod() const = 0;
// Overrides machine management state.
- virtual absl::optional<bool> IsMachineManaged() const = 0;
+ virtual std::optional<bool> IsMachineManaged() const = 0;
// True if the updater should request and apply diff updates.
virtual bool EnableDiffUpdates() const = 0;
diff --git a/chrome/updater/external_constants_builder.cc b/chrome/updater/external_constants_builder.cc
index aec530e..ab5ad29 100644
--- a/chrome/updater/external_constants_builder.cc
+++ b/chrome/updater/external_constants_builder.cc
@@ -5,6 +5,7 @@
#include "chrome/updater/external_constants_builder.h"
#include <iterator>
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -21,7 +22,6 @@
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/util/util.h"
#include "components/crx_file/crx_verifier.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
namespace updater {
@@ -168,7 +168,7 @@
}
ExternalConstantsBuilder& ExternalConstantsBuilder::SetMachineManaged(
- const absl::optional<bool>& is_managed_device) {
+ const std::optional<bool>& is_managed_device) {
if (is_managed_device.has_value()) {
overrides_.Set(kDevOverrideKeyManagedDevice, is_managed_device.value());
}
@@ -193,7 +193,7 @@
}
bool ExternalConstantsBuilder::Overwrite() {
- const absl::optional<base::FilePath> override_path =
+ const std::optional<base::FilePath> override_path =
GetOverrideFilePath(GetUpdaterScope());
if (!override_path) {
LOG(ERROR) << "Can't find base directory; can't save constant overrides.";
diff --git a/chrome/updater/external_constants_builder.h b/chrome/updater/external_constants_builder.h
index e9b713cc..cd95d2d5 100644
--- a/chrome/updater/external_constants_builder.h
+++ b/chrome/updater/external_constants_builder.h
@@ -5,12 +5,12 @@
#ifndef CHROME_UPDATER_EXTERNAL_CONSTANTS_BUILDER_H_
#define CHROME_UPDATER_EXTERNAL_CONSTANTS_BUILDER_H_
+#include <optional>
#include <string>
#include <vector>
#include "base/files/file_path.h"
#include "base/values.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace base {
class TimeDelta;
@@ -75,7 +75,7 @@
ExternalConstantsBuilder& ClearIdleCheckPeriod();
ExternalConstantsBuilder& SetMachineManaged(
- const absl::optional<bool>& is_managed_device);
+ const std::optional<bool>& is_managed_device);
ExternalConstantsBuilder& ClearMachineManaged();
ExternalConstantsBuilder& SetEnableDiffUpdates(bool enable_diffs);
diff --git a/chrome/updater/external_constants_builder_unittest.cc b/chrome/updater/external_constants_builder_unittest.cc
index 65177ce..bd58542 100644
--- a/chrome/updater/external_constants_builder_unittest.cc
+++ b/chrome/updater/external_constants_builder_unittest.cc
@@ -4,6 +4,7 @@
#include "testing/gtest/include/gtest/gtest.h"
+#include <optional>
#include <string>
#include <vector>
@@ -20,7 +21,6 @@
#include "chrome/updater/updater_branding.h"
#include "chrome/updater/util/unit_test_util.h"
#include "chrome/updater/util/util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
namespace updater {
@@ -38,7 +38,7 @@
private:
// This test runs non-elevated.
- const absl::optional<base::FilePath> overrides_file_path_ =
+ const std::optional<base::FilePath> overrides_file_path_ =
GetOverrideFilePath(UpdaterScope::kUser);
};
@@ -75,7 +75,7 @@
.SetGroupPolicies(group_policies)
.SetOverinstallTimeout(base::Seconds(3))
.SetIdleCheckPeriod(base::Seconds(4))
- .SetMachineManaged(absl::make_optional(true))
+ .SetMachineManaged(std::make_optional(true))
.SetEnableDiffUpdates(true);
EXPECT_TRUE(builder.Overwrite());
@@ -181,7 +181,7 @@
.SetUseCUP(true)
.SetInitialDelay(base::Seconds(123.4))
.SetServerKeepAliveTime(base::Seconds(2))
- .SetMachineManaged(absl::make_optional(true))
+ .SetMachineManaged(std::make_optional(true))
.SetGroupPolicies(group_policies)
.SetEnableDiffUpdates(false)
.SetUpdateURL(std::vector<std::string>{"https://www.example.com"})
@@ -190,7 +190,7 @@
.SetUseCUP(false)
.SetInitialDelay(base::Seconds(937.6))
.SetServerKeepAliveTime(base::Seconds(3))
- .SetMachineManaged(absl::make_optional(false))
+ .SetMachineManaged(std::make_optional(false))
.SetEnableDiffUpdates(true)
.Overwrite());
@@ -230,7 +230,7 @@
.SetServerKeepAliveTime(base::Seconds(3))
.SetUpdateURL(std::vector<std::string>{"https://www.example.com"})
.SetGroupPolicies(group_policies)
- .SetMachineManaged(absl::make_optional(true))
+ .SetMachineManaged(std::make_optional(true))
.SetEnableDiffUpdates(true)
.Overwrite());
@@ -307,7 +307,7 @@
.SetCrashUploadURL("https://crash.example.com")
.SetDeviceManagementURL("https://dm.example.com")
.SetGroupPolicies(group_policies)
- .SetMachineManaged(absl::make_optional(false))
+ .SetMachineManaged(std::make_optional(false))
.SetEnableDiffUpdates(true)
.Overwrite());
diff --git a/chrome/updater/external_constants_default.cc b/chrome/updater/external_constants_default.cc
index f883c00..c0c2770c 100644
--- a/chrome/updater/external_constants_default.cc
+++ b/chrome/updater/external_constants_default.cc
@@ -4,6 +4,9 @@
#include "chrome/updater/external_constants_default.h"
+#include <optional>
+#include <vector>
+
#include "base/memory/scoped_refptr.h"
#include "base/time/time.h"
#include "base/values.h"
@@ -11,7 +14,6 @@
#include "chrome/updater/external_constants.h"
#include "chrome/updater/updater_branding.h"
#include "components/crx_file/crx_verifier.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
namespace updater {
@@ -54,9 +56,7 @@
base::TimeDelta IdleCheckPeriod() const override { return base::Minutes(5); }
- absl::optional<bool> IsMachineManaged() const override {
- return absl::nullopt;
- }
+ std::optional<bool> IsMachineManaged() const override { return std::nullopt; }
bool EnableDiffUpdates() const override { return false; }
diff --git a/chrome/updater/external_constants_override.cc b/chrome/updater/external_constants_override.cc
index f847920..945cf700 100644
--- a/chrome/updater/external_constants_override.cc
+++ b/chrome/updater/external_constants_override.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <memory>
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -27,7 +28,6 @@
#include "chrome/updater/updater_version.h"
#include "chrome/updater/util/util.h"
#include "components/crx_file/crx_verifier.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
#if BUILDFLAG(IS_MAC)
@@ -56,10 +56,10 @@
namespace updater {
-absl::optional<base::FilePath> GetOverrideFilePath(UpdaterScope scope) {
- absl::optional<base::FilePath> base = GetInstallDirectory(scope);
+std::optional<base::FilePath> GetOverrideFilePath(UpdaterScope scope) {
+ std::optional<base::FilePath> base = GetInstallDirectory(scope);
if (!base) {
- return absl::nullopt;
+ return std::nullopt;
}
return base->DirName().AppendASCII(kDevOverrideFileName);
}
@@ -209,7 +209,7 @@
return base::Seconds(value->GetInt());
}
-absl::optional<bool> ExternalConstantsOverrider::IsMachineManaged() const {
+std::optional<bool> ExternalConstantsOverrider::IsMachineManaged() const {
if (!override_values_.contains(kDevOverrideKeyManagedDevice)) {
return next_provider_->IsMachineManaged();
}
@@ -219,7 +219,7 @@
<< "Unexpected type of override[" << kDevOverrideKeyManagedDevice
<< "]: " << base::Value::GetTypeName(is_managed->type());
- return absl::make_optional(is_managed->GetBool());
+ return std::make_optional(is_managed->GetBool());
}
bool ExternalConstantsOverrider::EnableDiffUpdates() const {
@@ -238,7 +238,7 @@
scoped_refptr<ExternalConstantsOverrider>
ExternalConstantsOverrider::FromDefaultJSONFile(
scoped_refptr<ExternalConstants> next_provider) {
- const absl::optional<base::FilePath> override_file_path =
+ const std::optional<base::FilePath> override_file_path =
GetOverrideFilePath(GetUpdaterScope());
if (!override_file_path) {
LOG(ERROR) << "Cannot find override file path.";
diff --git a/chrome/updater/external_constants_override.h b/chrome/updater/external_constants_override.h
index fd45e60..f628749 100644
--- a/chrome/updater/external_constants_override.h
+++ b/chrome/updater/external_constants_override.h
@@ -6,6 +6,7 @@
#define CHROME_UPDATER_EXTERNAL_CONSTANTS_OVERRIDE_H_
#include <memory>
+#include <optional>
#include <string>
#include <vector>
@@ -15,7 +16,6 @@
#include "base/values.h"
#include "chrome/updater/external_constants.h"
#include "chrome/updater/updater_scope.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
class GURL;
@@ -31,7 +31,7 @@
namespace updater {
-absl::optional<base::FilePath> GetOverrideFilePath(UpdaterScope scope);
+std::optional<base::FilePath> GetOverrideFilePath(UpdaterScope scope);
class ExternalConstantsOverrider : public ExternalConstants {
public:
@@ -57,7 +57,7 @@
base::Value::Dict GroupPolicies() const override;
base::TimeDelta OverinstallTimeout() const override;
base::TimeDelta IdleCheckPeriod() const override;
- absl::optional<bool> IsMachineManaged() const override;
+ std::optional<bool> IsMachineManaged() const override;
bool EnableDiffUpdates() const override;
private:
diff --git a/chrome/updater/installer.cc b/chrome/updater/installer.cc
index 1cdc585..e926f95 100644
--- a/chrome/updater/installer.cc
+++ b/chrome/updater/installer.cc
@@ -27,7 +27,6 @@
#include "components/crx_file/crx_verifier.h"
#include "components/update_client/update_client_errors.h"
#include "components/update_client/utils.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
diff --git a/chrome/updater/installer.h b/chrome/updater/installer.h
index cf21a89..6a86ab01 100644
--- a/chrome/updater/installer.h
+++ b/chrome/updater/installer.h
@@ -6,6 +6,7 @@
#define CHROME_UPDATER_INSTALLER_H_
#include <memory>
+#include <optional>
#include <string>
#include "base/files/file_path.h"
@@ -19,7 +20,6 @@
#include "chrome/updater/updater_scope.h"
#include "components/crx_file/crx_verifier.h"
#include "components/update_client/update_client.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace base {
class TimeDelta;
@@ -57,7 +57,7 @@
const AppInfo& app_info,
const base::FilePath& installer_path,
const std::string& install_args,
- const absl::optional<base::FilePath>& server_install_data,
+ const std::optional<base::FilePath>& server_install_data,
bool usage_stats_enabled,
const base::TimeDelta& timeout,
InstallProgressCallback progress_callback);
diff --git a/chrome/updater/installer_linux.cc b/chrome/updater/installer_linux.cc
index 72dd98b..7122c0651a 100644
--- a/chrome/updater/installer_linux.cc
+++ b/chrome/updater/installer_linux.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <optional>
+
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/process/launch.h"
@@ -16,7 +18,7 @@
const AppInfo& app_info,
const base::FilePath& installer_path,
const std::string& arguments,
- const absl::optional<base::FilePath>& install_data_file,
+ const std::optional<base::FilePath>& install_data_file,
bool usage_stats_enabled,
const base::TimeDelta& timeout,
InstallProgressCallback /*progress_callback*/) {
diff --git a/chrome/updater/installer_mac.cc b/chrome/updater/installer_mac.cc
index 7da3ffc..72839c6 100644
--- a/chrome/updater/installer_mac.cc
+++ b/chrome/updater/installer_mac.cc
@@ -4,6 +4,8 @@
#include "chrome/updater/installer.h"
+#include <optional>
+
#include "base/files/file_path.h"
#include "base/functional/callback.h"
#include "base/logging.h"
@@ -12,7 +14,6 @@
#include "chrome/updater/constants.h"
#include "chrome/updater/mac/install_from_archive.h"
#include "chrome/updater/util/mac_util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -20,7 +21,7 @@
const AppInfo& app_info,
const base::FilePath& app_installer,
const std::string& arguments,
- const absl::optional<base::FilePath>& installer_data_file,
+ const std::optional<base::FilePath>& installer_data_file,
bool usage_stats_enabled,
const base::TimeDelta& timeout,
InstallProgressCallback /*progress_callback*/) {
@@ -43,14 +44,14 @@
std::string LookupString(const base::FilePath& path,
const std::string& keyname,
const std::string& default_value) {
- absl::optional<std::string> value = ReadValueFromPlist(path, keyname);
+ std::optional<std::string> value = ReadValueFromPlist(path, keyname);
return value ? *value : default_value;
}
base::Version LookupVersion(const base::FilePath& path,
const std::string& keyname,
const base::Version& default_value) {
- absl::optional<std::string> value = ReadValueFromPlist(path, keyname);
+ std::optional<std::string> value = ReadValueFromPlist(path, keyname);
if (value) {
base::Version value_version(*value);
return value_version.IsValid() ? value_version : default_value;
diff --git a/chrome/updater/ipc/ipc_names_linux.cc b/chrome/updater/ipc/ipc_names_linux.cc
index 28da8d5..79106b19 100644
--- a/chrome/updater/ipc/ipc_names_linux.cc
+++ b/chrome/updater/ipc/ipc_names_linux.cc
@@ -4,10 +4,11 @@
#include "chrome/updater/ipc/ipc_names.h"
+#include <optional>
+
#include "chrome/updater/linux/ipc_constants.h"
#include "chrome/updater/updater_scope.h"
#include "mojo/public/cpp/platform/named_platform_channel.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -18,7 +19,7 @@
mojo::NamedPlatformChannel::ServerName GetUpdateServiceServerName(
UpdaterScope scope) {
- absl::optional<base::FilePath> socket = GetActiveDutySocketPath(scope);
+ std::optional<base::FilePath> socket = GetActiveDutySocketPath(scope);
CHECK(socket);
return socket->MaybeAsASCII();
}
diff --git a/chrome/updater/ipc/update_service_dialer_linux.cc b/chrome/updater/ipc/update_service_dialer_linux.cc
index fb92283d..8dd0f977 100644
--- a/chrome/updater/ipc/update_service_dialer_linux.cc
+++ b/chrome/updater/ipc/update_service_dialer_linux.cc
@@ -6,7 +6,9 @@
#include <sys/socket.h>
#include <sys/un.h>
+
#include <cstdio>
+#include <optional>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
@@ -16,7 +18,6 @@
#include "chrome/updater/linux/ipc_constants.h"
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/util/util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -49,7 +50,7 @@
}
bool DialUpdateInternalService(UpdaterScope scope) {
- absl::optional<base::FilePath> updater = GetUpdaterExecutablePath(scope);
+ std::optional<base::FilePath> updater = GetUpdaterExecutablePath(scope);
if (updater) {
base::CommandLine command(*updater);
command.AppendSwitch(kServerSwitch);
diff --git a/chrome/updater/ipc/update_service_dialer_mac.cc b/chrome/updater/ipc/update_service_dialer_mac.cc
index 64609dc..3144afb 100644
--- a/chrome/updater/ipc/update_service_dialer_mac.cc
+++ b/chrome/updater/ipc/update_service_dialer_mac.cc
@@ -4,6 +4,8 @@
#include "chrome/updater/ipc/update_service_dialer.h"
+#include <optional>
+
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
@@ -12,7 +14,6 @@
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/util/posix_util.h"
#include "chrome/updater/util/util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -36,7 +37,7 @@
} // namespace
bool DialUpdateService(UpdaterScope scope) {
- absl::optional<base::FilePath> launcher = GetUpdateServiceLauncherPath(scope);
+ std::optional<base::FilePath> launcher = GetUpdateServiceLauncherPath(scope);
if (!launcher) {
return true;
}
@@ -44,7 +45,7 @@
}
bool DialUpdateInternalService(UpdaterScope scope) {
- absl::optional<base::FilePath> bundle = GetUpdaterAppBundlePath(scope);
+ std::optional<base::FilePath> bundle = GetUpdaterAppBundlePath(scope);
if (!bundle) {
return true;
}
diff --git a/chrome/updater/ipc/update_service_internal_proxy.cc b/chrome/updater/ipc/update_service_internal_proxy.cc
index 3c64a73..97f9ad422 100644
--- a/chrome/updater/ipc/update_service_internal_proxy.cc
+++ b/chrome/updater/ipc/update_service_internal_proxy.cc
@@ -4,11 +4,11 @@
#include "chrome/updater/ipc/update_service_internal_proxy.h"
+#include <optional>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#if BUILDFLAG(IS_POSIX)
#include "chrome/updater/ipc/update_service_internal_proxy_posix.h"
@@ -47,7 +47,7 @@
void UpdateServiceInternalProxy::RunDone(base::OnceClosure callback,
int try_count,
- absl::optional<RpcError> error) {
+ std::optional<RpcError> error) {
if (error && CanRetry(try_count)) {
proxy_->Run(base::BindOnce(&UpdateServiceInternalProxy::RunDone, this,
std::move(callback), try_count + 1));
@@ -58,7 +58,7 @@
void UpdateServiceInternalProxy::HelloDone(base::OnceClosure callback,
int try_count,
- absl::optional<RpcError> error) {
+ std::optional<RpcError> error) {
if (error && CanRetry(try_count)) {
proxy_->Hello(base::BindOnce(&UpdateServiceInternalProxy::HelloDone, this,
std::move(callback), try_count + 1));
diff --git a/chrome/updater/ipc/update_service_internal_proxy.h b/chrome/updater/ipc/update_service_internal_proxy.h
index 2aeb1dc5..04cda7d8 100644
--- a/chrome/updater/ipc/update_service_internal_proxy.h
+++ b/chrome/updater/ipc/update_service_internal_proxy.h
@@ -5,12 +5,13 @@
#ifndef CHROME_UPDATER_IPC_UPDATE_SERVICE_INTERNAL_PROXY_H_
#define CHROME_UPDATER_IPC_UPDATE_SERVICE_INTERNAL_PROXY_H_
+#include <optional>
+
#include "base/functional/callback_forward.h"
#include "base/memory/scoped_refptr.h"
#include "base/sequence_checker.h"
#include "build/build_config.h"
#include "chrome/updater/update_service_internal.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#if BUILDFLAG(IS_POSIX)
#include "chrome/updater/ipc/update_service_internal_proxy_posix.h"
@@ -36,10 +37,10 @@
void RunDone(base::OnceClosure callback,
int try_count,
- absl::optional<RpcError> error);
+ std::optional<RpcError> error);
void HelloDone(base::OnceClosure callback,
int try_count,
- absl::optional<RpcError> result);
+ std::optional<RpcError> result);
SEQUENCE_CHECKER(sequence_checker_);
scoped_refptr<UpdateServiceInternalProxyImpl> proxy_;
diff --git a/chrome/updater/ipc/update_service_internal_proxy_posix.cc b/chrome/updater/ipc/update_service_internal_proxy_posix.cc
index d4fa2a7..00bb8e23 100644
--- a/chrome/updater/ipc/update_service_internal_proxy_posix.cc
+++ b/chrome/updater/ipc/update_service_internal_proxy_posix.cc
@@ -5,6 +5,7 @@
#include "chrome/updater/ipc/update_service_internal_proxy_posix.h"
#include <memory>
+#include <optional>
#include <utility>
#include "base/command_line.h"
@@ -33,7 +34,6 @@
#include "mojo/public/cpp/platform/platform_channel.h"
#include "mojo/public/cpp/platform/platform_channel_endpoint.h"
#include "mojo/public/cpp/system/isolated_connection.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace {
@@ -45,10 +45,10 @@
// Connect to the server.
// `retries` is 0 for the first try, 1 for the first retry, etc.
-absl::optional<mojo::PlatformChannelEndpoint> ConnectMojo(UpdaterScope scope,
- int retries) {
+std::optional<mojo::PlatformChannelEndpoint> ConnectMojo(UpdaterScope scope,
+ int retries) {
if (retries == 1 && !DialUpdateInternalService(scope)) {
- return absl::nullopt;
+ return std::nullopt;
}
return named_mojo_ipc_server::ConnectToServer(
GetUpdateServiceInternalServerName(scope));
@@ -58,22 +58,22 @@
UpdaterScope scope,
int tries,
base::Time deadline,
- base::OnceCallback<void(absl::optional<mojo::PlatformChannelEndpoint>)>
+ base::OnceCallback<void(std::optional<mojo::PlatformChannelEndpoint>)>
connected_callback) {
if (base::Time::Now() > deadline) {
LOG(ERROR) << "Failed to connect to UpdateServiceInternal remote. "
"Connection timed out.";
- std::move(connected_callback).Run(absl::nullopt);
+ std::move(connected_callback).Run(std::nullopt);
return;
}
- absl::optional<mojo::PlatformChannelEndpoint> endpoint =
+ std::optional<mojo::PlatformChannelEndpoint> endpoint =
ConnectMojo(scope, tries);
if (!endpoint) {
VLOG(1) << "Failed to connect to UpdateService remote. "
"No updater exists.";
- std::move(connected_callback).Run(absl::nullopt);
+ std::move(connected_callback).Run(std::nullopt);
return;
}
@@ -96,7 +96,7 @@
: scope_(scope) {}
void UpdateServiceInternalProxyImpl::Run(
- base::OnceCallback<void(absl::optional<RpcError>)> callback) {
+ base::OnceCallback<void(std::optional<RpcError>)> callback) {
VLOG(1) << __func__;
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
EnsureConnecting();
@@ -104,11 +104,11 @@
mojo::WrapCallbackWithDefaultInvokeIfNotRun(
base::BindPostTaskToCurrentDefault(std::move(callback)),
kErrorIpcDisconnect),
- absl::nullopt));
+ std::nullopt));
}
void UpdateServiceInternalProxyImpl::Hello(
- base::OnceCallback<void(absl::optional<RpcError>)> callback) {
+ base::OnceCallback<void(std::optional<RpcError>)> callback) {
VLOG(1) << __func__;
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
EnsureConnecting();
@@ -116,7 +116,7 @@
mojo::WrapCallbackWithDefaultInvokeIfNotRun(
base::BindPostTaskToCurrentDefault(std::move(callback)),
kErrorIpcDisconnect),
- absl::nullopt));
+ std::nullopt));
}
UpdateServiceInternalProxyImpl::~UpdateServiceInternalProxyImpl() = default;
@@ -144,7 +144,7 @@
void UpdateServiceInternalProxyImpl::OnConnected(
mojo::PendingReceiver<mojom::UpdateServiceInternal> pending_receiver,
- absl::optional<mojo::PlatformChannelEndpoint> endpoint) {
+ std::optional<mojo::PlatformChannelEndpoint> endpoint) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!endpoint) {
VLOG(2) << "No endpoint received.";
diff --git a/chrome/updater/ipc/update_service_internal_proxy_posix.h b/chrome/updater/ipc/update_service_internal_proxy_posix.h
index 289759e..c226c2e 100644
--- a/chrome/updater/ipc/update_service_internal_proxy_posix.h
+++ b/chrome/updater/ipc/update_service_internal_proxy_posix.h
@@ -6,6 +6,7 @@
#define CHROME_UPDATER_IPC_UPDATE_SERVICE_INTERNAL_PROXY_POSIX_H_
#include <memory>
+#include <optional>
#include "base/functional/callback_forward.h"
#include "base/memory/scoped_refptr.h"
@@ -15,7 +16,6 @@
#include "chrome/updater/update_service_internal.h"
#include "chrome/updater/updater_scope.h"
#include "mojo/public/cpp/bindings/remote.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace mojo {
class PlatformChannelEndpoint;
@@ -33,8 +33,8 @@
// It establishes a connection lazily and can be used immediately.
explicit UpdateServiceInternalProxyImpl(UpdaterScope scope);
- void Run(base::OnceCallback<void(absl::optional<RpcError>)> callback);
- void Hello(base::OnceCallback<void(absl::optional<RpcError>)> callback);
+ void Run(base::OnceCallback<void(std::optional<RpcError>)> callback);
+ void Hello(base::OnceCallback<void(std::optional<RpcError>)> callback);
private:
friend class base::RefCountedThreadSafe<UpdateServiceInternalProxyImpl>;
@@ -44,7 +44,7 @@
void OnDisconnected();
void OnConnected(
mojo::PendingReceiver<mojom::UpdateServiceInternal> pending_receiver,
- absl::optional<mojo::PlatformChannelEndpoint> endpoint);
+ std::optional<mojo::PlatformChannelEndpoint> endpoint);
SEQUENCE_CHECKER(sequence_checker_);
const UpdaterScope scope_;
diff --git a/chrome/updater/ipc/update_service_internal_proxy_win.cc b/chrome/updater/ipc/update_service_internal_proxy_win.cc
index 160a206..4c0d3b2 100644
--- a/chrome/updater/ipc/update_service_internal_proxy_win.cc
+++ b/chrome/updater/ipc/update_service_internal_proxy_win.cc
@@ -9,6 +9,7 @@
#include <wrl/implements.h>
#include <ios>
+#include <optional>
#include <utility>
#include "base/check_op.h"
@@ -24,7 +25,6 @@
#include "chrome/updater/util/win_util.h"
#include "chrome/updater/win/setup/setup_util.h"
#include "chrome/updater/win/win_constants.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace {
@@ -33,7 +33,7 @@
: public DYNAMICIIDSIMPL(IUpdaterInternalCallback) {
public:
explicit UpdaterInternalCallback(
- base::OnceCallback<void(absl::optional<RpcError>)> callback)
+ base::OnceCallback<void(std::optional<RpcError>)> callback)
: callback_(std::move(callback)) {}
UpdaterInternalCallback(const UpdaterInternalCallback&) = delete;
UpdaterInternalCallback& operator=(const UpdaterInternalCallback&) = delete;
@@ -45,16 +45,16 @@
// Disconnects this callback from its subject and ensures the callbacks are
// not posted after this function is called. Returns the completion callback
// so that the owner of this object can take back the callback ownership.
- base::OnceCallback<void(absl::optional<RpcError>)> Disconnect();
+ base::OnceCallback<void(std::optional<RpcError>)> Disconnect();
private:
~UpdaterInternalCallback() override {
if (callback_)
- std::move(callback_).Run(absl::nullopt);
+ std::move(callback_).Run(std::nullopt);
}
// Called by IUpdaterInternalCallback::Run when the COM RPC call is done.
- base::OnceCallback<void(absl::optional<RpcError>)> callback_;
+ base::OnceCallback<void(std::optional<RpcError>)> callback_;
};
IFACEMETHODIMP UpdaterInternalCallback::Run(LONG result) {
@@ -62,7 +62,7 @@
return S_OK;
}
-base::OnceCallback<void(absl::optional<RpcError>)>
+base::OnceCallback<void(std::optional<RpcError>)>
UpdaterInternalCallback::Disconnect() {
VLOG(2) << __func__;
return std::move(callback_);
@@ -85,13 +85,13 @@
: __uuidof(UpdaterInternalUserClass);
}
- void Run(base::OnceCallback<void(absl::optional<RpcError>)> callback) {
+ void Run(base::OnceCallback<void(std::optional<RpcError>)> callback) {
PostRPCTask(
base::BindOnce(&UpdateServiceInternalProxyImplImpl::RunOnTaskRunner,
this, std::move(callback)));
}
- void Hello(base::OnceCallback<void(absl::optional<RpcError>)> callback) {
+ void Hello(base::OnceCallback<void(std::optional<RpcError>)> callback) {
PostRPCTask(
base::BindOnce(&UpdateServiceInternalProxyImplImpl::HelloOnTaskRunner,
this, std::move(callback)));
@@ -102,7 +102,7 @@
~UpdateServiceInternalProxyImplImpl() = default;
void RunOnTaskRunner(
- base::OnceCallback<void(absl::optional<RpcError>)> callback) {
+ base::OnceCallback<void(std::optional<RpcError>)> callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (HRESULT connection = ConnectToServer(); FAILED(connection)) {
std::move(callback).Run(connection);
@@ -119,7 +119,7 @@
}
void HelloOnTaskRunner(
- base::OnceCallback<void(absl::optional<RpcError>)> callback) {
+ base::OnceCallback<void(std::optional<RpcError>)> callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (HRESULT connection = ConnectToServer(); FAILED(connection)) {
std::move(callback).Run(connection);
@@ -147,14 +147,14 @@
}
void UpdateServiceInternalProxyImpl::Run(
- base::OnceCallback<void(absl::optional<RpcError>)> callback) {
+ base::OnceCallback<void(std::optional<RpcError>)> callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
VLOG(1) << __func__;
impl_->Run(base::BindPostTaskToCurrentDefault(std::move(callback)));
}
void UpdateServiceInternalProxyImpl::Hello(
- base::OnceCallback<void(absl::optional<RpcError>)> callback) {
+ base::OnceCallback<void(std::optional<RpcError>)> callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
VLOG(1) << __func__;
impl_->Hello(base::BindPostTaskToCurrentDefault(std::move(callback)));
diff --git a/chrome/updater/ipc/update_service_internal_proxy_win.h b/chrome/updater/ipc/update_service_internal_proxy_win.h
index 3129c73..cf7113d7 100644
--- a/chrome/updater/ipc/update_service_internal_proxy_win.h
+++ b/chrome/updater/ipc/update_service_internal_proxy_win.h
@@ -7,11 +7,12 @@
#include <windows.h>
+#include <optional>
+
#include "base/functional/callback_forward.h"
#include "base/memory/scoped_refptr.h"
#include "base/sequence_checker.h"
#include "chrome/updater/update_service_internal.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -26,8 +27,8 @@
public:
explicit UpdateServiceInternalProxyImpl(UpdaterScope scope);
- void Run(base::OnceCallback<void(absl::optional<RpcError>)> callback);
- void Hello(base::OnceCallback<void(absl::optional<RpcError>)> callback);
+ void Run(base::OnceCallback<void(std::optional<RpcError>)> callback);
+ void Hello(base::OnceCallback<void(std::optional<RpcError>)> callback);
private:
friend class base::RefCountedThreadSafe<UpdateServiceInternalProxyImpl>;
diff --git a/chrome/updater/ipc/update_service_proxy.cc b/chrome/updater/ipc/update_service_proxy.cc
index 88b8471..37a77a8 100644
--- a/chrome/updater/ipc/update_service_proxy.cc
+++ b/chrome/updater/ipc/update_service_proxy.cc
@@ -19,7 +19,6 @@
#include "chrome/updater/constants.h"
#include "chrome/updater/registration_data.h"
#include "chrome/updater/update_service.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace {
diff --git a/chrome/updater/ipc/update_service_proxy_posix.cc b/chrome/updater/ipc/update_service_proxy_posix.cc
index 39a6205..9707b76a 100644
--- a/chrome/updater/ipc/update_service_proxy_posix.cc
+++ b/chrome/updater/ipc/update_service_proxy_posix.cc
@@ -5,6 +5,7 @@
#include "chrome/updater/ipc/update_service_proxy_posix.h"
#include <memory>
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -45,7 +46,6 @@
#include "mojo/public/cpp/platform/platform_channel_endpoint.h"
#include "mojo/public/cpp/system/isolated_connection.h"
#include "mojo/public/cpp/system/message_pipe.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace {
@@ -171,10 +171,10 @@
ToMojoCallback(std::move(complete_callback))));
}
-absl::optional<mojo::PlatformChannelEndpoint> ConnectMojo(UpdaterScope scope,
- int tries) {
+std::optional<mojo::PlatformChannelEndpoint> ConnectMojo(UpdaterScope scope,
+ int tries) {
if (tries == 1 && !DialUpdateService(scope)) {
- return absl::nullopt;
+ return std::nullopt;
}
return named_mojo_ipc_server::ConnectToServer(
GetUpdateServiceServerName(scope));
@@ -184,21 +184,21 @@
UpdaterScope scope,
int tries,
base::Time deadline,
- base::OnceCallback<void(absl::optional<mojo::PlatformChannelEndpoint>)>
+ base::OnceCallback<void(std::optional<mojo::PlatformChannelEndpoint>)>
connected_callback) {
if (base::Time::Now() > deadline) {
VLOG(1) << "Failed to connect to UpdateService remote. "
"Connection timed out.";
- std::move(connected_callback).Run(absl::nullopt);
+ std::move(connected_callback).Run(std::nullopt);
return;
}
- absl::optional<mojo::PlatformChannelEndpoint> endpoint =
+ std::optional<mojo::PlatformChannelEndpoint> endpoint =
ConnectMojo(scope, tries);
if (!endpoint) {
VLOG(1) << "Failed to connect to UpdateService remote. "
"No updater exists.";
- std::move(connected_callback).Run(absl::nullopt);
+ std::move(connected_callback).Run(std::nullopt);
return;
}
@@ -388,7 +388,7 @@
void UpdateServiceProxyImpl::OnConnected(
mojo::PendingReceiver<mojom::UpdateService> pending_receiver,
- absl::optional<mojo::PlatformChannelEndpoint> endpoint) {
+ std::optional<mojo::PlatformChannelEndpoint> endpoint) {
VLOG(1) << __func__;
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!endpoint) {
diff --git a/chrome/updater/ipc/update_service_proxy_posix.h b/chrome/updater/ipc/update_service_proxy_posix.h
index 20e14e50..34e1733 100644
--- a/chrome/updater/ipc/update_service_proxy_posix.h
+++ b/chrome/updater/ipc/update_service_proxy_posix.h
@@ -6,6 +6,7 @@
#define CHROME_UPDATER_IPC_UPDATE_SERVICE_PROXY_POSIX_H_
#include <memory>
+#include <optional>
#include "base/functional/callback_forward.h"
#include "base/memory/ref_counted.h"
@@ -16,7 +17,6 @@
#include "chrome/updater/update_service.h"
#include "chrome/updater/updater_scope.h"
#include "mojo/public/cpp/bindings/remote.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace base {
class FilePath;
@@ -111,7 +111,7 @@
friend class base::RefCountedThreadSafe<UpdateServiceProxyImpl>;
~UpdateServiceProxyImpl();
void OnConnected(mojo::PendingReceiver<mojom::UpdateService> pending_receiver,
- absl::optional<mojo::PlatformChannelEndpoint> endpoint);
+ std::optional<mojo::PlatformChannelEndpoint> endpoint);
void OnDisconnected();
void EnsureConnecting();
diff --git a/chrome/updater/ipc/update_service_proxy_win.cc b/chrome/updater/ipc/update_service_proxy_win.cc
index 1cab1d7..484e2af 100644
--- a/chrome/updater/ipc/update_service_proxy_win.cc
+++ b/chrome/updater/ipc/update_service_proxy_win.cc
@@ -10,6 +10,7 @@
#include <ios>
#include <memory>
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -34,7 +35,6 @@
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/util/win_util.h"
#include "chrome/updater/win/win_constants.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace {
@@ -93,7 +93,7 @@
HRESULT hr = update_state->get_state(&val_state);
if (SUCCEEDED(hr)) {
using State = UpdateService::UpdateState::State;
- absl::optional<State> state = CheckedCastToEnum<State>(val_state);
+ std::optional<State> state = CheckedCastToEnum<State>(val_state);
if (state)
update_service_state.state = *state;
}
@@ -135,7 +135,7 @@
HRESULT hr = update_state->get_errorCategory(&val_error_category);
if (SUCCEEDED(hr)) {
using ErrorCategory = UpdateService::ErrorCategory;
- absl::optional<ErrorCategory> error_category =
+ std::optional<ErrorCategory> error_category =
CheckedCastToEnum<ErrorCategory>(val_error_category);
if (error_category)
update_service_state.error_category = *error_category;
@@ -262,7 +262,7 @@
// The safearray is owned by the caller of `Run`, so ownership is released
// here after acquiring the `LockScope`.
base::win::ScopedSafearray safearray(V_ARRAY(&updater_app_states));
- absl::optional<base::win::ScopedSafearray::LockScope<VT_DISPATCH>>
+ std::optional<base::win::ScopedSafearray::LockScope<VT_DISPATCH>>
lock_scope = safearray.CreateLockScope<VT_DISPATCH>();
safearray.Release();
diff --git a/chrome/updater/linux/setup/setup.cc b/chrome/updater/linux/setup/setup.cc
index 6edcb86..8331e49 100644
--- a/chrome/updater/linux/setup/setup.cc
+++ b/chrome/updater/linux/setup/setup.cc
@@ -7,6 +7,8 @@
#include <stdio.h>
#include <unistd.h>
+#include <optional>
+
#include "base/base_paths.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
@@ -17,15 +19,13 @@
#include "chrome/updater/linux/systemd_util.h"
#include "chrome/updater/util/posix_util.h"
#include "chrome/updater/util/util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
int Setup(UpdaterScope scope) {
VLOG(1) << base::CommandLine::ForCurrentProcess()->GetCommandLineString()
<< " : " << __func__;
- absl::optional<base::FilePath> dest_path =
- GetVersionedInstallDirectory(scope);
+ std::optional<base::FilePath> dest_path = GetVersionedInstallDirectory(scope);
if (!dest_path) {
return kErrorFailedToGetVersionedInstallDirectory;
@@ -74,7 +74,7 @@
error = kErrorFailedToDeleteFolder;
}
- absl::optional<base::FilePath> versioned_socket =
+ std::optional<base::FilePath> versioned_socket =
GetActiveDutyInternalSocketPath(scope);
if (!versioned_socket || !base::DeleteFile(versioned_socket.value())) {
error = kErrorFailedToDeleteSocket;
@@ -85,7 +85,7 @@
int PromoteCandidate(UpdaterScope scope) {
// Create a hard link in the base install directory to this updater.
- absl::optional<base::FilePath> launcher_path =
+ std::optional<base::FilePath> launcher_path =
GetUpdateServiceLauncherPath(scope);
base::FilePath updater_executable;
diff --git a/chrome/updater/linux/systemd_util.cc b/chrome/updater/linux/systemd_util.cc
index 75e80e45..bba0cba 100644
--- a/chrome/updater/linux/systemd_util.cc
+++ b/chrome/updater/linux/systemd_util.cc
@@ -8,6 +8,8 @@
#include <sys/un.h>
#include <systemd/sd-daemon.h>
#include <unistd.h>
+
+#include <optional>
#include <utility>
#include "base/base_paths.h"
@@ -58,17 +60,17 @@
"WantedBy=sockets.target";
// Returns the path to the systemd unit directory for the given scope.
-absl::optional<base::FilePath> GetUnitDirectory(UpdaterScope scope) {
+std::optional<base::FilePath> GetUnitDirectory(UpdaterScope scope) {
base::FilePath unit_dir;
switch (scope) {
case UpdaterScope::kUser:
if (!base::PathService::Get(base::DIR_HOME, &unit_dir)) {
- return absl::nullopt;
+ return std::nullopt;
}
unit_dir = unit_dir.Append(kUserUnitRelativeDirectory);
if (!base::CreateDirectory(unit_dir)) {
- return absl::nullopt;
+ return std::nullopt;
}
break;
case UpdaterScope::kSystem:
@@ -182,9 +184,9 @@
}
bool InstallSystemdUnits(UpdaterScope scope) {
- absl::optional<base::FilePath> launcher_path =
+ std::optional<base::FilePath> launcher_path =
GetUpdateServiceLauncherPath(scope);
- absl::optional<base::FilePath> unit_dir = GetUnitDirectory(scope);
+ std::optional<base::FilePath> unit_dir = GetUnitDirectory(scope);
if (!launcher_path || !unit_dir) {
return false;
}
@@ -215,7 +217,7 @@
}
bool UninstallSystemdUnits(UpdaterScope scope) {
- absl::optional<base::FilePath> unit_dir = GetUnitDirectory(scope);
+ std::optional<base::FilePath> unit_dir = GetUnitDirectory(scope);
if (!unit_dir) {
return false;
}
@@ -231,7 +233,7 @@
}
bool SystemdUnitsInstalled(UpdaterScope scope) {
- absl::optional<base::FilePath> unit_dir = GetUnitDirectory(scope);
+ std::optional<base::FilePath> unit_dir = GetUnitDirectory(scope);
if (!unit_dir) {
return false;
}
diff --git a/chrome/updater/mac/install_from_archive.h b/chrome/updater/mac/install_from_archive.h
index 475f55d..60a0fe8f 100644
--- a/chrome/updater/mac/install_from_archive.h
+++ b/chrome/updater/mac/install_from_archive.h
@@ -5,10 +5,9 @@
#ifndef CHROME_UPDATER_MAC_INSTALL_FROM_ARCHIVE_H_
#define CHROME_UPDATER_MAC_INSTALL_FROM_ARCHIVE_H_
+#include <optional>
#include <string>
-#include "third_party/abseil-cpp/absl/types/optional.h"
-
namespace base {
class FilePath;
class TimeDelta;
@@ -55,16 +54,15 @@
// Choose which type of archive to install from. Possible types of archives are
// DMG, Zip and just the App. From there, it calls the archive specific
// installation method.
-int InstallFromArchive(
- const base::FilePath& file_path,
- const base::FilePath& existence_checker_path,
- const std::string& ap,
- const UpdaterScope& scope,
- const base::Version& pv,
- const std::string& arguments,
- const absl::optional<base::FilePath>& installer_data_file,
- bool usage_stats_enabled,
- const base::TimeDelta& timeout);
+int InstallFromArchive(const base::FilePath& file_path,
+ const base::FilePath& existence_checker_path,
+ const std::string& ap,
+ const UpdaterScope& scope,
+ const base::Version& pv,
+ const std::string& arguments,
+ const std::optional<base::FilePath>& installer_data_file,
+ bool usage_stats_enabled,
+ const base::TimeDelta& timeout);
} // namespace updater
diff --git a/chrome/updater/mac/install_from_archive.mm b/chrome/updater/mac/install_from_archive.mm
index f1b2133..9bb1ad0 100644
--- a/chrome/updater/mac/install_from_archive.mm
+++ b/chrome/updater/mac/install_from_archive.mm
@@ -7,6 +7,7 @@
#import <Cocoa/Cocoa.h>
#include <map>
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -37,7 +38,6 @@
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/util/mac_util.h"
#include "chrome/updater/util/util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace {
@@ -136,7 +136,7 @@
int RunExecutable(const base::FilePath& existence_checker_path,
const std::string& ap,
const std::string& arguments,
- const absl::optional<base::FilePath>& installer_data_file,
+ const std::optional<base::FilePath>& installer_data_file,
const UpdaterScope& scope,
const base::Version& pv,
bool usage_stats_enabled,
@@ -171,7 +171,7 @@
command.AppendArg(pv.GetString());
std::string env_path = "/bin:/usr/bin";
- absl::optional<base::FilePath> ksadmin_path =
+ std::optional<base::FilePath> ksadmin_path =
GetKSAdminPath(GetUpdaterScope());
if (ksadmin_path) {
env_path = base::StrCat({env_path, ":", ksadmin_path->DirName().value()});
@@ -379,16 +379,15 @@
}
} // namespace
-int InstallFromArchive(
- const base::FilePath& file_path,
- const base::FilePath& existence_checker_path,
- const std::string& ap,
- const UpdaterScope& scope,
- const base::Version& pv,
- const std::string& arguments,
- const absl::optional<base::FilePath>& installer_data_file,
- const bool usage_stats_enabled,
- const base::TimeDelta& timeout) {
+int InstallFromArchive(const base::FilePath& file_path,
+ const base::FilePath& existence_checker_path,
+ const std::string& ap,
+ const UpdaterScope& scope,
+ const base::Version& pv,
+ const std::string& arguments,
+ const std::optional<base::FilePath>& installer_data_file,
+ const bool usage_stats_enabled,
+ const base::TimeDelta& timeout) {
const std::map<std::string,
int (*)(const base::FilePath&,
base::OnceCallback<int(const base::FilePath&)>)>
diff --git a/chrome/updater/mac/keystone/agent_main.cc b/chrome/updater/mac/keystone/agent_main.cc
index 7bdb7a61..5362f113 100644
--- a/chrome/updater/mac/keystone/agent_main.cc
+++ b/chrome/updater/mac/keystone/agent_main.cc
@@ -6,6 +6,7 @@
#include <iostream>
#include <map>
+#include <optional>
#include <string>
#include <utility>
@@ -31,7 +32,6 @@
#include "chrome/updater/update_service.h"
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/util/util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -188,7 +188,7 @@
void KSAgentApp::Wake() {
for (UpdaterScope scope : {UpdaterScope::kSystem, UpdaterScope::kUser}) {
- absl::optional<base::FilePath> path = GetUpdaterExecutablePath(scope);
+ std::optional<base::FilePath> path = GetUpdaterExecutablePath(scope);
if (!path) {
continue;
}
diff --git a/chrome/updater/mac/keystone/ksadmin.mm b/chrome/updater/mac/keystone/ksadmin.mm
index bcd8a08a..a938419 100644
--- a/chrome/updater/mac/keystone/ksadmin.mm
+++ b/chrome/updater/mac/keystone/ksadmin.mm
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <map>
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -43,7 +44,6 @@
#include "chrome/updater/updater_version.h"
#include "chrome/updater/util/mac_util.h"
#include "chrome/updater/util/util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -185,7 +185,7 @@
}
void MaybeInstallUpdater(UpdaterScope scope) {
- const absl::optional<base::FilePath> path = GetUpdaterExecutablePath(scope);
+ const std::optional<base::FilePath> path = GetUpdaterExecutablePath(scope);
if (path &&
[NSFileManager.defaultManager
@@ -198,7 +198,7 @@
return;
}
- const absl::optional<base::FilePath> setup_path = GetUpdaterExecutablePath(
+ const std::optional<base::FilePath> setup_path = GetUpdaterExecutablePath(
IsSystemShim() ? UpdaterScope::kSystem : UpdaterScope::kUser);
if (!setup_path || ![NSFileManager.defaultManager
fileExistsAtPath:base::apple::FilePathToNSString(
@@ -317,23 +317,23 @@
// 3. Choose system updater if user is root.
// 4. Prefer system updater if app ID is given and is a system app.
// 5. Otherwise choose user updater.
- absl::optional<UpdaterScope> scope = absl::nullopt;
+ std::optional<UpdaterScope> scope = std::nullopt;
if (HasSwitch(kCommandSystemStore)) {
- scope = absl::make_optional(UpdaterScope::kSystem);
+ scope = std::make_optional(UpdaterScope::kSystem);
} else if (HasSwitch(kCommandUserStore) || !IsSystemShim()) {
- scope = absl::make_optional(UpdaterScope::kUser);
+ scope = std::make_optional(UpdaterScope::kUser);
} else if (HasSwitch(kCommandStorePath)) {
- scope = absl::make_optional(
+ scope = std::make_optional(
SwitchValue(kCommandStorePath) ==
KeystoneTicketStorePath(UpdaterScope::kSystem)
? UpdaterScope::kSystem
: UpdaterScope::kUser);
} else if (geteuid() == 0) {
- scope = absl::make_optional(UpdaterScope::kSystem);
+ scope = std::make_optional(UpdaterScope::kSystem);
} else {
const std::string app_id = SwitchValue(kCommandProductId);
if (app_id.empty())
- scope = absl::make_optional(UpdaterScope::kSystem);
+ scope = std::make_optional(UpdaterScope::kSystem);
}
if (scope) {
diff --git a/chrome/updater/mac/keystone/ksinstall.mm b/chrome/updater/mac/keystone/ksinstall.mm
index af25b705..b452205 100644
--- a/chrome/updater/mac/keystone/ksinstall.mm
+++ b/chrome/updater/mac/keystone/ksinstall.mm
@@ -4,12 +4,11 @@
#include "chrome/updater/mac/keystone/ksinstall.h"
-#include "base/memory/raw_ptr.h"
-
#import <Foundation/Foundation.h>
#import <getopt.h>
-
#import <stdio.h>
+
+#include <optional>
#include <string>
#include "base/at_exit.h"
@@ -20,6 +19,7 @@
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
+#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/message_loop/message_pump_type.h"
#include "base/task/single_thread_task_executor.h"
@@ -54,7 +54,7 @@
void KSInstallApp::Uninstall(base::OnceCallback<void(int)> callback) {
base::ThreadPool::PostTaskAndReplyWithResult(
FROM_HERE, {base::MayBlock()}, base::BindOnce([] {
- const absl::optional<base::FilePath>& keystone_path =
+ const std::optional<base::FilePath>& keystone_path =
GetKeystoneFolderPath((geteuid() == 0) ? UpdaterScope::kSystem
: UpdaterScope::kUser);
if (!keystone_path ||
diff --git a/chrome/updater/mac/privileged_helper/service.mm b/chrome/updater/mac/privileged_helper/service.mm
index 7aaac899..49eb0f4 100644
--- a/chrome/updater/mac/privileged_helper/service.mm
+++ b/chrome/updater/mac/privileged_helper/service.mm
@@ -148,9 +148,9 @@
int InstallUpdater(const base::FilePath& browser_path) {
base::FilePath browser_plist = browser_path.Append("Contents/Info.plist");
- absl::optional<std::string> browser_app_id =
+ std::optional<std::string> browser_app_id =
ReadValueFromPlist(browser_plist, "KSProductID");
- absl::optional<std::string> browser_version =
+ std::optional<std::string> browser_version =
ReadValueFromPlist(browser_plist, "KSVersion");
if (!browser_app_id || !browser_version) {
return kFailedToReadBrowserPlist;
diff --git a/chrome/updater/mac/setup/keystone.mm b/chrome/updater/mac/setup/keystone.mm
index afd78e9..b0ea1d8 100644
--- a/chrome/updater/mac/setup/keystone.mm
+++ b/chrome/updater/mac/setup/keystone.mm
@@ -4,6 +4,7 @@
#include "chrome/updater/mac/setup/keystone.h"
+#include <optional>
#include <string>
#include <vector>
@@ -29,7 +30,6 @@
#include "chrome/updater/util/mac_util.h"
#include "chrome/updater/util/posix_util.h"
#include "chrome/updater/util/util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
// Class to read the Keystone apps' client-regulated-counting data.
@interface CountingMetricsStore : NSObject {
@@ -38,8 +38,8 @@
+ (instancetype)storeAtPath:(const base::FilePath&)path;
-- (absl::optional<int>)dateLastActiveForApp:(NSString*)appid;
-- (absl::optional<int>)dateLastRollcallForApp:(NSString*)appid;
+- (std::optional<int>)dateLastActiveForApp:(NSString*)appid;
+- (std::optional<int>)dateLastRollcallForApp:(NSString*)appid;
@end
@@ -64,21 +64,21 @@
return self;
}
-- (absl::optional<int>)daynumValueOfKey:(NSString*)key forApp:(NSString*)appid {
+- (std::optional<int>)daynumValueOfKey:(NSString*)key forApp:(NSString*)appid {
id appObject = [_metrics objectForKey:appid.lowercaseString];
if (![appObject isKindOfClass:[NSDictionary class]]) {
LOG(WARNING) << "Malformed input client-regulated-counting data.";
- return absl::nullopt;
+ return std::nullopt;
}
id daynumObject = appObject[key];
if (!daynumObject) {
- return absl::nullopt;
+ return std::nullopt;
}
if (![daynumObject isKindOfClass:[NSNumber class]]) {
LOG(WARNING) << "daynum is not a number.";
- return absl::nullopt;
+ return std::nullopt;
}
// daynum the number of days since January 1, 2007. The accepted range is
@@ -86,17 +86,17 @@
int daynum = [daynumObject intValue];
if (daynum < 3000 || daynum > 50000) {
LOG(WARNING) << "Ignored out-of-range daynum: " << daynum;
- return absl::nullopt;
+ return std::nullopt;
}
return daynum;
}
-- (absl::optional<int>)dateLastActiveForApp:(NSString*)appid {
+- (std::optional<int>)dateLastActiveForApp:(NSString*)appid {
return [self daynumValueOfKey:@"DayOfLastActive" forApp:appid];
}
-- (absl::optional<int>)dateLastRollcallForApp:(NSString*)appid {
+- (std::optional<int>)dateLastRollcallForApp:(NSString*)appid {
return [self daynumValueOfKey:@"DayOfLastRollcall" forApp:appid];
}
@@ -121,7 +121,7 @@
return false;
}
- const absl::optional<base::FilePath> dest_folder_path =
+ const std::optional<base::FilePath> dest_folder_path =
GetKeystoneFolderPath(scope);
if (!dest_folder_path)
return false;
@@ -246,7 +246,7 @@
}
void UninstallKeystone(UpdaterScope scope) {
- const absl::optional<base::FilePath> keystone_folder_path =
+ const std::optional<base::FilePath> keystone_folder_path =
GetKeystoneFolderPath(scope);
if (!keystone_folder_path) {
LOG(ERROR) << "Can't find Keystone path.";
diff --git a/chrome/updater/mac/setup/setup.mm b/chrome/updater/mac/setup/setup.mm
index 64e6edf..503738e 100644
--- a/chrome/updater/mac/setup/setup.mm
+++ b/chrome/updater/mac/setup/setup.mm
@@ -9,6 +9,8 @@
#include <sys/stat.h>
#include <unistd.h>
+#include <optional>
+
#include "base/apple/bundle_locations.h"
#include "base/apple/foundation_util.h"
#include "base/at_exit.h"
@@ -42,14 +44,13 @@
#include "chrome/updater/util/posix_util.h"
#include "chrome/updater/util/util.h"
#include "components/crash/core/common/crash_key.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace {
bool CopyBundle(UpdaterScope scope) {
- absl::optional<base::FilePath> base_install_dir = GetInstallDirectory(scope);
- absl::optional<base::FilePath> versioned_install_dir =
+ std::optional<base::FilePath> base_install_dir = GetInstallDirectory(scope);
+ std::optional<base::FilePath> versioned_install_dir =
GetVersionedInstallDirectory(scope);
if (!base_install_dir || !versioned_install_dir) {
LOG(ERROR) << "Failed to get install directory.";
@@ -118,7 +119,7 @@
// plist, with the specified contents. If not, the plist will be overwritten and
// the item reloaded. May block.
bool EnsureWakeLaunchItemPresence(UpdaterScope scope, NSDictionary* contents) {
- const absl::optional<base::FilePath> path = GetWakeTaskPlistPath(scope);
+ const std::optional<base::FilePath> path = GetWakeTaskPlistPath(scope);
if (!path) {
VLOG(1) << "Failed to find wake plist path.";
return false;
@@ -168,7 +169,7 @@
}
// Update app registration with LaunchServices.
- const absl::optional<base::FilePath> install_path =
+ const std::optional<base::FilePath> install_path =
GetInstallDirectory(scope);
if (install_path) {
OSStatus ls_result = LSRegisterURL(
@@ -227,7 +228,7 @@
// Quarantine attribute needs to be removed here as the copied bundle might be
// given com.apple.quarantine attribute, and the server is attempted to be
// launched below, Gatekeeper could prompt the user.
- const absl::optional<base::FilePath> install_dir = GetInstallDirectory(scope);
+ const std::optional<base::FilePath> install_dir = GetInstallDirectory(scope);
if (!install_dir) {
return kErrorFailedToGetInstallDir;
}
@@ -249,7 +250,7 @@
}
if (scope == UpdaterScope::kSystem) {
- const absl::optional<base::FilePath> bundle_path =
+ const std::optional<base::FilePath> bundle_path =
GetUpdaterAppBundlePath(scope);
if (bundle_path) {
base::FilePath path =
@@ -279,10 +280,10 @@
}
int PromoteCandidate(UpdaterScope scope) {
- const absl::optional<base::FilePath> updater_executable_path =
+ const std::optional<base::FilePath> updater_executable_path =
GetUpdaterExecutablePath(scope);
- const absl::optional<base::FilePath> install_dir = GetInstallDirectory(scope);
- const absl::optional<base::FilePath> bundle_path =
+ const std::optional<base::FilePath> install_dir = GetInstallDirectory(scope);
+ const std::optional<base::FilePath> bundle_path =
GetUpdaterAppBundlePath(scope);
if (!updater_executable_path || !install_dir || !bundle_path) {
return kErrorFailedToGetVersionedInstallDirectory;
diff --git a/chrome/updater/mac/setup/wake_task.h b/chrome/updater/mac/setup/wake_task.h
index d1cfe723..b632d89 100644
--- a/chrome/updater/mac/setup/wake_task.h
+++ b/chrome/updater/mac/setup/wake_task.h
@@ -8,7 +8,6 @@
#include <Foundation/Foundation.h>
#include "chrome/updater/updater_scope.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
diff --git a/chrome/updater/mac/setup/wake_task.mm b/chrome/updater/mac/setup/wake_task.mm
index 051caee..3cbdcf3 100644
--- a/chrome/updater/mac/setup/wake_task.mm
+++ b/chrome/updater/mac/setup/wake_task.mm
@@ -6,6 +6,8 @@
#include <Foundation/Foundation.h>
+#include <optional>
+
#include "base/apple/foundation_util.h"
#include "base/files/file_path.h"
#include "base/strings/strcat.h"
@@ -15,7 +17,6 @@
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/util/mac_util.h"
#include "chrome/updater/util/util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -39,10 +40,10 @@
return base::SysUTF8ToNSString(base::StrCat({"--", argument, "=", value}));
}
-absl::optional<base::FilePath> GetWakeTaskTarget(UpdaterScope scope) {
- absl::optional<base::FilePath> install_dir = GetInstallDirectory(scope);
+std::optional<base::FilePath> GetWakeTaskTarget(UpdaterScope scope) {
+ std::optional<base::FilePath> install_dir = GetInstallDirectory(scope);
if (!install_dir) {
- return absl::nullopt;
+ return std::nullopt;
}
return install_dir->Append("Current").Append(GetExecutableRelativePath());
}
@@ -50,7 +51,7 @@
} // namespace
NSDictionary* CreateWakeLaunchdPlist(UpdaterScope scope) {
- absl::optional<base::FilePath> target = GetWakeTaskTarget(scope);
+ std::optional<base::FilePath> target = GetWakeTaskTarget(scope);
if (!target) {
return nil;
}
diff --git a/chrome/updater/net/network.h b/chrome/updater/net/network.h
index 6564ad6d..82b43ab 100644
--- a/chrome/updater/net/network.h
+++ b/chrome/updater/net/network.h
@@ -6,12 +6,12 @@
#define CHROME_UPDATER_NET_NETWORK_H_
#include <memory>
+#include <optional>
#include "base/memory/scoped_refptr.h"
#include "base/sequence_checker.h"
#include "build/build_config.h"
#include "components/update_client/network.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -22,7 +22,7 @@
// outlive the lives of the network fetchers it creates.
class NetworkFetcherFactory : public update_client::NetworkFetcherFactory {
public:
- explicit NetworkFetcherFactory(absl::optional<PolicyServiceProxyConfiguration>
+ explicit NetworkFetcherFactory(std::optional<PolicyServiceProxyConfiguration>
policy_service_proxy_configuration);
NetworkFetcherFactory(const NetworkFetcherFactory&) = delete;
NetworkFetcherFactory& operator=(const NetworkFetcherFactory&) = delete;
diff --git a/chrome/updater/net/network_fetcher_linux.cc b/chrome/updater/net/network_fetcher_linux.cc
index e8b17a8..8cf53ba 100644
--- a/chrome/updater/net/network_fetcher_linux.cc
+++ b/chrome/updater/net/network_fetcher_linux.cc
@@ -10,6 +10,7 @@
#include <array>
#include <memory>
+#include <optional>
#include <string>
#include <utility>
@@ -35,7 +36,6 @@
#include "chrome/updater/policy/service.h"
#include "chrome/updater/util/util.h"
#include "components/update_client/network.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
namespace updater {
@@ -461,7 +461,7 @@
class NetworkFetcherFactory::Impl {};
NetworkFetcherFactory::NetworkFetcherFactory(
- absl::optional<PolicyServiceProxyConfiguration>) {}
+ std::optional<PolicyServiceProxyConfiguration>) {}
NetworkFetcherFactory::~NetworkFetcherFactory() = default;
std::unique_ptr<update_client::NetworkFetcher> NetworkFetcherFactory::Create()
diff --git a/chrome/updater/net/network_fetcher_mac.mm b/chrome/updater/net/network_fetcher_mac.mm
index f6db8dd0..afbef84 100644
--- a/chrome/updater/net/network_fetcher_mac.mm
+++ b/chrome/updater/net/network_fetcher_mac.mm
@@ -8,6 +8,7 @@
#include <cstdint>
#include <memory>
+#include <optional>
#include <string>
#include <utility>
@@ -29,7 +30,6 @@
#include "chrome/updater/util/util.h"
#include "components/update_client/network.h"
#import "net/base/mac/url_conversions.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
using ResponseStartedCallback =
@@ -399,7 +399,7 @@
class NetworkFetcherFactory::Impl {};
NetworkFetcherFactory::NetworkFetcherFactory(
- absl::optional<PolicyServiceProxyConfiguration>) {}
+ std::optional<PolicyServiceProxyConfiguration>) {}
NetworkFetcherFactory::~NetworkFetcherFactory() = default;
std::unique_ptr<update_client::NetworkFetcher> NetworkFetcherFactory::Create()
diff --git a/chrome/updater/net/network_fetcher_win.cc b/chrome/updater/net/network_fetcher_win.cc
index bc2127fe..e303a15 100644
--- a/chrome/updater/net/network_fetcher_win.cc
+++ b/chrome/updater/net/network_fetcher_win.cc
@@ -8,6 +8,7 @@
#include <cstdint>
#include <memory>
+#include <optional>
#include <string>
#include <utility>
@@ -28,7 +29,6 @@
#include "components/winhttp/network_fetcher.h"
#include "components/winhttp/proxy_configuration.h"
#include "components/winhttp/scoped_hinternet.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
namespace updater {
@@ -36,7 +36,7 @@
// Factory method for the proxy configuration strategy.
scoped_refptr<winhttp::ProxyConfiguration> GetProxyConfiguration(
- absl::optional<PolicyServiceProxyConfiguration>
+ std::optional<PolicyServiceProxyConfiguration>
policy_service_proxy_configuration) {
if (policy_service_proxy_configuration) {
return base::MakeRefCounted<winhttp::ProxyConfiguration>(winhttp::ProxyInfo{
@@ -182,7 +182,7 @@
class NetworkFetcherFactory::Impl {
public:
- explicit Impl(absl::optional<PolicyServiceProxyConfiguration>
+ explicit Impl(std::optional<PolicyServiceProxyConfiguration>
policy_service_proxy_configuration)
: proxy_configuration_(
GetProxyConfiguration(policy_service_proxy_configuration)),
@@ -203,7 +203,7 @@
};
NetworkFetcherFactory::NetworkFetcherFactory(
- absl::optional<PolicyServiceProxyConfiguration>
+ std::optional<PolicyServiceProxyConfiguration>
policy_service_proxy_configuration)
: impl_(std::make_unique<Impl>(policy_service_proxy_configuration)) {}
NetworkFetcherFactory::~NetworkFetcherFactory() = default;
diff --git a/chrome/updater/persisted_data.cc b/chrome/updater/persisted_data.cc
index 8be6e0be..16504af 100644
--- a/chrome/updater/persisted_data.cc
+++ b/chrome/updater/persisted_data.cc
@@ -4,6 +4,7 @@
#include "chrome/updater/persisted_data.h"
+#include <optional>
#include <string>
#include <vector>
@@ -25,7 +26,6 @@
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "components/update_client/persisted_data.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
@@ -211,7 +211,7 @@
SetString(id, kAPKey, key);
}
-absl::optional<int> PersistedData::GetDateLastActive(
+std::optional<int> PersistedData::GetDateLastActive(
const std::string& id) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return GetInteger(id, kDLA);
@@ -222,7 +222,7 @@
SetInteger(id, kDLA, dla);
}
-absl::optional<int> PersistedData::GetDateLastRollcall(
+std::optional<int> PersistedData::GetDateLastRollcall(
const std::string& id) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return GetInteger(id, kDLRC);
@@ -394,21 +394,21 @@
return app;
}
-absl::optional<int> PersistedData::GetInteger(const std::string& id,
- const std::string& key) const {
+std::optional<int> PersistedData::GetInteger(const std::string& id,
+ const std::string& key) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!pref_service_) {
- return absl::nullopt;
+ return std::nullopt;
}
ScopedDictPrefUpdate update(pref_service_,
update_client::kPersistedDataPreference);
base::Value::Dict* apps = update->FindDict("apps");
if (!apps) {
- return absl::nullopt;
+ return std::nullopt;
}
base::Value::Dict* app = apps->FindDict(base::ToLowerASCII(id));
if (!app) {
- return absl::nullopt;
+ return std::nullopt;
}
return app->FindInt(key);
}
@@ -482,7 +482,7 @@
}
#if BUILDFLAG(IS_WIN)
-absl::optional<OSVERSIONINFOEX> PersistedData::GetLastOSVersion() const {
+std::optional<OSVERSIONINFOEX> PersistedData::GetLastOSVersion() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Unpacks the os version from a base-64-encoded string internally.
@@ -490,13 +490,13 @@
pref_service_->GetString(kLastOSVersion);
if (encoded_os_version.empty())
- return absl::nullopt;
+ return std::nullopt;
- const absl::optional<std::vector<uint8_t>> decoded_os_version =
+ const std::optional<std::vector<uint8_t>> decoded_os_version =
base::Base64Decode(encoded_os_version);
if (!decoded_os_version ||
decoded_os_version->size() != sizeof(OSVERSIONINFOEX)) {
- return absl::nullopt;
+ return std::nullopt;
}
return *reinterpret_cast<const OSVERSIONINFOEX*>(decoded_os_version->data());
@@ -509,7 +509,7 @@
return;
// Get and set the current OS version.
- absl::optional<OSVERSIONINFOEX> os_version = GetOSVersion();
+ std::optional<OSVERSIONINFOEX> os_version = GetOSVersion();
if (!os_version)
return;
diff --git a/chrome/updater/persisted_data.h b/chrome/updater/persisted_data.h
index 29e63e10..b21ce1ed 100644
--- a/chrome/updater/persisted_data.h
+++ b/chrome/updater/persisted_data.h
@@ -5,6 +5,7 @@
#ifndef CHROME_UPDATER_PERSISTED_DATA_H_
#define CHROME_UPDATER_PERSISTED_DATA_H_
+#include <optional>
#include <string>
#include <vector>
@@ -13,7 +14,6 @@
#include "base/sequence_checker.h"
#include "base/values.h"
#include "chrome/updater/updater_scope.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
@@ -90,9 +90,9 @@
// The getters return nullopt when the persisted data does not have the
// corresponding value, or any node subtype is not expected along the
// path to the target value.
- absl::optional<int> GetDateLastActive(const std::string& id) const;
+ std::optional<int> GetDateLastActive(const std::string& id) const;
void SetDateLastActive(const std::string& id, int dla);
- absl::optional<int> GetDateLastRollcall(const std::string& id) const;
+ std::optional<int> GetDateLastRollcall(const std::string& id) const;
void SetDateLastRollcall(const std::string& id, int dlrc);
// These functions access the cohort values for the specified id.
@@ -141,7 +141,7 @@
#if BUILDFLAG(IS_WIN)
// Retrieves the previously stored OS version.
- absl::optional<OSVERSIONINFOEX> GetLastOSVersion() const;
+ std::optional<OSVERSIONINFOEX> GetLastOSVersion() const;
// Stores the current os version.
void SetLastOSVersion();
@@ -158,8 +158,8 @@
base::Value::Dict* GetOrCreateAppKey(const std::string& id,
base::Value::Dict& root);
- absl::optional<int> GetInteger(const std::string& id,
- const std::string& key) const;
+ std::optional<int> GetInteger(const std::string& id,
+ const std::string& key) const;
void SetInteger(const std::string& id, const std::string& key, int value);
std::string GetString(const std::string& id, const std::string& key) const;
void SetString(const std::string& id,
diff --git a/chrome/updater/persisted_data_unittest.cc b/chrome/updater/persisted_data_unittest.cc
index e277262c..48e8e49 100644
--- a/chrome/updater/persisted_data_unittest.cc
+++ b/chrome/updater/persisted_data_unittest.cc
@@ -229,11 +229,11 @@
auto metadata =
base::MakeRefCounted<PersistedData>(GetTestScope(), pref.get());
- EXPECT_EQ(metadata->GetLastOSVersion(), absl::nullopt);
+ EXPECT_EQ(metadata->GetLastOSVersion(), std::nullopt);
// This will persist the current OS version into the persisted data.
metadata->SetLastOSVersion();
- EXPECT_NE(metadata->GetLastOSVersion(), absl::nullopt);
+ EXPECT_NE(metadata->GetLastOSVersion(), std::nullopt);
// Compare the persisted data OS version to the version from `::GetVersionEx`.
const OSVERSIONINFOEX metadata_os = metadata->GetLastOSVersion().value();
diff --git a/chrome/updater/policy/dm_policy_manager.cc b/chrome/updater/policy/dm_policy_manager.cc
index 55fd891..01e5fc41 100644
--- a/chrome/updater/policy/dm_policy_manager.cc
+++ b/chrome/updater/policy/dm_policy_manager.cc
@@ -5,6 +5,7 @@
#include "chrome/updater/policy/dm_policy_manager.h"
#include <memory>
+#include <optional>
#include <string>
#include <vector>
@@ -17,7 +18,6 @@
#include "build/build_config.h"
#include "chrome/updater/constants.h"
#include "chrome/updater/policy/manager.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -80,7 +80,7 @@
DMPolicyManager::DMPolicyManager(
const ::wireless_android_enterprise_devicemanagement::
OmahaSettingsClientProto& omaha_settings,
- const absl::optional<bool>& override_is_managed_device)
+ const std::optional<bool>& override_is_managed_device)
: is_managed_device_(override_is_managed_device.value_or(true)),
omaha_settings_(omaha_settings) {}
@@ -94,23 +94,23 @@
return kSourceDMPolicyManager;
}
-absl::optional<base::TimeDelta> DMPolicyManager::GetLastCheckPeriod() const {
+std::optional<base::TimeDelta> DMPolicyManager::GetLastCheckPeriod() const {
if (!omaha_settings_.has_auto_update_check_period_minutes())
- return absl::nullopt;
+ return std::nullopt;
return base::Minutes(omaha_settings_.auto_update_check_period_minutes());
}
-absl::optional<UpdatesSuppressedTimes>
+std::optional<UpdatesSuppressedTimes>
DMPolicyManager::GetUpdatesSuppressedTimes() const {
if (!omaha_settings_.has_updates_suppressed())
- return absl::nullopt;
+ return std::nullopt;
const auto& updates_suppressed = omaha_settings_.updates_suppressed();
if (!updates_suppressed.has_start_hour() ||
!updates_suppressed.has_start_minute() ||
!updates_suppressed.has_duration_min())
- return absl::nullopt;
+ return std::nullopt;
UpdatesSuppressedTimes suppressed_times;
suppressed_times.start_hour_ = updates_suppressed.start_hour();
@@ -119,38 +119,38 @@
return suppressed_times;
}
-absl::optional<std::string> DMPolicyManager::GetDownloadPreference() const {
+std::optional<std::string> DMPolicyManager::GetDownloadPreference() const {
if (!omaha_settings_.has_download_preference())
- return absl::nullopt;
+ return std::nullopt;
return omaha_settings_.download_preference();
}
-absl::optional<int> DMPolicyManager::GetPackageCacheSizeLimitMBytes() const {
- return absl::nullopt;
+std::optional<int> DMPolicyManager::GetPackageCacheSizeLimitMBytes() const {
+ return std::nullopt;
}
-absl::optional<int> DMPolicyManager::GetPackageCacheExpirationTimeDays() const {
- return absl::nullopt;
+std::optional<int> DMPolicyManager::GetPackageCacheExpirationTimeDays() const {
+ return std::nullopt;
}
-absl::optional<std::string> DMPolicyManager::GetProxyMode() const {
+std::optional<std::string> DMPolicyManager::GetProxyMode() const {
if (!omaha_settings_.has_proxy_mode())
- return absl::nullopt;
+ return std::nullopt;
return omaha_settings_.proxy_mode();
}
-absl::optional<std::string> DMPolicyManager::GetProxyPacUrl() const {
+std::optional<std::string> DMPolicyManager::GetProxyPacUrl() const {
if (!omaha_settings_.has_proxy_pac_url())
- return absl::nullopt;
+ return std::nullopt;
return omaha_settings_.proxy_pac_url();
}
-absl::optional<std::string> DMPolicyManager::GetProxyServer() const {
+std::optional<std::string> DMPolicyManager::GetProxyServer() const {
if (!omaha_settings_.has_proxy_server())
- return absl::nullopt;
+ return std::nullopt;
return omaha_settings_.proxy_server();
}
@@ -177,7 +177,7 @@
return nullptr;
}
-absl::optional<int> DMPolicyManager::GetEffectivePolicyForAppInstalls(
+std::optional<int> DMPolicyManager::GetEffectivePolicyForAppInstalls(
const std::string& app_id) const {
const auto* app_settings = GetAppSettings(app_id);
if (app_settings && app_settings->has_install()) {
@@ -190,10 +190,10 @@
omaha_settings_.install_default());
}
- return absl::nullopt;
+ return std::nullopt;
}
-absl::optional<int> DMPolicyManager::GetEffectivePolicyForAppUpdates(
+std::optional<int> DMPolicyManager::GetEffectivePolicyForAppUpdates(
const std::string& app_id) const {
const auto* app_settings = GetAppSettings(app_id);
if (app_settings && app_settings->has_update()) {
@@ -205,39 +205,39 @@
return PolicyValueFromProtoUpdateValue(omaha_settings_.update_default());
}
- return absl::nullopt;
+ return std::nullopt;
}
-absl::optional<std::string> DMPolicyManager::GetTargetVersionPrefix(
+std::optional<std::string> DMPolicyManager::GetTargetVersionPrefix(
const std::string& app_id) const {
const auto* app_settings = GetAppSettings(app_id);
if (!app_settings || !app_settings->has_target_version_prefix())
- return absl::nullopt;
+ return std::nullopt;
return app_settings->target_version_prefix();
}
-absl::optional<std::string> DMPolicyManager::GetTargetChannel(
+std::optional<std::string> DMPolicyManager::GetTargetChannel(
const std::string& app_id) const {
const auto* app_settings = GetAppSettings(app_id);
if (!app_settings || !app_settings->has_target_channel())
- return absl::nullopt;
+ return std::nullopt;
return app_settings->target_channel();
}
-absl::optional<bool> DMPolicyManager::IsRollbackToTargetVersionAllowed(
+std::optional<bool> DMPolicyManager::IsRollbackToTargetVersionAllowed(
const std::string& app_id) const {
const auto* app_settings = GetAppSettings(app_id);
if (!app_settings || !app_settings->has_rollback_to_target_version())
- return absl::nullopt;
+ return std::nullopt;
return (app_settings->rollback_to_target_version() ==
::wireless_android_enterprise_devicemanagement::
ROLLBACK_TO_TARGET_VERSION_ENABLED);
}
-absl::optional<std::vector<std::string>> DMPolicyManager::GetForceInstallApps()
+std::optional<std::vector<std::string>> DMPolicyManager::GetForceInstallApps()
const {
std::vector<std::string> force_install_apps;
for (const auto& app_settings_proto :
@@ -259,11 +259,11 @@
}
}
return force_install_apps.empty()
- ? absl::nullopt
- : absl::optional<std::vector<std::string>>(force_install_apps);
+ ? std::nullopt
+ : std::optional<std::vector<std::string>>(force_install_apps);
}
-absl::optional<std::vector<std::string>> DMPolicyManager::GetAppsWithPolicy()
+std::optional<std::vector<std::string>> DMPolicyManager::GetAppsWithPolicy()
const {
std::vector<std::string> apps_with_policy;
@@ -286,7 +286,7 @@
}
scoped_refptr<PolicyManagerInterface> CreateDMPolicyManager(
- const absl::optional<bool>& override_is_managed_device) {
+ const std::optional<bool>& override_is_managed_device) {
scoped_refptr<DMStorage> default_dm_storage = GetDefaultDMStorage();
if (!default_dm_storage) {
return nullptr;
diff --git a/chrome/updater/policy/dm_policy_manager.h b/chrome/updater/policy/dm_policy_manager.h
index 5c95ff0..b5dc8d3cb 100644
--- a/chrome/updater/policy/dm_policy_manager.h
+++ b/chrome/updater/policy/dm_policy_manager.h
@@ -5,6 +5,7 @@
#ifndef CHROME_UPDATER_POLICY_DM_POLICY_MANAGER_H_
#define CHROME_UPDATER_POLICY_DM_POLICY_MANAGER_H_
+#include <optional>
#include <string>
#include <vector>
@@ -12,7 +13,6 @@
#include "chrome/updater/device_management/dm_storage.h"
#include "chrome/updater/policy/manager.h"
#include "chrome/updater/protos/omaha_settings.pb.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -22,7 +22,7 @@
DMPolicyManager(
const ::wireless_android_enterprise_devicemanagement::
OmahaSettingsClientProto& omaha_settings,
- const absl::optional<bool>& override_is_managed_device = absl::nullopt);
+ const std::optional<bool>& override_is_managed_device = std::nullopt);
DMPolicyManager(const DMPolicyManager&) = delete;
DMPolicyManager& operator=(const DMPolicyManager&) = delete;
@@ -31,27 +31,27 @@
bool HasActiveDevicePolicies() const override;
- absl::optional<base::TimeDelta> GetLastCheckPeriod() const override;
- absl::optional<UpdatesSuppressedTimes> GetUpdatesSuppressedTimes()
+ std::optional<base::TimeDelta> GetLastCheckPeriod() const override;
+ std::optional<UpdatesSuppressedTimes> GetUpdatesSuppressedTimes()
const override;
- absl::optional<std::string> GetDownloadPreference() const override;
- absl::optional<int> GetPackageCacheSizeLimitMBytes() const override;
- absl::optional<int> GetPackageCacheExpirationTimeDays() const override;
- absl::optional<int> GetEffectivePolicyForAppInstalls(
+ std::optional<std::string> GetDownloadPreference() const override;
+ std::optional<int> GetPackageCacheSizeLimitMBytes() const override;
+ std::optional<int> GetPackageCacheExpirationTimeDays() const override;
+ std::optional<int> GetEffectivePolicyForAppInstalls(
const std::string& app_id) const override;
- absl::optional<int> GetEffectivePolicyForAppUpdates(
+ std::optional<int> GetEffectivePolicyForAppUpdates(
const std::string& app_id) const override;
- absl::optional<std::string> GetTargetVersionPrefix(
+ std::optional<std::string> GetTargetVersionPrefix(
const std::string& app_id) const override;
- absl::optional<bool> IsRollbackToTargetVersionAllowed(
+ std::optional<bool> IsRollbackToTargetVersionAllowed(
const std::string& app_id) const override;
- absl::optional<std::string> GetProxyMode() const override;
- absl::optional<std::string> GetProxyPacUrl() const override;
- absl::optional<std::string> GetProxyServer() const override;
- absl::optional<std::string> GetTargetChannel(
+ std::optional<std::string> GetProxyMode() const override;
+ std::optional<std::string> GetProxyPacUrl() const override;
+ std::optional<std::string> GetProxyServer() const override;
+ std::optional<std::string> GetTargetChannel(
const std::string& app_id) const override;
- absl::optional<std::vector<std::string>> GetForceInstallApps() const override;
- absl::optional<std::vector<std::string>> GetAppsWithPolicy() const override;
+ std::optional<std::vector<std::string>> GetForceInstallApps() const override;
+ std::optional<std::vector<std::string>> GetAppsWithPolicy() const override;
private:
~DMPolicyManager() override;
@@ -65,7 +65,7 @@
// A factory method to create a DM policy manager.
scoped_refptr<PolicyManagerInterface> CreateDMPolicyManager(
- const absl::optional<bool>& override_is_managed_device);
+ const std::optional<bool>& override_is_managed_device);
} // namespace updater
diff --git a/chrome/updater/policy/dm_policy_manager_unittest.cc b/chrome/updater/policy/dm_policy_manager_unittest.cc
index 7dd774a..4821816 100644
--- a/chrome/updater/policy/dm_policy_manager_unittest.cc
+++ b/chrome/updater/policy/dm_policy_manager_unittest.cc
@@ -4,6 +4,8 @@
#include "chrome/updater/policy/dm_policy_manager.h"
+#include <optional>
+
#include "base/enterprise_util.h"
#include "base/memory/ref_counted.h"
#include "build/build_config.h"
@@ -11,7 +13,6 @@
#include "chrome/updater/util/unit_test_util.h"
#include "components/policy/proto/device_management_backend.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -123,14 +124,14 @@
EXPECT_TRUE(policy_manager->HasActiveDevicePolicies());
EXPECT_EQ(policy_manager->source(), "Device Management");
- EXPECT_EQ(policy_manager->GetLastCheckPeriod(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetUpdatesSuppressedTimes(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetDownloadPreference(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetProxyMode(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetProxyPacUrl(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetProxyServer(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetPackageCacheSizeLimitMBytes(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetPackageCacheExpirationTimeDays(), absl::nullopt);
+ EXPECT_EQ(policy_manager->GetLastCheckPeriod(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetUpdatesSuppressedTimes(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetDownloadPreference(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetProxyMode(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetProxyPacUrl(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetProxyServer(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetPackageCacheSizeLimitMBytes(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetPackageCacheExpirationTimeDays(), std::nullopt);
EXPECT_FALSE(
policy_manager->GetEffectivePolicyForAppInstalls(test::kChromeAppId));
EXPECT_FALSE(
@@ -138,7 +139,7 @@
EXPECT_FALSE(
policy_manager->IsRollbackToTargetVersionAllowed(test::kChromeAppId));
EXPECT_EQ(policy_manager->GetTargetVersionPrefix(test::kChromeAppId),
- absl::nullopt);
+ std::nullopt);
}
TEST(DMPolicyManager, PolicyManagerFromProto) {
@@ -204,7 +205,7 @@
// Verify global policies
EXPECT_EQ(policy_manager->GetLastCheckPeriod(), base::Minutes(111));
- absl::optional<UpdatesSuppressedTimes> suppressed_times =
+ std::optional<UpdatesSuppressedTimes> suppressed_times =
policy_manager->GetUpdatesSuppressedTimes();
ASSERT_TRUE(suppressed_times);
EXPECT_EQ(suppressed_times->start_hour_, 9);
@@ -218,8 +219,8 @@
EXPECT_EQ(policy_manager->GetProxyMode(), "test_proxy_mode");
EXPECT_EQ(policy_manager->GetProxyPacUrl(), "foo.c/proxy.pa");
- EXPECT_EQ(policy_manager->GetPackageCacheSizeLimitMBytes(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetPackageCacheExpirationTimeDays(), absl::nullopt);
+ EXPECT_EQ(policy_manager->GetPackageCacheSizeLimitMBytes(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetPackageCacheExpirationTimeDays(), std::nullopt);
EXPECT_EQ(policy_manager->GetForceInstallApps(),
std::vector<std::string>({kApp2}));
EXPECT_EQ(policy_manager->GetAppsWithPolicy(),
@@ -234,8 +235,7 @@
EXPECT_TRUE(
policy_manager->IsRollbackToTargetVersionAllowed(test::kChromeAppId));
EXPECT_EQ(policy_manager->GetTargetVersionPrefix(test::kChromeAppId), "81.");
- EXPECT_EQ(policy_manager->GetTargetChannel(test::kChromeAppId),
- absl::nullopt);
+ EXPECT_EQ(policy_manager->GetTargetChannel(test::kChromeAppId), std::nullopt);
// Verify app1 policies.
EXPECT_EQ(policy_manager->GetEffectivePolicyForAppInstalls(kApp1),
@@ -243,8 +243,8 @@
EXPECT_EQ(policy_manager->GetEffectivePolicyForAppUpdates(kApp1),
kPolicyDisabled);
EXPECT_EQ(policy_manager->IsRollbackToTargetVersionAllowed(kApp1),
- absl::nullopt);
- EXPECT_EQ(policy_manager->GetTargetVersionPrefix(kApp1), absl::nullopt);
+ std::nullopt);
+ EXPECT_EQ(policy_manager->GetTargetVersionPrefix(kApp1), std::nullopt);
EXPECT_EQ(policy_manager->GetTargetChannel(kApp1), "canary");
// Verify app2 policies.
@@ -253,8 +253,8 @@
EXPECT_EQ(policy_manager->GetEffectivePolicyForAppUpdates(kApp2),
kPolicyEnabled);
EXPECT_EQ(policy_manager->IsRollbackToTargetVersionAllowed(kApp2),
- absl::nullopt);
- EXPECT_EQ(policy_manager->GetTargetVersionPrefix(kApp2), absl::nullopt);
+ std::nullopt);
+ EXPECT_EQ(policy_manager->GetTargetVersionPrefix(kApp2), std::nullopt);
EXPECT_EQ(policy_manager->GetTargetChannel(kApp2), "dev");
// Verify that if no app-specific polices, fallback to global-level policies
@@ -265,8 +265,8 @@
EXPECT_EQ(policy_manager->GetEffectivePolicyForAppUpdates(app_guid),
kPolicyManualUpdatesOnly);
EXPECT_EQ(policy_manager->IsRollbackToTargetVersionAllowed(app_guid),
- absl::nullopt);
- EXPECT_EQ(policy_manager->GetTargetVersionPrefix(app_guid), absl::nullopt);
+ std::nullopt);
+ EXPECT_EQ(policy_manager->GetTargetVersionPrefix(app_guid), std::nullopt);
}
#if BUILDFLAG(IS_MAC)
@@ -289,20 +289,20 @@
EXPECT_TRUE(policy_manager->HasActiveDevicePolicies());
EXPECT_EQ(policy_manager->source(), "Device Management");
- EXPECT_EQ(policy_manager->GetLastCheckPeriod(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetUpdatesSuppressedTimes(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetDownloadPreference(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetProxyMode(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetProxyPacUrl(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetProxyServer(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetPackageCacheSizeLimitMBytes(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetPackageCacheExpirationTimeDays(), absl::nullopt);
+ EXPECT_EQ(policy_manager->GetLastCheckPeriod(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetUpdatesSuppressedTimes(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetDownloadPreference(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetProxyMode(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetProxyPacUrl(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetProxyServer(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetPackageCacheSizeLimitMBytes(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetPackageCacheExpirationTimeDays(), std::nullopt);
const std::string chrome_guid = "com.google.Chrome";
EXPECT_EQ(policy_manager->GetEffectivePolicyForAppInstalls(chrome_guid),
- absl::nullopt);
+ std::nullopt);
EXPECT_EQ(policy_manager->GetEffectivePolicyForAppUpdates(chrome_guid),
- absl::nullopt);
+ std::nullopt);
EXPECT_EQ(policy_manager->IsRollbackToTargetVersionAllowed(chrome_guid),
true);
diff --git a/chrome/updater/policy/mac/managed_preference_policy_manager.h b/chrome/updater/policy/mac/managed_preference_policy_manager.h
index 05a09ca..730d2909 100644
--- a/chrome/updater/policy/mac/managed_preference_policy_manager.h
+++ b/chrome/updater/policy/mac/managed_preference_policy_manager.h
@@ -5,15 +5,16 @@
#ifndef CHROME_UPDATER_POLICY_MAC_MANAGED_PREFERENCE_POLICY_MANAGER_H_
#define CHROME_UPDATER_POLICY_MAC_MANAGED_PREFERENCE_POLICY_MANAGER_H_
+#include <optional>
+
#include "base/memory/scoped_refptr.h"
#include "chrome/updater/policy/manager.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
// A factory method to create a managed preference policy manager.
scoped_refptr<PolicyManagerInterface> CreateManagedPreferencePolicyManager(
- const absl::optional<bool>& override_is_managed_device = absl::nullopt);
+ const std::optional<bool>& override_is_managed_device = std::nullopt);
} // namespace updater
diff --git a/chrome/updater/policy/mac/managed_preference_policy_manager.mm b/chrome/updater/policy/mac/managed_preference_policy_manager.mm
index 7922c48..17d011c8 100644
--- a/chrome/updater/policy/mac/managed_preference_policy_manager.mm
+++ b/chrome/updater/policy/mac/managed_preference_policy_manager.mm
@@ -4,6 +4,7 @@
#include "chrome/updater/policy/mac/managed_preference_policy_manager.h"
+#include <optional>
#include <string>
#include <vector>
@@ -17,7 +18,6 @@
#include "chrome/updater/constants.h"
#include "chrome/updater/policy/mac/managed_preference_policy_manager_impl.h"
#include "chrome/updater/policy/manager.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -28,7 +28,7 @@
public:
ManagedPreferencePolicyManager(
CRUUpdatePolicyDictionary* policy,
- const absl::optional<bool>& override_is_managed_device);
+ const std::optional<bool>& override_is_managed_device);
ManagedPreferencePolicyManager(const ManagedPreferencePolicyManager&) =
delete;
ManagedPreferencePolicyManager& operator=(
@@ -39,27 +39,27 @@
bool HasActiveDevicePolicies() const override;
- absl::optional<base::TimeDelta> GetLastCheckPeriod() const override;
- absl::optional<UpdatesSuppressedTimes> GetUpdatesSuppressedTimes()
+ std::optional<base::TimeDelta> GetLastCheckPeriod() const override;
+ std::optional<UpdatesSuppressedTimes> GetUpdatesSuppressedTimes()
const override;
- absl::optional<std::string> GetDownloadPreference() const override;
- absl::optional<int> GetPackageCacheSizeLimitMBytes() const override;
- absl::optional<int> GetPackageCacheExpirationTimeDays() const override;
- absl::optional<int> GetEffectivePolicyForAppInstalls(
+ std::optional<std::string> GetDownloadPreference() const override;
+ std::optional<int> GetPackageCacheSizeLimitMBytes() const override;
+ std::optional<int> GetPackageCacheExpirationTimeDays() const override;
+ std::optional<int> GetEffectivePolicyForAppInstalls(
const std::string& app_id) const override;
- absl::optional<int> GetEffectivePolicyForAppUpdates(
+ std::optional<int> GetEffectivePolicyForAppUpdates(
const std::string& app_id) const override;
- absl::optional<std::string> GetTargetVersionPrefix(
+ std::optional<std::string> GetTargetVersionPrefix(
const std::string& app_id) const override;
- absl::optional<bool> IsRollbackToTargetVersionAllowed(
+ std::optional<bool> IsRollbackToTargetVersionAllowed(
const std::string& app_id) const override;
- absl::optional<std::string> GetProxyMode() const override;
- absl::optional<std::string> GetProxyPacUrl() const override;
- absl::optional<std::string> GetProxyServer() const override;
- absl::optional<std::string> GetTargetChannel(
+ std::optional<std::string> GetProxyMode() const override;
+ std::optional<std::string> GetProxyPacUrl() const override;
+ std::optional<std::string> GetProxyServer() const override;
+ std::optional<std::string> GetTargetChannel(
const std::string& app_id) const override;
- absl::optional<std::vector<std::string>> GetForceInstallApps() const override;
- absl::optional<std::vector<std::string>> GetAppsWithPolicy() const override;
+ std::optional<std::vector<std::string>> GetForceInstallApps() const override;
+ std::optional<std::vector<std::string>> GetAppsWithPolicy() const override;
private:
~ManagedPreferencePolicyManager() override;
@@ -70,7 +70,7 @@
ManagedPreferencePolicyManager::ManagedPreferencePolicyManager(
CRUUpdatePolicyDictionary* policyDict,
- const absl::optional<bool>& override_is_managed_device)
+ const std::optional<bool>& override_is_managed_device)
: impl_([[CRUManagedPreferencePolicyManager alloc]
initWithDictionary:policyDict]),
is_managed_device_(override_is_managed_device.value_or(
@@ -86,46 +86,46 @@
return base::SysNSStringToUTF8(impl_.source);
}
-absl::optional<base::TimeDelta>
+std::optional<base::TimeDelta>
ManagedPreferencePolicyManager::GetLastCheckPeriod() const {
int minutes = [impl_ lastCheckPeriodMinutes];
return minutes != kPolicyNotSet
- ? absl::optional<base::TimeDelta>(base::Minutes(minutes))
- : absl::nullopt;
+ ? std::optional<base::TimeDelta>(base::Minutes(minutes))
+ : std::nullopt;
}
-absl::optional<UpdatesSuppressedTimes>
+std::optional<UpdatesSuppressedTimes>
ManagedPreferencePolicyManager::GetUpdatesSuppressedTimes() const {
UpdatesSuppressedTimes suppressed_times = [impl_ updatesSuppressed];
return suppressed_times.valid()
- ? absl::optional<UpdatesSuppressedTimes>(suppressed_times)
- : absl::nullopt;
+ ? std::optional<UpdatesSuppressedTimes>(suppressed_times)
+ : std::nullopt;
}
-absl::optional<std::string>
+std::optional<std::string>
ManagedPreferencePolicyManager::GetDownloadPreference() const {
NSString* value = [impl_ downloadPreference];
- return value ? absl::optional<std::string>(base::SysNSStringToUTF8(value))
- : absl::nullopt;
+ return value ? std::optional<std::string>(base::SysNSStringToUTF8(value))
+ : std::nullopt;
}
-absl::optional<int>
+std::optional<int>
ManagedPreferencePolicyManager::GetPackageCacheSizeLimitMBytes() const {
- return absl::nullopt; // Not supported on Mac.
+ return std::nullopt; // Not supported on Mac.
}
-absl::optional<int>
+std::optional<int>
ManagedPreferencePolicyManager::GetPackageCacheExpirationTimeDays() const {
- return absl::nullopt; // Not supported on Mac.
+ return std::nullopt; // Not supported on Mac.
}
-absl::optional<int>
+std::optional<int>
ManagedPreferencePolicyManager::GetEffectivePolicyForAppInstalls(
const std::string& app_id) const {
- return absl::nullopt; // Not supported on Mac.
+ return std::nullopt; // Not supported on Mac.
}
-absl::optional<int>
+std::optional<int>
ManagedPreferencePolicyManager::GetEffectivePolicyForAppUpdates(
const std::string& app_id) const {
// Check app-specific settings first.
@@ -135,66 +135,66 @@
// Then fallback to global-level policy if needed.
update_policy = [impl_ defaultUpdatePolicy];
- return update_policy != kPolicyNotSet ? absl::optional<int>(update_policy)
- : absl::nullopt;
+ return update_policy != kPolicyNotSet ? std::optional<int>(update_policy)
+ : std::nullopt;
}
-absl::optional<std::string>
+std::optional<std::string>
ManagedPreferencePolicyManager::GetTargetVersionPrefix(
const std::string& app_id) const {
NSString* value = [impl_ targetVersionPrefix:base::SysUTF8ToNSString(app_id)];
- return value ? absl::optional<std::string>(base::SysNSStringToUTF8(value))
- : absl::nullopt;
+ return value ? std::optional<std::string>(base::SysNSStringToUTF8(value))
+ : std::nullopt;
}
-absl::optional<bool>
+std::optional<bool>
ManagedPreferencePolicyManager::IsRollbackToTargetVersionAllowed(
const std::string& app_id) const {
int rollback_policy =
[impl_ rollbackToTargetVersion:base::SysUTF8ToNSString(app_id)];
return rollback_policy != kPolicyNotSet
- ? absl::optional<bool>(rollback_policy != 0)
- : absl::nullopt;
+ ? std::optional<bool>(rollback_policy != 0)
+ : std::nullopt;
}
-absl::optional<std::string> ManagedPreferencePolicyManager::GetProxyMode()
+std::optional<std::string> ManagedPreferencePolicyManager::GetProxyMode()
const {
NSString* value = [impl_ proxyMode];
- return value ? absl::optional<std::string>(base::SysNSStringToUTF8(value))
- : absl::nullopt;
+ return value ? std::optional<std::string>(base::SysNSStringToUTF8(value))
+ : std::nullopt;
}
-absl::optional<std::string> ManagedPreferencePolicyManager::GetProxyPacUrl()
+std::optional<std::string> ManagedPreferencePolicyManager::GetProxyPacUrl()
const {
NSString* value = [impl_ proxyPacURL];
- return value ? absl::optional<std::string>(base::SysNSStringToUTF8(value))
- : absl::nullopt;
+ return value ? std::optional<std::string>(base::SysNSStringToUTF8(value))
+ : std::nullopt;
}
-absl::optional<std::string> ManagedPreferencePolicyManager::GetProxyServer()
+std::optional<std::string> ManagedPreferencePolicyManager::GetProxyServer()
const {
NSString* value = [impl_ proxyServer];
- return value ? absl::optional<std::string>(base::SysNSStringToUTF8(value))
- : absl::nullopt;
+ return value ? std::optional<std::string>(base::SysNSStringToUTF8(value))
+ : std::nullopt;
}
-absl::optional<std::string> ManagedPreferencePolicyManager::GetTargetChannel(
+std::optional<std::string> ManagedPreferencePolicyManager::GetTargetChannel(
const std::string& app_id) const {
NSString* value = [impl_ targetChannel:base::SysUTF8ToNSString(app_id)];
- return value ? absl::optional<std::string>(base::SysNSStringToUTF8(value))
- : absl::nullopt;
+ return value ? std::optional<std::string>(base::SysNSStringToUTF8(value))
+ : std::nullopt;
}
-absl::optional<std::vector<std::string>>
+std::optional<std::vector<std::string>>
ManagedPreferencePolicyManager::GetForceInstallApps() const {
- return absl::nullopt;
+ return std::nullopt;
}
-absl::optional<std::vector<std::string>>
+std::optional<std::vector<std::string>>
ManagedPreferencePolicyManager::GetAppsWithPolicy() const {
NSArray<NSString*>* apps_with_policy = [impl_ appsWithPolicy];
if (!apps_with_policy) {
- return absl::nullopt;
+ return std::nullopt;
}
std::vector<std::string> app_ids;
@@ -227,7 +227,7 @@
}
scoped_refptr<PolicyManagerInterface> CreateManagedPreferencePolicyManager(
- const absl::optional<bool>& override_is_managed_device) {
+ const std::optional<bool>& override_is_managed_device) {
NSDictionary* policyDict = ReadManagedPreferencePolicyDictionary();
return base::MakeRefCounted<ManagedPreferencePolicyManager>(
policyDict, override_is_managed_device);
diff --git a/chrome/updater/policy/mac/managed_preference_policy_manager_unittest.cc b/chrome/updater/policy/mac/managed_preference_policy_manager_unittest.cc
index 9932d58..0046514 100644
--- a/chrome/updater/policy/mac/managed_preference_policy_manager_unittest.cc
+++ b/chrome/updater/policy/mac/managed_preference_policy_manager_unittest.cc
@@ -7,7 +7,6 @@
#include <memory>
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
diff --git a/chrome/updater/policy/manager.cc b/chrome/updater/policy/manager.cc
index eb10dfb..73ca22f5 100644
--- a/chrome/updater/policy/manager.cc
+++ b/chrome/updater/policy/manager.cc
@@ -4,6 +4,7 @@
#include "chrome/updater/policy/manager.h"
+#include <optional>
#include <string>
#include <vector>
@@ -11,7 +12,6 @@
#include "base/memory/scoped_refptr.h"
#include "base/time/time.h"
#include "chrome/updater/constants.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -60,27 +60,27 @@
bool HasActiveDevicePolicies() const override;
- absl::optional<base::TimeDelta> GetLastCheckPeriod() const override;
- absl::optional<UpdatesSuppressedTimes> GetUpdatesSuppressedTimes()
+ std::optional<base::TimeDelta> GetLastCheckPeriod() const override;
+ std::optional<UpdatesSuppressedTimes> GetUpdatesSuppressedTimes()
const override;
- absl::optional<std::string> GetDownloadPreference() const override;
- absl::optional<int> GetPackageCacheSizeLimitMBytes() const override;
- absl::optional<int> GetPackageCacheExpirationTimeDays() const override;
- absl::optional<int> GetEffectivePolicyForAppInstalls(
+ std::optional<std::string> GetDownloadPreference() const override;
+ std::optional<int> GetPackageCacheSizeLimitMBytes() const override;
+ std::optional<int> GetPackageCacheExpirationTimeDays() const override;
+ std::optional<int> GetEffectivePolicyForAppInstalls(
const std::string& app_id) const override;
- absl::optional<int> GetEffectivePolicyForAppUpdates(
+ std::optional<int> GetEffectivePolicyForAppUpdates(
const std::string& app_id) const override;
- absl::optional<std::string> GetTargetVersionPrefix(
+ std::optional<std::string> GetTargetVersionPrefix(
const std::string& app_id) const override;
- absl::optional<bool> IsRollbackToTargetVersionAllowed(
+ std::optional<bool> IsRollbackToTargetVersionAllowed(
const std::string& app_id) const override;
- absl::optional<std::string> GetProxyMode() const override;
- absl::optional<std::string> GetProxyPacUrl() const override;
- absl::optional<std::string> GetProxyServer() const override;
- absl::optional<std::string> GetTargetChannel(
+ std::optional<std::string> GetProxyMode() const override;
+ std::optional<std::string> GetProxyPacUrl() const override;
+ std::optional<std::string> GetProxyServer() const override;
+ std::optional<std::string> GetTargetChannel(
const std::string& app_id) const override;
- absl::optional<std::vector<std::string>> GetForceInstallApps() const override;
- absl::optional<std::vector<std::string>> GetAppsWithPolicy() const override;
+ std::optional<std::vector<std::string>> GetForceInstallApps() const override;
+ std::optional<std::vector<std::string>> GetAppsWithPolicy() const override;
private:
~DefaultValuesPolicyManager() override;
@@ -98,78 +98,77 @@
return kSourceDefaultValuesPolicyManager;
}
-absl::optional<base::TimeDelta> DefaultValuesPolicyManager::GetLastCheckPeriod()
+std::optional<base::TimeDelta> DefaultValuesPolicyManager::GetLastCheckPeriod()
const {
return kDefaultLastCheckPeriod;
}
-absl::optional<UpdatesSuppressedTimes>
+std::optional<UpdatesSuppressedTimes>
DefaultValuesPolicyManager::GetUpdatesSuppressedTimes() const {
- return absl::nullopt;
+ return std::nullopt;
}
-absl::optional<std::string> DefaultValuesPolicyManager::GetDownloadPreference()
+std::optional<std::string> DefaultValuesPolicyManager::GetDownloadPreference()
const {
- return absl::nullopt;
+ return std::nullopt;
}
-absl::optional<int> DefaultValuesPolicyManager::GetPackageCacheSizeLimitMBytes()
+std::optional<int> DefaultValuesPolicyManager::GetPackageCacheSizeLimitMBytes()
const {
- return absl::nullopt;
+ return std::nullopt;
}
-absl::optional<int>
+std::optional<int>
DefaultValuesPolicyManager::GetPackageCacheExpirationTimeDays() const {
- return absl::nullopt;
+ return std::nullopt;
}
-absl::optional<int>
-DefaultValuesPolicyManager::GetEffectivePolicyForAppInstalls(
+std::optional<int> DefaultValuesPolicyManager::GetEffectivePolicyForAppInstalls(
const std::string& app_id) const {
return kInstallPolicyDefault;
}
-absl::optional<int> DefaultValuesPolicyManager::GetEffectivePolicyForAppUpdates(
+std::optional<int> DefaultValuesPolicyManager::GetEffectivePolicyForAppUpdates(
const std::string& app_id) const {
return kUpdatePolicyDefault;
}
-absl::optional<std::string> DefaultValuesPolicyManager::GetTargetVersionPrefix(
+std::optional<std::string> DefaultValuesPolicyManager::GetTargetVersionPrefix(
const std::string& app_id) const {
- return absl::nullopt;
+ return std::nullopt;
}
-absl::optional<bool>
+std::optional<bool>
DefaultValuesPolicyManager::IsRollbackToTargetVersionAllowed(
const std::string& app_id) const {
return false;
}
-absl::optional<std::string> DefaultValuesPolicyManager::GetProxyMode() const {
- return absl::nullopt;
+std::optional<std::string> DefaultValuesPolicyManager::GetProxyMode() const {
+ return std::nullopt;
}
-absl::optional<std::string> DefaultValuesPolicyManager::GetProxyPacUrl() const {
- return absl::nullopt;
+std::optional<std::string> DefaultValuesPolicyManager::GetProxyPacUrl() const {
+ return std::nullopt;
}
-absl::optional<std::string> DefaultValuesPolicyManager::GetProxyServer() const {
- return absl::nullopt;
+std::optional<std::string> DefaultValuesPolicyManager::GetProxyServer() const {
+ return std::nullopt;
}
-absl::optional<std::string> DefaultValuesPolicyManager::GetTargetChannel(
+std::optional<std::string> DefaultValuesPolicyManager::GetTargetChannel(
const std::string& app_id) const {
- return absl::nullopt;
+ return std::nullopt;
}
-absl::optional<std::vector<std::string>>
+std::optional<std::vector<std::string>>
DefaultValuesPolicyManager::GetForceInstallApps() const {
- return absl::nullopt;
+ return std::nullopt;
}
-absl::optional<std::vector<std::string>>
+std::optional<std::vector<std::string>>
DefaultValuesPolicyManager::GetAppsWithPolicy() const {
- return absl::nullopt;
+ return std::nullopt;
}
scoped_refptr<PolicyManagerInterface> GetDefaultValuesPolicyManager() {
diff --git a/chrome/updater/policy/manager.h b/chrome/updater/policy/manager.h
index 87c48b4..f4ff6646 100644
--- a/chrome/updater/policy/manager.h
+++ b/chrome/updater/policy/manager.h
@@ -5,6 +5,7 @@
#ifndef CHROME_UPDATER_POLICY_MANAGER_H_
#define CHROME_UPDATER_POLICY_MANAGER_H_
+#include <optional>
#include <string>
#include <vector>
@@ -12,7 +13,6 @@
#include "base/memory/scoped_refptr.h"
#include "base/time/time.h"
#include "chrome/updater/constants.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -55,30 +55,30 @@
// Returns the policy for how often the Updater should check for updates.
// Returns the time interval between update checks.
// 0 indicates updates are disabled.
- virtual absl::optional<base::TimeDelta> GetLastCheckPeriod() const = 0;
+ virtual std::optional<base::TimeDelta> GetLastCheckPeriod() const = 0;
// For domain-joined machines, checks the current time against the times that
// updates are suppressed.
- virtual absl::optional<UpdatesSuppressedTimes> GetUpdatesSuppressedTimes()
+ virtual std::optional<UpdatesSuppressedTimes> GetUpdatesSuppressedTimes()
const = 0;
// Returns the policy for the download preference.
- virtual absl::optional<std::string> GetDownloadPreference() const = 0;
+ virtual std::optional<std::string> GetDownloadPreference() const = 0;
// Returns the policy for the package cache size limit in megabytes.
- virtual absl::optional<int> GetPackageCacheSizeLimitMBytes() const = 0;
+ virtual std::optional<int> GetPackageCacheSizeLimitMBytes() const = 0;
// Returns the policy for the package cache expiration in days.
- virtual absl::optional<int> GetPackageCacheExpirationTimeDays() const = 0;
+ virtual std::optional<int> GetPackageCacheExpirationTimeDays() const = 0;
// Returns kPolicyEnabled if installation of the specified app is allowed.
// Otherwise, returns kPolicyDisabled.
- virtual absl::optional<int> GetEffectivePolicyForAppInstalls(
+ virtual std::optional<int> GetEffectivePolicyForAppInstalls(
const std::string& app_id) const = 0;
// Returns kPolicyEnabled if updates of the specified app is allowed.
// Otherwise, returns one of kPolicyDisabled, kPolicyManualUpdatesOnly, or
// kPolicyAutomaticUpdatesOnly.
- virtual absl::optional<int> GetEffectivePolicyForAppUpdates(
+ virtual std::optional<int> GetEffectivePolicyForAppUpdates(
const std::string& app_id) const = 0;
// Returns the target version prefix for the app.
// Examples:
@@ -86,34 +86,33 @@
// * "55.": update to any minor version of 55 (e.g. 55.24.34 or 55.60.2).
// * "55.2.": update to any minor version of 55.2 (e.g. 55.2.34 or 55.2.2).
// * "55.24.34": update to this specific version only.
- virtual absl::optional<std::string> GetTargetVersionPrefix(
+ virtual std::optional<std::string> GetTargetVersionPrefix(
const std::string& app_id) const = 0;
// Returns whether the RollbackToTargetVersion policy has been set for the
// app. If RollbackToTargetVersion is set, the TargetVersionPrefix policy
// governs the version to rollback clients with higher versions to.
- virtual absl::optional<bool> IsRollbackToTargetVersionAllowed(
+ virtual std::optional<bool> IsRollbackToTargetVersionAllowed(
const std::string& app_id) const = 0;
// Returns a proxy mode such as |auto_detect|.
- virtual absl::optional<std::string> GetProxyMode() const = 0;
+ virtual std::optional<std::string> GetProxyMode() const = 0;
// Returns a proxy PAC URL.
- virtual absl::optional<std::string> GetProxyPacUrl() const = 0;
+ virtual std::optional<std::string> GetProxyPacUrl() const = 0;
// Returns a proxy server.
- virtual absl::optional<std::string> GetProxyServer() const = 0;
+ virtual std::optional<std::string> GetProxyServer() const = 0;
// Returns a channel, for example {stable|beta|dev}.
- virtual absl::optional<std::string> GetTargetChannel(
+ virtual std::optional<std::string> GetTargetChannel(
const std::string& app_id) const = 0;
// Returns a list of apps that need to be downloaded and installed by the
// updater.
- virtual absl::optional<std::vector<std::string>> GetForceInstallApps()
+ virtual std::optional<std::vector<std::string>> GetForceInstallApps()
const = 0;
// Returns all apps that have some policy set.
- virtual absl::optional<std::vector<std::string>> GetAppsWithPolicy()
- const = 0;
+ virtual std::optional<std::vector<std::string>> GetAppsWithPolicy() const = 0;
protected:
friend class base::RefCountedThreadSafe<PolicyManagerInterface>;
diff --git a/chrome/updater/policy/policy_fetcher.cc b/chrome/updater/policy/policy_fetcher.cc
index 344e3904..1d0186b 100644
--- a/chrome/updater/policy/policy_fetcher.cc
+++ b/chrome/updater/policy/policy_fetcher.cc
@@ -4,6 +4,7 @@
#include "chrome/updater/policy/policy_fetcher.h"
+#include <optional>
#include <utility>
#include <vector>
@@ -24,15 +25,14 @@
#include "chrome/updater/policy/dm_policy_manager.h"
#include "chrome/updater/policy/service.h"
#include "chrome/updater/util/util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
namespace updater {
PolicyFetcher::PolicyFetcher(
const GURL& server_url,
- const absl::optional<PolicyServiceProxyConfiguration>& proxy_configuration,
- const absl::optional<bool>& override_is_managed_device)
+ const std::optional<PolicyServiceProxyConfiguration>& proxy_configuration,
+ const std::optional<bool>& override_is_managed_device)
: server_url_(server_url),
policy_service_proxy_configuration_(proxy_configuration),
override_is_managed_device_(override_is_managed_device),
diff --git a/chrome/updater/policy/policy_fetcher.h b/chrome/updater/policy/policy_fetcher.h
index 8681ce9..29dacb6 100644
--- a/chrome/updater/policy/policy_fetcher.h
+++ b/chrome/updater/policy/policy_fetcher.h
@@ -5,6 +5,7 @@
#ifndef CHROME_UPDATER_POLICY_POLICY_FETCHER_H_
#define CHROME_UPDATER_POLICY_POLICY_FETCHER_H_
+#include <optional>
#include <vector>
#include "base/functional/callback_forward.h"
@@ -17,7 +18,6 @@
#include "chrome/updater/device_management/dm_response_validator.h"
#include "chrome/updater/policy/manager.h"
#include "chrome/updater/policy/service.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
namespace updater {
@@ -25,10 +25,10 @@
// The PolicyFetcher handles registration and DM policy refreshes.
class PolicyFetcher : public base::RefCountedThreadSafe<PolicyFetcher> {
public:
- PolicyFetcher(const GURL& server_url,
- const absl::optional<PolicyServiceProxyConfiguration>&
- proxy_configuration,
- const absl::optional<bool>& override_is_managed_device);
+ PolicyFetcher(
+ const GURL& server_url,
+ const std::optional<PolicyServiceProxyConfiguration>& proxy_configuration,
+ const std::optional<bool>& override_is_managed_device);
void FetchPolicies(
base::OnceCallback<void(int, scoped_refptr<PolicyManagerInterface>)>
callback);
@@ -54,9 +54,9 @@
SEQUENCE_CHECKER(sequence_checker_);
const GURL server_url_;
- const absl::optional<PolicyServiceProxyConfiguration>
+ const std::optional<PolicyServiceProxyConfiguration>
policy_service_proxy_configuration_;
- const absl::optional<bool> override_is_managed_device_;
+ const std::optional<bool> override_is_managed_device_;
const scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_;
};
diff --git a/chrome/updater/policy/policy_manager.cc b/chrome/updater/policy/policy_manager.cc
index 2087767..fdf143e 100644
--- a/chrome/updater/policy/policy_manager.cc
+++ b/chrome/updater/policy/policy_manager.cc
@@ -4,6 +4,7 @@
#include "chrome/updater/policy/policy_manager.h"
+#include <optional>
#include <set>
#include <string>
#include <vector>
@@ -14,7 +15,6 @@
#include "base/values.h"
#include "chrome/updater/policy/manager.h"
#include "chrome/updater/updater_scope.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -96,25 +96,24 @@
return kSourceDictValuesPolicyManager;
}
-absl::optional<base::TimeDelta> PolicyManager::GetLastCheckPeriod() const {
- absl::optional<int> minutes =
+std::optional<base::TimeDelta> PolicyManager::GetLastCheckPeriod() const {
+ std::optional<int> minutes =
GetIntegerPolicy(kAutoUpdateCheckPeriodOverrideMinutes);
if (!minutes) {
- return absl::nullopt;
+ return std::nullopt;
}
return base::Minutes(*minutes);
}
-absl::optional<UpdatesSuppressedTimes>
-PolicyManager::GetUpdatesSuppressedTimes() const {
- absl::optional<int> start_hour =
- GetIntegerPolicy(kUpdatesSuppressedStartHour);
- absl::optional<int> start_min = GetIntegerPolicy(kUpdatesSuppressedStartMin);
- absl::optional<int> duration_min =
+std::optional<UpdatesSuppressedTimes> PolicyManager::GetUpdatesSuppressedTimes()
+ const {
+ std::optional<int> start_hour = GetIntegerPolicy(kUpdatesSuppressedStartHour);
+ std::optional<int> start_min = GetIntegerPolicy(kUpdatesSuppressedStartMin);
+ std::optional<int> duration_min =
GetIntegerPolicy(kUpdatesSuppressedDurationMin);
if (!start_hour || !start_min || !duration_min)
- return absl::nullopt;
+ return std::nullopt;
UpdatesSuppressedTimes supressed_times;
supressed_times.start_hour_ = start_hour.value();
@@ -123,76 +122,75 @@
return supressed_times;
}
-absl::optional<std::string> PolicyManager::GetDownloadPreference() const {
+std::optional<std::string> PolicyManager::GetDownloadPreference() const {
return GetStringPolicy(kDownloadPreference);
}
-absl::optional<int> PolicyManager::GetPackageCacheSizeLimitMBytes() const {
+std::optional<int> PolicyManager::GetPackageCacheSizeLimitMBytes() const {
return GetIntegerPolicy(kCacheSizeLimitMBytes);
}
-absl::optional<int> PolicyManager::GetPackageCacheExpirationTimeDays() const {
+std::optional<int> PolicyManager::GetPackageCacheExpirationTimeDays() const {
return GetIntegerPolicy(kCacheLifeLimitDays);
}
-absl::optional<int> PolicyManager::GetEffectivePolicyForAppInstalls(
+std::optional<int> PolicyManager::GetEffectivePolicyForAppInstalls(
const std::string& app_id) const {
std::string app_value_name(kInstallAppPrefix);
app_value_name.append(app_id);
- absl::optional<int> policy = GetIntegerPolicy(app_value_name);
+ std::optional<int> policy = GetIntegerPolicy(app_value_name);
return policy ? policy : GetIntegerPolicy(kInstallAppsDefault);
}
-absl::optional<int> PolicyManager::GetEffectivePolicyForAppUpdates(
+std::optional<int> PolicyManager::GetEffectivePolicyForAppUpdates(
const std::string& app_id) const {
std::string app_value_name(kUpdateAppPrefix);
app_value_name.append(app_id);
- absl::optional<int> policy = GetIntegerPolicy(app_value_name);
+ std::optional<int> policy = GetIntegerPolicy(app_value_name);
return policy ? policy : GetIntegerPolicy(kUpdateAppsDefault);
}
-absl::optional<std::string> PolicyManager::GetTargetChannel(
+std::optional<std::string> PolicyManager::GetTargetChannel(
const std::string& app_id) const {
std::string app_value_name(kTargetChannel);
app_value_name.append(app_id);
return GetStringPolicy(app_value_name.c_str());
}
-absl::optional<std::string> PolicyManager::GetTargetVersionPrefix(
+std::optional<std::string> PolicyManager::GetTargetVersionPrefix(
const std::string& app_id) const {
std::string app_value_name(kTargetVersionPrefix);
app_value_name.append(app_id);
return GetStringPolicy(app_value_name.c_str());
}
-absl::optional<bool> PolicyManager::IsRollbackToTargetVersionAllowed(
+std::optional<bool> PolicyManager::IsRollbackToTargetVersionAllowed(
const std::string& app_id) const {
std::string app_value_name(kRollbackToTargetVersion);
app_value_name.append(app_id);
- absl::optional<int> policy = GetIntegerPolicy(app_value_name);
- return policy ? absl::optional<bool>(policy.value()) : absl::nullopt;
+ std::optional<int> policy = GetIntegerPolicy(app_value_name);
+ return policy ? std::optional<bool>(policy.value()) : std::nullopt;
}
-absl::optional<std::string> PolicyManager::GetProxyMode() const {
+std::optional<std::string> PolicyManager::GetProxyMode() const {
return GetStringPolicy(kProxyMode);
}
-absl::optional<std::string> PolicyManager::GetProxyPacUrl() const {
+std::optional<std::string> PolicyManager::GetProxyPacUrl() const {
return GetStringPolicy(kProxyPacUrl);
}
-absl::optional<std::string> PolicyManager::GetProxyServer() const {
+std::optional<std::string> PolicyManager::GetProxyServer() const {
return GetStringPolicy(kProxyServer);
}
-absl::optional<std::vector<std::string>> PolicyManager::GetForceInstallApps()
+std::optional<std::vector<std::string>> PolicyManager::GetForceInstallApps()
const {
- return force_install_apps_.empty()
- ? absl::optional<std::vector<std::string>>()
- : force_install_apps_;
+ return force_install_apps_.empty() ? std::optional<std::vector<std::string>>()
+ : force_install_apps_;
}
-absl::optional<std::vector<std::string>> PolicyManager::GetAppsWithPolicy()
+std::optional<std::vector<std::string>> PolicyManager::GetAppsWithPolicy()
const {
const std::set<std::string> kPrefixedPolicyNames = {
// prefixed by kUpdateAppPrefix:
@@ -219,14 +217,14 @@
return apps_with_policy;
}
-absl::optional<int> PolicyManager::GetIntegerPolicy(
+std::optional<int> PolicyManager::GetIntegerPolicy(
const std::string& key) const {
return policies_.FindInt(base::ToLowerASCII(key));
}
-absl::optional<std::string> PolicyManager::GetStringPolicy(
+std::optional<std::string> PolicyManager::GetStringPolicy(
const std::string& key) const {
const std::string* policy = policies_.FindString(base::ToLowerASCII(key));
- return policy ? absl::make_optional(*policy) : absl::nullopt;
+ return policy ? std::make_optional(*policy) : std::nullopt;
}
} // namespace updater
diff --git a/chrome/updater/policy/policy_manager.h b/chrome/updater/policy/policy_manager.h
index 9ef010f1..cdbf475 100644
--- a/chrome/updater/policy/policy_manager.h
+++ b/chrome/updater/policy/policy_manager.h
@@ -5,12 +5,12 @@
#ifndef CHROME_UPDATER_POLICY_POLICY_MANAGER_H_
#define CHROME_UPDATER_POLICY_POLICY_MANAGER_H_
+#include <optional>
#include <string>
#include <vector>
#include "base/values.h"
#include "chrome/updater/policy/manager.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -25,35 +25,35 @@
PolicyManager(const PolicyManager&) = delete;
PolicyManager& operator=(const PolicyManager&) = delete;
- absl::optional<int> GetIntegerPolicy(const std::string& key) const;
- absl::optional<std::string> GetStringPolicy(const std::string& key) const;
+ std::optional<int> GetIntegerPolicy(const std::string& key) const;
+ std::optional<std::string> GetStringPolicy(const std::string& key) const;
// Overrides for PolicyManagerInterface.
std::string source() const override;
bool HasActiveDevicePolicies() const override;
- absl::optional<base::TimeDelta> GetLastCheckPeriod() const override;
- absl::optional<UpdatesSuppressedTimes> GetUpdatesSuppressedTimes()
+ std::optional<base::TimeDelta> GetLastCheckPeriod() const override;
+ std::optional<UpdatesSuppressedTimes> GetUpdatesSuppressedTimes()
const override;
- absl::optional<std::string> GetDownloadPreference() const override;
- absl::optional<int> GetPackageCacheSizeLimitMBytes() const override;
- absl::optional<int> GetPackageCacheExpirationTimeDays() const override;
- absl::optional<int> GetEffectivePolicyForAppInstalls(
+ std::optional<std::string> GetDownloadPreference() const override;
+ std::optional<int> GetPackageCacheSizeLimitMBytes() const override;
+ std::optional<int> GetPackageCacheExpirationTimeDays() const override;
+ std::optional<int> GetEffectivePolicyForAppInstalls(
const std::string& app_id) const override;
- absl::optional<int> GetEffectivePolicyForAppUpdates(
+ std::optional<int> GetEffectivePolicyForAppUpdates(
const std::string& app_id) const override;
- absl::optional<std::string> GetTargetVersionPrefix(
+ std::optional<std::string> GetTargetVersionPrefix(
const std::string& app_id) const override;
- absl::optional<bool> IsRollbackToTargetVersionAllowed(
+ std::optional<bool> IsRollbackToTargetVersionAllowed(
const std::string& app_id) const override;
- absl::optional<std::string> GetProxyMode() const override;
- absl::optional<std::string> GetProxyPacUrl() const override;
- absl::optional<std::string> GetProxyServer() const override;
- absl::optional<std::string> GetTargetChannel(
+ std::optional<std::string> GetProxyMode() const override;
+ std::optional<std::string> GetProxyPacUrl() const override;
+ std::optional<std::string> GetProxyServer() const override;
+ std::optional<std::string> GetTargetChannel(
const std::string& app_id) const override;
- absl::optional<std::vector<std::string>> GetForceInstallApps() const override;
- absl::optional<std::vector<std::string>> GetAppsWithPolicy() const override;
+ std::optional<std::vector<std::string>> GetForceInstallApps() const override;
+ std::optional<std::vector<std::string>> GetAppsWithPolicy() const override;
protected:
~PolicyManager() override;
diff --git a/chrome/updater/policy/policy_manager_unittest.cc b/chrome/updater/policy/policy_manager_unittest.cc
index 5bf91545..0a566ff7 100644
--- a/chrome/updater/policy/policy_manager_unittest.cc
+++ b/chrome/updater/policy/policy_manager_unittest.cc
@@ -5,6 +5,7 @@
#include "chrome/updater/policy/policy_manager.h"
#include <memory>
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -29,32 +30,32 @@
EXPECT_EQ(policy_manager->source(), "DictValuePolicy");
- EXPECT_EQ(policy_manager->GetLastCheckPeriod(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetUpdatesSuppressedTimes(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetDownloadPreference(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetPackageCacheSizeLimitMBytes(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetPackageCacheExpirationTimeDays(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetProxyMode(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetProxyServer(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetProxyPacUrl(), absl::nullopt);
+ EXPECT_EQ(policy_manager->GetLastCheckPeriod(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetUpdatesSuppressedTimes(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetDownloadPreference(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetPackageCacheSizeLimitMBytes(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetPackageCacheExpirationTimeDays(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetProxyMode(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetProxyServer(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetProxyPacUrl(), std::nullopt);
EXPECT_EQ(policy_manager->GetEffectivePolicyForAppInstalls(kTestAppID),
- absl::nullopt);
+ std::nullopt);
EXPECT_FALSE(policy_manager->GetEffectivePolicyForAppInstalls(
"non-exist-app-fallback-to-global"));
EXPECT_EQ(policy_manager->GetEffectivePolicyForAppUpdates(kTestAppID),
- absl::nullopt);
+ std::nullopt);
EXPECT_FALSE(policy_manager->GetEffectivePolicyForAppUpdates(
"non-exist-app-fallback-to-global"));
- EXPECT_EQ(policy_manager->GetTargetChannel(kTestAppID), absl::nullopt);
- EXPECT_EQ(policy_manager->GetTargetChannel("non-exist-app"), absl::nullopt);
- EXPECT_EQ(policy_manager->GetTargetVersionPrefix(kTestAppID), absl::nullopt);
+ EXPECT_EQ(policy_manager->GetTargetChannel(kTestAppID), std::nullopt);
+ EXPECT_EQ(policy_manager->GetTargetChannel("non-exist-app"), std::nullopt);
+ EXPECT_EQ(policy_manager->GetTargetVersionPrefix(kTestAppID), std::nullopt);
EXPECT_EQ(policy_manager->GetTargetVersionPrefix("non-exist-app"),
- absl::nullopt);
+ std::nullopt);
EXPECT_EQ(policy_manager->IsRollbackToTargetVersionAllowed(kTestAppID),
- absl::nullopt);
+ std::nullopt);
EXPECT_FALSE(
policy_manager->IsRollbackToTargetVersionAllowed("non-exist-app"));
- EXPECT_EQ(policy_manager->GetForceInstallApps(), absl::nullopt);
+ EXPECT_EQ(policy_manager->GetForceInstallApps(), std::nullopt);
}
TEST_F(PolicyManagerTests, PolicyRead) {
@@ -90,7 +91,7 @@
EXPECT_EQ(policy_manager->GetLastCheckPeriod(), base::Minutes(480));
- absl::optional<UpdatesSuppressedTimes> suppressed_times =
+ std::optional<UpdatesSuppressedTimes> suppressed_times =
policy_manager->GetUpdatesSuppressedTimes();
ASSERT_TRUE(suppressed_times);
EXPECT_EQ(suppressed_times->start_hour_, 2);
@@ -117,17 +118,17 @@
1);
EXPECT_EQ(policy_manager->GetTargetChannel(kTestAppID), "beta");
- EXPECT_EQ(policy_manager->GetTargetChannel("non-exist-app"), absl::nullopt);
+ EXPECT_EQ(policy_manager->GetTargetChannel("non-exist-app"), std::nullopt);
EXPECT_EQ(policy_manager->GetTargetVersionPrefix(kTestAppID), "55.55.");
EXPECT_EQ(policy_manager->GetTargetVersionPrefix("non-exist-app"),
- absl::nullopt);
+ std::nullopt);
EXPECT_EQ(policy_manager->IsRollbackToTargetVersionAllowed(kTestAppID), true);
EXPECT_FALSE(
policy_manager->IsRollbackToTargetVersionAllowed("non-exist-app"));
- absl::optional<std::vector<std::string>> force_install_apps =
+ std::optional<std::vector<std::string>> force_install_apps =
policy_manager->GetForceInstallApps();
ASSERT_EQ(force_install_apps.has_value(), !IsSystemInstall());
@@ -167,29 +168,29 @@
EXPECT_TRUE(policy_manager->HasActiveDevicePolicies());
- EXPECT_EQ(policy_manager->GetLastCheckPeriod(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetUpdatesSuppressedTimes(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetDownloadPreference(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetPackageCacheSizeLimitMBytes(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetPackageCacheExpirationTimeDays(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetProxyMode(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetProxyServer(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetProxyPacUrl(), absl::nullopt);
+ EXPECT_EQ(policy_manager->GetLastCheckPeriod(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetUpdatesSuppressedTimes(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetDownloadPreference(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetPackageCacheSizeLimitMBytes(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetPackageCacheExpirationTimeDays(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetProxyMode(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetProxyServer(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetProxyPacUrl(), std::nullopt);
EXPECT_EQ(policy_manager->GetEffectivePolicyForAppInstalls(kTestAppID),
- absl::nullopt);
+ std::nullopt);
EXPECT_FALSE(policy_manager->GetEffectivePolicyForAppInstalls(
"non-exist-app-fallback-to-global"));
EXPECT_EQ(policy_manager->GetEffectivePolicyForAppUpdates(kTestAppID),
- absl::nullopt);
+ std::nullopt);
EXPECT_FALSE(policy_manager->GetEffectivePolicyForAppUpdates(
"non-exist-app-fallback-to-global"));
- EXPECT_EQ(policy_manager->GetTargetChannel(kTestAppID), absl::nullopt);
- EXPECT_EQ(policy_manager->GetTargetChannel("non-exist-app"), absl::nullopt);
- EXPECT_EQ(policy_manager->GetTargetVersionPrefix(kTestAppID), absl::nullopt);
+ EXPECT_EQ(policy_manager->GetTargetChannel(kTestAppID), std::nullopt);
+ EXPECT_EQ(policy_manager->GetTargetChannel("non-exist-app"), std::nullopt);
+ EXPECT_EQ(policy_manager->GetTargetVersionPrefix(kTestAppID), std::nullopt);
EXPECT_EQ(policy_manager->GetTargetVersionPrefix("non-exist-app"),
- absl::nullopt);
+ std::nullopt);
EXPECT_EQ(policy_manager->IsRollbackToTargetVersionAllowed(kTestAppID),
- absl::nullopt);
+ std::nullopt);
EXPECT_FALSE(
policy_manager->IsRollbackToTargetVersionAllowed("non-exist-app"));
}
diff --git a/chrome/updater/policy/service.cc b/chrome/updater/policy/service.cc
index 796a317..73d0b7ab 100644
--- a/chrome/updater/policy/service.cc
+++ b/chrome/updater/policy/service.cc
@@ -4,6 +4,7 @@
#include "chrome/updater/policy/service.h"
+#include <optional>
#include <set>
#include <string>
#include <utility>
@@ -33,7 +34,6 @@
#elif BUILDFLAG(IS_MAC)
#include "chrome/updater/policy/mac/managed_preference_policy_manager.h"
#endif
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -303,9 +303,9 @@
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return QueryPolicy(
base::BindRepeating(&PolicyManagerInterface::GetLastCheckPeriod)
- .Then(base::BindRepeating([](absl::optional<base::TimeDelta> period) {
- return period ? absl::optional<int>(period->InMinutes())
- : absl::nullopt;
+ .Then(base::BindRepeating([](std::optional<base::TimeDelta> period) {
+ return period ? std::optional<int>(period->InMinutes())
+ : std::nullopt;
})));
}
@@ -458,11 +458,11 @@
template <typename T>
PolicyStatus<T> PolicyService::QueryPolicy(
- const base::RepeatingCallback<absl::optional<T>(
- const PolicyManagerInterface*)>& policy_query_callback,
+ const base::RepeatingCallback<
+ std::optional<T>(const PolicyManagerInterface*)>& policy_query_callback,
const base::RepeatingCallback<bool(const T&)>& validator) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
- absl::optional<T> query_result;
+ std::optional<T> query_result;
PolicyStatus<T> status;
for (const scoped_refptr<PolicyManagerInterface>& policy_manager :
policy_managers_.vector) {
@@ -481,11 +481,11 @@
template <typename T>
PolicyStatus<T> PolicyService::QueryAppPolicy(
const base::RepeatingCallback<
- absl::optional<T>(const PolicyManagerInterface*, const std::string&)>&
+ std::optional<T>(const PolicyManagerInterface*, const std::string&)>&
policy_query_callback,
const std::string& app_id) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
- absl::optional<T> query_result;
+ std::optional<T> query_result;
PolicyStatus<T> status;
for (const scoped_refptr<PolicyManagerInterface>& policy_manager :
policy_managers_.vector) {
@@ -506,12 +506,12 @@
PolicyServiceProxyConfiguration& PolicyServiceProxyConfiguration::operator=(
const PolicyServiceProxyConfiguration&) = default;
-absl::optional<PolicyServiceProxyConfiguration>
+std::optional<PolicyServiceProxyConfiguration>
PolicyServiceProxyConfiguration::Get(
scoped_refptr<PolicyService> policy_service) {
PolicyStatus<std::string> proxy_mode = policy_service->GetProxyMode();
if (!proxy_mode || proxy_mode.policy().compare(kProxyModeSystem) == 0) {
- return absl::nullopt;
+ return std::nullopt;
}
VLOG(2) << "Using policy proxy " << proxy_mode.policy();
@@ -540,7 +540,7 @@
if (!is_policy_config_valid) {
VLOG(1) << "Configuration set by policy was invalid.";
- return absl::nullopt;
+ return std::nullopt;
}
return policy_service_proxy_configuration;
diff --git a/chrome/updater/policy/service.h b/chrome/updater/policy/service.h
index 48f780f..71315bb6 100644
--- a/chrome/updater/policy/service.h
+++ b/chrome/updater/policy/service.h
@@ -5,6 +5,7 @@
#ifndef CHROME_UPDATER_POLICY_SERVICE_H_
#define CHROME_UPDATER_POLICY_SERVICE_H_
+#include <optional>
#include <set>
#include <string>
#include <vector>
@@ -17,7 +18,6 @@
#include "base/time/time.h"
#include "chrome/updater/external_constants.h"
#include "chrome/updater/policy/manager.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -46,17 +46,17 @@
return; // We already have enough policies.
if (!effective_policy_ && is_managed) {
- effective_policy_ = absl::make_optional<Entry>(source, policy);
+ effective_policy_ = std::make_optional<Entry>(source, policy);
} else if (effective_policy_ &&
policy != effective_policy_.value().policy) {
- conflict_policy_ = absl::make_optional<Entry>(source, policy);
+ conflict_policy_ = std::make_optional<Entry>(source, policy);
}
}
- const absl::optional<Entry>& effective_policy() const {
+ const std::optional<Entry>& effective_policy() const {
return effective_policy_;
}
- const absl::optional<Entry>& conflict_policy() const {
+ const std::optional<Entry>& conflict_policy() const {
return conflict_policy_;
}
@@ -71,8 +71,8 @@
}
private:
- absl::optional<Entry> effective_policy_;
- absl::optional<Entry> conflict_policy_;
+ std::optional<Entry> effective_policy_;
+ std::optional<Entry> conflict_policy_;
};
// The PolicyService returns policies for enterprise managed machines from the
@@ -161,7 +161,7 @@
// determines the policy status.
template <typename T>
PolicyStatus<T> QueryPolicy(
- const base::RepeatingCallback<absl::optional<T>(
+ const base::RepeatingCallback<std::optional<T>(
const PolicyManagerInterface*)>& policy_query_callback,
const base::RepeatingCallback<bool(const T&)>& validator =
base::NullCallback()) const;
@@ -171,8 +171,8 @@
template <typename T>
PolicyStatus<T> QueryAppPolicy(
const base::RepeatingCallback<
- absl::optional<T>(const PolicyManagerInterface*,
- const std::string& app_id)>& policy_query_callback,
+ std::optional<T>(const PolicyManagerInterface*,
+ const std::string& app_id)>& policy_query_callback,
const std::string& app_id) const;
std::set<std::string> GetAppsWithPolicy() const;
@@ -186,12 +186,12 @@
PolicyServiceProxyConfiguration& operator=(
const PolicyServiceProxyConfiguration&);
- static absl::optional<PolicyServiceProxyConfiguration> Get(
+ static std::optional<PolicyServiceProxyConfiguration> Get(
scoped_refptr<PolicyService> policy_service);
- absl::optional<bool> proxy_auto_detect;
- absl::optional<std::string> proxy_pac_url;
- absl::optional<std::string> proxy_url;
+ std::optional<bool> proxy_auto_detect;
+ std::optional<std::string> proxy_pac_url;
+ std::optional<std::string> proxy_url;
};
PolicyService::PolicyManagerVector CreatePolicyManagerVector(
diff --git a/chrome/updater/policy/service_unittest.cc b/chrome/updater/policy/service_unittest.cc
index cc2c732..1ad98a9 100644
--- a/chrome/updater/policy/service_unittest.cc
+++ b/chrome/updater/policy/service_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <memory>
+#include <optional>
#include <set>
#include <string>
#include <utility>
@@ -16,7 +17,6 @@
#include "chrome/updater/policy/service.h"
#include "chrome/updater/protos/omaha_settings.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#if BUILDFLAG(IS_WIN)
#include "base/test/test_reg_util_win.h"
@@ -42,13 +42,13 @@
bool HasActiveDevicePolicies() const override {
return has_active_device_policies_;
}
- absl::optional<base::TimeDelta> GetLastCheckPeriod() const override {
- return absl::nullopt;
+ std::optional<base::TimeDelta> GetLastCheckPeriod() const override {
+ return std::nullopt;
}
- absl::optional<UpdatesSuppressedTimes> GetUpdatesSuppressedTimes()
+ std::optional<UpdatesSuppressedTimes> GetUpdatesSuppressedTimes()
const override {
if (!suppressed_times_.valid())
- return absl::nullopt;
+ return std::nullopt;
return suppressed_times_;
}
@@ -56,68 +56,66 @@
const UpdatesSuppressedTimes& suppressed_times) {
suppressed_times_ = suppressed_times;
}
- absl::optional<std::string> GetDownloadPreference() const override {
+ std::optional<std::string> GetDownloadPreference() const override {
return download_preference_.empty()
- ? absl::nullopt
- : absl::make_optional(download_preference_);
+ ? std::nullopt
+ : std::make_optional(download_preference_);
}
void SetDownloadPreference(const std::string& preference) {
download_preference_ = preference;
}
- absl::optional<int> GetPackageCacheSizeLimitMBytes() const override {
- return absl::nullopt;
+ std::optional<int> GetPackageCacheSizeLimitMBytes() const override {
+ return std::nullopt;
}
- absl::optional<int> GetPackageCacheExpirationTimeDays() const override {
- return absl::nullopt;
+ std::optional<int> GetPackageCacheExpirationTimeDays() const override {
+ return std::nullopt;
}
- absl::optional<int> GetEffectivePolicyForAppInstalls(
+ std::optional<int> GetEffectivePolicyForAppInstalls(
const std::string& app_id) const override {
- return absl::nullopt;
+ return std::nullopt;
}
- absl::optional<int> GetEffectivePolicyForAppUpdates(
+ std::optional<int> GetEffectivePolicyForAppUpdates(
const std::string& app_id) const override {
auto value = update_policies_.find(app_id);
if (value == update_policies_.end())
- return absl::nullopt;
+ return std::nullopt;
return value->second;
}
void SetUpdatePolicy(const std::string& app_id, int update_policy) {
update_policies_[app_id] = update_policy;
}
- absl::optional<std::string> GetTargetVersionPrefix(
+ std::optional<std::string> GetTargetVersionPrefix(
const std::string& app_id) const override {
- return absl::nullopt;
+ return std::nullopt;
}
- absl::optional<bool> IsRollbackToTargetVersionAllowed(
+ std::optional<bool> IsRollbackToTargetVersionAllowed(
const std::string& app_id) const override {
- return absl::nullopt;
+ return std::nullopt;
}
- absl::optional<std::string> GetProxyMode() const override {
- return proxy_mode_.empty() ? absl::nullopt
- : absl::make_optional(proxy_mode_);
+ std::optional<std::string> GetProxyMode() const override {
+ return proxy_mode_.empty() ? std::nullopt : std::make_optional(proxy_mode_);
}
void SetProxyMode(const std::string& proxy_mode) { proxy_mode_ = proxy_mode; }
- absl::optional<std::string> GetProxyPacUrl() const override {
- return absl::nullopt;
+ std::optional<std::string> GetProxyPacUrl() const override {
+ return std::nullopt;
}
- absl::optional<std::string> GetProxyServer() const override {
- return absl::nullopt;
+ std::optional<std::string> GetProxyServer() const override {
+ return std::nullopt;
}
- absl::optional<std::string> GetTargetChannel(
+ std::optional<std::string> GetTargetChannel(
const std::string& app_id) const override {
auto value = channels_.find(app_id);
if (value == channels_.end())
- return absl::nullopt;
+ return std::nullopt;
return value->second;
}
void SetChannel(const std::string& app_id, std::string channel) {
channels_[app_id] = std::move(channel);
}
- absl::optional<std::vector<std::string>> GetForceInstallApps()
- const override {
- return absl::nullopt;
+ std::optional<std::vector<std::string>> GetForceInstallApps() const override {
+ return std::nullopt;
}
- absl::optional<std::vector<std::string>> GetAppsWithPolicy() const override {
+ std::optional<std::vector<std::string>> GetAppsWithPolicy() const override {
std::set<std::string> apps_with_policy;
for (const auto& policy_entry : update_policies_) {
apps_with_policy.insert(policy_entry.first);
@@ -219,23 +217,23 @@
policy_service->GetTargetChannel("app1");
ASSERT_TRUE(app1_channel);
EXPECT_EQ(app1_channel.policy(), "test_channel");
- EXPECT_EQ(app1_channel.conflict_policy(), absl::nullopt);
+ EXPECT_EQ(app1_channel.conflict_policy(), std::nullopt);
PolicyStatus<std::string> app2_channel =
policy_service->GetTargetChannel("app2");
EXPECT_FALSE(app2_channel);
- EXPECT_EQ(app2_channel.conflict_policy(), absl::nullopt);
+ EXPECT_EQ(app2_channel.conflict_policy(), std::nullopt);
PolicyStatus<int> app1_update_status =
policy_service->GetPolicyForAppUpdates("app1");
EXPECT_FALSE(app1_update_status);
- EXPECT_EQ(app1_update_status.conflict_policy(), absl::nullopt);
+ EXPECT_EQ(app1_update_status.conflict_policy(), std::nullopt);
PolicyStatus<int> app2_update_status =
policy_service->GetPolicyForAppUpdates("app2");
EXPECT_TRUE(app2_update_status);
EXPECT_EQ(app2_update_status.policy(), 3);
- EXPECT_EQ(app2_update_status.conflict_policy(), absl::nullopt);
+ EXPECT_EQ(app2_update_status.conflict_policy(), std::nullopt);
}
TEST(PolicyService, MultiplePolicyManagers) {
@@ -322,7 +320,7 @@
EXPECT_EQ(app2_update_policy.source, "group_policy");
EXPECT_EQ(app2_update_policy.policy, 1);
EXPECT_EQ(app2_update_status.policy(), 1);
- EXPECT_EQ(app2_update_status.conflict_policy(), absl::nullopt);
+ EXPECT_EQ(app2_update_status.conflict_policy(), std::nullopt);
PolicyStatus<std::string> download_preference_status =
policy_service->GetDownloadPreference();
@@ -332,7 +330,7 @@
EXPECT_EQ(download_preference_policy.source, "imaginary");
EXPECT_EQ(download_preference_policy.policy, "cacheable");
EXPECT_EQ(download_preference_status.policy(), "cacheable");
- EXPECT_EQ(download_preference_status.conflict_policy(), absl::nullopt);
+ EXPECT_EQ(download_preference_status.conflict_policy(), std::nullopt);
EXPECT_FALSE(policy_service->GetPackageCacheSizeLimitMBytes());
EXPECT_EQ(policy_service->GetAllPoliciesAsString(),
@@ -434,7 +432,7 @@
PolicyStatus<int> app2_update_status =
policy_service->GetPolicyForAppUpdates("app2");
ASSERT_TRUE(app2_update_status);
- EXPECT_EQ(app2_update_status.conflict_policy(), absl::nullopt);
+ EXPECT_EQ(app2_update_status.conflict_policy(), std::nullopt);
const PolicyStatus<int>::Entry& app2_update_status_policy =
app2_update_status.effective_policy().value();
EXPECT_EQ(app2_update_status_policy.source, "Default");
@@ -447,7 +445,7 @@
EXPECT_EQ(download_preference_status.effective_policy().value().source,
"imaginary");
EXPECT_EQ(download_preference_status.policy(), "cacheable");
- EXPECT_EQ(download_preference_status.conflict_policy(), absl::nullopt);
+ EXPECT_EQ(download_preference_status.conflict_policy(), std::nullopt);
EXPECT_FALSE(policy_service->GetPackageCacheSizeLimitMBytes());
diff --git a/chrome/updater/policy/win/group_policy_manager.cc b/chrome/updater/policy/win/group_policy_manager.cc
index e0a146bd..edd9690 100644
--- a/chrome/updater/policy/win/group_policy_manager.cc
+++ b/chrome/updater/policy/win/group_policy_manager.cc
@@ -4,11 +4,12 @@
#include "chrome/updater/policy/win/group_policy_manager.h"
+#include <userenv.h>
+
+#include <optional>
#include <ostream>
#include <string>
-#include <userenv.h>
-
#include "base/check.h"
#include "base/enterprise_util.h"
#include "base/functional/bind.h"
@@ -26,7 +27,6 @@
#include "base/values.h"
#include "base/win/registry.h"
#include "chrome/updater/win/win_constants.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -116,7 +116,7 @@
GroupPolicyManager::GroupPolicyManager(
bool should_take_policy_critical_section,
- const absl::optional<bool>& override_is_managed_device)
+ const std::optional<bool>& override_is_managed_device)
: PolicyManager(LoadGroupPolicies(should_take_policy_critical_section)),
is_managed_device_(override_is_managed_device.value_or(
base::IsManagedOrEnterpriseDevice())) {}
diff --git a/chrome/updater/policy/win/group_policy_manager.h b/chrome/updater/policy/win/group_policy_manager.h
index d21ecbc23..a08c925f 100644
--- a/chrome/updater/policy/win/group_policy_manager.h
+++ b/chrome/updater/policy/win/group_policy_manager.h
@@ -5,10 +5,10 @@
#ifndef CHROME_UPDATER_POLICY_WIN_GROUP_POLICY_MANAGER_H_
#define CHROME_UPDATER_POLICY_WIN_GROUP_POLICY_MANAGER_H_
+#include <optional>
#include <string>
#include "chrome/updater/policy/policy_manager.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -17,7 +17,7 @@
public:
GroupPolicyManager(
bool should_take_policy_critical_section,
- const absl::optional<bool>& override_is_managed_device = absl::nullopt);
+ const std::optional<bool>& override_is_managed_device = std::nullopt);
GroupPolicyManager(const GroupPolicyManager&) = delete;
GroupPolicyManager& operator=(const GroupPolicyManager&) = delete;
diff --git a/chrome/updater/policy/win/group_policy_manager_unittest.cc b/chrome/updater/policy/win/group_policy_manager_unittest.cc
index 21163bf..4ae01ecf 100644
--- a/chrome/updater/policy/win/group_policy_manager_unittest.cc
+++ b/chrome/updater/policy/win/group_policy_manager_unittest.cc
@@ -4,6 +4,7 @@
#include "chrome/updater/policy/win/group_policy_manager.h"
+#include <optional>
#include <string>
#include "base/memory/ref_counted.h"
@@ -17,7 +18,6 @@
#include "chrome/updater/util/win_util.h"
#include "chrome/updater/win/win_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -59,35 +59,35 @@
EXPECT_EQ(policy_manager->source(), "Group Policy");
EXPECT_FALSE(policy_manager->CloudPolicyOverridesPlatformPolicy());
- EXPECT_EQ(policy_manager->GetLastCheckPeriod(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetUpdatesSuppressedTimes(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetDownloadPreference(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetPackageCacheSizeLimitMBytes(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetPackageCacheExpirationTimeDays(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetProxyMode(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetProxyServer(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetProxyPacUrl(), absl::nullopt);
+ EXPECT_EQ(policy_manager->GetLastCheckPeriod(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetUpdatesSuppressedTimes(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetDownloadPreference(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetPackageCacheSizeLimitMBytes(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetPackageCacheExpirationTimeDays(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetProxyMode(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetProxyServer(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetProxyPacUrl(), std::nullopt);
std::string app_id = base::WideToUTF8(TEST_APP_ID);
EXPECT_EQ(policy_manager->GetEffectivePolicyForAppInstalls(app_id),
- absl::nullopt);
+ std::nullopt);
EXPECT_EQ(policy_manager->GetEffectivePolicyForAppInstalls(
"non-exist-app-fallback-to-global"),
- absl::nullopt);
+ std::nullopt);
EXPECT_EQ(policy_manager->GetEffectivePolicyForAppUpdates(app_id),
- absl::nullopt);
+ std::nullopt);
EXPECT_EQ(policy_manager->GetEffectivePolicyForAppUpdates(
"non-exist-app-fallback-to-global"),
- absl::nullopt);
- EXPECT_EQ(policy_manager->GetTargetChannel(app_id), absl::nullopt);
- EXPECT_EQ(policy_manager->GetTargetChannel("non-exist-app"), absl::nullopt);
- EXPECT_EQ(policy_manager->GetTargetVersionPrefix(app_id), absl::nullopt);
+ std::nullopt);
+ EXPECT_EQ(policy_manager->GetTargetChannel(app_id), std::nullopt);
+ EXPECT_EQ(policy_manager->GetTargetChannel("non-exist-app"), std::nullopt);
+ EXPECT_EQ(policy_manager->GetTargetVersionPrefix(app_id), std::nullopt);
EXPECT_EQ(policy_manager->GetTargetVersionPrefix("non-exist-app"),
- absl::nullopt);
+ std::nullopt);
EXPECT_EQ(policy_manager->IsRollbackToTargetVersionAllowed(app_id),
- absl::nullopt);
+ std::nullopt);
EXPECT_EQ(policy_manager->IsRollbackToTargetVersionAllowed("non-exist-app"),
- absl::nullopt);
+ std::nullopt);
}
TEST_F(GroupPolicyManagerTests, PolicyRead) {
@@ -132,7 +132,7 @@
EXPECT_TRUE(policy_manager->CloudPolicyOverridesPlatformPolicy());
EXPECT_EQ(policy_manager->GetLastCheckPeriod(), base::Minutes(480));
- absl::optional<UpdatesSuppressedTimes> suppressed_times =
+ std::optional<UpdatesSuppressedTimes> suppressed_times =
policy_manager->GetUpdatesSuppressedTimes();
ASSERT_TRUE(suppressed_times);
EXPECT_EQ(suppressed_times->start_hour_, 2);
@@ -156,13 +156,13 @@
"non-exist-app-fallback-to-global"),
1);
EXPECT_EQ(policy_manager->GetTargetChannel(app_id), "beta");
- EXPECT_EQ(policy_manager->GetTargetChannel("non-exist-app"), absl::nullopt);
+ EXPECT_EQ(policy_manager->GetTargetChannel("non-exist-app"), std::nullopt);
EXPECT_EQ(policy_manager->GetTargetVersionPrefix(app_id), "55.55.");
EXPECT_EQ(policy_manager->GetTargetVersionPrefix("non-exist-app"),
- absl::nullopt);
+ std::nullopt);
EXPECT_EQ(policy_manager->IsRollbackToTargetVersionAllowed(app_id), true);
EXPECT_EQ(policy_manager->IsRollbackToTargetVersionAllowed("non-exist-app"),
- absl::nullopt);
+ std::nullopt);
}
TEST_F(GroupPolicyManagerTests, WrongPolicyValueType) {
@@ -203,35 +203,35 @@
EXPECT_TRUE(policy_manager->HasActiveDevicePolicies());
EXPECT_FALSE(policy_manager->CloudPolicyOverridesPlatformPolicy());
- EXPECT_EQ(policy_manager->GetLastCheckPeriod(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetUpdatesSuppressedTimes(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetDownloadPreference(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetPackageCacheSizeLimitMBytes(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetPackageCacheExpirationTimeDays(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetProxyMode(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetProxyServer(), absl::nullopt);
- EXPECT_EQ(policy_manager->GetProxyPacUrl(), absl::nullopt);
+ EXPECT_EQ(policy_manager->GetLastCheckPeriod(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetUpdatesSuppressedTimes(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetDownloadPreference(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetPackageCacheSizeLimitMBytes(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetPackageCacheExpirationTimeDays(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetProxyMode(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetProxyServer(), std::nullopt);
+ EXPECT_EQ(policy_manager->GetProxyPacUrl(), std::nullopt);
std::string app_id = base::WideToUTF8(TEST_APP_ID);
EXPECT_EQ(policy_manager->GetEffectivePolicyForAppInstalls(app_id),
- absl::nullopt);
+ std::nullopt);
EXPECT_EQ(policy_manager->GetEffectivePolicyForAppInstalls(
"non-exist-app-fallback-to-global"),
- absl::nullopt);
+ std::nullopt);
EXPECT_EQ(policy_manager->GetEffectivePolicyForAppUpdates(app_id),
- absl::nullopt);
+ std::nullopt);
EXPECT_EQ(policy_manager->GetEffectivePolicyForAppUpdates(
"non-exist-app-fallback-to-global"),
- absl::nullopt);
- EXPECT_EQ(policy_manager->GetTargetChannel(app_id), absl::nullopt);
- EXPECT_EQ(policy_manager->GetTargetChannel("non-exist-app"), absl::nullopt);
- EXPECT_EQ(policy_manager->GetTargetVersionPrefix(app_id), absl::nullopt);
+ std::nullopt);
+ EXPECT_EQ(policy_manager->GetTargetChannel(app_id), std::nullopt);
+ EXPECT_EQ(policy_manager->GetTargetChannel("non-exist-app"), std::nullopt);
+ EXPECT_EQ(policy_manager->GetTargetVersionPrefix(app_id), std::nullopt);
EXPECT_EQ(policy_manager->GetTargetVersionPrefix("non-exist-app"),
- absl::nullopt);
+ std::nullopt);
EXPECT_EQ(policy_manager->IsRollbackToTargetVersionAllowed(app_id),
- absl::nullopt);
+ std::nullopt);
EXPECT_EQ(policy_manager->IsRollbackToTargetVersionAllowed("non-exist-app"),
- absl::nullopt);
+ std::nullopt);
}
} // namespace updater
diff --git a/chrome/updater/prefs.cc b/chrome/updater/prefs.cc
index 924814f..9062a4a 100644
--- a/chrome/updater/prefs.cc
+++ b/chrome/updater/prefs.cc
@@ -7,6 +7,7 @@
#include <algorithm>
#include <functional>
#include <memory>
+#include <optional>
#include <string>
#include <utility>
@@ -29,7 +30,6 @@
#include "components/prefs/pref_service.h"
#include "components/prefs/pref_service_factory.h"
#include "components/update_client/update_client.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -153,7 +153,7 @@
return nullptr;
}
- const absl::optional<base::FilePath> global_prefs_dir =
+ const std::optional<base::FilePath> global_prefs_dir =
GetInstallDirectory(scope);
if (!global_prefs_dir || !base::CreateDirectory(*global_prefs_dir)) {
return nullptr;
@@ -180,7 +180,7 @@
scoped_refptr<LocalPrefs> CreateLocalPrefs(UpdaterScope scope) {
VLOG(2) << __func__;
- const absl::optional<base::FilePath> local_prefs_dir =
+ const std::optional<base::FilePath> local_prefs_dir =
GetVersionedInstallDirectory(scope);
if (!local_prefs_dir || !base::CreateDirectory(*local_prefs_dir)) {
return nullptr;
diff --git a/chrome/updater/registration_data.h b/chrome/updater/registration_data.h
index 08bf2860..ed738df 100644
--- a/chrome/updater/registration_data.h
+++ b/chrome/updater/registration_data.h
@@ -5,12 +5,12 @@
#ifndef CHROME_UPDATER_REGISTRATION_DATA_H_
#define CHROME_UPDATER_REGISTRATION_DATA_H_
+#include <optional>
#include <string>
#include "base/files/file_path.h"
#include "base/version.h"
#include "chrome/updater/constants.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -63,10 +63,10 @@
base::FilePath existence_checker_path;
// Date-last-active. The value is the number of days since Jan 1, 2007.
- absl::optional<int> dla;
+ std::optional<int> dla;
// Date-last-rollcall. The value is the number of days since Jan 1, 2007.
- absl::optional<int> dlrc;
+ std::optional<int> dlrc;
// Opaque cohort string meaningful to the server.
std::string cohort;
diff --git a/chrome/updater/remove_uninstalled_apps_task.cc b/chrome/updater/remove_uninstalled_apps_task.cc
index ec6f59b..8cbe6311 100644
--- a/chrome/updater/remove_uninstalled_apps_task.cc
+++ b/chrome/updater/remove_uninstalled_apps_task.cc
@@ -4,6 +4,7 @@
#include "chrome/updater/remove_uninstalled_apps_task.h"
+#include <optional>
#include <string>
#include <vector>
@@ -26,7 +27,6 @@
#include "chrome/updater/util/util.h"
#include "components/prefs/pref_service.h"
#include "components/update_client/update_client.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -66,12 +66,12 @@
std::vector<PingInfo> GetAppIDsToRemove(
const std::vector<AppInfo>& apps,
- base::RepeatingCallback<absl::optional<int>(const std::string&,
- const base::FilePath&)>
+ base::RepeatingCallback<std::optional<int>(const std::string&,
+ const base::FilePath&)>
predicate) {
std::vector<PingInfo> app_ids_to_remove;
for (const auto& app : apps) {
- absl::optional<int> remove_reason = predicate.Run(app.app_id_, app.ecp_);
+ std::optional<int> remove_reason = predicate.Run(app.app_id_, app.ecp_);
if (remove_reason) {
app_ids_to_remove.emplace_back(app.app_id_, app.app_version_,
*remove_reason);
diff --git a/chrome/updater/remove_uninstalled_apps_task.h b/chrome/updater/remove_uninstalled_apps_task.h
index 5c0a212..fdf1fe6 100644
--- a/chrome/updater/remove_uninstalled_apps_task.h
+++ b/chrome/updater/remove_uninstalled_apps_task.h
@@ -5,6 +5,7 @@
#ifndef CHROME_UPDATER_REMOVE_UNINSTALLED_APPS_TASK_H_
#define CHROME_UPDATER_REMOVE_UNINSTALLED_APPS_TASK_H_
+#include <optional>
#include <string>
#include "base/functional/callback_forward.h"
@@ -12,7 +13,6 @@
#include "base/memory/scoped_refptr.h"
#include "base/sequence_checker.h"
#include "chrome/updater/updater_scope.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace base {
class FilePath;
@@ -38,8 +38,8 @@
friend class base::RefCountedThreadSafe<RemoveUninstalledAppsTask>;
virtual ~RemoveUninstalledAppsTask();
- absl::optional<int> GetUnregisterReason(const std::string& app_id,
- const base::FilePath& ecp) const;
+ std::optional<int> GetUnregisterReason(const std::string& app_id,
+ const base::FilePath& ecp) const;
SEQUENCE_CHECKER(sequence_checker_);
scoped_refptr<Configurator> config_;
diff --git a/chrome/updater/remove_uninstalled_apps_task_posix.cc b/chrome/updater/remove_uninstalled_apps_task_posix.cc
index ce54fbb..bc3f9a9 100644
--- a/chrome/updater/remove_uninstalled_apps_task_posix.cc
+++ b/chrome/updater/remove_uninstalled_apps_task_posix.cc
@@ -7,6 +7,7 @@
#include <sys/stat.h>
#include <unistd.h>
+#include <optional>
#include <string>
#include "base/files/file_path.h"
@@ -14,7 +15,6 @@
#include "base/logging.h"
#include "chrome/updater/constants.h"
#include "chrome/updater/util/util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -31,19 +31,19 @@
} // namespace
-absl::optional<int> RemoveUninstalledAppsTask::GetUnregisterReason(
+std::optional<int> RemoveUninstalledAppsTask::GetUnregisterReason(
const std::string& /*app_id*/,
const base::FilePath& ecp) const {
if (ecp.empty()) {
- return absl::nullopt;
+ return std::nullopt;
}
if (!base::PathExists(ecp)) {
- return absl::make_optional(kUninstallPingReasonUninstalled);
+ return std::make_optional(kUninstallPingReasonUninstalled);
}
if (scope_ == UpdaterScope::kUser && PathOwnedByRoot(ecp)) {
- return absl::make_optional(kUninstallPingReasonUserNotAnOwner);
+ return std::make_optional(kUninstallPingReasonUserNotAnOwner);
}
- return absl::nullopt;
+ return std::nullopt;
}
} // namespace updater
diff --git a/chrome/updater/remove_uninstalled_apps_task_win.cc b/chrome/updater/remove_uninstalled_apps_task_win.cc
index 8cbb1f5..5b8481d 100644
--- a/chrome/updater/remove_uninstalled_apps_task_win.cc
+++ b/chrome/updater/remove_uninstalled_apps_task_win.cc
@@ -4,6 +4,7 @@
#include "chrome/updater/remove_uninstalled_apps_task.h"
+#include <optional>
#include <string>
#include "base/files/file_path.h"
@@ -16,20 +17,19 @@
#include "chrome/updater/util/util.h"
#include "chrome/updater/util/win_util.h"
#include "chrome/updater/win/win_constants.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
-absl::optional<int> RemoveUninstalledAppsTask::GetUnregisterReason(
+std::optional<int> RemoveUninstalledAppsTask::GetUnregisterReason(
const std::string& app_id,
const base::FilePath& /*ecp*/) const {
base::win::RegKey key;
if (key.Open(IsSystemInstall(scope_) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
GetAppClientsKey(app_id).c_str(),
Wow6432(KEY_READ)) == ERROR_FILE_NOT_FOUND) {
- return absl::make_optional(kUninstallPingReasonUninstalled);
+ return std::make_optional(kUninstallPingReasonUninstalled);
}
- return absl::nullopt;
+ return std::nullopt;
}
} // namespace updater
diff --git a/chrome/updater/tag.cc b/chrome/updater/tag.cc
index 1fd6b94..2b52221 100644
--- a/chrome/updater/tag.cc
+++ b/chrome/updater/tag.cc
@@ -7,6 +7,7 @@
#include <algorithm>
#include <cstdint>
#include <map>
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -24,7 +25,6 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/updater/certificate_tag.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace tagging {
@@ -98,7 +98,7 @@
constexpr uint8_t kTagMagicUtf8[] = {'G', 'a', 'c', 't', '2', '.',
'0', 'O', 'm', 'a', 'h', 'a'};
-absl::optional<AppArgs::NeedsAdmin> ParseNeedsAdminEnum(base::StringPiece str) {
+std::optional<AppArgs::NeedsAdmin> ParseNeedsAdminEnum(base::StringPiece str) {
if (base::EqualsCaseInsensitiveASCII("false", str))
return AppArgs::NeedsAdmin::kNo;
@@ -108,18 +108,18 @@
if (base::EqualsCaseInsensitiveASCII("prefers", str))
return AppArgs::NeedsAdmin::kPrefers;
- return absl::nullopt;
+ return std::nullopt;
}
-// Returns absl::nullopt if parsing failed.
-absl::optional<bool> ParseBool(base::StringPiece str) {
+// Returns std::nullopt if parsing failed.
+std::optional<bool> ParseBool(base::StringPiece str) {
if (base::EqualsCaseInsensitiveASCII("false", str))
return false;
if (base::EqualsCaseInsensitiveASCII("true", str))
return true;
- return absl::nullopt;
+ return std::nullopt;
}
// Functor used by associative containers of strings as a case-insensitive ASCII
@@ -196,7 +196,7 @@
}
ErrorCode ParseFlighting(base::StringPiece value, TagArgs* args) {
- const absl::optional<bool> flighting = ParseBool(value);
+ const std::optional<bool> flighting = ParseBool(value);
if (!flighting.has_value())
return ErrorCode::kGlobal_FlightingValueIsNotABoolean;
@@ -214,7 +214,7 @@
} else if (tristate == 1) {
args->usage_stats_enable = true;
} else if (tristate == 2) {
- args->usage_stats_enable = absl::nullopt;
+ args->usage_stats_enable = std::nullopt;
} else {
return ErrorCode::kGlobal_UsageStatsValueIsInvalid;
}
@@ -331,7 +331,7 @@
// index to |current_app_index|.
ErrorCode FindAppIdInTagArgs(base::StringPiece value,
TagArgs* args,
- absl::optional<size_t>* current_app_index) {
+ std::optional<size_t>* current_app_index) {
if (!base::IsStringASCII(value))
return ErrorCode::kApp_AppIdIsNotValid;
@@ -350,7 +350,7 @@
ErrorCode ParseInstallerData(base::StringPiece value,
TagArgs* args,
- absl::optional<size_t>* current_app_index) {
+ std::optional<size_t>* current_app_index) {
if (!current_app_index->has_value())
return ErrorCode::
kAppInstallerData_InstallerDataCannotBeSpecifiedBeforeAppId;
@@ -369,7 +369,7 @@
using ParseInstallerDataAttributeFunPtr =
ErrorCode (*)(base::StringPiece value,
TagArgs* args,
- absl::optional<size_t>* current_app_index);
+ std::optional<size_t>* current_app_index);
using InstallerDataParseTable = std::map<base::StringPiece,
ParseInstallerDataAttributeFunPtr,
@@ -481,7 +481,7 @@
ErrorCode ParseAppInstallerDataArgs(base::StringPiece app_installer_data_args,
TagArgs* args) {
// The currently tracked app index to apply installer data to.
- absl::optional<size_t> current_app_index;
+ std::optional<size_t> current_app_index;
// Installer data is assumed to be URL-encoded, so we don't unescape it.
bool unescape_value = false;
@@ -553,7 +553,7 @@
return buffer;
}
-absl::optional<tagging::TagArgs> ParseTagBuffer(
+std::optional<tagging::TagArgs> ParseTagBuffer(
const std::vector<uint8_t>& tag_buffer) {
if (tag_buffer.empty()) {
return {};
@@ -647,7 +647,7 @@
TagArgs& TagArgs::operator=(TagArgs&&) = default;
ErrorCode Parse(base::StringPiece tag,
- absl::optional<base::StringPiece> app_installer_data_args,
+ std::optional<base::StringPiece> app_installer_data_args,
TagArgs* args) {
if (!IsValidArgs(tag))
return ErrorCode::kTagIsInvalid;
@@ -780,13 +780,13 @@
std::string ExeReadTag(const base::FilePath& file) {
const std::vector<uint8_t> contents = ReadEntireFile(file);
- absl::optional<tagging::Binary> bin = Binary::Parse(contents);
+ std::optional<tagging::Binary> bin = Binary::Parse(contents);
if (!bin) {
LOG(ERROR) << __func__ << ": Could not parse binary: " << file;
return {};
}
- absl::optional<base::span<const uint8_t>> tag = bin->tag();
+ std::optional<base::span<const uint8_t>> tag = bin->tag();
if (!tag) {
LOG(ERROR) << __func__ << ": No superfluous certificate in file: " << file;
return {};
@@ -805,7 +805,7 @@
int padded_length,
const base::FilePath& out_file) {
const std::vector<uint8_t> contents = ReadEntireFile(in_file);
- absl::optional<tagging::Binary> bin = tagging::Binary::Parse(contents);
+ std::optional<tagging::Binary> bin = tagging::Binary::Parse(contents);
if (!bin) {
LOG(ERROR) << __func__ << ": Could not parse binary: " << in_file;
return false;
@@ -849,7 +849,7 @@
return true;
}
-absl::optional<tagging::TagArgs> MsiReadTag(const base::FilePath& filename) {
+std::optional<tagging::TagArgs> MsiReadTag(const base::FilePath& filename) {
return ParseTagBuffer(ReadFileTail(filename));
}
diff --git a/chrome/updater/tag.h b/chrome/updater/tag.h
index 6fda06c..8560dd2 100644
--- a/chrome/updater/tag.h
+++ b/chrome/updater/tag.h
@@ -6,13 +6,13 @@
#define CHROME_UPDATER_TAG_H_
#include <cstdint>
+#include <optional>
#include <ostream>
#include <string>
#include <vector>
#include "base/files/file_path.h"
#include "base/strings/string_piece.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace tagging {
@@ -69,7 +69,7 @@
std::string install_data_index;
std::string experiment_labels;
std::string untrusted_data;
- absl::optional<NeedsAdmin> needs_admin;
+ std::optional<NeedsAdmin> needs_admin;
};
std::ostream& operator<<(std::ostream&, const AppArgs::NeedsAdmin&);
@@ -105,9 +105,9 @@
std::string experiment_labels;
std::string referral_id;
std::string language;
- absl::optional<BrowserType> browser_type;
- absl::optional<bool> flighting = false;
- absl::optional<bool> usage_stats_enable;
+ std::optional<BrowserType> browser_type;
+ std::optional<bool> flighting = false;
+ std::optional<bool> usage_stats_enable;
// List of apps to install.
std::vector<AppArgs> apps;
@@ -242,7 +242,7 @@
//
// Note: This method assumes all attribute names are ASCII.
ErrorCode Parse(base::StringPiece tag,
- absl::optional<base::StringPiece> app_installer_data_args,
+ std::optional<base::StringPiece> app_installer_data_args,
TagArgs* args);
std::string ReadTag(std::vector<uint8_t>::const_iterator begin,
@@ -284,7 +284,7 @@
// | s t |
// +-----------------------------------------------------------------+
// Extracts a tag from the end of the MSI `filename`.
-absl::optional<tagging::TagArgs> MsiReadTag(const base::FilePath& filename);
+std::optional<tagging::TagArgs> MsiReadTag(const base::FilePath& filename);
// Tags `file` with `tag_string` and writes the result to `file` by default, or
// to `out_file` if `out_file` is provided.
diff --git a/chrome/updater/tag_unittest.cc b/chrome/updater/tag_unittest.cc
index 18f647a..e3b7c1d 100644
--- a/chrome/updater/tag_unittest.cc
+++ b/chrome/updater/tag_unittest.cc
@@ -5,6 +5,7 @@
#include "chrome/updater/tag.h"
#include <cstdint>
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -15,7 +16,6 @@
#include "base/strings/string_piece.h"
#include "chrome/updater/util/unit_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace {
@@ -120,7 +120,7 @@
void VerifyTagParseSuccess(
base::StringPiece tag,
- absl::optional<base::StringPiece> app_installer_data_args,
+ std::optional<base::StringPiece> app_installer_data_args,
const TagArgs& expected) {
TagArgs actual;
ASSERT_EQ(ErrorCode::kSuccess, Parse(tag, app_installer_data_args, &actual));
@@ -130,7 +130,7 @@
void VerifyTagParseFail(
base::StringPiece tag,
- absl::optional<base::StringPiece> app_installer_data_args,
+ std::optional<base::StringPiece> app_installer_data_args,
ErrorCode expected) {
TagArgs args;
ASSERT_EQ(expected, Parse(tag, app_installer_data_args, &args));
@@ -149,28 +149,28 @@
VerifyTagParseFail(
"appguid=D0324988-DA8A-49e5-BCE5-925FCD04EAB7&"
"appname1=Hello",
- absl::nullopt, ErrorCode::kUnrecognizedName);
+ std::nullopt, ErrorCode::kUnrecognizedName);
}
TEST(TagParserTest, AppNameSpaceForValue) {
VerifyTagParseFail(
"appguid=D0324988-DA8A-49e5-BCE5-925FCD04EAB7&"
"appname= ",
- absl::nullopt, ErrorCode::kAttributeMustHaveValue);
+ std::nullopt, ErrorCode::kAttributeMustHaveValue);
}
TEST(TagParserTest, AppNameEncodedSpaceForValue) {
VerifyTagParseFail(
"appguid=D0324988-DA8A-49e5-BCE5-925FCD04EAB7&"
"appname=%20",
- absl::nullopt, ErrorCode::kApp_AppNameCannotBeWhitespace);
+ std::nullopt, ErrorCode::kApp_AppNameCannotBeWhitespace);
}
TEST(TagParserTest, AppNameValid) {
VerifyTagParseSuccess(
"appguid=D0324988-DA8A-49e5-BCE5-925FCD04EAB7&"
"appname=Test",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithBundleName("Test")
.WithApp(AppArgsBuilder("d0324988-da8a-49e5-bce5-925fcd04eab7")
@@ -184,7 +184,7 @@
VerifyTagParseSuccess(
"appguid=D0324988-DA8A-49e5-BCE5-925FCD04EAB7&"
"appname=Test App",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithBundleName("Test App")
.WithApp(AppArgsBuilder("d0324988-da8a-49e5-bce5-925fcd04eab7")
@@ -197,7 +197,7 @@
VerifyTagParseSuccess(
"appguid=D0324988-DA8A-49e5-BCE5-925FCD04EAB7&"
"appname= T Ap p ",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithBundleName("T Ap p")
.WithApp(AppArgsBuilder("d0324988-da8a-49e5-bce5-925fcd04eab7")
@@ -210,7 +210,7 @@
VerifyTagParseSuccess(
"appguid=D0324988-DA8A-49e5-BCE5-925FCD04EAB7&"
"appname=%20T%20Ap%20p%20",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithBundleName("T Ap p")
.WithApp(AppArgsBuilder("d0324988-da8a-49e5-bce5-925fcd04eab7")
@@ -223,7 +223,7 @@
VerifyTagParseSuccess(
"appguid=D0324988-DA8A-49e5-BCE5-925FCD04EAB7&"
"appname= T Ap p",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithBundleName("T Ap p")
.WithApp(AppArgsBuilder("d0324988-da8a-49e5-bce5-925fcd04eab7")
@@ -237,7 +237,7 @@
VerifyTagParseSuccess(
"appguid=D0324988-DA8A-49e5-BCE5-925FCD04EAB7&"
"appname=%E0%A4%B0%E0%A4%B9%E0%A4%BE",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithBundleName(non_ascii_name)
.WithApp(AppArgsBuilder("d0324988-da8a-49e5-bce5-925fcd04eab7")
@@ -257,7 +257,7 @@
tag << "appguid=D0324988-DA8A-49e5-BCE5-925FCD04EAB7&";
tag << "appname=" << escaped;
VerifyTagParseSuccess(
- tag.str(), absl::nullopt,
+ tag.str(), std::nullopt,
TagArgsBuilder()
.WithBundleName(non_ascii_name)
.WithApp(AppArgsBuilder("d0324988-da8a-49e5-bce5-925fcd04eab7")
@@ -268,7 +268,7 @@
TEST(TagParserTest, AppIdValid) {
VerifyTagParseSuccess(
- "appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B", absl::nullopt,
+ "appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B", std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -276,7 +276,7 @@
}
TEST(TagParserTest, AppIdNotASCII) {
- VerifyTagParseFail("appguid=रहा", absl::nullopt,
+ VerifyTagParseFail("appguid=रहा", std::nullopt,
ErrorCode::kApp_AppIdIsNotValid);
}
@@ -284,13 +284,13 @@
// strings.
TEST(TagParserTest, AppIdNotAGuid) {
VerifyTagParseSuccess(
- "appguid=non-guid-id", absl::nullopt,
+ "appguid=non-guid-id", std::nullopt,
TagArgsBuilder().WithApp(AppArgsBuilder("non-guid-id").Build()).Build());
}
TEST(TagParserTest, AppIdCaseInsensitive) {
VerifyTagParseSuccess(
- "appguid=ShouldBeCaseInsensitive", absl::nullopt,
+ "appguid=ShouldBeCaseInsensitive", std::nullopt,
TagArgsBuilder()
.WithApp(AppArgsBuilder("shouldbecaseinsensitive").Build())
.Build());
@@ -300,21 +300,21 @@
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"needsadmin=Hello",
- absl::nullopt, ErrorCode::kApp_NeedsAdminValueIsInvalid);
+ std::nullopt, ErrorCode::kApp_NeedsAdminValueIsInvalid);
}
TEST(TagParserTest, NeedsAdminSpaceForValue) {
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"needsadmin= ",
- absl::nullopt, ErrorCode::kAttributeMustHaveValue);
+ std::nullopt, ErrorCode::kAttributeMustHaveValue);
}
TEST(TagParserTest, NeedsAdminTrueUpperCaseT) {
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"needsadmin=True",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b")
.WithNeedsAdmin(AppArgs::NeedsAdmin::kYes)
@@ -326,7 +326,7 @@
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"needsadmin=true",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b")
.WithNeedsAdmin(AppArgs::NeedsAdmin::kYes)
@@ -338,7 +338,7 @@
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"needsadmin=False",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b")
.WithNeedsAdmin(AppArgs::NeedsAdmin::kNo)
@@ -350,7 +350,7 @@
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"needsadmin=false",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b")
.WithNeedsAdmin(AppArgs::NeedsAdmin::kNo)
@@ -363,42 +363,42 @@
//
TEST(TagParserTest, AssignmentOnly) {
- VerifyTagParseFail("=", absl::nullopt, ErrorCode::kUnrecognizedName);
+ VerifyTagParseFail("=", std::nullopt, ErrorCode::kUnrecognizedName);
}
TEST(TagParserTest, ExtraAssignment1) {
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=1=",
- absl::nullopt, ErrorCode::kGlobal_UsageStatsValueIsInvalid);
+ std::nullopt, ErrorCode::kGlobal_UsageStatsValueIsInvalid);
}
TEST(TagParserTest, ExtraAssignment2) {
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"=usagestats=1",
- absl::nullopt, ErrorCode::kUnrecognizedName);
+ std::nullopt, ErrorCode::kUnrecognizedName);
}
TEST(TagParserTest, ExtraAssignment3) {
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=1&=",
- absl::nullopt, ErrorCode::kUnrecognizedName);
+ std::nullopt, ErrorCode::kUnrecognizedName);
}
TEST(TagParserTest, ExtraAssignment4) {
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"=&usagestats=1",
- absl::nullopt, ErrorCode::kUnrecognizedName);
+ std::nullopt, ErrorCode::kUnrecognizedName);
}
TEST(TagParserTest, ValueWithoutName) {
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"=hello",
- absl::nullopt, ErrorCode::kUnrecognizedName);
+ std::nullopt, ErrorCode::kUnrecognizedName);
}
// Also tests ending extra arguments with '='.
@@ -406,28 +406,28 @@
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=",
- absl::nullopt, ErrorCode::kAttributeMustHaveValue);
+ std::nullopt, ErrorCode::kAttributeMustHaveValue);
}
TEST(TagParserTest, NameWithoutValueBeforeNextArgument) {
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=&client=hello",
- absl::nullopt, ErrorCode::kAttributeMustHaveValue);
+ std::nullopt, ErrorCode::kAttributeMustHaveValue);
}
TEST(TagParserTest, NameWithoutArgumentSeparatorAfterIntValue) {
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=1client=hello",
- absl::nullopt, ErrorCode::kGlobal_UsageStatsValueIsInvalid);
+ std::nullopt, ErrorCode::kGlobal_UsageStatsValueIsInvalid);
}
TEST(TagParserTest, NameWithoutArgumentSeparatorAfterStringValue) {
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=yesclient=hello",
- absl::nullopt, ErrorCode::kGlobal_UsageStatsValueIsInvalid);
+ std::nullopt, ErrorCode::kGlobal_UsageStatsValueIsInvalid);
}
TEST(TagParserTest, TagHasDoubleAmpersand) {
@@ -446,14 +446,14 @@
}
TEST(TagParserTest, TagAmpersandOnly) {
- VerifyTagParseSuccess("&", absl::nullopt, TagArgsBuilder().Build());
+ VerifyTagParseSuccess("&", std::nullopt, TagArgsBuilder().Build());
}
TEST(TagParserTest, TagBeginsInAmpersand) {
VerifyTagParseSuccess(
"&appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=1",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -465,7 +465,7 @@
VerifyTagParseSuccess(
"&appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=1&",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -475,7 +475,7 @@
TEST(TagParserTest, WhitespaceOnly) {
for (const auto* whitespace : {"", " ", "\t", "\r", "\n", "\r\n"}) {
- VerifyTagParseSuccess(whitespace, absl::nullopt, TagArgsBuilder().Build());
+ VerifyTagParseSuccess(whitespace, std::nullopt, TagArgsBuilder().Build());
}
}
@@ -487,7 +487,7 @@
VerifyTagParseSuccess(
"&appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=1",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -499,7 +499,7 @@
VerifyTagParseSuccess(
"&appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=1&client=hello",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -512,49 +512,49 @@
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=1/other_value=9",
- absl::nullopt, ErrorCode::kTagIsInvalid);
+ std::nullopt, ErrorCode::kTagIsInvalid);
}
TEST(TagParserTest, TagHasDoubleQuoteInTheMiddle) {
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=1\"/other_value=9",
- absl::nullopt, ErrorCode::kTagIsInvalid);
+ std::nullopt, ErrorCode::kTagIsInvalid);
}
TEST(TagParserTest, TagHasDoubleQuoteInTheMiddleAndNoForwardSlash) {
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=1\"other_value=9",
- absl::nullopt, ErrorCode::kGlobal_UsageStatsValueIsInvalid);
+ std::nullopt, ErrorCode::kGlobal_UsageStatsValueIsInvalid);
}
TEST(TagParserTest, TagHasSpaceAndForwardSlashBeforeQuote) {
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=1 /other_value=9",
- absl::nullopt, ErrorCode::kTagIsInvalid);
+ std::nullopt, ErrorCode::kTagIsInvalid);
}
TEST(TagParserTest, TagHasForwardSlashBeforeQuote) {
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=1/other_value=9",
- absl::nullopt, ErrorCode::kTagIsInvalid);
+ std::nullopt, ErrorCode::kTagIsInvalid);
}
TEST(TagParserTest, AttributeSpecifiedTwice) {
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=1\" \"client=10",
- absl::nullopt, ErrorCode::kGlobal_UsageStatsValueIsInvalid);
+ std::nullopt, ErrorCode::kGlobal_UsageStatsValueIsInvalid);
}
TEST(TagParserTest, WhiteSpaceBeforeArgs1) {
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
" usagestats=1",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617EE50-F91C-4DC1-B937-0969EEF59B0B").Build())
@@ -566,7 +566,7 @@
VerifyTagParseSuccess(
"\tappguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=1",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617EE50-F91C-4DC1-B937-0969EEF59B0B").Build())
@@ -578,7 +578,7 @@
VerifyTagParseSuccess(
"\rappguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=1",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617EE50-F91C-4DC1-B937-0969EEF59B0B").Build())
@@ -590,7 +590,7 @@
VerifyTagParseSuccess(
"\nappguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B"
"&usagestats=1",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617EE50-F91C-4DC1-B937-0969EEF59B0B").Build())
@@ -599,31 +599,31 @@
}
TEST(TagParserTest, WhiteSpaceBeforeArgs5) {
- VerifyTagParseSuccess("\r\nusagestats=1", absl::nullopt,
+ VerifyTagParseSuccess("\r\nusagestats=1", std::nullopt,
TagArgsBuilder().WithUsageStatsEnable(true).Build());
}
TEST(TagParserTest, ForwardSlash1) {
- VerifyTagParseFail("/", absl::nullopt, ErrorCode::kTagIsInvalid);
+ VerifyTagParseFail("/", std::nullopt, ErrorCode::kTagIsInvalid);
}
TEST(TagParserTest, ForwardSlash2) {
VerifyTagParseFail("/ appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B",
- absl::nullopt, ErrorCode::kTagIsInvalid);
+ std::nullopt, ErrorCode::kTagIsInvalid);
}
TEST(TagParserTest, BackwardSlash1) {
- VerifyTagParseFail("\\", absl::nullopt, ErrorCode::kUnrecognizedName);
+ VerifyTagParseFail("\\", std::nullopt, ErrorCode::kUnrecognizedName);
}
TEST(TagParserTest, BackwardSlash2) {
VerifyTagParseFail("\\appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B",
- absl::nullopt, ErrorCode::kUnrecognizedName);
+ std::nullopt, ErrorCode::kUnrecognizedName);
}
TEST(TagParserTest, BackwardSlash3) {
VerifyTagParseFail("\\ appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B",
- absl::nullopt, ErrorCode::kUnrecognizedName);
+ std::nullopt, ErrorCode::kUnrecognizedName);
}
TEST(TagParserTest, AppArgsMustHaveValue) {
@@ -634,7 +634,7 @@
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&needsadmin",
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&installdataindex",
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&untrusteddata"}) {
- VerifyTagParseFail(tag, absl::nullopt, ErrorCode::kAttributeMustHaveValue);
+ VerifyTagParseFail(tag, std::nullopt, ErrorCode::kAttributeMustHaveValue);
}
}
@@ -646,14 +646,14 @@
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"/usagestats",
- absl::nullopt, ErrorCode::kTagIsInvalid);
+ std::nullopt, ErrorCode::kTagIsInvalid);
}
TEST(TagParserTest, UsageStatsOn) {
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=1",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -665,7 +665,7 @@
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=0",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -677,7 +677,7 @@
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=2",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -688,28 +688,28 @@
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=3",
- absl::nullopt, ErrorCode::kGlobal_UsageStatsValueIsInvalid);
+ std::nullopt, ErrorCode::kGlobal_UsageStatsValueIsInvalid);
}
TEST(TagParserTest, UsageStatsInvalidNegativeValue) {
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=-1",
- absl::nullopt, ErrorCode::kGlobal_UsageStatsValueIsInvalid);
+ std::nullopt, ErrorCode::kGlobal_UsageStatsValueIsInvalid);
}
TEST(TagParserTest, UsageStatsValueIsString) {
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"usagestats=true",
- absl::nullopt, ErrorCode::kGlobal_UsageStatsValueIsInvalid);
+ std::nullopt, ErrorCode::kGlobal_UsageStatsValueIsInvalid);
}
TEST(TagParserTest, BundleNameValid) {
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"bundlename=Google%20Bundle",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -722,21 +722,21 @@
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"bundlename= ",
- absl::nullopt, ErrorCode::kAttributeMustHaveValue);
+ std::nullopt, ErrorCode::kAttributeMustHaveValue);
}
TEST(TagParserTest, BundleNameEncodedSpaceForValue) {
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"bundlename=%20",
- absl::nullopt, ErrorCode::kGlobal_BundleNameCannotBeWhitespace);
+ std::nullopt, ErrorCode::kGlobal_BundleNameCannotBeWhitespace);
}
TEST(TagParserTest, BundleNameNotPresentButAppNameIs) {
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"appname=Google%20Chrome",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b")
.WithAppName("Google Chrome")
@@ -746,7 +746,7 @@
}
TEST(TagParserTest, BundleNameNorAppNamePresent) {
VerifyTagParseSuccess(
- "appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&", absl::nullopt,
+ "appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&", std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -755,7 +755,7 @@
TEST(TagParserTest, BundleNameNotPresentAndNoApp) {
VerifyTagParseSuccess(
- "browser=0", absl::nullopt,
+ "browser=0", std::nullopt,
TagArgsBuilder().WithBrowserType(TagArgs::BrowserType::kUnknown).Build());
}
@@ -763,7 +763,7 @@
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"iid=98CEC468-9429-4984-AEDE-4F53C6A14869",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -775,7 +775,7 @@
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"iid=रहा",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -787,7 +787,7 @@
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"brand=GOOG",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -799,7 +799,7 @@
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"client=some_partner",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -811,7 +811,7 @@
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"omahaexperiments=experiment%3DgroupA%7Cexpir",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -823,21 +823,21 @@
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"omahaexperiments= ",
- absl::nullopt, ErrorCode::kAttributeMustHaveValue);
+ std::nullopt, ErrorCode::kAttributeMustHaveValue);
}
TEST(TagParserTest, UpdaterExperimentIdEncodedSpaceForValue) {
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"omahaexperiments=%20",
- absl::nullopt, ErrorCode::kGlobal_ExperimentLabelsCannotBeWhitespace);
+ std::nullopt, ErrorCode::kGlobal_ExperimentLabelsCannotBeWhitespace);
}
TEST(TagParserTest, AppExperimentIdValid) {
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"experiments=experiment%3DgroupA%7Cexpir",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b")
.WithExperimentLabels("experiment=groupA|expir")
@@ -849,21 +849,21 @@
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"experiments= ",
- absl::nullopt, ErrorCode::kAttributeMustHaveValue);
+ std::nullopt, ErrorCode::kAttributeMustHaveValue);
}
TEST(TagParserTest, AppExperimentIdEncodedSpaceForValue) {
VerifyTagParseFail(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"experiments=%20",
- absl::nullopt, ErrorCode::kApp_ExperimentLabelsCannotBeWhitespace);
+ std::nullopt, ErrorCode::kApp_ExperimentLabelsCannotBeWhitespace);
}
TEST(TagParserTest, ReferralIdValid) {
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"referral=ABCD123",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -875,7 +875,7 @@
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"ap=developer",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b")
.WithAp("developer")
@@ -915,14 +915,14 @@
"appname=TestApp2&"
"needsadmin=true&"
"installerdata=Hello%20World",
- absl::nullopt, ErrorCode::kUnrecognizedName);
+ std::nullopt, ErrorCode::kUnrecognizedName);
}
TEST(TagParserTest, InstallDataIndexValid) {
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"installdataindex=foobar",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b")
.WithInstallDataIndex("foobar")
@@ -945,7 +945,7 @@
tag << "appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&";
tag << "browser=" << std::get<0>(pair);
VerifyTagParseSuccess(
- tag.str(), absl::nullopt,
+ tag.str(), std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -962,7 +962,7 @@
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"browser=5",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -972,7 +972,7 @@
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"browser=9",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -984,7 +984,7 @@
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"lang=en",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -997,7 +997,7 @@
VerifyTagParseSuccess(
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"lang=foobar",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(
AppArgsBuilder("8617ee50-f91c-4dc1-b937-0969eef59b0b").Build())
@@ -1010,7 +1010,7 @@
"appguid=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"appname=TestApp&"
"appname=TestApp2&",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(AppArgsBuilder("8617EE50-F91C-4DC1-B937-0969EEF59B0B")
.WithAppName("TestApp2")
@@ -1023,7 +1023,7 @@
VerifyTagParseSuccess(
"APPguID=8617EE50-F91C-4DC1-B937-0969EEF59B0B&"
"APPNAME=TestApp&",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(AppArgsBuilder("8617EE50-F91C-4DC1-B937-0969EEF59B0B")
.WithAppName("TestApp")
@@ -1036,7 +1036,7 @@
VerifyTagParseSuccess(
"appguid=%7B8617EE50-F91C-4DC1-B937-0969EEF59B0B%7D&"
"appname=TestApp&",
- absl::nullopt,
+ std::nullopt,
TagArgsBuilder()
.WithApp(AppArgsBuilder("{8617EE50-F91C-4DC1-B937-0969EEF59B0B}")
.WithAppName("TestApp")
@@ -1058,7 +1058,7 @@
"ap=test_ap&"
"usagestats=1&"
"browser=2&",
- absl::nullopt, ErrorCode::kApp_AppIdNotSpecified);
+ std::nullopt, ErrorCode::kApp_AppIdNotSpecified);
}
// This also tests that the last occurrence of a global extra arg is the one
@@ -1234,7 +1234,7 @@
struct MsiTagTestMsiReadTagTestCase {
const std::string msi_file_name;
- const absl::optional<tagging::TagArgs> expected_tag_args;
+ const std::optional<tagging::TagArgs> expected_tag_args;
};
class MsiTagTestMsiReadTagTest
diff --git a/chrome/updater/test/integration_test_commands.h b/chrome/updater/test/integration_test_commands.h
index b8e1f01..2553f6b 100644
--- a/chrome/updater/test/integration_test_commands.h
+++ b/chrome/updater/test/integration_test_commands.h
@@ -12,7 +12,6 @@
#include "build/build_config.h"
#include "chrome/updater/test/integration_tests_impl.h"
#include "chrome/updater/update_service.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
class GURL;
diff --git a/chrome/updater/test/integration_test_commands_system.cc b/chrome/updater/test/integration_test_commands_system.cc
index d940b10..9c5d1ce 100644
--- a/chrome/updater/test/integration_test_commands_system.cc
+++ b/chrome/updater/test/integration_test_commands_system.cc
@@ -4,6 +4,7 @@
#include <cstdlib>
#include <memory>
+#include <optional>
#include <string>
#include <vector>
@@ -30,7 +31,6 @@
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/util/util.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
#if BUILDFLAG(IS_WIN)
@@ -65,7 +65,7 @@
void PrintLog() const override { RunCommand("print_log"); }
void CopyLog() const override {
- const absl::optional<base::FilePath> path =
+ const std::optional<base::FilePath> path =
GetInstallDirectory(updater_scope_);
ASSERT_TRUE(path);
if (path)
diff --git a/chrome/updater/test/integration_test_commands_user.cc b/chrome/updater/test/integration_test_commands_user.cc
index bb4aaa6..c884639 100644
--- a/chrome/updater/test/integration_test_commands_user.cc
+++ b/chrome/updater/test/integration_test_commands_user.cc
@@ -4,6 +4,7 @@
#include <cstdlib>
#include <memory>
+#include <optional>
#include <string>
#include "base/files/file_path.h"
@@ -20,7 +21,6 @@
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/util/util.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
namespace updater {
@@ -37,7 +37,7 @@
void PrintLog() const override { updater::test::PrintLog(updater_scope_); }
void CopyLog() const override {
- absl::optional<base::FilePath> path = GetInstallDirectory(updater_scope_);
+ std::optional<base::FilePath> path = GetInstallDirectory(updater_scope_);
EXPECT_TRUE(path);
if (path)
updater::test::CopyLog(*path);
diff --git a/chrome/updater/test/integration_tests.cc b/chrome/updater/test/integration_tests.cc
index b93bb15..074a69f 100644
--- a/chrome/updater/test/integration_tests.cc
+++ b/chrome/updater/test/integration_tests.cc
@@ -4,6 +4,7 @@
#include <cstdlib>
#include <memory>
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -52,7 +53,6 @@
#include "components/policy/proto/device_management_backend.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/abseil-cpp/absl/cleanup/cleanup.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
#if BUILDFLAG(IS_LINUX)
@@ -766,7 +766,7 @@
// Waking the new version should clean up the old.
ASSERT_NO_FATAL_FAILURE(RunWake(0));
ASSERT_TRUE(WaitForUpdaterExit());
- absl::optional<base::FilePath> path = GetInstallDirectory(GetTestScope());
+ std::optional<base::FilePath> path = GetInstallDirectory(GetTestScope());
ASSERT_TRUE(path);
int dirs = 0;
base::FileEnumerator(*path, false, base::FileEnumerator::DIRECTORIES)
@@ -1695,7 +1695,7 @@
// Delete the dmp files generated by this test, so `ExpectNoCrashes` won't
// complain at TearDown.
- absl::optional<base::FilePath> database_path(
+ std::optional<base::FilePath> database_path(
GetCrashDatabasePath(GetTestScope()));
if (database_path && base::PathExists(*database_path)) {
base::FileEnumerator(*database_path, true, base::FileEnumerator::FILES,
diff --git a/chrome/updater/test/integration_tests_helper.cc b/chrome/updater/test/integration_tests_helper.cc
index 8b85fdb2..207b78f 100644
--- a/chrome/updater/test/integration_tests_helper.cc
+++ b/chrome/updater/test/integration_tests_helper.cc
@@ -4,6 +4,7 @@
#include <iostream>
#include <map>
+#include <optional>
#include <string>
#include <utility>
@@ -34,7 +35,6 @@
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/util/unit_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
#if BUILDFLAG(IS_WIN)
@@ -59,7 +59,7 @@
constexpr int kBadCommand = 102;
base::Value ValueFromString(const std::string& values) {
- absl::optional<base::Value> results_value = base::JSONReader::Read(values);
+ std::optional<base::Value> results_value = base::JSONReader::Read(values);
EXPECT_TRUE(results_value);
return results_value->Clone();
}
diff --git a/chrome/updater/test/integration_tests_impl.cc b/chrome/updater/test/integration_tests_impl.cc
index 5880df5..96a0cf9 100644
--- a/chrome/updater/test/integration_tests_impl.cc
+++ b/chrome/updater/test/integration_tests_impl.cc
@@ -7,6 +7,7 @@
#include <cstdint>
#include <cstdlib>
#include <memory>
+#include <optional>
#include <set>
#include <string>
#include <utility>
@@ -68,7 +69,6 @@
#include "crypto/secure_hash.h"
#include "crypto/sha2.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/re2/src/re2/re2.h"
#if BUILDFLAG(IS_WIN)
@@ -118,7 +118,7 @@
const base::FilePath& update_file,
const std::string& run_action,
const std::string& arguments,
- const absl::optional<std::string>& file_hash = absl::nullopt) {
+ const std::optional<std::string>& file_hash = std::nullopt) {
return base::StringPrintf(
R"( {)"
R"( "appid":"%s",)"
@@ -193,8 +193,8 @@
void RunUpdaterWithSwitch(const base::Version& version,
UpdaterScope scope,
const std::string& command,
- absl::optional<int> expected_exit_code) {
- const absl::optional<base::FilePath> installed_executable_path =
+ std::optional<int> expected_exit_code) {
+ const std::optional<base::FilePath> installed_executable_path =
GetVersionedInstallDirectory(scope, version)
->Append(GetExecutableRelativePath());
ASSERT_TRUE(installed_executable_path);
@@ -457,7 +457,7 @@
void PrintLog(UpdaterScope scope) {
std::string contents;
- absl::optional<base::FilePath> path = GetInstallDirectory(scope);
+ std::optional<base::FilePath> path = GetInstallDirectory(scope);
EXPECT_TRUE(path);
if (path &&
base::ReadFileToString(path->AppendASCII("updater.log"), &contents)) {
@@ -499,7 +499,7 @@
}
void ExpectNoCrashes(UpdaterScope scope) {
- absl::optional<base::FilePath> database_path(GetCrashDatabasePath(scope));
+ std::optional<base::FilePath> database_path(GetCrashDatabasePath(scope));
if (!database_path || !base::PathExists(*database_path)) {
return;
}
@@ -648,11 +648,11 @@
void RunCrashMe(UpdaterScope scope) {
RunUpdaterWithSwitch(base::Version(kUpdaterVersion), scope, kCrashMeSwitch,
- absl::nullopt);
+ std::nullopt);
}
void RunServer(UpdaterScope scope, int expected_exit_code, bool internal) {
- const absl::optional<base::FilePath> installed_executable_path =
+ const std::optional<base::FilePath> installed_executable_path =
GetVersionedInstallDirectory(scope, base::Version(kUpdaterVersion))
->Append(GetExecutableRelativePath());
ASSERT_TRUE(installed_executable_path);
@@ -734,7 +734,7 @@
EXPECT_EQ(final_update_state.p, *_state_member); \
}
#define CHECK_STATE_MEMBER_INT(p) \
- if (const absl::optional<int> _state_member = \
+ if (const std::optional<int> _state_member = \
expected_update_state->FindInt(#p); \
_state_member) { \
EXPECT_EQ(static_cast<int>(final_update_state.p), *_state_member); \
@@ -763,7 +763,7 @@
#undef CHECK_STATE_MEMBER_STRING
}
- if (const absl::optional<int> expected_result =
+ if (const std::optional<int> expected_result =
expected_final_values.FindInt("expected_result");
expected_result) {
EXPECT_EQ(static_cast<int>(final_result), *expected_result);
@@ -811,7 +811,7 @@
}
void DeleteUpdaterDirectory(UpdaterScope scope) {
- absl::optional<base::FilePath> install_dir = GetInstallDirectory(scope);
+ std::optional<base::FilePath> install_dir = GetInstallDirectory(scope);
ASSERT_TRUE(install_dir);
ASSERT_TRUE(base::DeletePathRecursively(*install_dir));
}
@@ -825,7 +825,7 @@
ASSERT_TRUE(active_version.IsValid()) << "No active updater.";
}
- absl::optional<base::FilePath> exe_path =
+ std::optional<base::FilePath> exe_path =
GetUpdaterExecutablePath(scope, active_version);
ASSERT_TRUE(exe_path.has_value())
<< "No path for active updater. Version: " << active_version;
@@ -833,7 +833,7 @@
#if BUILDFLAG(IS_LINUX)
// On Linux, a qualified service makes a full copy of itself, so we have to
// delete the copy that systemd uses too.
- absl::optional<base::FilePath> launcher_path =
+ std::optional<base::FilePath> launcher_path =
GetUpdateServiceLauncherPath(GetTestScope());
ASSERT_TRUE(launcher_path.has_value()) << "No launcher path.";
DeleteFile(*launcher_path);
@@ -878,7 +878,7 @@
}
void FillLog(UpdaterScope scope) {
- absl::optional<base::FilePath> log = GetLogFilePath(scope);
+ std::optional<base::FilePath> log = GetLogFilePath(scope);
ASSERT_TRUE(log);
std::string data = "This test string is used to fill up log space.\n";
for (int i = 0; i < 1024 * 1024 * 3; i += data.length()) {
@@ -887,7 +887,7 @@
}
void ExpectLogRotated(UpdaterScope scope) {
- absl::optional<base::FilePath> log = GetLogFilePath(scope);
+ std::optional<base::FilePath> log = GetLogFilePath(scope);
ASSERT_TRUE(log);
EXPECT_TRUE(base::PathExists(log->AddExtension(FILE_PATH_LITERAL(".old"))));
int64_t size = 0;
diff --git a/chrome/updater/test/integration_tests_impl.h b/chrome/updater/test/integration_tests_impl.h
index e427c75b..2149a1a 100644
--- a/chrome/updater/test/integration_tests_impl.h
+++ b/chrome/updater/test/integration_tests_impl.h
@@ -5,6 +5,7 @@
#ifndef CHROME_UPDATER_TEST_INTEGRATION_TESTS_IMPL_H_
#define CHROME_UPDATER_TEST_INTEGRATION_TESTS_IMPL_H_
+#include <optional>
#include <set>
#include <string>
#include <vector>
@@ -16,7 +17,6 @@
#include "build/build_config.h"
#include "chrome/updater/test/server.h"
#include "chrome/updater/update_service.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
class GURL;
@@ -218,7 +218,7 @@
int* exit_code = nullptr);
// Returns the path of the Updater executable.
-absl::optional<base::FilePath> GetInstalledExecutablePath(UpdaterScope scope);
+std::optional<base::FilePath> GetInstalledExecutablePath(UpdaterScope scope);
// Sets up a fake updater on the system at a version lower than the test.
void SetupFakeUpdaterLowerVersion(UpdaterScope scope);
diff --git a/chrome/updater/test/integration_tests_linux.cc b/chrome/updater/test/integration_tests_linux.cc
index 193b75b..151a0e3 100644
--- a/chrome/updater/test/integration_tests_linux.cc
+++ b/chrome/updater/test/integration_tests_linux.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <optional>
#include <string>
#include "base/base_paths.h"
@@ -37,7 +38,6 @@
#include "chrome/updater/util/util.h"
#include "components/crx_file/crx_verifier.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
namespace updater::test {
@@ -51,7 +51,7 @@
}
} // namespace
-absl::optional<base::FilePath> GetFakeUpdaterInstallFolderPath(
+std::optional<base::FilePath> GetFakeUpdaterInstallFolderPath(
UpdaterScope scope,
const base::Version& version) {
return GetVersionedInstallDirectory(scope, version);
@@ -62,10 +62,10 @@
return GetExecutablePath();
}
-absl::optional<base::FilePath> GetInstalledExecutablePath(UpdaterScope scope) {
- absl::optional<base::FilePath> path = GetVersionedInstallDirectory(scope);
+std::optional<base::FilePath> GetInstalledExecutablePath(UpdaterScope scope) {
+ std::optional<base::FilePath> path = GetVersionedInstallDirectory(scope);
if (!path) {
- return absl::nullopt;
+ return std::nullopt;
}
return path->Append(GetExecutableRelativePath());
}
@@ -81,7 +81,7 @@
}
void Uninstall(UpdaterScope scope) {
- absl::optional<base::FilePath> path = GetExecutablePath();
+ std::optional<base::FilePath> path = GetExecutablePath();
ASSERT_TRUE(path);
base::CommandLine command_line(*path);
command_line.AppendSwitch(kUninstallSwitch);
@@ -91,7 +91,7 @@
}
void ExpectCandidateUninstalled(UpdaterScope scope) {
- absl::optional<base::FilePath> path = GetVersionedInstallDirectory(scope);
+ std::optional<base::FilePath> path = GetVersionedInstallDirectory(scope);
EXPECT_TRUE(path);
if (path) {
EXPECT_FALSE(base::PathExists(*path));
@@ -99,7 +99,7 @@
}
void ExpectInstalled(UpdaterScope scope) {
- absl::optional<base::FilePath> path = GetInstalledExecutablePath(scope);
+ std::optional<base::FilePath> path = GetInstalledExecutablePath(scope);
EXPECT_TRUE(path);
if (path) {
EXPECT_TRUE(base::PathExists(*path));
@@ -107,7 +107,7 @@
}
void Clean(UpdaterScope scope) {
- absl::optional<base::FilePath> path = GetInstallDirectory(scope);
+ std::optional<base::FilePath> path = GetInstallDirectory(scope);
EXPECT_TRUE(path);
if (path) {
EXPECT_TRUE(base::DeletePathRecursively(*path));
@@ -120,7 +120,7 @@
// itself, because it uses the prefs file and writes the log file while it
// is operating. If the provided path exists, it must be a directory with
// only these residual files present to be considered "clean".
-void ExpectMostlyClean(const absl::optional<base::FilePath>& path) {
+void ExpectMostlyClean(const std::optional<base::FilePath>& path) {
EXPECT_TRUE(path);
if (!path || !base::PathExists(*path)) {
return;
@@ -162,7 +162,7 @@
}
void SetActive(UpdaterScope scope, const std::string& app_id) {
- const absl::optional<base::FilePath> path =
+ const std::optional<base::FilePath> path =
GetActiveFile(base::GetHomeDir(), app_id);
ASSERT_TRUE(path);
base::File::Error err = base::File::FILE_OK;
@@ -172,7 +172,7 @@
}
void ExpectActive(UpdaterScope scope, const std::string& app_id) {
- const absl::optional<base::FilePath> path =
+ const std::optional<base::FilePath> path =
GetActiveFile(base::GetHomeDir(), app_id);
ASSERT_TRUE(path);
EXPECT_TRUE(base::PathExists(*path));
@@ -180,7 +180,7 @@
}
void ExpectNotActive(UpdaterScope scope, const std::string& app_id) {
- const absl::optional<base::FilePath> path =
+ const std::optional<base::FilePath> path =
GetActiveFile(base::GetHomeDir(), app_id);
ASSERT_TRUE(path);
EXPECT_FALSE(base::PathExists(*path));
diff --git a/chrome/updater/test/integration_tests_mac.mm b/chrome/updater/test/integration_tests_mac.mm
index 4ddaac4..0607e88 100644
--- a/chrome/updater/test/integration_tests_mac.mm
+++ b/chrome/updater/test/integration_tests_mac.mm
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <stdint.h>
+#include <cstdint>
+#include <optional>
#include <string>
#include <vector>
@@ -43,7 +44,6 @@
#include "chrome/updater/util/util.h"
#include "components/crx_file/crx_verifier.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
namespace updater::test {
@@ -56,13 +56,13 @@
return out_dir.Append(GetExecutableRelativePath());
}
-absl::optional<base::FilePath> GetActiveFile(UpdaterScope /*scope*/,
- const std::string& id) {
+std::optional<base::FilePath> GetActiveFile(UpdaterScope /*scope*/,
+ const std::string& id) {
// The active user is always managed in the updater scope for the user.
- const absl::optional<base::FilePath> path =
+ const std::optional<base::FilePath> path =
GetLibraryFolderPath(UpdaterScope::kUser);
if (!path)
- return absl::nullopt;
+ return std::nullopt;
return path->AppendASCII(COMPANY_SHORTNAME_STRING)
.AppendASCII(COMPANY_SHORTNAME_STRING "SoftwareUpdate")
@@ -97,7 +97,7 @@
void Clean(UpdaterScope scope) {
CleanProcesses();
- absl::optional<base::FilePath> path = GetInstallDirectory(scope);
+ std::optional<base::FilePath> path = GetInstallDirectory(scope);
EXPECT_TRUE(path);
if (path) {
EXPECT_TRUE(base::DeletePathRecursively(*path));
@@ -110,13 +110,13 @@
EXPECT_TRUE(base::DeletePathRecursively(*path));
}
- absl::optional<base::FilePath> keystone_path = GetKeystoneFolderPath(scope);
+ std::optional<base::FilePath> keystone_path = GetKeystoneFolderPath(scope);
EXPECT_TRUE(keystone_path);
if (keystone_path) {
EXPECT_TRUE(base::DeletePathRecursively(*keystone_path));
}
- absl::optional<base::FilePath> cache_path = GetCacheBaseDirectory(scope);
+ std::optional<base::FilePath> cache_path = GetCacheBaseDirectory(scope);
EXPECT_TRUE(cache_path);
if (cache_path) {
EXPECT_TRUE(base::DeletePathRecursively(*cache_path));
@@ -149,13 +149,13 @@
// Caches must have been removed. On Mac, this is separate from other
// updater directories, so we can reliably remove it completely.
- absl::optional<base::FilePath> cache_path = GetCacheBaseDirectory(scope);
+ std::optional<base::FilePath> cache_path = GetCacheBaseDirectory(scope);
EXPECT_TRUE(cache_path);
if (cache_path) {
EXPECT_FALSE(base::PathExists(*cache_path));
}
- absl::optional<base::FilePath> path = GetInstallDirectory(scope);
+ std::optional<base::FilePath> path = GetInstallDirectory(scope);
EXPECT_TRUE(path);
if (path && base::PathExists(*path)) {
// If the path exists, then expect only the log and json files to be
@@ -178,7 +178,7 @@
}
}
// Keystone must not exist on the file system.
- absl::optional<base::FilePath> keystone_path = GetKeystoneFolderPath(scope);
+ std::optional<base::FilePath> keystone_path = GetKeystoneFolderPath(scope);
EXPECT_TRUE(keystone_path);
if (keystone_path) {
EXPECT_FALSE(
@@ -187,7 +187,7 @@
}
void ExpectInstalled(UpdaterScope scope) {
- absl::optional<base::FilePath> keystone_path = GetKeystoneFolderPath(scope);
+ std::optional<base::FilePath> keystone_path = GetKeystoneFolderPath(scope);
ASSERT_TRUE(keystone_path);
// Files must exist on the file system.
@@ -200,19 +200,19 @@
EXPECT_TRUE(base::PathExists(*GetWakeTaskPlistPath(scope)));
}
-absl::optional<base::FilePath> GetInstalledExecutablePath(UpdaterScope scope) {
+std::optional<base::FilePath> GetInstalledExecutablePath(UpdaterScope scope) {
return GetUpdaterExecutablePath(scope);
}
void ExpectCandidateUninstalled(UpdaterScope scope) {
- absl::optional<base::FilePath> versioned_folder_path =
+ std::optional<base::FilePath> versioned_folder_path =
GetVersionedInstallDirectory(scope);
ASSERT_TRUE(versioned_folder_path);
EXPECT_FALSE(base::PathExists(*versioned_folder_path));
}
void Uninstall(UpdaterScope scope) {
- absl::optional<base::FilePath> path = GetExecutablePath();
+ std::optional<base::FilePath> path = GetExecutablePath();
ASSERT_TRUE(path);
base::CommandLine command_line(*path);
command_line.AppendSwitch(kUninstallSwitch);
@@ -222,7 +222,7 @@
}
void SetActive(UpdaterScope scope, const std::string& app_id) {
- const absl::optional<base::FilePath> path = GetActiveFile(scope, app_id);
+ const std::optional<base::FilePath> path = GetActiveFile(scope, app_id);
ASSERT_TRUE(path);
VLOG(0) << "Actives file: " << *path;
base::File::Error err = base::File::FILE_OK;
@@ -232,14 +232,14 @@
}
void ExpectActive(UpdaterScope scope, const std::string& app_id) {
- const absl::optional<base::FilePath> path = GetActiveFile(scope, app_id);
+ const std::optional<base::FilePath> path = GetActiveFile(scope, app_id);
ASSERT_TRUE(path);
EXPECT_TRUE(base::PathExists(*path));
EXPECT_TRUE(base::PathIsWritable(*path));
}
void ExpectNotActive(UpdaterScope scope, const std::string& app_id) {
- const absl::optional<base::FilePath> path = GetActiveFile(scope, app_id);
+ const std::optional<base::FilePath> path = GetActiveFile(scope, app_id);
ASSERT_TRUE(path);
EXPECT_FALSE(base::PathExists(*path));
EXPECT_FALSE(base::PathIsWritable(*path));
diff --git a/chrome/updater/test/integration_tests_win.cc b/chrome/updater/test/integration_tests_win.cc
index ac3cc28..0fa2157 100644
--- a/chrome/updater/test/integration_tests_win.cc
+++ b/chrome/updater/test/integration_tests_win.cc
@@ -11,6 +11,7 @@
#include <functional>
#include <iostream>
#include <memory>
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -82,7 +83,6 @@
#include "components/crx_file/crx_verifier.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
namespace updater::test {
@@ -397,7 +397,7 @@
});
}
- const absl::optional<base::FilePath> path =
+ const std::optional<base::FilePath> path =
GetVersionedInstallDirectory(scope, base::Version(kUpdaterVersion));
ASSERT_TRUE(path);
EXPECT_TRUE(WaitFor([&]() { return is_installed == base::PathExists(*path); },
@@ -619,7 +619,7 @@
EXPECT_TRUE(DeleteRegKey(root, app_client_state_key));
- const absl::optional<base::FilePath> updater_exe =
+ const std::optional<base::FilePath> updater_exe =
GetUpdaterExecutablePath(scope);
ASSERT_TRUE(updater_exe.has_value());
@@ -829,12 +829,12 @@
EXPECT_TRUE(task_scheduler->DeleteTask(task_name));
});
- const absl::optional<base::FilePath> target_path =
+ const std::optional<base::FilePath> target_path =
GetGoogleUpdateExePath(scope);
if (target_path)
base::DeleteFile(*target_path);
- absl::optional<base::FilePath> path = GetInstallDirectory(scope);
+ std::optional<base::FilePath> path = GetInstallDirectory(scope);
ASSERT_TRUE(path);
ASSERT_TRUE(base::DeletePathRecursively(*path)) << *path;
}
@@ -867,7 +867,7 @@
CheckInstallationVersions::kCheckActiveAndSxS);
// Check that the caches have been removed.
- const absl::optional<base::FilePath> path = GetCacheBaseDirectory(scope);
+ const std::optional<base::FilePath> path = GetCacheBaseDirectory(scope);
ASSERT_TRUE(path);
EXPECT_TRUE(WaitFor(
[&]() { return !base::PathExists(*path); },
@@ -1679,7 +1679,7 @@
}
void RunHandoff(UpdaterScope scope, const std::string& app_id) {
- const absl::optional<base::FilePath> installed_executable_path =
+ const std::optional<base::FilePath> installed_executable_path =
GetUpdaterExecutablePath(scope);
ASSERT_TRUE(installed_executable_path);
ASSERT_TRUE(base::PathExists(*installed_executable_path));
@@ -1802,14 +1802,14 @@
// Set up a mock `GoogleUpdate.exe`, and the following mock directories:
// `Download`, `Install`, and a versioned `1.2.3.4` directory.
- const absl::optional<base::FilePath> google_update_exe =
+ const std::optional<base::FilePath> google_update_exe =
GetGoogleUpdateExePath(scope);
ASSERT_TRUE(google_update_exe.has_value());
SetupMockUpdater(google_update_exe.value());
}
void RunFakeLegacyUpdater(UpdaterScope scope) {
- const absl::optional<base::FilePath> google_update_exe =
+ const std::optional<base::FilePath> google_update_exe =
GetGoogleUpdateExePath(scope);
ASSERT_TRUE(base::PathExists(*google_update_exe));
@@ -1945,7 +1945,7 @@
// Expect only a single file `GoogleUpdate.exe` and nothing else under
// `\Google\Update`.
- const absl::optional<base::FilePath> google_update_exe =
+ const std::optional<base::FilePath> google_update_exe =
GetGoogleUpdateExePath(scope);
ASSERT_TRUE(google_update_exe.has_value());
ExpectOnlyMockUpdater(google_update_exe.value());
diff --git a/chrome/updater/test/request_matcher.cc b/chrome/updater/test/request_matcher.cc
index c189e867..562ff3c 100644
--- a/chrome/updater/test/request_matcher.cc
+++ b/chrome/updater/test/request_matcher.cc
@@ -4,6 +4,7 @@
#include "chrome/updater/test/request_matcher.h"
+#include <optional>
#include <string>
#include <string_view>
#include <utility>
@@ -20,7 +21,6 @@
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/util/util.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/re2/src/re2/re2.h"
namespace updater::test::request {
@@ -99,7 +99,7 @@
Matcher GetScopeMatcher(UpdaterScope scope) {
return base::BindLambdaForTesting([scope](const HttpRequest& request) {
const bool is_match = [&scope, &request]() {
- const absl::optional<base::Value> doc =
+ const std::optional<base::Value> doc =
base::JSONReader::Read(request.decoded_content);
if (!doc || !doc->is_dict()) {
return false;
@@ -109,7 +109,7 @@
if (!object_request) {
return false;
}
- absl::optional<bool> ismachine = object_request->FindBool("ismachine");
+ std::optional<bool> ismachine = object_request->FindBool("ismachine");
if (!ismachine.has_value()) {
return false;
}
@@ -133,7 +133,7 @@
return base::BindLambdaForTesting(
[app_id, priority](const HttpRequest& request) {
const bool is_match = [&app_id, priority, &request]() {
- const absl::optional<base::Value> doc =
+ const std::optional<base::Value> doc =
base::JSONReader::Read(request.decoded_content);
if (!doc || !doc->is_dict()) {
return false;
diff --git a/chrome/updater/test/test_installer/main.cc b/chrome/updater/test/test_installer/main.cc
index d2b20ec..580040e 100644
--- a/chrome/updater/test/test_installer/main.cc
+++ b/chrome/updater/test/test_installer/main.cc
@@ -8,6 +8,8 @@
// All command lines arguments are forwarded to the child process.
#include <windows.h>
+
+#include <optional>
#include <string>
#include "base/command_line.h"
@@ -15,7 +17,6 @@
#include "base/files/scoped_temp_dir.h"
#include "base/process/launch.h"
#include "chrome/updater/win/installer/pe_resource.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace {
@@ -45,7 +46,7 @@
return {};
}
-absl::optional<int> RunScript(const base::FilePath& script_path) {
+std::optional<int> RunScript(const base::FilePath& script_path) {
// Copy current process's command line so all arguments are forwarded.
base::CommandLine command = *base::CommandLine::ForCurrentProcess();
command.SetProgram(script_path);
@@ -53,11 +54,11 @@
int exit_code = -1;
return base::LaunchProcess(command, {})
.WaitForExitWithTimeout(base::Minutes(1), &exit_code)
- ? absl::make_optional(exit_code)
- : absl::nullopt;
+ ? std::make_optional(exit_code)
+ : std::nullopt;
}
-absl::optional<base::FilePath> CreateScriptFile(
+std::optional<base::FilePath> CreateScriptFile(
HMODULE module,
const std::wstring& name,
const std::wstring& type,
@@ -73,8 +74,8 @@
working_dir.AppendASCII("TestAppSetup")
.AddExtension(ExtensionFromResourceName(name));
return resource.WriteToDisk(script_path.value().c_str())
- ? absl::make_optional(script_path)
- : absl::nullopt;
+ ? std::make_optional(script_path)
+ : std::nullopt;
}
BOOL CALLBACK OnResourceFound(HMODULE module,
diff --git a/chrome/updater/tools/tag_main.cc b/chrome/updater/tools/tag_main.cc
index 290a624..f20e6475 100644
--- a/chrome/updater/tools/tag_main.cc
+++ b/chrome/updater/tools/tag_main.cc
@@ -5,6 +5,7 @@
#include <cstdint>
#include <cstdlib>
#include <iostream>
+#include <optional>
#include <string>
#include <tuple>
#include <utility>
@@ -129,7 +130,7 @@
if (args.is_exe) {
return tagging::ExeReadTag(args.in_filename);
}
- absl::optional<tagging::TagArgs> tag_args =
+ std::optional<tagging::TagArgs> tag_args =
tagging::MsiReadTag(args.in_filename);
return tag_args ? tag_args->tag_string : std::string();
}();
diff --git a/chrome/updater/update_service_impl.cc b/chrome/updater/update_service_impl.cc
index 7a2b9e18..7e36ee4 100644
--- a/chrome/updater/update_service_impl.cc
+++ b/chrome/updater/update_service_impl.cc
@@ -6,6 +6,7 @@
#include <algorithm>
#include <map>
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -56,7 +57,6 @@
#include "components/update_client/crx_update_item.h"
#include "components/update_client/update_client.h"
#include "components/update_client/update_client_errors.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#if BUILDFLAG(IS_WIN)
#include <winhttp.h>
@@ -108,29 +108,27 @@
UpdateService::PolicySameVersionUpdate policy_same_version_update,
const std::vector<std::string>& ids,
base::OnceCallback<
- void(const std::vector<absl::optional<update_client::CrxComponent>>&)>
+ void(const std::vector<std::optional<update_client::CrxComponent>>&)>
callback) {
VLOG(1) << __func__
<< ". Same version update: " << policy_same_version_update;
const bool is_foreground = priority == UpdateService::Priority::kForeground;
auto barrier_callback =
- base::BarrierCallback<absl::optional<update_client::CrxComponent>>(
+ base::BarrierCallback<std::optional<update_client::CrxComponent>>(
ids.size(),
base::BindOnce(
[](const std::vector<std::string>& ids,
- const std::vector<absl::optional<update_client::CrxComponent>>&
+ const std::vector<std::optional<update_client::CrxComponent>>&
unordered) {
// Re-order the vector to match the order of `ids`.
- std::vector<absl::optional<update_client::CrxComponent>>
- ordered;
+ std::vector<std::optional<update_client::CrxComponent>> ordered;
for (const auto& id : ids) {
auto it = std::find_if(
unordered.begin(), unordered.end(),
- [&id](absl::optional<update_client::CrxComponent> v) {
+ [&id](std::optional<update_client::CrxComponent> v) {
return v && v->app_id == id;
});
- ordered.push_back(it != unordered.end() ? *it
- : absl::nullopt);
+ ordered.push_back(it != unordered.end() ? *it : std::nullopt);
}
return ordered;
},
diff --git a/chrome/updater/update_service_impl.h b/chrome/updater/update_service_impl.h
index ec77507..2bbb504 100644
--- a/chrome/updater/update_service_impl.h
+++ b/chrome/updater/update_service_impl.h
@@ -6,6 +6,7 @@
#define CHROME_UPDATER_UPDATE_SERVICE_IMPL_H_
#include <map>
+#include <optional>
#include <string>
#include <vector>
@@ -16,7 +17,6 @@
#include "base/sequence_checker.h"
#include "base/values.h"
#include "chrome/updater/update_service.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace base {
class FilePath;
@@ -153,7 +153,7 @@
UpdateService::PolicySameVersionUpdate policy_same_version_update,
const std::vector<std::string>& ids,
base::OnceCallback<
- void(const std::vector<absl::optional<update_client::CrxComponent>>&)>
+ void(const std::vector<std::optional<update_client::CrxComponent>>&)>
callback);
#if BUILDFLAG(IS_WIN)
diff --git a/chrome/updater/update_service_impl_unittest.cc b/chrome/updater/update_service_impl_unittest.cc
index e77870f..ad7d551b 100644
--- a/chrome/updater/update_service_impl_unittest.cc
+++ b/chrome/updater/update_service_impl_unittest.cc
@@ -4,6 +4,7 @@
#include "chrome/updater/update_service_impl.h"
+#include <optional>
#include <string>
#include "base/files/file_path.h"
@@ -78,7 +79,7 @@
metadata->SetAPKey("id1", "brand_key");
metadata->SetBrandCode("id1", "BRND");
- std::vector<absl::optional<update_client::CrxComponent>> crxs;
+ std::vector<std::optional<update_client::CrxComponent>> crxs;
base::RunLoop loop;
internal::GetComponents(
base::MakeRefCounted<Configurator>(nullptr, CreateExternalConstants()),
@@ -86,7 +87,7 @@
UpdateService::PolicySameVersionUpdate::kNotAllowed,
{"id1", "id2", "id3", "id4"},
base::BindLambdaForTesting(
- [&](const std::vector<absl::optional<update_client::CrxComponent>>&
+ [&](const std::vector<std::optional<update_client::CrxComponent>>&
out) {
crxs = out;
loop.Quit();
@@ -105,8 +106,8 @@
const UpdateService::ErrorCategory error_category;
const int error_code;
const std::string expected_completion_message;
- absl::optional<int> extra_code;
- absl::optional<bool> is_installer_error;
+ std::optional<int> extra_code;
+ std::optional<bool> is_installer_error;
};
class UpdateServiceImplGetInstallerTextTest
diff --git a/chrome/updater/update_service_internal_impl_qualifying_mac.cc b/chrome/updater/update_service_internal_impl_qualifying_mac.cc
index 062445f..d362046 100644
--- a/chrome/updater/update_service_internal_impl_qualifying_mac.cc
+++ b/chrome/updater/update_service_internal_impl_qualifying_mac.cc
@@ -4,6 +4,8 @@
#include "chrome/updater/update_service_internal_impl_qualifying.h"
+#include <optional>
+
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/process/launch.h"
@@ -20,7 +22,7 @@
// and exit with exit code 0 if so. This function returns true if the launcher
// exits with 0.
bool CheckLauncherCanLaunchServer(UpdaterScope scope) {
- absl::optional<base::FilePath> app_bundle_path =
+ std::optional<base::FilePath> app_bundle_path =
GetUpdaterAppBundlePath(scope);
if (!app_bundle_path) {
VLOG(1) << "No app bundle path.";
diff --git a/chrome/updater/update_usage_stats_task_mac.mm b/chrome/updater/update_usage_stats_task_mac.mm
index c7d48fd..f49b94a1 100644
--- a/chrome/updater/update_usage_stats_task_mac.mm
+++ b/chrome/updater/update_usage_stats_task_mac.mm
@@ -5,6 +5,7 @@
#include "chrome/updater/update_usage_stats_task.h"
#include <memory>
+#include <optional>
#include <string>
#include <vector>
@@ -15,7 +16,6 @@
#include "chrome/updater/updater_branding.h"
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/util/mac_util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/crashpad/crashpad/client/crash_report_database.h"
#include "third_party/crashpad/crashpad/client/settings.h"
@@ -55,7 +55,7 @@
bool OtherAppUsageStatsAllowed(const std::vector<std::string>& app_ids,
UpdaterScope scope) {
if (!IsSystemInstall(scope)) {
- absl::optional<base::FilePath> application_support_dir =
+ std::optional<base::FilePath> application_support_dir =
GetApplicationSupportDirectory(UpdaterScope::kUser);
return application_support_dir &&
OtherAppUsageStatsAllowedInDir(*application_support_dir);
diff --git a/chrome/updater/update_usage_stats_task_unittest.cc b/chrome/updater/update_usage_stats_task_unittest.cc
index bb079b0d..0605c5f 100644
--- a/chrome/updater/update_usage_stats_task_unittest.cc
+++ b/chrome/updater/update_usage_stats_task_unittest.cc
@@ -5,6 +5,7 @@
#include "chrome/updater/update_usage_stats_task.h"
#include <memory>
+#include <optional>
#include <string>
#include <vector>
@@ -28,7 +29,6 @@
#if BUILDFLAG(IS_MAC)
#include "chrome/updater/util/mac_util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#elif BUILDFLAG(IS_WIN)
#include "base/strings/sys_string_conversions.h"
#include "base/win/registry.h"
@@ -43,7 +43,7 @@
#if BUILDFLAG(IS_MAC)
base::FilePath AppIDToPath(const std::string& app_id) {
- absl::optional<base::FilePath> application_support_dir =
+ std::optional<base::FilePath> application_support_dir =
GetApplicationSupportDirectory(UpdaterScope::kUser);
EXPECT_TRUE(application_support_dir);
return (*application_support_dir)
diff --git a/chrome/updater/updater.cc b/chrome/updater/updater.cc
index b71d42a..db6bc30 100644
--- a/chrome/updater/updater.cc
+++ b/chrome/updater/updater.cc
@@ -41,7 +41,6 @@
#include "chrome/updater/util/util.h"
#include "components/crash/core/common/crash_key.h"
#include "components/crash/core/common/crash_keys.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#if BUILDFLAG(IS_POSIX)
#include "chrome/updater/ipc/ipc_support.h"
diff --git a/chrome/updater/updater_scope.cc b/chrome/updater/updater_scope.cc
index 22a16470..a34d43b 100644
--- a/chrome/updater/updater_scope.cc
+++ b/chrome/updater/updater_scope.cc
@@ -4,12 +4,13 @@
#include "chrome/updater/updater_scope.h"
+#include <optional>
+
#include "base/command_line.h"
#include "base/path_service.h"
#include "build/build_config.h"
#include "chrome/updater/constants.h"
#include "chrome/updater/util/util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#if BUILDFLAG(IS_WIN)
#include "chrome/updater/tag.h"
@@ -27,7 +28,7 @@
bool IsPrefersForCommandLine(const base::CommandLine& command_line) {
#if BUILDFLAG(IS_WIN)
- const absl::optional<tagging::TagArgs> tag_args =
+ const std::optional<tagging::TagArgs> tag_args =
GetTagArgsForCommandLine(command_line).tag_args;
return tag_args && !tag_args->apps.empty() &&
tag_args->apps.front().needs_admin &&
@@ -46,7 +47,7 @@
}
// Assume only one app is present since bundles are not supported.
- const absl::optional<tagging::TagArgs> tag_args =
+ const std::optional<tagging::TagArgs> tag_args =
GetTagArgsForCommandLine(command_line).tag_args;
if (tag_args && !tag_args->apps.empty() &&
tag_args->apps.front().needs_admin) {
@@ -66,7 +67,7 @@
// explicitly. This includes command line switches: '/healthcheck', '/regsvc',
// '/regserver', and '/ping'. In this case, choose system scope if this
// program is run as a system shim.
- absl::optional<base::FilePath> system_shim_path =
+ std::optional<base::FilePath> system_shim_path =
GetGoogleUpdateExePath(UpdaterScope::kSystem);
base::FilePath exe_path;
if (system_shim_path && base::PathService::Get(base::FILE_EXE, &exe_path) &&
diff --git a/chrome/updater/util/linux_util.cc b/chrome/updater/util/linux_util.cc
index b165433..5f642143 100644
--- a/chrome/updater/util/linux_util.cc
+++ b/chrome/updater/util/linux_util.cc
@@ -4,6 +4,8 @@
#include "chrome/updater/util/linux_util.h"
+#include <optional>
+
#include "base/base_paths.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
@@ -13,7 +15,6 @@
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/util/posix_util.h"
#include "chrome/updater/util/util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace {
@@ -31,7 +32,7 @@
return base::FilePath(base::StrCat({kExecutableName, kExecutableSuffix}));
}
-absl::optional<base::FilePath> GetInstallDirectory(UpdaterScope scope) {
+std::optional<base::FilePath> GetInstallDirectory(UpdaterScope scope) {
base::FilePath path;
switch (scope) {
case UpdaterScope::kUser:
@@ -43,14 +44,13 @@
case UpdaterScope::kSystem:
return base::FilePath(kSystemDataPath).Append(GetUpdaterFolderName());
}
- return absl::nullopt;
+ return std::nullopt;
}
-absl::optional<base::FilePath> GetUpdateServiceLauncherPath(
- UpdaterScope scope) {
- absl::optional<base::FilePath> path = GetInstallDirectory(scope);
- return path ? absl::optional<base::FilePath>(path->AppendASCII(kLauncherName))
- : absl::nullopt;
+std::optional<base::FilePath> GetUpdateServiceLauncherPath(UpdaterScope scope) {
+ std::optional<base::FilePath> path = GetInstallDirectory(scope);
+ return path ? std::optional<base::FilePath>(path->AppendASCII(kLauncherName))
+ : std::nullopt;
}
} // namespace updater
diff --git a/chrome/updater/util/linux_util.h b/chrome/updater/util/linux_util.h
index 6b234282..b0f67809 100644
--- a/chrome/updater/util/linux_util.h
+++ b/chrome/updater/util/linux_util.h
@@ -5,7 +5,6 @@
#ifndef CHROME_UPDATER_UTIL_LINUX_UTIL_H_
#define CHROME_UPDATER_UTIL_LINUX_UTIL_H_
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
diff --git a/chrome/updater/util/mac_util.h b/chrome/updater/util/mac_util.h
index 24078f5..e85e6a9 100644
--- a/chrome/updater/util/mac_util.h
+++ b/chrome/updater/util/mac_util.h
@@ -5,10 +5,10 @@
#ifndef CHROME_UPDATER_UTIL_MAC_UTIL_H_
#define CHROME_UPDATER_UTIL_MAC_UTIL_H_
+#include <optional>
#include <string>
#include "chrome/updater/updater_scope.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace base {
class FilePath;
@@ -18,23 +18,23 @@
// For user installations returns: the "~/Library" for the logged in user.
// For system installations returns: "/Library".
-absl::optional<base::FilePath> GetLibraryFolderPath(UpdaterScope scope);
+std::optional<base::FilePath> GetLibraryFolderPath(UpdaterScope scope);
// For user installations returns "~/Library/Application Support" for the
// logged in user. For system installations returns
// "/Library/Application Support".
-absl::optional<base::FilePath> GetApplicationSupportDirectory(
+std::optional<base::FilePath> GetApplicationSupportDirectory(
UpdaterScope scope);
// Returns the path to Keystone's root directory.
-absl::optional<base::FilePath> GetKeystoneFolderPath(UpdaterScope scope);
+std::optional<base::FilePath> GetKeystoneFolderPath(UpdaterScope scope);
// Returns the path to ksadmin, if it is present on the system. Ksadmin may be
// the shim installed by this updater or a Keystone ksadmin.
-absl::optional<base::FilePath> GetKSAdminPath(UpdaterScope scope);
+std::optional<base::FilePath> GetKSAdminPath(UpdaterScope scope);
// Returns the path to the wake task plist.
-absl::optional<base::FilePath> GetWakeTaskPlistPath(UpdaterScope scope);
+std::optional<base::FilePath> GetWakeTaskPlistPath(UpdaterScope scope);
std::string GetWakeLaunchdName(UpdaterScope scope);
@@ -49,8 +49,8 @@
// Reads the value associated with `key` from the plist at `path`. Returns
// nullopt if `path` or `key` are empty, if the plist does not contain `key`, or
// if there are any errors.
-absl::optional<std::string> ReadValueFromPlist(const base::FilePath& path,
- const std::string& key);
+std::optional<std::string> ReadValueFromPlist(const base::FilePath& path,
+ const std::string& key);
} // namespace updater
diff --git a/chrome/updater/util/mac_util.mm b/chrome/updater/util/mac_util.mm
index 2c21a6f..df5f845c 100644
--- a/chrome/updater/util/mac_util.mm
+++ b/chrome/updater/util/mac_util.mm
@@ -6,6 +6,8 @@
#import <CoreFoundation/CoreFoundation.h>
+#include <optional>
+
#include "base/apple/bridging.h"
#include "base/apple/foundation_util.h"
#include "base/command_line.h"
@@ -27,7 +29,6 @@
#include "chrome/updater/updater_version.h"
#include "chrome/updater/util/posix_util.h"
#include "chrome/updater/util/util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace {
@@ -53,7 +54,7 @@
}
}
-absl::optional<base::FilePath> GetLibraryFolderPath(UpdaterScope scope) {
+std::optional<base::FilePath> GetLibraryFolderPath(UpdaterScope scope) {
switch (scope) {
case UpdaterScope::kUser:
return base::apple::GetUserLibraryPath();
@@ -62,14 +63,14 @@
if (!base::apple::GetLocalDirectory(NSLibraryDirectory,
&local_library_path)) {
VLOG(1) << "Could not get local library path";
- return absl::nullopt;
+ return std::nullopt;
}
return local_library_path;
}
}
}
-absl::optional<base::FilePath> GetApplicationSupportDirectory(
+std::optional<base::FilePath> GetApplicationSupportDirectory(
UpdaterScope scope) {
base::FilePath path;
switch (scope) {
@@ -87,22 +88,22 @@
}
VLOG(1) << "Could not get applications support path";
- return absl::nullopt;
+ return std::nullopt;
}
-absl::optional<base::FilePath> GetKSAdminPath(UpdaterScope scope) {
- const absl::optional<base::FilePath> keystone_folder_path =
+std::optional<base::FilePath> GetKSAdminPath(UpdaterScope scope) {
+ const std::optional<base::FilePath> keystone_folder_path =
GetKeystoneFolderPath(scope);
if (!keystone_folder_path || !base::PathExists(*keystone_folder_path))
- return absl::nullopt;
+ return std::nullopt;
base::FilePath ksadmin_path =
keystone_folder_path->Append(FILE_PATH_LITERAL(KEYSTONE_NAME ".bundle"))
.Append(FILE_PATH_LITERAL("Contents"))
.Append(FILE_PATH_LITERAL("Helpers"))
.Append(FILE_PATH_LITERAL("ksadmin"));
if (!base::PathExists(ksadmin_path))
- return absl::nullopt;
- return absl::make_optional(ksadmin_path);
+ return std::nullopt;
+ return std::make_optional(ksadmin_path);
}
std::string GetWakeLaunchdName(UpdaterScope scope) {
@@ -111,7 +112,7 @@
}
bool RemoveWakeJobFromLaunchd(UpdaterScope scope) {
- const absl::optional<base::FilePath> path = GetWakeTaskPlistPath(scope);
+ const std::optional<base::FilePath> path = GetWakeTaskPlistPath(scope);
if (!path) {
return false;
}
@@ -158,20 +159,20 @@
return exit_code <= 1;
}
-absl::optional<base::FilePath> GetExecutableFolderPathForVersion(
+std::optional<base::FilePath> GetExecutableFolderPathForVersion(
UpdaterScope scope,
const base::Version& version) {
- absl::optional<base::FilePath> path =
+ std::optional<base::FilePath> path =
GetVersionedInstallDirectory(scope, version);
if (!path)
- return absl::nullopt;
+ return std::nullopt;
return path->Append(ExecutableFolderPath());
}
-absl::optional<base::FilePath> GetUpdaterAppBundlePath(UpdaterScope scope) {
- absl::optional<base::FilePath> path = GetVersionedInstallDirectory(scope);
+std::optional<base::FilePath> GetUpdaterAppBundlePath(UpdaterScope scope) {
+ std::optional<base::FilePath> path = GetVersionedInstallDirectory(scope);
if (!path)
- return absl::nullopt;
+ return std::nullopt;
return path->Append(
base::StrCat({PRODUCT_FULLNAME_STRING, kExecutableSuffix, ".app"}));
}
@@ -181,10 +182,10 @@
base::StrCat({PRODUCT_FULLNAME_STRING, kExecutableSuffix}));
}
-absl::optional<base::FilePath> GetKeystoneFolderPath(UpdaterScope scope) {
- absl::optional<base::FilePath> path = GetLibraryFolderPath(scope);
+std::optional<base::FilePath> GetKeystoneFolderPath(UpdaterScope scope) {
+ std::optional<base::FilePath> path = GetLibraryFolderPath(scope);
if (!path)
- return absl::nullopt;
+ return std::nullopt;
return path->Append(FILE_PATH_LITERAL(COMPANY_SHORTNAME_STRING))
.Append(FILE_PATH_LITERAL(KEYSTONE_NAME));
}
@@ -219,36 +220,35 @@
return true;
}
-absl::optional<base::FilePath> GetInstallDirectory(UpdaterScope scope) {
- absl::optional<base::FilePath> path = GetLibraryFolderPath(scope);
- return path ? absl::optional<base::FilePath>(
+std::optional<base::FilePath> GetInstallDirectory(UpdaterScope scope) {
+ std::optional<base::FilePath> path = GetLibraryFolderPath(scope);
+ return path ? std::optional<base::FilePath>(
path->Append("Application Support")
.Append(GetUpdaterFolderName()))
- : absl::nullopt;
+ : std::nullopt;
}
-absl::optional<base::FilePath> GetCacheBaseDirectory(UpdaterScope scope) {
+std::optional<base::FilePath> GetCacheBaseDirectory(UpdaterScope scope) {
base::FilePath caches_path;
if (!base::apple::GetLocalDirectory(NSCachesDirectory, &caches_path)) {
VLOG(1) << "Could not get Caches path";
- return absl::nullopt;
+ return std::nullopt;
}
- return absl::optional<base::FilePath>(
+ return std::optional<base::FilePath>(
caches_path.AppendASCII(MAC_BUNDLE_IDENTIFIER_STRING));
}
-absl::optional<base::FilePath> GetUpdateServiceLauncherPath(
- UpdaterScope scope) {
- absl::optional<base::FilePath> install_dir = GetInstallDirectory(scope);
+std::optional<base::FilePath> GetUpdateServiceLauncherPath(UpdaterScope scope) {
+ std::optional<base::FilePath> install_dir = GetInstallDirectory(scope);
return install_dir
- ? absl::optional<base::FilePath>(
+ ? std::optional<base::FilePath>(
install_dir->Append("Current")
.Append(base::StrCat({PRODUCT_FULLNAME_STRING,
kExecutableSuffix, ".app"}))
.Append("Contents")
.Append("Helpers")
.Append("launcher"))
- : absl::nullopt;
+ : std::nullopt;
}
bool RemoveQuarantineAttributes(const base::FilePath& updater_bundle_path) {
@@ -264,13 +264,13 @@
return success;
}
-absl::optional<base::FilePath> GetWakeTaskPlistPath(UpdaterScope scope) {
+std::optional<base::FilePath> GetWakeTaskPlistPath(UpdaterScope scope) {
@autoreleasepool {
NSArray* library_paths = NSSearchPathForDirectoriesInDomains(
NSLibraryDirectory,
IsSystemInstall(scope) ? NSLocalDomainMask : NSUserDomainMask, YES);
if ([library_paths count] < 1) {
- return absl::nullopt;
+ return std::nullopt;
}
return base::apple::NSStringToFilePath(library_paths[0])
.Append(IsSystemInstall(scope) ? "LaunchDaemons" : "LaunchAgents")
@@ -278,10 +278,10 @@
}
}
-absl::optional<std::string> ReadValueFromPlist(const base::FilePath& path,
- const std::string& key) {
+std::optional<std::string> ReadValueFromPlist(const base::FilePath& path,
+ const std::string& key) {
if (key.empty() || path.empty()) {
- return absl::nullopt;
+ return std::nullopt;
}
NSData* data;
{
@@ -291,7 +291,7 @@
[NSData dataWithContentsOfFile:base::apple::FilePathToNSString(path)];
}
if ([data length] == 0) {
- return absl::nullopt;
+ return std::nullopt;
}
NSDictionary* all_keys = base::apple::ObjCCastStrict<NSDictionary>(
[NSPropertyListSerialization propertyListWithData:data
@@ -299,13 +299,13 @@
format:nil
error:nil]);
if (all_keys == nil) {
- return absl::nullopt;
+ return std::nullopt;
}
CFStringRef value = base::apple::GetValueFromDictionary<CFStringRef>(
base::apple::NSToCFPtrCast(all_keys),
base::SysUTF8ToCFStringRef(key).get());
if (value == nullptr) {
- return absl::nullopt;
+ return std::nullopt;
}
return base::SysCFStringRefToUTF8(value);
}
diff --git a/chrome/updater/util/posix_util.cc b/chrome/updater/util/posix_util.cc
index 2ce5937..6a52cd80 100644
--- a/chrome/updater/util/posix_util.cc
+++ b/chrome/updater/util/posix_util.cc
@@ -8,6 +8,8 @@
#include <sys/stat.h>
#include <unistd.h>
+#include <optional>
+
#include "base/files/file.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_util.h"
@@ -42,7 +44,7 @@
} // namespace
// Recursively delete a folder and its contents, returning `true` on success.
-bool DeleteFolder(const absl::optional<base::FilePath>& installed_path) {
+bool DeleteFolder(const std::optional<base::FilePath>& installed_path) {
if (!installed_path)
return false;
if (!base::DeletePathRecursively(*installed_path)) {
diff --git a/chrome/updater/util/posix_util.h b/chrome/updater/util/posix_util.h
index 87c4b0b..7e4f9d266 100644
--- a/chrome/updater/util/posix_util.h
+++ b/chrome/updater/util/posix_util.h
@@ -5,7 +5,7 @@
#ifndef CHROME_UPDATER_UTIL_POSIX_UTIL_H_
#define CHROME_UPDATER_UTIL_POSIX_UTIL_H_
-#include <third_party/abseil-cpp/absl/types/optional.h>
+#include <optional>
namespace base {
class FilePath;
@@ -15,14 +15,14 @@
enum class UpdaterScope;
// Recursively delete a folder and its contents, returning `true` on success.
-bool DeleteFolder(const absl::optional<base::FilePath>& installed_path);
+bool DeleteFolder(const std::optional<base::FilePath>& installed_path);
// Delete this updater's versioned install folder.
bool DeleteCandidateInstallFolder(UpdaterScope scope);
base::FilePath GetUpdaterFolderName();
-absl::optional<base::FilePath> GetUpdateServiceLauncherPath(UpdaterScope scope);
+std::optional<base::FilePath> GetUpdateServiceLauncherPath(UpdaterScope scope);
// Copy a directory, including symlinks.
bool CopyDir(const base::FilePath& from_path,
diff --git a/chrome/updater/util/unit_test_util.cc b/chrome/updater/util/unit_test_util.cc
index d4b9c152..383e470 100644
--- a/chrome/updater/util/unit_test_util.cc
+++ b/chrome/updater/util/unit_test_util.cc
@@ -6,6 +6,7 @@
#include <cstdint>
#include <memory>
+#include <optional>
#include <sstream>
#include <string>
#include <utility>
@@ -44,7 +45,6 @@
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/util/util.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#if BUILDFLAG(IS_WIN)
#include <shlobj.h>
@@ -144,7 +144,7 @@
void SetupFakeUpdaterInstallFolder(UpdaterScope scope,
const base::Version& version,
bool should_create_updater_executable) {
- absl::optional<base::FilePath> folder_path =
+ std::optional<base::FilePath> folder_path =
GetVersionedInstallDirectory(scope, version);
ASSERT_TRUE(folder_path);
const base::FilePath updater_executable_path(
@@ -222,7 +222,7 @@
}
bool DeleteFileAndEmptyParentDirectories(
- const absl::optional<base::FilePath>& file_path) {
+ const std::optional<base::FilePath>& file_path) {
struct Local {
// Deletes recursively `dir` and its parents up, if dir is empty
// and until one non-empty parent directory is found.
@@ -249,11 +249,11 @@
}
void InitLoggingForUnitTest(const base::FilePath& log_base_path) {
- const absl::optional<base::FilePath> log_file_path = [&log_base_path]() {
+ const std::optional<base::FilePath> log_file_path = [&log_base_path]() {
const base::FilePath dest_dir = GetLogDestinationDir();
return dest_dir.empty()
- ? absl::nullopt
- : absl::make_optional(dest_dir.Append(log_base_path));
+ ? std::nullopt
+ : std::make_optional(dest_dir.Append(log_base_path));
}();
if (log_file_path) {
logging::LoggingSettings settings;
diff --git a/chrome/updater/util/unit_test_util.h b/chrome/updater/util/unit_test_util.h
index 89b56218..5f83353 100644
--- a/chrome/updater/util/unit_test_util.h
+++ b/chrome/updater/util/unit_test_util.h
@@ -5,6 +5,7 @@
#ifndef CHROME_UPDATER_UTIL_UNIT_TEST_UTIL_H_
#define CHROME_UPDATER_UTIL_UNIT_TEST_UTIL_H_
+#include <optional>
#include <string>
#include "base/files/file_path.h"
@@ -15,7 +16,6 @@
#include "base/process/process_iterator.h"
#include "base/synchronization/waitable_event.h"
#include "chrome/updater/tag.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace base {
class TimeDelta;
@@ -58,7 +58,7 @@
// - the file does not exist.
// - the directory is not empty.
bool DeleteFileAndEmptyParentDirectories(
- const absl::optional<base::FilePath>& file_path);
+ const std::optional<base::FilePath>& file_path);
// Fetches the path to the ${ISOLATED_OUTDIR} env var.
// ResultDB reads logs and test artifacts info from there.
diff --git a/chrome/updater/util/unit_test_util_unittest.cc b/chrome/updater/util/unit_test_util_unittest.cc
index cd5c3c54..441c632 100644
--- a/chrome/updater/util/unit_test_util_unittest.cc
+++ b/chrome/updater/util/unit_test_util_unittest.cc
@@ -4,6 +4,10 @@
#include "chrome/updater/util/unit_test_util.h"
+#include <optional>
+#include <string>
+#include <vector>
+
#include "base/base_paths.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
@@ -24,7 +28,6 @@
#include "chrome/updater/test/integration_tests_impl.h"
#include "chrome/updater/test_scope.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/re2/src/re2/re2.h"
#if BUILDFLAG(IS_WIN)
@@ -130,7 +133,7 @@
}
TEST(UnitTestUtil, DeleteFileAndEmptyParentDirectories) {
- EXPECT_FALSE(DeleteFileAndEmptyParentDirectories(absl::nullopt));
+ EXPECT_FALSE(DeleteFileAndEmptyParentDirectories(std::nullopt));
const base::FilePath path_not_found(FILE_PATH_LITERAL("path-not-found"));
EXPECT_TRUE(DeleteFileAndEmptyParentDirectories(path_not_found));
diff --git a/chrome/updater/util/util.cc b/chrome/updater/util/util.cc
index 551547d..671acc2 100644
--- a/chrome/updater/util/util.cc
+++ b/chrome/updater/util/util.cc
@@ -4,6 +4,7 @@
#include "chrome/updater/util/util.h"
+#include <optional>
#include <string>
#include <vector>
@@ -40,7 +41,6 @@
#include "chrome/updater/updater_branding.h"
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/updater_version.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
#if BUILDFLAG(IS_LINUX)
@@ -112,65 +112,63 @@
} // namespace
-absl::optional<base::FilePath> GetVersionedInstallDirectory(
+std::optional<base::FilePath> GetVersionedInstallDirectory(
UpdaterScope scope,
const base::Version& version) {
- const absl::optional<base::FilePath> path = GetInstallDirectory(scope);
+ const std::optional<base::FilePath> path = GetInstallDirectory(scope);
if (!path)
- return absl::nullopt;
+ return std::nullopt;
return path->AppendASCII(version.GetString());
}
-absl::optional<base::FilePath> GetVersionedInstallDirectory(
- UpdaterScope scope) {
+std::optional<base::FilePath> GetVersionedInstallDirectory(UpdaterScope scope) {
return GetVersionedInstallDirectory(scope, base::Version(kUpdaterVersion));
}
-absl::optional<base::FilePath> GetUpdaterExecutablePath(
+std::optional<base::FilePath> GetUpdaterExecutablePath(
UpdaterScope scope,
const base::Version& version) {
- absl::optional<base::FilePath> path =
+ std::optional<base::FilePath> path =
GetVersionedInstallDirectory(scope, version);
if (!path) {
- return absl::nullopt;
+ return std::nullopt;
}
return path->Append(GetExecutableRelativePath());
}
#if !BUILDFLAG(IS_MAC)
-absl::optional<base::FilePath> GetCacheBaseDirectory(UpdaterScope scope) {
+std::optional<base::FilePath> GetCacheBaseDirectory(UpdaterScope scope) {
return GetInstallDirectory(scope);
}
#endif
-absl::optional<base::FilePath> GetCrxDiffCacheDirectory(UpdaterScope scope) {
- const absl::optional<base::FilePath> cache_path(GetCacheBaseDirectory(scope));
+std::optional<base::FilePath> GetCrxDiffCacheDirectory(UpdaterScope scope) {
+ const std::optional<base::FilePath> cache_path(GetCacheBaseDirectory(scope));
if (!cache_path) {
- return absl::nullopt;
+ return std::nullopt;
}
- return absl::optional<base::FilePath>(cache_path->AppendASCII("crx_cache"));
+ return std::optional<base::FilePath>(cache_path->AppendASCII("crx_cache"));
}
-absl::optional<base::FilePath> GetUpdaterExecutablePath(UpdaterScope scope) {
+std::optional<base::FilePath> GetUpdaterExecutablePath(UpdaterScope scope) {
return GetUpdaterExecutablePath(scope, base::Version(kUpdaterVersion));
}
-absl::optional<base::FilePath> GetCrashDatabasePath(UpdaterScope scope) {
- const absl::optional<base::FilePath> path(
- GetVersionedInstallDirectory(scope));
- return path ? absl::optional<base::FilePath>(path->AppendASCII("Crashpad"))
- : absl::nullopt;
+std::optional<base::FilePath> GetCrashDatabasePath(UpdaterScope scope) {
+ const std::optional<base::FilePath> path(GetVersionedInstallDirectory(scope));
+ return path ? std::optional<base::FilePath>(path->AppendASCII("Crashpad"))
+ : std::nullopt;
}
-absl::optional<base::FilePath> EnsureCrashDatabasePath(UpdaterScope scope) {
- const absl::optional<base::FilePath> database_path(
+std::optional<base::FilePath> EnsureCrashDatabasePath(UpdaterScope scope) {
+ const std::optional<base::FilePath> database_path(
GetCrashDatabasePath(scope));
return database_path && base::CreateDirectory(*database_path) ? database_path
- : absl::nullopt;
+ : std::nullopt;
}
TagParsingResult::TagParsingResult() = default;
-TagParsingResult::TagParsingResult(absl::optional<tagging::TagArgs> tag_args,
+TagParsingResult::TagParsingResult(std::optional<tagging::TagArgs> tag_args,
tagging::ErrorCode error)
: tag_args(tag_args), error(error) {}
TagParsingResult::~TagParsingResult() = default;
@@ -198,10 +196,10 @@
return GetTagArgsForCommandLine(*base::CommandLine::ForCurrentProcess());
}
-absl::optional<tagging::AppArgs> GetAppArgs(const std::string& app_id) {
- const absl::optional<tagging::TagArgs> tag_args = GetTagArgs().tag_args;
+std::optional<tagging::AppArgs> GetAppArgs(const std::string& app_id) {
+ const std::optional<tagging::TagArgs> tag_args = GetTagArgs().tag_args;
if (!tag_args || tag_args->apps.empty()) {
- return absl::nullopt;
+ return std::nullopt;
}
const std::vector<tagging::AppArgs>& apps_args = tag_args->apps;
@@ -209,12 +207,12 @@
apps_args, [&app_id](const tagging::AppArgs& app_args) {
return base::EqualsCaseInsensitiveASCII(app_args.app_id, app_id);
});
- return it != std::end(apps_args) ? absl::optional<tagging::AppArgs>(*it)
- : absl::nullopt;
+ return it != std::end(apps_args) ? std::optional<tagging::AppArgs>(*it)
+ : std::nullopt;
}
std::string GetDecodedInstallDataFromAppArgs(const std::string& app_id) {
- const absl::optional<tagging::AppArgs> app_args = GetAppArgs(app_id);
+ const std::optional<tagging::AppArgs> app_args = GetAppArgs(app_id);
if (!app_args) {
return std::string();
}
@@ -232,21 +230,21 @@
}
std::string GetInstallDataIndexFromAppArgs(const std::string& app_id) {
- const absl::optional<tagging::AppArgs> app_args = GetAppArgs(app_id);
+ const std::optional<tagging::AppArgs> app_args = GetAppArgs(app_id);
return app_args ? app_args->install_data_index : std::string();
}
// The log file is created in DIR_LOCAL_APP_DATA or DIR_ROAMING_APP_DATA.
-absl::optional<base::FilePath> GetLogFilePath(UpdaterScope scope) {
- const absl::optional<base::FilePath> log_dir = GetInstallDirectory(scope);
+std::optional<base::FilePath> GetLogFilePath(UpdaterScope scope) {
+ const std::optional<base::FilePath> log_dir = GetInstallDirectory(scope);
if (log_dir) {
return log_dir->Append(FILE_PATH_LITERAL("updater.log"));
}
- return absl::nullopt;
+ return std::nullopt;
}
void InitLogging(UpdaterScope updater_scope) {
- absl::optional<base::FilePath> log_file = GetLogFilePath(updater_scope);
+ std::optional<base::FilePath> log_file = GetLogFilePath(updater_scope);
if (!log_file) {
LOG(ERROR) << "Error getting base dir.";
return;
@@ -315,35 +313,35 @@
}
base::CommandLine GetCommandLineLegacyCompatible() {
- absl::optional<base::CommandLine> cmd_line =
+ std::optional<base::CommandLine> cmd_line =
CommandLineForLegacyFormat(::GetCommandLine());
return cmd_line ? *cmd_line : *base::CommandLine::ForCurrentProcess();
}
#endif // BUILDFLAG(IS_WIN)
-absl::optional<base::FilePath> WriteInstallerDataToTempFile(
+std::optional<base::FilePath> WriteInstallerDataToTempFile(
const base::FilePath& directory,
const std::string& installer_data) {
VLOG(2) << __func__ << ": " << directory << ": " << installer_data;
if (!base::DirectoryExists(directory))
- return absl::nullopt;
+ return std::nullopt;
if (installer_data.empty())
- return absl::nullopt;
+ return std::nullopt;
base::FilePath path;
base::File file = base::CreateAndOpenTemporaryFileInDir(directory, &path);
if (!file.IsValid())
- return absl::nullopt;
+ return std::nullopt;
const std::string installer_data_utf8_bom =
base::StrCat({kUTF8BOM, installer_data});
if (file.Write(0, installer_data_utf8_bom.c_str(),
installer_data_utf8_bom.length()) == -1) {
VLOG(2) << __func__ << " file.Write failed";
- return absl::nullopt;
+ return std::nullopt;
}
return path;
@@ -363,7 +361,7 @@
base::ThreadPoolInstance::Get()->Start(init_params);
}
-bool DeleteExcept(const absl::optional<base::FilePath>& except) {
+bool DeleteExcept(const std::optional<base::FilePath>& except) {
if (!except) {
return false;
}
diff --git a/chrome/updater/util/util.h b/chrome/updater/util/util.h
index 1851795..96635d38 100644
--- a/chrome/updater/util/util.h
+++ b/chrome/updater/util/util.h
@@ -5,6 +5,7 @@
#ifndef CHROME_UPDATER_UTIL_UTIL_H_
#define CHROME_UPDATER_UTIL_UTIL_H_
+#include <optional>
#include <ostream>
#include <string>
#include <type_traits>
@@ -19,7 +20,6 @@
#include "build/build_config.h"
#include "chrome/updater/tag.h"
#include "chrome/updater/updater_scope.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
class GURL;
@@ -30,11 +30,11 @@
class Version;
template <class T>
-std::ostream& operator<<(std::ostream& os, const absl::optional<T>& opt) {
+std::ostream& operator<<(std::ostream& os, const std::optional<T>& opt) {
if (opt.has_value()) {
return os << opt.value();
} else {
- return os << "absl::nullopt";
+ return os << "std::nullopt";
}
}
@@ -60,33 +60,33 @@
// executables. For example, on macOS this function may return
// ~/Library/Google/GoogleUpdater/88.0.4293.0 (/Library for system). Does not
// create the directory if it does not exist.
-absl::optional<base::FilePath> GetVersionedInstallDirectory(
+std::optional<base::FilePath> GetVersionedInstallDirectory(
UpdaterScope scope,
const base::Version& version);
// Simpler form of GetVersionedInstallDirectory for the currently running
// version of the updater.
-absl::optional<base::FilePath> GetVersionedInstallDirectory(UpdaterScope scope);
+std::optional<base::FilePath> GetVersionedInstallDirectory(UpdaterScope scope);
// Returns the base install directory common to all versions of the updater.
// Does not create the directory if it does not exist.
-absl::optional<base::FilePath> GetInstallDirectory(UpdaterScope scope);
+std::optional<base::FilePath> GetInstallDirectory(UpdaterScope scope);
// Returns the base path for discardable caches. Deleting a discardable cache
// between runs of the updater may impair performance, cause a redownload, etc.,
// but otherwise not interfere with overall updater function. Cache contents
// should only be stored in subpaths under this path. Does not create the
// directory if it does not exist.
-absl::optional<base::FilePath> GetCacheBaseDirectory(UpdaterScope scope);
+std::optional<base::FilePath> GetCacheBaseDirectory(UpdaterScope scope);
// Returns the path where CRXes cached for delta updates should be stored,
// common to all versions of the updater. Does not create the directory if it
// does not exist.
-absl::optional<base::FilePath> GetCrxDiffCacheDirectory(UpdaterScope scope);
+std::optional<base::FilePath> GetCrxDiffCacheDirectory(UpdaterScope scope);
#if BUILDFLAG(IS_MAC)
// For example: ~/Library/Google/GoogleUpdater/88.0.4293.0/GoogleUpdater.app
-absl::optional<base::FilePath> GetUpdaterAppBundlePath(UpdaterScope scope);
+std::optional<base::FilePath> GetUpdaterAppBundlePath(UpdaterScope scope);
#endif // BUILDFLAG(IS_MAC)
// For user installations:
@@ -95,13 +95,13 @@
// For system installations:
// /Library/Google/GoogleUpdater/88.0.4293.0/GoogleUpdater.app/Contents/
// MacOS/GoogleUpdater
-absl::optional<base::FilePath> GetUpdaterExecutablePath(
+std::optional<base::FilePath> GetUpdaterExecutablePath(
UpdaterScope scope,
const base::Version& version);
// Simpler form of GetUpdaterExecutablePath for the currently running version
// of the updater.
-absl::optional<base::FilePath> GetUpdaterExecutablePath(UpdaterScope scope);
+std::optional<base::FilePath> GetUpdaterExecutablePath(UpdaterScope scope);
// Returns a relative path to the executable from GetVersionedInstallDirectory.
// "GoogleUpdater.app/Contents/MacOS/GoogleUpdater" on macOS.
@@ -110,22 +110,22 @@
// Returns the path to the crashpad database directory. The directory is not
// created if it does not exist.
-absl::optional<base::FilePath> GetCrashDatabasePath(UpdaterScope scope);
+std::optional<base::FilePath> GetCrashDatabasePath(UpdaterScope scope);
// Returns the path to the crashpad database, creating it if it does not exist.
-absl::optional<base::FilePath> EnsureCrashDatabasePath(UpdaterScope scope);
+std::optional<base::FilePath> EnsureCrashDatabasePath(UpdaterScope scope);
// Return the parsed values from --tag command line argument. The functions
// return {} if there was no tag at all. An error is set if the tag fails to
// parse.
struct TagParsingResult {
TagParsingResult();
- TagParsingResult(absl::optional<tagging::TagArgs> tag_args,
+ TagParsingResult(std::optional<tagging::TagArgs> tag_args,
tagging::ErrorCode error);
~TagParsingResult();
TagParsingResult(const TagParsingResult&);
TagParsingResult& operator=(const TagParsingResult&);
- absl::optional<tagging::TagArgs> tag_args;
+ std::optional<tagging::TagArgs> tag_args;
tagging::ErrorCode error = tagging::ErrorCode::kSuccess;
};
@@ -133,13 +133,13 @@
const base::CommandLine& command_line);
TagParsingResult GetTagArgs();
-absl::optional<tagging::AppArgs> GetAppArgs(const std::string& app_id);
+std::optional<tagging::AppArgs> GetAppArgs(const std::string& app_id);
std::string GetDecodedInstallDataFromAppArgs(const std::string& app_id);
std::string GetInstallDataIndexFromAppArgs(const std::string& app_id);
-absl::optional<base::FilePath> GetLogFilePath(UpdaterScope scope);
+std::optional<base::FilePath> GetLogFilePath(UpdaterScope scope);
// Initializes logging for an executable.
void InitLogging(UpdaterScope updater_scope);
@@ -170,7 +170,7 @@
bool UnzipWithExe(const base::FilePath& src_path,
const base::FilePath& dest_path);
-absl::optional<base::FilePath> GetKeystoneFolderPath(UpdaterScope scope);
+std::optional<base::FilePath> GetKeystoneFolderPath(UpdaterScope scope);
// Read the file at path to confirm that the file at the path has the same
// permissions as the given permissions mask.
@@ -194,7 +194,7 @@
// The string must be in format like:
// program.exe /switch1 value1 /switch2 /switch3 value3
// Returns empty if a Chromium style switch is found.
-absl::optional<base::CommandLine> CommandLineForLegacyFormat(
+std::optional<base::CommandLine> CommandLineForLegacyFormat(
const std::wstring& cmd_string);
// Returns the command line for current process, either in legacy style, or
@@ -205,7 +205,7 @@
// Writes the provided string prefixed with the UTF8 byte order mark to a
// temporary file. The temporary file is created in the specified `directory`.
-absl::optional<base::FilePath> WriteInstallerDataToTempFile(
+std::optional<base::FilePath> WriteInstallerDataToTempFile(
const base::FilePath& directory,
const std::string& installer_data);
@@ -219,7 +219,7 @@
bool WrongUser(UpdaterScope scope);
// Delete everything other than `except` under `except.DirName()`.
-[[nodiscard]] bool DeleteExcept(const absl::optional<base::FilePath>& except);
+[[nodiscard]] bool DeleteExcept(const std::optional<base::FilePath>& except);
} // namespace updater
diff --git a/chrome/updater/util/util_mac_unittest.mm b/chrome/updater/util/util_mac_unittest.mm
index ed21e71..59a8de9 100644
--- a/chrome/updater/util/util_mac_unittest.mm
+++ b/chrome/updater/util/util_mac_unittest.mm
@@ -4,13 +4,14 @@
#include "chrome/updater/util/util.h"
+#include <optional>
+
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "chrome/updater/test_scope.h"
#include "chrome/updater/updater_branding.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -36,7 +37,7 @@
}
TEST(UtilTest, GetCacheBaseDirectoryTest) {
- absl::optional<base::FilePath> path(GetCacheBaseDirectory(GetTestScope()));
+ std::optional<base::FilePath> path(GetCacheBaseDirectory(GetTestScope()));
ASSERT_TRUE(path);
EXPECT_EQ(path->BaseName().value(),
diff --git a/chrome/updater/util/util_unittest.cc b/chrome/updater/util/util_unittest.cc
index b9000ed..e660654 100644
--- a/chrome/updater/util/util_unittest.cc
+++ b/chrome/updater/util/util_unittest.cc
@@ -4,7 +4,9 @@
#include "chrome/updater/util/util.h"
+#include <optional>
#include <sstream>
+#include <string>
#include "base/command_line.h"
#include "base/files/file_enumerator.h"
@@ -26,7 +28,6 @@
#include "chrome/updater/test_scope.h"
#include "chrome/updater/util/unit_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -49,10 +50,10 @@
"a69d9e530f96&appname=TestApp&ap=TestAP");
// Test GetAppArgs.
- EXPECT_EQ(GetAppArgs("NonExistentAppId"), absl::nullopt);
- absl::optional<tagging::AppArgs> app_args =
+ EXPECT_EQ(GetAppArgs("NonExistentAppId"), std::nullopt);
+ std::optional<tagging::AppArgs> app_args =
GetAppArgs("8a69f345-c564-463c-aff1-a69d9e530f96");
- ASSERT_NE(app_args, absl::nullopt);
+ ASSERT_NE(app_args, std::nullopt);
EXPECT_STREQ(app_args->app_id.c_str(),
"8a69f345-c564-463c-aff1-a69d9e530f96");
EXPECT_STREQ(app_args->app_name.c_str(), "TestApp");
@@ -71,7 +72,7 @@
directory.Append(FILE_PATH_LITERAL("NonExistentDirectory")),
kInstallerData));
- const absl::optional<base::FilePath> installer_data_file =
+ const std::optional<base::FilePath> installer_data_file =
WriteInstallerDataToTempFile(directory, kInstallerData);
ASSERT_TRUE(installer_data_file);
@@ -102,7 +103,7 @@
}
TEST(Util, GetCrashDatabasePath) {
- absl::optional<base::FilePath> crash_database_path(
+ std::optional<base::FilePath> crash_database_path(
GetCrashDatabasePath(GetTestScope()));
ASSERT_TRUE(crash_database_path);
EXPECT_EQ(crash_database_path->BaseName().value(),
@@ -110,7 +111,7 @@
}
TEST(Util, GetCrxDiffCacheDirectory) {
- absl::optional<base::FilePath> diff_cache_directory(
+ std::optional<base::FilePath> diff_cache_directory(
GetCrxDiffCacheDirectory(GetTestScope()));
ASSERT_TRUE(diff_cache_directory);
EXPECT_EQ(diff_cache_directory->BaseName().value(),
diff --git a/chrome/updater/util/util_win_unittest.cc b/chrome/updater/util/util_win_unittest.cc
index aa9c5235..940e89f 100644
--- a/chrome/updater/util/util_win_unittest.cc
+++ b/chrome/updater/util/util_win_unittest.cc
@@ -4,17 +4,17 @@
#include "chrome/updater/util/util.h"
+#include <optional>
#include <string>
#include <vector>
#include "chrome/updater/tag.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
TEST(UtilTest, CommandLineForLegacyFormat) {
- absl::optional<base::CommandLine> cmd_line = CommandLineForLegacyFormat(
+ std::optional<base::CommandLine> cmd_line = CommandLineForLegacyFormat(
L"program.exe /handoff \"appguid={8a69}&appname=Chrome\" /appargs "
L"\"&appguid={8a69}"
L"&installerdata=%7B%22homepage%22%3A%22http%3A%2F%2Fwww.google.com%\" "
@@ -35,7 +35,7 @@
}
TEST(UtilTest, CommandLineForLegacyFormat_Mixed) {
- absl::optional<base::CommandLine> cmd_line = CommandLineForLegacyFormat(
+ std::optional<base::CommandLine> cmd_line = CommandLineForLegacyFormat(
L"program.exe --handoff \"appguid={8a69}&appname=Chrome\""
L"/silent /sessionid {123-456}");
@@ -43,7 +43,7 @@
}
TEST(UtilTest, CommandLineForLegacyFormat_WithArgs) {
- absl::optional<base::CommandLine> cmd_line = CommandLineForLegacyFormat(
+ std::optional<base::CommandLine> cmd_line = CommandLineForLegacyFormat(
L"program.exe arg1 /SWITCH1 value1 \"arg2 with space\" /Switch2 /s3");
EXPECT_TRUE(cmd_line);
diff --git a/chrome/updater/util/win_util.cc b/chrome/updater/util/win_util.cc
index b7310d5..ccd92658 100644
--- a/chrome/updater/util/win_util.cc
+++ b/chrome/updater/util/win_util.cc
@@ -17,6 +17,7 @@
#include <algorithm>
#include <cstdlib>
#include <memory>
+#include <optional>
#include <string>
#include <vector>
@@ -67,7 +68,6 @@
#include "chrome/updater/win/user_info.h"
#include "chrome/updater/win/win_constants.h"
#include "third_party/abseil-cpp/absl/cleanup/cleanup.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -230,32 +230,32 @@
}
}
-absl::optional<CSecurityDesc> GetCurrentUserDefaultSecurityDescriptor() {
+std::optional<CSecurityDesc> GetCurrentUserDefaultSecurityDescriptor() {
CAccessToken token;
if (!token.GetProcessToken(TOKEN_QUERY))
- return absl::nullopt;
+ return std::nullopt;
CSecurityDesc security_desc;
CSid sid_owner;
if (!token.GetOwner(&sid_owner))
- return absl::nullopt;
+ return std::nullopt;
security_desc.SetOwner(sid_owner);
CSid sid_group;
if (!token.GetPrimaryGroup(&sid_group))
- return absl::nullopt;
+ return std::nullopt;
security_desc.SetGroup(sid_group);
CDacl dacl;
if (!token.GetDefaultDacl(&dacl))
- return absl::nullopt;
+ return std::nullopt;
CSid sid_user;
if (!token.GetUser(&sid_user))
- return absl::nullopt;
+ return std::nullopt;
if (!dacl.AddAllowedAce(sid_user, GENERIC_ALL))
- return absl::nullopt;
+ return std::nullopt;
security_desc.SetDacl(dacl);
@@ -595,14 +595,14 @@
base::win::ScopedVariant::kEmptyVariant);
}
-absl::optional<base::FilePath> GetGoogleUpdateExePath(UpdaterScope scope) {
+std::optional<base::FilePath> GetGoogleUpdateExePath(UpdaterScope scope) {
base::FilePath goopdate_base_dir;
if (!base::PathService::Get(IsSystemInstall(scope)
? base::DIR_PROGRAM_FILESX86
: base::DIR_LOCAL_APP_DATA,
&goopdate_base_dir)) {
LOG(ERROR) << "Can't retrieve GoogleUpdate base directory.";
- return absl::nullopt;
+ return std::nullopt;
}
return goopdate_base_dir.AppendASCII(COMPANY_SHORTNAME_STRING)
@@ -622,7 +622,7 @@
std::wstring BuildMsiCommandLine(
const std::wstring& arguments,
- const absl::optional<base::FilePath>& installer_data_file,
+ const std::optional<base::FilePath>& installer_data_file,
const base::FilePath& msi_installer) {
if (!msi_installer.MatchesExtension(L".msi")) {
return std::wstring();
@@ -647,7 +647,7 @@
std::wstring BuildExeCommandLine(
const std::wstring& arguments,
- const absl::optional<base::FilePath>& installer_data_file,
+ const std::optional<base::FilePath>& installer_data_file,
const base::FilePath& exe_installer) {
if (!exe_installer.MatchesExtension(L".exe")) {
return std::wstring();
@@ -699,7 +699,7 @@
return IsSystemInstall(scope) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
}
-absl::optional<OSVERSIONINFOEX> GetOSVersion() {
+std::optional<OSVERSIONINFOEX> GetOSVersion() {
// `::RtlGetVersion` is being used here instead of `::GetVersionEx`, because
// the latter function can return the incorrect version if it is shimmed using
// an app compat shim.
@@ -707,14 +707,14 @@
static const RtlGetVersion rtl_get_version = reinterpret_cast<RtlGetVersion>(
::GetProcAddress(::GetModuleHandle(L"ntdll.dll"), "RtlGetVersion"));
if (!rtl_get_version)
- return absl::nullopt;
+ return std::nullopt;
OSVERSIONINFOEX os_out = {};
os_out.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
rtl_get_version(&os_out);
if (!os_out.dwMajorVersion)
- return absl::nullopt;
+ return std::nullopt;
return os_out;
}
@@ -761,7 +761,7 @@
return true;
}
-absl::optional<base::ScopedTempDir> CreateSecureTempDir() {
+std::optional<base::ScopedTempDir> CreateSecureTempDir() {
// This function uses `base::CreateNewTempDirectory` and then a
// `base::ScopedTempDir` as owner, instead of just
// `base::ScopedTempDir::CreateUniqueTempDir`, because the former allows
@@ -770,14 +770,14 @@
base::FilePath temp_dir;
if (!base::CreateNewTempDirectory(FILE_PATH_LITERAL(COMPANY_SHORTNAME_STRING),
&temp_dir)) {
- return absl::nullopt;
+ return std::nullopt;
}
base::ScopedTempDir temp_dir_owner;
if (temp_dir_owner.Set(temp_dir)) {
return temp_dir_owner;
}
- return absl::nullopt;
+ return std::nullopt;
}
base::ScopedClosureRunner SignalShutdownEvent(UpdaterScope scope) {
@@ -855,13 +855,13 @@
}
}
-absl::optional<base::CommandLine> CommandLineForLegacyFormat(
+std::optional<base::CommandLine> CommandLineForLegacyFormat(
const std::wstring& cmd_string) {
int num_args = 0;
base::win::ScopedLocalAllocTyped<wchar_t*> args(
::CommandLineToArgvW(cmd_string.c_str(), &num_args));
if (!args)
- return absl::nullopt;
+ return std::nullopt;
auto is_switch = [](const std::wstring& arg) { return arg[0] == L'-'; };
@@ -877,7 +877,7 @@
if (is_switch(args.get()[i]) || is_switch(next_arg)) {
// Won't parse Chromium-style command line.
- return absl::nullopt;
+ return std::nullopt;
}
if (!is_legacy_switch(args.get()[i])) {
@@ -889,7 +889,7 @@
const std::string switch_name = base::WideToASCII(&args.get()[i][1]);
if (switch_name.empty()) {
VLOG(1) << "Empty switch in command line: [" << cmd_string << "]";
- return absl::nullopt;
+ return std::nullopt;
}
if (is_legacy_switch(next_arg) || next_arg.empty()) {
@@ -904,13 +904,13 @@
return command_line;
}
-absl::optional<base::FilePath> GetInstallDirectory(UpdaterScope scope) {
+std::optional<base::FilePath> GetInstallDirectory(UpdaterScope scope) {
base::FilePath app_data_dir;
if (!base::PathService::Get(IsSystemInstall(scope) ? base::DIR_PROGRAM_FILES
: base::DIR_LOCAL_APP_DATA,
&app_data_dir)) {
LOG(ERROR) << "Can't retrieve app data directory.";
- return absl::nullopt;
+ return std::nullopt;
}
return app_data_dir.AppendASCII(COMPANY_SHORTNAME_STRING)
.AppendASCII(PRODUCT_FULLNAME_STRING);
@@ -1047,20 +1047,20 @@
}
}
-absl::optional<base::FilePath> GetInstallDirectoryX86(UpdaterScope scope) {
+std::optional<base::FilePath> GetInstallDirectoryX86(UpdaterScope scope) {
if (!IsSystemInstall(scope)) {
return GetInstallDirectory(scope);
}
base::FilePath install_dir;
if (!base::PathService::Get(base::DIR_PROGRAM_FILESX86, &install_dir)) {
LOG(ERROR) << "Can't retrieve directory for DIR_PROGRAM_FILESX86.";
- return absl::nullopt;
+ return std::nullopt;
}
return install_dir.AppendASCII(COMPANY_SHORTNAME_STRING)
.AppendASCII(PRODUCT_FULLNAME_STRING);
}
-absl::optional<std::wstring> GetRegKeyContents(const std::wstring& reg_key) {
+std::optional<std::wstring> GetRegKeyContents(const std::wstring& reg_key) {
base::FilePath system_path;
if (!base::PathService::Get(base::DIR_SYSTEM, &system_path)) {
return {};
diff --git a/chrome/updater/util/win_util.h b/chrome/updater/util/win_util.h
index ec60053..bfce902b 100644
--- a/chrome/updater/util/win_util.h
+++ b/chrome/updater/util/win_util.h
@@ -10,6 +10,7 @@
#include <wrl/implements.h>
#include <cstdint>
+#include <optional>
#include <string>
#include <tuple>
#include <utility>
@@ -35,7 +36,6 @@
#include "base/win/win_util.h"
#include "base/win/windows_types.h"
#include "chrome/updater/updater_scope.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace base {
class FilePath;
@@ -184,7 +184,7 @@
// Gets the security descriptor with the default DACL for the current process
// user. The owner is the current user, the group is the current primary group.
// Returns security attributes on success, nullopt on failure.
-absl::optional<CSecurityDesc> GetCurrentUserDefaultSecurityDescriptor();
+std::optional<CSecurityDesc> GetCurrentUserDefaultSecurityDescriptor();
// Get security descriptor containing a DACL that grants the ACCESS_MASK access
// to admins and system.
@@ -294,7 +294,7 @@
// spawned process.
HRESULT RunDeElevated(const std::wstring& path, const std::wstring& parameters);
-absl::optional<base::FilePath> GetGoogleUpdateExePath(UpdaterScope scope);
+std::optional<base::FilePath> GetGoogleUpdateExePath(UpdaterScope scope);
// Causes the COM runtime not to handle exceptions. Failing to set this
// up is a critical error, since ignoring exceptions may lead to corrupted
@@ -306,14 +306,14 @@
// a log file in the same directory as the MSI installer.
std::wstring BuildMsiCommandLine(
const std::wstring& arguments,
- const absl::optional<base::FilePath>& installer_data_file,
+ const std::optional<base::FilePath>& installer_data_file,
const base::FilePath& msi_installer);
// Builds a command line running the provided `exe_installer`, `arguments`, and
// `installer_data_file`.
std::wstring BuildExeCommandLine(
const std::wstring& arguments,
- const absl::optional<base::FilePath>& installer_data_file,
+ const std::optional<base::FilePath>& installer_data_file,
const base::FilePath& exe_installer);
// Returns `true` if the service specified is currently running or starting.
@@ -325,7 +325,7 @@
HKEY UpdaterScopeToHKeyRoot(UpdaterScope scope);
// Returns an OSVERSIONINFOEX for the current OS version.
-absl::optional<OSVERSIONINFOEX> GetOSVersion();
+std::optional<OSVERSIONINFOEX> GetOSVersion();
// Compares the current OS to the supplied version. The value of `oper` should
// be one of the predicate values from `::VerSetConditionMask()`, for example,
@@ -347,7 +347,7 @@
// Creates a unique temporary directory. The directory is created under a secure
// location if the caller is admin.
-absl::optional<base::ScopedTempDir> CreateSecureTempDir();
+std::optional<base::ScopedTempDir> CreateSecureTempDir();
// Signals the shutdown event that causes legacy GoogleUpdate processes to exit.
// Returns a closure that resets the shutdown event when it goes out of scope.
@@ -413,11 +413,11 @@
// Returns the base install directory for the x86 versions of the updater.
// Does not create the directory if it does not exist.
-[[nodiscard]] absl::optional<base::FilePath> GetInstallDirectoryX86(
+[[nodiscard]] std::optional<base::FilePath> GetInstallDirectoryX86(
UpdaterScope scope);
// Gets the contents under a given registry key.
-absl::optional<std::wstring> GetRegKeyContents(const std::wstring& reg_key);
+std::optional<std::wstring> GetRegKeyContents(const std::wstring& reg_key);
// Returns the textual description of a system `error` as provided by the
// operating system. The function assumes that the locale value for the calling
diff --git a/chrome/updater/util/win_util_unittest.cc b/chrome/updater/util/win_util_unittest.cc
index 516ecb99..d3e9c47 100644
--- a/chrome/updater/util/win_util_unittest.cc
+++ b/chrome/updater/util/win_util_unittest.cc
@@ -9,6 +9,7 @@
#include <shlobj.h>
#include <windows.h>
+#include <optional>
#include <string>
#include <vector>
@@ -51,7 +52,6 @@
#include "chrome/updater/win/test/test_strings.h"
#include "chrome/updater/win/win_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -200,8 +200,8 @@
}
TEST(WinUtil, GetOSVersion) {
- absl::optional<OSVERSIONINFOEX> rtl_os_version = GetOSVersion();
- ASSERT_NE(rtl_os_version, absl::nullopt);
+ std::optional<OSVERSIONINFOEX> rtl_os_version = GetOSVersion();
+ ASSERT_NE(rtl_os_version, std::nullopt);
// Compare to the version from `::GetVersionEx`.
OSVERSIONINFOEX os = {};
@@ -224,8 +224,8 @@
}
TEST(WinUtil, CompareOSVersions_SameAsCurrent) {
- absl::optional<OSVERSIONINFOEX> this_os = GetOSVersion();
- ASSERT_NE(this_os, absl::nullopt);
+ std::optional<OSVERSIONINFOEX> this_os = GetOSVersion();
+ ASSERT_NE(this_os, std::nullopt);
EXPECT_TRUE(CompareOSVersions(this_os.value(), VER_EQUAL));
EXPECT_TRUE(CompareOSVersions(this_os.value(), VER_GREATER_EQUAL));
@@ -235,8 +235,8 @@
}
TEST(WinUtil, CompareOSVersions_NewBuildNumber) {
- absl::optional<OSVERSIONINFOEX> prior_os = GetOSVersion();
- ASSERT_NE(prior_os, absl::nullopt);
+ std::optional<OSVERSIONINFOEX> prior_os = GetOSVersion();
+ ASSERT_NE(prior_os, std::nullopt);
ASSERT_GT(prior_os->dwBuildNumber, 0UL);
--prior_os->dwBuildNumber;
@@ -248,8 +248,8 @@
}
TEST(WinUtil, CompareOSVersions_NewMajor) {
- absl::optional<OSVERSIONINFOEX> prior_os = GetOSVersion();
- ASSERT_NE(prior_os, absl::nullopt);
+ std::optional<OSVERSIONINFOEX> prior_os = GetOSVersion();
+ ASSERT_NE(prior_os, std::nullopt);
ASSERT_GT(prior_os->dwMajorVersion, 0UL);
--prior_os->dwMajorVersion;
@@ -261,8 +261,8 @@
}
TEST(WinUtil, CompareOSVersions_NewMinor) {
- absl::optional<OSVERSIONINFOEX> prior_os = GetOSVersion();
- ASSERT_NE(prior_os, absl::nullopt);
+ std::optional<OSVERSIONINFOEX> prior_os = GetOSVersion();
+ ASSERT_NE(prior_os, std::nullopt);
// This test only runs if the current OS has a minor version.
if (prior_os->dwMinorVersion >= 1) {
@@ -277,8 +277,8 @@
}
TEST(WinUtil, CompareOSVersions_NewMajorWithLowerMinor) {
- absl::optional<OSVERSIONINFOEX> prior_os = GetOSVersion();
- ASSERT_NE(prior_os, absl::nullopt);
+ std::optional<OSVERSIONINFOEX> prior_os = GetOSVersion();
+ ASSERT_NE(prior_os, std::nullopt);
ASSERT_GT(prior_os->dwMajorVersion, 0UL);
--prior_os->dwMajorVersion;
++prior_os->dwMinorVersion;
@@ -291,8 +291,8 @@
}
TEST(WinUtil, CompareOSVersions_OldMajor) {
- absl::optional<OSVERSIONINFOEX> prior_os = GetOSVersion();
- ASSERT_NE(prior_os, absl::nullopt);
+ std::optional<OSVERSIONINFOEX> prior_os = GetOSVersion();
+ ASSERT_NE(prior_os, std::nullopt);
++prior_os->dwMajorVersion;
EXPECT_FALSE(CompareOSVersions(prior_os.value(), VER_EQUAL));
@@ -303,8 +303,8 @@
}
TEST(WinUtil, CompareOSVersions_OldMajorWithHigherMinor) {
- absl::optional<OSVERSIONINFOEX> prior_os = GetOSVersion();
- ASSERT_NE(prior_os, absl::nullopt);
+ std::optional<OSVERSIONINFOEX> prior_os = GetOSVersion();
+ ASSERT_NE(prior_os, std::nullopt);
// This test only runs if the current OS has a minor version.
if (prior_os->dwMinorVersion >= 1) {
@@ -332,7 +332,7 @@
}
TEST(WinUtil, CreateSecureTempDir) {
- absl::optional<base::ScopedTempDir> temp_dir = CreateSecureTempDir();
+ std::optional<base::ScopedTempDir> temp_dir = CreateSecureTempDir();
EXPECT_TRUE(temp_dir);
EXPECT_TRUE(temp_dir->IsValid());
}
@@ -552,7 +552,7 @@
}));
TEST_P(WinUtilGetRegKeyContentsTest, TestCases) {
- absl::optional<std::wstring> contents = GetRegKeyContents(GetParam().reg_key);
+ std::optional<std::wstring> contents = GetRegKeyContents(GetParam().reg_key);
ASSERT_TRUE(contents);
ASSERT_NE(contents->find(GetParam().expected_substring), std::wstring::npos);
}
diff --git a/chrome/updater/win/app_command_runner.cc b/chrome/updater/win/app_command_runner.cc
index 7a891ef..1c6a1fb 100644
--- a/chrome/updater/win/app_command_runner.cc
+++ b/chrome/updater/win/app_command_runner.cc
@@ -7,6 +7,7 @@
#include <shellapi.h>
#include <windows.h>
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -28,7 +29,6 @@
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/util/win_util.h"
#include "chrome/updater/win/win_constants.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -268,7 +268,7 @@
}
// static
-absl::optional<std::wstring> AppCommandRunner::FormatParameter(
+std::optional<std::wstring> AppCommandRunner::FormatParameter(
const std::wstring& parameter,
const std::vector<std::wstring>& substitutions) {
return base::internal::DoReplaceStringPlaceholders(
@@ -279,17 +279,17 @@
}
// static
-absl::optional<std::wstring> AppCommandRunner::FormatAppCommandLine(
+std::optional<std::wstring> AppCommandRunner::FormatAppCommandLine(
const std::vector<std::wstring>& parameters,
const std::vector<std::wstring>& substitutions) {
std::wstring formatted_command_line;
for (size_t i = 0; i < parameters.size(); ++i) {
- absl::optional<std::wstring> formatted_parameter =
+ std::optional<std::wstring> formatted_parameter =
FormatParameter(parameters[i], substitutions);
if (!formatted_parameter) {
VLOG(1) << __func__ << " FormatParameter failed: " << parameters[i]
<< ": " << substitutions.size();
- return absl::nullopt;
+ return std::nullopt;
}
constexpr wchar_t kQuotableCharacters[] = L" \t\\\"";
@@ -318,7 +318,7 @@
<< base::JoinString(parameters, L",")
<< base::JoinString(substitutions, L",");
- const absl::optional<std::wstring> command_line_parameters =
+ const std::optional<std::wstring> command_line_parameters =
FormatAppCommandLine(parameters, substitutions);
if (!command_line_parameters) {
LOG(ERROR) << __func__ << "!command_line_parameters";
diff --git a/chrome/updater/win/app_command_runner.h b/chrome/updater/win/app_command_runner.h
index 3ddd352..b313774 100644
--- a/chrome/updater/win/app_command_runner.h
+++ b/chrome/updater/win/app_command_runner.h
@@ -7,6 +7,7 @@
#include <windows.h>
+#include <optional>
#include <string>
#include <vector>
@@ -15,7 +16,6 @@
#include "base/process/process.h"
#include "chrome/updater/updater_scope.h"
#include "chrome/updater/util/win_util.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -68,10 +68,10 @@
// `parameter` is replaced with substitutions[N - 1]. Any literal `%` needs to
// be escaped with a `%`.
//
- // Returns `absl::nullopt` if:
+ // Returns `std::nullopt` if:
// * a placeholder %N is encountered where N > substitutions.size().
// * a literal `%` is not escaped with a `%`.
- static absl::optional<std::wstring> FormatParameter(
+ static std::optional<std::wstring> FormatParameter(
const std::wstring& parameter,
const std::vector<std::wstring>& substitutions);
@@ -84,10 +84,10 @@
// parameter will be interpreted as a single command-line parameter according
// to the rules for ::CommandLineToArgvW.
//
- // Returns `absl::nullopt` if:
+ // Returns `std::nullopt` if:
// * a placeholder %N is encountered where N > substitutions.size().
// * a literal `%` is not escaped with a `%`.
- static absl::optional<std::wstring> FormatAppCommandLine(
+ static std::optional<std::wstring> FormatAppCommandLine(
const std::vector<std::wstring>& parameters,
const std::vector<std::wstring>& substitutions);
diff --git a/chrome/updater/win/app_command_runner_unittest.cc b/chrome/updater/win/app_command_runner_unittest.cc
index 79d3050..257f5f1 100644
--- a/chrome/updater/win/app_command_runner_unittest.cc
+++ b/chrome/updater/win/app_command_runner_unittest.cc
@@ -9,6 +9,7 @@
#include <windows.h>
#include <array>
+#include <optional>
#include <string>
#include <vector>
@@ -29,7 +30,6 @@
#include "chrome/updater/util/win_util.h"
#include "chrome/updater/win/win_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace {
@@ -198,12 +198,12 @@
}));
TEST_P(AppCommandFormatParameterTest, TestCases) {
- absl::optional<std::wstring> output = AppCommandRunner::FormatParameter(
+ std::optional<std::wstring> output = AppCommandRunner::FormatParameter(
GetParam().format_string, GetParam().substitutions);
if (GetParam().expected_output) {
EXPECT_EQ(output.value(), GetParam().expected_output);
} else {
- EXPECT_EQ(output, absl::nullopt);
+ EXPECT_EQ(output, std::nullopt);
}
}
@@ -316,11 +316,11 @@
base::CommandLine::FromString(process_command_line).GetProgram());
EXPECT_EQ(parameters.size(), GetParam().input.size());
- absl::optional<std::wstring> command_line =
+ std::optional<std::wstring> command_line =
AppCommandRunner::FormatAppCommandLine(parameters,
GetParam().substitutions);
if (!GetParam().output) {
- EXPECT_EQ(command_line, absl::nullopt);
+ EXPECT_EQ(command_line, std::nullopt);
return;
}
diff --git a/chrome/updater/win/installer/installer.cc b/chrome/updater/win/installer/installer.cc
index 649d8af..f84374b 100644
--- a/chrome/updater/win/installer/installer.cc
+++ b/chrome/updater/win/installer/installer.cc
@@ -16,6 +16,7 @@
#include <shellapi.h>
#include <shlobj.h>
+#include <optional>
#include <string>
// TODO(crbug.com/1128529): remove the dependencies on //base/ to reduce the
@@ -46,7 +47,6 @@
#include "chrome/updater/win/installer/configuration.h"
#include "chrome/updater/win/installer/installer_constants.h"
#include "chrome/updater/win/installer/pe_resource.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -162,12 +162,12 @@
return TRUE;
}
-absl::optional<base::FilePath> FindOfflineDir(
+std::optional<base::FilePath> FindOfflineDir(
const base::FilePath& unpack_path) {
const base::FilePath base_offline_dir =
unpack_path.Append(L"bin").Append(L"Offline");
if (!base::PathExists(base_offline_dir)) {
- return absl::nullopt;
+ return std::nullopt;
}
base::FileEnumerator file_enumerator(base_offline_dir, false,
base::FileEnumerator::DIRECTORIES);
@@ -177,7 +177,7 @@
return path;
}
}
- return absl::nullopt;
+ return std::nullopt;
}
// Finds and writes to disk resources of type 'B7' (7zip archive). Returns false
@@ -406,7 +406,7 @@
// First get a path where we can extract the resource payload, which is
// a compressed LZMA archive of a single file.
- absl::optional<base::ScopedTempDir> base_path_owner = CreateSecureTempDir();
+ std::optional<base::ScopedTempDir> base_path_owner = CreateSecureTempDir();
if (!base_path_owner) {
return ProcessExitResult(TEMP_DIR_FAILED);
}
@@ -422,7 +422,7 @@
&compressed_archive);
// Create a temp folder where the archives are unpacked.
- absl::optional<base::ScopedTempDir> temp_path = CreateSecureTempDir();
+ std::optional<base::ScopedTempDir> temp_path = CreateSecureTempDir();
if (!temp_path) {
return ProcessExitResult(TEMP_DIR_FAILED);
}
@@ -455,8 +455,7 @@
// Determine if an offlinedir is embedded and, if it is, add an
// --offlinedir={GUID} switch to indicate that an offline install should
// be performed.
- const absl::optional<base::FilePath> offline_dir =
- FindOfflineDir(unpack_path);
+ const std::optional<base::FilePath> offline_dir = FindOfflineDir(unpack_path);
if (offline_dir.has_value()) {
if (!cmd_line_args.append(L" --") ||
!cmd_line_args.append(base::SysUTF8ToWide(kOfflineDirSwitch).c_str()) ||
diff --git a/chrome/updater/win/installer/installer.h b/chrome/updater/win/installer/installer.h
index fdbbfcd..49ed74e 100644
--- a/chrome/updater/win/installer/installer.h
+++ b/chrome/updater/win/installer/installer.h
@@ -7,10 +7,11 @@
#include <windows.h>
+#include <optional>
+
#include "base/command_line.h"
#include "chrome/updater/win/installer/exit_code.h"
#include "chrome/updater/win/installer/string.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace base {
class FilePath;
@@ -35,8 +36,7 @@
// (which is a path), plus a few extra arguments.
using CommandString = StackString<MAX_PATH * 4>;
-absl::optional<base::FilePath> FindOfflineDir(
- const base::FilePath& unpack_path);
+std::optional<base::FilePath> FindOfflineDir(const base::FilePath& unpack_path);
// Handles elevating the installer, waiting for the installer process, and
// returning the resulting process exit code.
diff --git a/chrome/updater/win/installer/installer_win_unittest.cc b/chrome/updater/win/installer/installer_win_unittest.cc
index 68ac37e..97de22a2 100644
--- a/chrome/updater/win/installer/installer_win_unittest.cc
+++ b/chrome/updater/win/installer/installer_win_unittest.cc
@@ -6,6 +6,8 @@
#include <shlobj.h>
+#include <optional>
+
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
@@ -48,7 +50,7 @@
.Append(L"{8D5D0563-F2A0-40E3-932D-AFEAE261A9D1}");
ASSERT_TRUE(base::CreateDirectory(offline_install_dir));
- absl::optional<base::FilePath> offline_dir =
+ std::optional<base::FilePath> offline_dir =
updater::FindOfflineDir(unpack_path);
EXPECT_TRUE(offline_dir.has_value());
EXPECT_EQ(offline_dir->BaseName(),
diff --git a/chrome/updater/win/installer/msi_custom_action.cc b/chrome/updater/win/installer/msi_custom_action.cc
index b9e33e9..7fb4029 100644
--- a/chrome/updater/win/installer/msi_custom_action.cc
+++ b/chrome/updater/win/installer/msi_custom_action.cc
@@ -9,6 +9,7 @@
#include <msi.h>
#include <msiquery.h>
+#include <optional>
#include <string>
#include <vector>
@@ -18,7 +19,6 @@
#include "chrome/updater/tag.h"
#include "chrome/updater/util/win_util.h"
#include "chrome/updater/win/win_constants.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -73,8 +73,8 @@
}
// Gets the value of the property `name` from `msi_handle`.
-absl::optional<std::wstring> MsiGetProperty(MsiHandleInterface& msi_handle,
- const std::wstring& name) {
+std::optional<std::wstring> MsiGetProperty(MsiHandleInterface& msi_handle,
+ const std::wstring& name) {
DWORD value_length = 0;
UINT result = ERROR_SUCCESS;
std::vector<wchar_t> value;
@@ -83,18 +83,18 @@
result = msi_handle.GetProperty(name, value, value_length);
} while (result == ERROR_MORE_DATA && value_length <= 0xFFFF);
return result == ERROR_SUCCESS && !value.empty()
- ? absl::make_optional(std::wstring(value.begin(), value.end()))
- : absl::nullopt;
+ ? std::make_optional(std::wstring(value.begin(), value.end()))
+ : std::nullopt;
}
// If the app installer failed with a custom error and provided a UI string,
// returns that string.
-absl::optional<std::wstring> GetLastInstallerResultUIString(
+std::optional<std::wstring> GetLastInstallerResultUIString(
const std::wstring& app_id) {
if (app_id.empty()) {
return {};
}
- auto key = [&app_id]() -> absl::optional<base::win::RegKey> {
+ auto key = [&app_id]() -> std::optional<base::win::RegKey> {
if (base::win::RegKey client_state_key(HKEY_LOCAL_MACHINE,
GetAppClientStateKey(app_id).c_str(),
Wow6432(KEY_READ));
@@ -119,8 +119,8 @@
key->ReadValue(kRegValueLastInstallerResultUIString, &val) ==
ERROR_SUCCESS &&
!val.empty()
- ? absl::make_optional(val)
- : absl::nullopt;
+ ? std::make_optional(val)
+ : std::nullopt;
}
} // namespace
diff --git a/chrome/updater/win/installer/msi_custom_action.h b/chrome/updater/win/installer/msi_custom_action.h
index 056a219..43c9515 100644
--- a/chrome/updater/win/installer/msi_custom_action.h
+++ b/chrome/updater/win/installer/msi_custom_action.h
@@ -12,7 +12,6 @@
#include <string>
#include <vector>
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
diff --git a/chrome/updater/win/installer/msi_custom_action_unittest.cc b/chrome/updater/win/installer/msi_custom_action_unittest.cc
index c1365bf9..ac2ddd8 100644
--- a/chrome/updater/win/installer/msi_custom_action_unittest.cc
+++ b/chrome/updater/win/installer/msi_custom_action_unittest.cc
@@ -17,7 +17,6 @@
#include "chrome/updater/win/installer_api.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace {
diff --git a/chrome/updater/win/installer_api.cc b/chrome/updater/win/installer_api.cc
index 45dc3a5..e307b8b 100644
--- a/chrome/updater/win/installer_api.cc
+++ b/chrome/updater/win/installer_api.cc
@@ -6,6 +6,7 @@
#include <algorithm>
#include <iterator>
+#include <optional>
#include <string>
#include <utility>
#include <vector>
@@ -30,7 +31,6 @@
#include "chrome/updater/util/util.h"
#include "chrome/updater/util/win_util.h"
#include "chrome/updater/win/win_constants.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace {
@@ -38,19 +38,19 @@
// Creates or opens the registry ClientState subkey for the `app_id`. `regsam`
// must contain the KEY_WRITE access right for the creation of the subkey to
// succeed.
-absl::optional<base::win::RegKey> ClientStateAppKeyCreate(
+std::optional<base::win::RegKey> ClientStateAppKeyCreate(
UpdaterScope updater_scope,
const std::string& app_id,
REGSAM regsam) {
std::wstring subkey;
if (!base::UTF8ToWide(app_id.c_str(), app_id.size(), &subkey)) {
- return absl::nullopt;
+ return std::nullopt;
}
base::win::RegKey key(UpdaterScopeToHKeyRoot(updater_scope), CLIENT_STATE_KEY,
Wow6432(regsam));
if (!key.Valid() ||
key.CreateKey(subkey.c_str(), Wow6432(regsam)) != ERROR_SUCCESS) {
- return absl::nullopt;
+ return std::nullopt;
}
return key;
}
@@ -92,7 +92,7 @@
void PersistLastInstallerResultValues(UpdaterScope updater_scope,
const std::string& app_id) {
- absl::optional<base::win::RegKey> key =
+ std::optional<base::win::RegKey> key =
ClientStateAppKeyOpen(updater_scope, app_id, KEY_READ | KEY_WRITE);
if (!key) {
return;
@@ -139,10 +139,10 @@
.Valid();
}
-absl::optional<InstallerOutcome> GetLastInstallerOutcome(
- absl::optional<base::win::RegKey> key) {
+std::optional<InstallerOutcome> GetLastInstallerOutcome(
+ std::optional<base::win::RegKey> key) {
if (!key) {
- return absl::nullopt;
+ return std::nullopt;
}
InstallerOutcome installer_outcome;
{
@@ -186,19 +186,19 @@
InstallerOutcome::InstallerOutcome(const InstallerOutcome&) = default;
InstallerOutcome::~InstallerOutcome() = default;
-absl::optional<base::win::RegKey> ClientStateAppKeyOpen(
+std::optional<base::win::RegKey> ClientStateAppKeyOpen(
UpdaterScope updater_scope,
const std::string& app_id,
REGSAM regsam) {
std::wstring subkey;
if (!base::UTF8ToWide(app_id.c_str(), app_id.size(), &subkey)) {
- return absl::nullopt;
+ return std::nullopt;
}
base::win::RegKey key(UpdaterScopeToHKeyRoot(updater_scope), CLIENT_STATE_KEY,
Wow6432(regsam));
if (!key.Valid() ||
key.OpenKey(subkey.c_str(), Wow6432(regsam)) != ERROR_SUCCESS) {
- return absl::nullopt;
+ return std::nullopt;
}
return key;
}
@@ -218,7 +218,7 @@
// {HKLM|HKCU}\Software\Google\Update\ClientState\<appid>\InstallerProgress.
int GetInstallerProgress(UpdaterScope updater_scope,
const std::string& app_id) {
- absl::optional<base::win::RegKey> key =
+ std::optional<base::win::RegKey> key =
ClientStateAppKeyOpen(updater_scope, app_id, KEY_READ);
DWORD progress = 0;
if (!key || key->ReadValueDW(kRegValueInstallerProgress, &progress) !=
@@ -231,7 +231,7 @@
bool SetInstallerProgressForTesting(UpdaterScope updater_scope,
const std::string& app_id,
int value) {
- absl::optional<base::win::RegKey> key =
+ std::optional<base::win::RegKey> key =
ClientStateAppKeyCreate(updater_scope, app_id, KEY_WRITE);
return key && key->WriteValue(kRegValueInstallerProgress,
static_cast<DWORD>(value)) == ERROR_SUCCESS;
@@ -242,7 +242,7 @@
if (!ClientStateAppKeyExists(updater_scope, app_id)) {
return false;
}
- absl::optional<base::win::RegKey> key =
+ std::optional<base::win::RegKey> key =
ClientStateAppKeyOpen(updater_scope, app_id, KEY_SET_VALUE);
return key && key->DeleteValue(kRegValueInstallerProgress) == ERROR_SUCCESS;
}
@@ -252,7 +252,7 @@
if (!ClientStateAppKeyExists(updater_scope, app_id)) {
return false;
}
- absl::optional<base::win::RegKey> key = ClientStateAppKeyOpen(
+ std::optional<base::win::RegKey> key = ClientStateAppKeyOpen(
updater_scope, app_id, KEY_SET_VALUE | KEY_QUERY_VALUE);
if (!key) {
return false;
@@ -271,13 +271,12 @@
return !base::Contains(results, false);
}
-absl::optional<InstallerOutcome> GetInstallerOutcome(
- UpdaterScope updater_scope,
- const std::string& app_id) {
- absl::optional<base::win::RegKey> key =
+std::optional<InstallerOutcome> GetInstallerOutcome(UpdaterScope updater_scope,
+ const std::string& app_id) {
+ std::optional<base::win::RegKey> key =
ClientStateAppKeyOpen(updater_scope, app_id, KEY_READ);
if (!key) {
- return absl::nullopt;
+ return std::nullopt;
}
InstallerOutcome installer_outcome;
{
@@ -316,17 +315,17 @@
return installer_outcome;
}
-absl::optional<InstallerOutcome> GetClientStateKeyLastInstallerOutcome(
+std::optional<InstallerOutcome> GetClientStateKeyLastInstallerOutcome(
UpdaterScope updater_scope,
const std::string& app_id) {
return GetLastInstallerOutcome(
ClientStateAppKeyOpen(updater_scope, app_id, KEY_READ));
}
-absl::optional<InstallerOutcome> GetUpdaterKeyLastInstallerOutcome(
+std::optional<InstallerOutcome> GetUpdaterKeyLastInstallerOutcome(
UpdaterScope updater_scope) {
return GetLastInstallerOutcome(
- [&updater_scope]() -> absl::optional<base::win::RegKey> {
+ [&updater_scope]() -> std::optional<base::win::RegKey> {
if (base::win::RegKey updater_key(UpdaterScopeToHKeyRoot(updater_scope),
UPDATER_KEY, Wow6432(KEY_READ));
updater_key.Valid()) {
@@ -339,7 +338,7 @@
bool SetInstallerOutcomeForTesting(UpdaterScope updater_scope,
const std::string& app_id,
const InstallerOutcome& installer_outcome) {
- absl::optional<base::win::RegKey> key =
+ std::optional<base::win::RegKey> key =
ClientStateAppKeyCreate(updater_scope, app_id, KEY_WRITE);
if (!key) {
return false;
@@ -388,7 +387,7 @@
// backward compatible with the implementation of the Installer API in
// Omaha/Google Update. Some edge cases could be missing.
Installer::Result MakeInstallerResult(
- absl::optional<InstallerOutcome> installer_outcome,
+ std::optional<InstallerOutcome> installer_outcome,
int exit_code) {
InstallerOutcome outcome;
if (installer_outcome && installer_outcome->installer_result) {
@@ -468,7 +467,7 @@
const AppInfo& app_info,
const base::FilePath& app_installer,
const std::string& arguments,
- const absl::optional<base::FilePath>& installer_data_file,
+ const std::optional<base::FilePath>& installer_data_file,
bool usage_stats_enabled,
const base::TimeDelta& timeout,
InstallProgressCallback progress_callback) {
diff --git a/chrome/updater/win/installer_api.h b/chrome/updater/win/installer_api.h
index 1a8b733..f089b14 100644
--- a/chrome/updater/win/installer_api.h
+++ b/chrome/updater/win/installer_api.h
@@ -5,6 +5,7 @@
#ifndef CHROME_UPDATER_WIN_INSTALLER_API_H_
#define CHROME_UPDATER_WIN_INSTALLER_API_H_
+#include <optional>
#include <string>
#include <utility>
@@ -12,7 +13,6 @@
#include "chrome/updater/enum_traits.h"
#include "chrome/updater/installer.h"
#include "chrome/updater/win/win_constants.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
@@ -84,15 +84,15 @@
InstallerOutcome(const InstallerOutcome&);
~InstallerOutcome();
- absl::optional<InstallerResult> installer_result;
- absl::optional<int> installer_error;
- absl::optional<int> installer_extracode1;
- absl::optional<std::string> installer_text;
- absl::optional<std::string> installer_cmd_line;
+ std::optional<InstallerResult> installer_result;
+ std::optional<int> installer_error;
+ std::optional<int> installer_extracode1;
+ std::optional<std::string> installer_text;
+ std::optional<std::string> installer_cmd_line;
};
// Opens the registry ClientState subkey for the `app_id`.
-absl::optional<base::win::RegKey> ClientStateAppKeyOpen(
+std::optional<base::win::RegKey> ClientStateAppKeyOpen(
UpdaterScope updater_scope,
const std::string& app_id,
REGSAM regsam);
@@ -116,14 +116,14 @@
// Returns the Installer API outcome, best-effort, and renames the InstallerXXX
// values to LastInstallerXXX values. The LastInstallerXXX values remain around
// until the next update or install.
-absl::optional<InstallerOutcome> GetInstallerOutcome(UpdaterScope updater_scope,
- const std::string& app_id);
+std::optional<InstallerOutcome> GetInstallerOutcome(UpdaterScope updater_scope,
+ const std::string& app_id);
// Returns the Last Installer API outcome, i.e., the LastInstallerXXX values.
-absl::optional<InstallerOutcome> GetClientStateKeyLastInstallerOutcome(
+std::optional<InstallerOutcome> GetClientStateKeyLastInstallerOutcome(
UpdaterScope updater_scope,
const std::string& app_id);
-absl::optional<InstallerOutcome> GetUpdaterKeyLastInstallerOutcome(
+std::optional<InstallerOutcome> GetUpdaterKeyLastInstallerOutcome(
UpdaterScope updater_scope);
bool SetInstallerOutcomeForTesting(UpdaterScope updater_scope,
@@ -141,7 +141,7 @@
// mean `FINGERPRINT_WRITE_FAILED = 2` or the windows error
// `ERROR_FILE_NOT_FOUND`.
Installer::Result MakeInstallerResult(
- absl::optional<InstallerOutcome> installer_outcome,
+ std::optional<InstallerOutcome> installer_outcome,
int exit_code);
} // namespace updater
diff --git a/chrome/updater/win/installer_api_unittest.cc b/chrome/updater/win/installer_api_unittest.cc
index db89f51..143b7bf 100644
--- a/chrome/updater/win/installer_api_unittest.cc
+++ b/chrome/updater/win/installer_api_unittest.cc
@@ -4,6 +4,7 @@
#include "chrome/updater/win/installer_api.h"
+#include <optional>
#include <string>
#include "base/strings/utf_string_conversions.h"
@@ -14,7 +15,6 @@
#include "chrome/updater/util/win_util.h"
#include "chrome/updater/win/win_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace {
@@ -73,7 +73,7 @@
installer_outcome));
}
- absl::optional<InstallerOutcome> installer_outcome =
+ std::optional<InstallerOutcome> installer_outcome =
GetInstallerOutcome(updater_scope_, kAppId);
ASSERT_TRUE(installer_outcome);
EXPECT_EQ(installer_outcome->installer_result, InstallerResult::kSystemError);
@@ -83,7 +83,7 @@
EXPECT_STREQ(installer_outcome->installer_cmd_line->c_str(), "some cmd line");
// Checks that LastInstallerXXX values match the installer outcome.
- for (absl::optional<InstallerOutcome> last_installer_outcome :
+ for (std::optional<InstallerOutcome> last_installer_outcome :
{GetClientStateKeyLastInstallerOutcome(updater_scope_, kAppId),
GetUpdaterKeyLastInstallerOutcome(updater_scope_)}) {
ASSERT_TRUE(last_installer_outcome);
@@ -162,7 +162,7 @@
EXPECT_EQ(installer_result.extended_error, -2);
EXPECT_STREQ(installer_result.installer_text.c_str(), "some text");
EXPECT_TRUE(installer_result.installer_cmd_line.empty());
- installer_outcome.installer_error = absl::nullopt;
+ installer_outcome.installer_error = std::nullopt;
installer_result = MakeInstallerResult(installer_outcome, 10);
EXPECT_EQ(installer_result.error, kErrorApplicationInstallerFailed);
EXPECT_EQ(installer_result.original_error, 10);
@@ -184,7 +184,7 @@
EXPECT_EQ(installer_result.extended_error, -2);
EXPECT_FALSE(installer_result.installer_text.empty());
EXPECT_TRUE(installer_result.installer_cmd_line.empty());
- installer_outcome.installer_error = absl::nullopt;
+ installer_outcome.installer_error = std::nullopt;
installer_result = MakeInstallerResult(installer_outcome, 10);
EXPECT_EQ(installer_result.error, kErrorApplicationInstallerFailed);
EXPECT_EQ(installer_result.original_error, 10);
@@ -206,7 +206,7 @@
EXPECT_EQ(installer_result.extended_error, -2);
EXPECT_FALSE(installer_result.installer_text.empty());
EXPECT_TRUE(installer_result.installer_cmd_line.empty());
- installer_outcome.installer_error = absl::nullopt;
+ installer_outcome.installer_error = std::nullopt;
installer_result = MakeInstallerResult(installer_outcome, 10);
EXPECT_EQ(installer_result.error, kErrorApplicationInstallerFailed);
EXPECT_EQ(installer_result.original_error, 10);
diff --git a/chrome/updater/win/manifest_util.cc b/chrome/updater/win/manifest_util.cc
index 05c39ff..da70dfa 100644
--- a/chrome/updater/win/manifest_util.cc
+++ b/chrome/updater/win/manifest_util.cc
@@ -6,6 +6,7 @@
#include <cstdint>
#include <memory>
+#include <optional>
#include <string>
#include <vector>
@@ -24,14 +25,13 @@
#include "chrome/updater/win/protocol_parser_xml.h"
#include "components/update_client/protocol_parser.h"
#include "components/update_client/utils.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace {
constexpr char kArchAmd64Omaha3[] = "x64";
-absl::optional<base::FilePath> GetOfflineManifest(
+std::optional<base::FilePath> GetOfflineManifest(
const base::FilePath& offline_dir,
const std::string& app_id) {
// Check manifest with fixed name first.
@@ -44,14 +44,14 @@
manifest_path =
offline_dir.AppendASCII(app_id).AddExtension(FILE_PATH_LITERAL(".gup"));
return base::PathExists(manifest_path)
- ? absl::optional<base::FilePath>(manifest_path)
- : absl::nullopt;
+ ? std::optional<base::FilePath>(manifest_path)
+ : std::nullopt;
}
std::unique_ptr<ProtocolParserXML> ParseOfflineManifest(
const base::FilePath& offline_dir,
const std::string& app_id) {
- absl::optional<base::FilePath> manifest_path =
+ std::optional<base::FilePath> manifest_path =
GetOfflineManifest(offline_dir, app_id);
if (!manifest_path) {
VLOG(2) << "Cannot find manifest file in: " << offline_dir;
diff --git a/chrome/updater/win/setup/setup.cc b/chrome/updater/win/setup/setup.cc
index 79ed694e..a2e96097 100644
--- a/chrome/updater/win/setup/setup.cc
+++ b/chrome/updater/win/setup/setup.cc
@@ -7,6 +7,7 @@
#include <shlobj.h>
#include <memory>
+#include <optional>
#include <string>
#include <vector>
@@ -29,7 +30,6 @@
#include "chrome/updater/util/win_util.h"
#include "chrome/updater/win/setup/setup_util.h"
#include "chrome/updater/win/win_constants.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace {
@@ -72,7 +72,7 @@
LOG(ERROR) << "GetTempDir failed.";
return kErrorCreatingTempDir;
}
- const absl::optional<base::FilePath> versioned_dir =
+ const std::optional<base::FilePath> versioned_dir =
GetVersionedInstallDirectory(scope);
if (!versioned_dir) {
LOG(ERROR) << "GetVersionedInstallDirectory failed.";
diff --git a/chrome/updater/win/setup/setup_util.cc b/chrome/updater/win/setup/setup_util.cc
index e282623..0a770d3 100644
--- a/chrome/updater/win/setup/setup_util.cc
+++ b/chrome/updater/win/setup/setup_util.cc
@@ -11,6 +11,7 @@
#include <wrl/implements.h>
#include <cstring>
+#include <optional>
#include <string>
#include <tuple>
#include <utility>
@@ -230,7 +231,7 @@
bool InstallComInterfaces(UpdaterScope scope, bool is_internal) {
VLOG(1) << __func__ << ": scope: " << scope
<< ": is_internal: " << is_internal;
- const absl::optional<base::FilePath> versioned_directory =
+ const std::optional<base::FilePath> versioned_directory =
GetVersionedInstallDirectory(scope);
if (!versioned_directory) {
return false;
diff --git a/chrome/updater/win/setup/uninstall.cc b/chrome/updater/win/setup/uninstall.cc
index 2b00069e..2cbc16a 100644
--- a/chrome/updater/win/setup/uninstall.cc
+++ b/chrome/updater/win/setup/uninstall.cc
@@ -8,6 +8,7 @@
#include <windows.h>
#include <memory>
+#include <optional>
#include <string>
#include <vector>
@@ -30,7 +31,6 @@
#include "chrome/updater/util/win_util.h"
#include "chrome/updater/win/setup/setup_util.h"
#include "chrome/updater/win/win_constants.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
namespace updater {
namespace {
@@ -137,7 +137,7 @@
void DeleteGoogleUpdateFilesAndKeys(UpdaterScope scope) {
DeleteUpdaterKey(scope);
- const absl::optional<base::FilePath> target_path =
+ const std::optional<base::FilePath> target_path =
GetGoogleUpdateExePath(scope);
if (target_path) {
base::DeletePathRecursively(target_path->DirName());
@@ -145,13 +145,13 @@
}
int RunUninstallScript(UpdaterScope scope, bool uninstall_all) {
- const absl::optional<base::FilePath> versioned_dir =
+ const std::optional<base::FilePath> versioned_dir =
GetVersionedInstallDirectory(scope);
if (!versioned_dir) {
LOG(ERROR) << "GetVersionedInstallDirectory failed.";
return kErrorNoVersionedDirectory;
}
- const absl::optional<base::FilePath> base_dir = GetInstallDirectory(scope);
+ const std::optional<base::FilePath> base_dir = GetInstallDirectory(scope);
if (IsSystemInstall(scope) && !base_dir) {
LOG(ERROR) << "GetInstallDirectory failed.";
return kErrorNoBaseDirectory;
diff --git a/chrome/updater/win/task_scheduler_unittest.cc b/chrome/updater/win/task_scheduler_unittest.cc
index eef30ace..c6b01af 100644
--- a/chrome/updater/win/task_scheduler_unittest.cc
+++ b/chrome/updater/win/task_scheduler_unittest.cc
@@ -11,6 +11,7 @@
#include <taskschd.h>
#include <memory>
+#include <optional>
#include <string>
#include <vector>
@@ -82,7 +83,7 @@
}
std::wstring GetRegKeyTaskCacheTasksContents() {
- absl::optional<std::wstring> contents = GetRegKeyContents(
+ std::optional<std::wstring> contents = GetRegKeyContents(
L"HKLM\\SOFTWARE\\Microsoft\\Windows "
L"NT\\CurrentVersion\\Schedule\\TaskCache\\Tasks");
return contents ? *contents : L"";