0

components: Replace base::Optional and friends with absl counterparts

This replaces:
- base::Optional -> absl::optional
- include "base/optional.h"
  ->
  include "third_party/abseil-cpp/absl/types/optional.h"
- base::nullopt -> absl::nullopt
- base::make_optional -> absl::make_optional

Bug: 1202909
Change-Id: If697b7bf69b199c1796f873eedca3359cdb48c64
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2897151
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Owners-Override: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#883296}
This commit is contained in:
Anton Bikineev
2021-05-15 22:35:36 +00:00
committed by Chromium LUCI CQ
parent 330c3555c6
commit 1156b5f891
1791 changed files with 7792 additions and 7790 deletions
components
account_id
account_manager_core
apdu
arc
appfuse
arc_features_parser.ccarc_features_parser.harc_features_parser_unittest.ccarc_util.cc
bluetooth
compat_mode
crash_collector
disk_quota
enterprise
ime
intent_helper
lock_screen
metrics
mojom
net
power
property
sensor
session
test
timer
usb
video_accelerator
autofill
content
core
browser
address_profile_save_manager.haddress_profile_save_manager_unittest.ccautofill_field.hautofill_form_test_utils.ccautofill_form_test_utils.hautofill_merge_unittest.ccautofill_metrics_unittest.ccautofill_profile_import_process.ccautofill_profile_import_process.hautofill_profile_save_strike_database.ccautofill_profile_save_strike_database.hautofill_profile_update_strike_database.ccautofill_profile_update_strike_database.hautofill_save_update_address_profile_delegate_ios.hbrowser_autofill_manager.ccbrowser_autofill_manager.h
data_model
field_filler.ccform_data_importer.ccform_data_importer.hform_data_importer_unittest.cc
form_parsing
form_processing
form_structure.ccform_structure.h
geo
metrics
pattern_provider
payments
personal_data_manager_unittest.ccstrike_database_integrator_base.ccstrike_database_integrator_base.hstrike_database_integrator_test_strike_database.ccstrike_database_integrator_test_strike_database.hstrike_database_integrator_test_strike_database_unittest.cctest_autofill_client.htest_browser_autofill_manager.cctest_browser_autofill_manager.htest_personal_data_manager.h
ui
webdata
common
ios
autofill_assistant
browser
actions
autofill_assistant_onboarding_fetcher.ccclient.hclient_context_unittest.ccclient_settings.hcontroller.cccontroller.hcontroller_unittest.ccdetails.ccdetails.h
devtools
element_precondition.hevent_handler.ccevent_handler.hfake_starter_platform_delegate.ccfake_starter_platform_delegate.hfield_formatter.ccfield_formatter.hfield_formatter_unittest.ccmock_client.hprotocol_utils.ccprotocol_utils.hprotocol_utils_unittest.ccscript_executor.hscript_parameters.ccscript_parameters.hselector.h
service
starter.ccstarter.hstarter_heuristic.ccstarter_heuristic.hstarter_heuristic_unittest.ccstarter_platform_delegate.hstarter_unittest.ccstartup_util.ccstartup_util.hstartup_util_unittest.cctrigger_context.h
trigger_scripts
ui_delegate.huser_data.ccuser_data.huser_data_util_unittest.ccuser_model.ccuser_model.huser_model_unittest.ccvalue_util.ccvalue_util.hvalue_util_unittest.cc
web
background_sync
background_task_scheduler
blocked_content
blocklist
bookmarks
breadcrumbs
browser_sync
browsing_data
captive_portal
cast
cast_channel
cast_streaming
cbor
cdm
chromeos_camera
client_hints
cloud_devices
component_updater
consent_auditor
content_capture
content_settings
crash
cronet
crx_file
data_reduction_proxy
digital_asset_links
discardable_memory
dom_distiller
domain_reliability
download
embedder_support
enterprise
error_page
exo
favicon
feature_engagement
federated_learning
feed
full_restore
gcm_driver
gwp_asan
history
history_clusters
image_fetcher
invalidation
javascript_dialogs
js_injection
link_header_util
live_caption
media_message_center
media_router
metrics
mirroring
navigation_interception
network_hints
network_session_configurator
no_state_prefetch
ntp_snippets
ntp_tiles
offline_items_collection
offline_pages
omnibox
open_from_clipboard
openscreen_platform
optimization_guide
content
core
os_crypt
page_image_annotation
page_info
page_load_metrics
paint_preview
password_manager
content
core
browser
browser_save_password_progress_logger.ccchange_password_url_service_impl.cccredential_manager_impl.cccredential_manager_impl.hcredential_manager_impl_unittest.cccredential_manager_utils.cc
form_parsing
form_saver.hhash_password_manager.cchash_password_manager.hhash_password_manager_unittest.cchttp_auth_manager_unittest.cc
import
leak_detection
password_form_manager.ccpassword_form_manager_unittest.ccpassword_form_metrics_recorder.ccpassword_form_metrics_recorder.hpassword_form_metrics_recorder_unittest.ccpassword_generation_frame_helper.ccpassword_generation_manager.hpassword_manager.hpassword_manager_features_util.ccpassword_manager_metrics_util.ccpassword_manager_metrics_util.hpassword_manager_test_utils.ccpassword_manager_test_utils.hpassword_manager_unittest.ccpassword_reuse_detection_manager.ccpassword_reuse_detection_manager.hpassword_reuse_detection_manager_unittest.ccpassword_reuse_detector.ccpassword_reuse_detector.hpassword_reuse_detector_consumer.hpassword_reuse_detector_unittest.ccpassword_save_manager_impl.ccpassword_save_manager_impl.hpassword_save_manager_impl_unittest.ccpassword_scripts_fetcher_impl.ccpassword_store.ccpassword_store.hpassword_store_unittest.ccpossible_username_data.hstub_password_manager_client.h
sync
ui
votes_uploader.ccvotes_uploader.hvotes_uploader_unittest.ccwell_known_change_password_state.ccwell_known_change_password_state.h
common
ios
payments
pdf
performance_manager
permissions
policy
power_scheduler
prefs
printing
qr_code_generator
query_tiles
reading_list
remote_cocoa
reporting
safe_browsing
safe_search_api
scheduling_metrics
schema_org
search
search_engines
search_provider_logos
security_interstitials
send_tab_to_self
services
app_service
filesystem
font
heap_profiling
paint_preview_compositor
print_compositor
storage
sessions
shared_highlighting
signin
soda
sqlite_proto
startup_metric_utils
subresource_filter
suggestions
sync
base
driver
engine
loopback_server
invalidations
model
nigori
test
trusted_vault
sync_bookmarks
sync_device_info
sync_preferences
sync_sessions
sync_user_events
system_media_controls
thin_webview
translate
ui_devtools
ukm
update_client
upload_list
url_matcher
url_pattern_index
user_manager
variations
visitedlink
viz
client
common
demo
host
service
compositor_frame_fuzzer
debugger
display
display_embedder
frame_sinks
gl
hit_test
main
surfaces
transitions
test
web_cache
web_package
webapps
webauthn
webcrypto
webrtc_logging
zucchini
tools/variations/unittest_data

@ -244,7 +244,7 @@ std::string AccountId::Serialize() const {
// static
bool AccountId::Deserialize(const std::string& serialized,
AccountId* account_id) {
base::Optional<base::Value> value(base::JSONReader::Read(serialized));
absl::optional<base::Value> value(base::JSONReader::Read(serialized));
if (!value || !value->is_dict())
return false;

@ -5,9 +5,9 @@
#ifndef COMPONENTS_ACCOUNT_MANAGER_CORE_ACCOUNT_ADDITION_RESULT_H_
#define COMPONENTS_ACCOUNT_MANAGER_CORE_ACCOUNT_ADDITION_RESULT_H_
#include "base/optional.h"
#include "components/account_manager_core/account.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace account_manager {
@ -31,9 +31,9 @@ struct COMPONENT_EXPORT(ACCOUNT_MANAGER_CORE) AccountAdditionResult {
Status status;
// The account that was added.
base::Optional<Account> account;
absl::optional<Account> account;
// The error is set only if `status` is set to `kNetworkError`.
base::Optional<GoogleServiceAuthError> error;
absl::optional<GoogleServiceAuthError> error;
explicit AccountAdditionResult(Status status);
AccountAdditionResult(Status status, Account account);

@ -98,7 +98,7 @@ class COMPONENT_EXPORT(ACCOUNT_MANAGER_CORE) AccountManagerFacade {
// Launches account addition dialog and calls the `callback` with the result.
// If `result` is `kSuccess`, the added account will be passed to the
// callback. Otherwise `account` will be set to `base::nullopt`.
// callback. Otherwise `account` will be set to `absl::nullopt`.
virtual void ShowAddAccountDialog(
const AccountAdditionSource& source,
base::OnceCallback<void(const AccountAdditionResult& result)>

@ -14,7 +14,6 @@
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/optional.h"
#include "chromeos/crosapi/mojom/account_manager.mojom.h"
#include "components/account_manager_core/account.h"
#include "components/account_manager_core/account_addition_result.h"
@ -23,6 +22,7 @@
#include "google_apis/gaia/oauth2_access_token_consumer.h"
#include "google_apis/gaia/oauth2_access_token_fetcher.h"
#include "google_apis/gaia/oauth2_access_token_fetcher_immediate_error.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace account_manager {
@ -39,7 +39,7 @@ void UnmarshalAccounts(
std::vector<crosapi::mojom::AccountPtr> mojo_accounts) {
std::vector<Account> accounts;
for (const auto& mojo_account : mojo_accounts) {
base::Optional<Account> maybe_account = FromMojoAccount(mojo_account);
absl::optional<Account> maybe_account = FromMojoAccount(mojo_account);
if (!maybe_account) {
// Skip accounts we couldn't unmarshal. No logging, as it would produce
// a lot of noise.
@ -53,7 +53,7 @@ void UnmarshalAccounts(
void UnmarshalPersistentError(
base::OnceCallback<void(const GoogleServiceAuthError&)> callback,
crosapi::mojom::GoogleServiceAuthErrorPtr mojo_error) {
base::Optional<GoogleServiceAuthError> maybe_error =
absl::optional<GoogleServiceAuthError> maybe_error =
FromMojoGoogleServiceAuthError(mojo_error);
if (!maybe_error) {
// Couldn't unmarshal GoogleServiceAuthError, report the account as not
@ -158,7 +158,7 @@ class AccountManagerFacadeImpl::AccessTokenFetcher
is_request_pending_ = false;
if (result->is_error()) {
base::Optional<GoogleServiceAuthError> maybe_error =
absl::optional<GoogleServiceAuthError> maybe_error =
account_manager::FromMojoGoogleServiceAuthError(result->get_error());
if (!maybe_error.has_value()) {
@ -368,7 +368,7 @@ void AccountManagerFacadeImpl::OnShowAddAccountDialogFinished(
base::OnceCallback<
void(const account_manager::AccountAdditionResult& result)> callback,
crosapi::mojom::AccountAdditionResultPtr mojo_result) {
base::Optional<account_manager::AccountAdditionResult> result =
absl::optional<account_manager::AccountAdditionResult> result =
account_manager::FromMojoAccountAdditionResult(mojo_result);
if (!result.has_value()) {
FinishAddAccount(std::move(callback),
@ -390,7 +390,7 @@ void AccountManagerFacadeImpl::FinishAddAccount(
void AccountManagerFacadeImpl::OnTokenUpserted(
crosapi::mojom::AccountPtr account) {
base::Optional<Account> maybe_account = FromMojoAccount(account);
absl::optional<Account> maybe_account = FromMojoAccount(account);
if (!maybe_account) {
LOG(WARNING) << "Can't unmarshal account of type: "
<< account->key->account_type;
@ -403,7 +403,7 @@ void AccountManagerFacadeImpl::OnTokenUpserted(
void AccountManagerFacadeImpl::OnAccountRemoved(
crosapi::mojom::AccountPtr account) {
base::Optional<Account> maybe_account = FromMojoAccount(account);
absl::optional<Account> maybe_account = FromMojoAccount(account);
if (!maybe_account) {
LOG(WARNING) << "Can't unmarshal account of type: "
<< account->key->account_type;

@ -140,7 +140,7 @@ class FakeAccountManager : public crosapi::mojom::AccountManager {
void GetPersistentErrorForAccount(
crosapi::mojom::AccountKeyPtr mojo_account_key,
GetPersistentErrorForAccountCallback callback) override {
base::Optional<AccountKey> account_key =
absl::optional<AccountKey> account_key =
FromMojoAccountKey(mojo_account_key);
DCHECK(account_key.has_value());
auto it = persistent_errors_.find(account_key.value());

@ -91,7 +91,7 @@ crosapi::mojom::GoogleServiceAuthError::State ToMojoGoogleServiceAuthErrorState(
}
}
base::Optional<account_manager::AccountAdditionResult::Status>
absl::optional<account_manager::AccountAdditionResult::Status>
FromMojoAccountAdditionStatus(
crosapi::mojom::AccountAdditionResult::Status mojo_status) {
switch (mojo_status) {
@ -109,7 +109,7 @@ FromMojoAccountAdditionStatus(
default:
LOG(WARNING) << "Unknown crosapi::mojom::AccountAdditionResult::Status: "
<< mojo_status;
return base::nullopt;
return absl::nullopt;
}
}
@ -131,12 +131,12 @@ crosapi::mojom::AccountAdditionResult::Status ToMojoAccountAdditionStatus(
} // namespace
base::Optional<account_manager::Account> FromMojoAccount(
absl::optional<account_manager::Account> FromMojoAccount(
const crosapi::mojom::AccountPtr& mojom_account) {
const base::Optional<account_manager::AccountKey> account_key =
const absl::optional<account_manager::AccountKey> account_key =
FromMojoAccountKey(mojom_account->key);
if (!account_key.has_value())
return base::nullopt;
return absl::nullopt;
account_manager::Account account;
account.key = account_key.value();
@ -152,12 +152,12 @@ crosapi::mojom::AccountPtr ToMojoAccount(
return mojom_account;
}
base::Optional<account_manager::AccountKey> FromMojoAccountKey(
absl::optional<account_manager::AccountKey> FromMojoAccountKey(
const crosapi::mojom::AccountKeyPtr& mojom_account_key) {
const base::Optional<account_manager::AccountType> account_type =
const absl::optional<account_manager::AccountType> account_type =
FromMojoAccountType(mojom_account_key->account_type);
if (!account_type.has_value())
return base::nullopt;
return absl::nullopt;
account_manager::AccountKey account_key;
account_key.id = mojom_account_key->id;
@ -174,7 +174,7 @@ crosapi::mojom::AccountKeyPtr ToMojoAccountKey(
return mojom_account_key;
}
base::Optional<account_manager::AccountType> FromMojoAccountType(
absl::optional<account_manager::AccountType> FromMojoAccountType(
const crosapi::mojom::AccountType& account_type) {
switch (account_type) {
case crosapi::mojom::AccountType::kGaia:
@ -192,7 +192,7 @@ base::Optional<account_manager::AccountType> FromMojoAccountType(
// Don't consider this as as error to preserve forwards compatibility with
// lacros.
LOG(WARNING) << "Unknown account type: " << account_type;
return base::nullopt;
return absl::nullopt;
}
}
@ -206,7 +206,7 @@ crosapi::mojom::AccountType ToMojoAccountType(
}
}
base::Optional<GoogleServiceAuthError> FromMojoGoogleServiceAuthError(
absl::optional<GoogleServiceAuthError> FromMojoGoogleServiceAuthError(
const crosapi::mojom::GoogleServiceAuthErrorPtr& mojo_error) {
switch (mojo_error->state) {
case cm::GoogleServiceAuthError::State::kNone:
@ -236,7 +236,7 @@ base::Optional<GoogleServiceAuthError> FromMojoGoogleServiceAuthError(
default:
LOG(WARNING) << "Unknown crosapi::mojom::GoogleServiceAuthError::State: "
<< mojo_error->state;
return base::nullopt;
return absl::nullopt;
}
}
@ -258,13 +258,13 @@ crosapi::mojom::GoogleServiceAuthErrorPtr ToMojoGoogleServiceAuthError(
return mojo_result;
}
base::Optional<account_manager::AccountAdditionResult>
absl::optional<account_manager::AccountAdditionResult>
FromMojoAccountAdditionResult(
const crosapi::mojom::AccountAdditionResultPtr& mojo_result) {
base::Optional<account_manager::AccountAdditionResult::Status> status =
absl::optional<account_manager::AccountAdditionResult::Status> status =
FromMojoAccountAdditionStatus(mojo_result->status);
if (!status.has_value()) {
return base::nullopt;
return absl::nullopt;
}
account_manager::AccountAdditionResult result(status.value());
result.status = status.value();

@ -5,47 +5,47 @@
#ifndef COMPONENTS_ACCOUNT_MANAGER_CORE_ACCOUNT_MANAGER_UTIL_H_
#define COMPONENTS_ACCOUNT_MANAGER_CORE_ACCOUNT_MANAGER_UTIL_H_
#include "base/optional.h"
#include "chromeos/crosapi/mojom/account_manager.mojom.h"
#include "components/account_manager_core/account.h"
#include "components/account_manager_core/account_addition_result.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
class GoogleServiceAuthError;
namespace account_manager {
// Returns `base::nullopt` if `mojom_account` cannot be parsed.
// Returns `absl::nullopt` if `mojom_account` cannot be parsed.
COMPONENT_EXPORT(ACCOUNT_MANAGER_CORE)
base::Optional<account_manager::Account> FromMojoAccount(
absl::optional<account_manager::Account> FromMojoAccount(
const crosapi::mojom::AccountPtr& mojom_account);
COMPONENT_EXPORT(ACCOUNT_MANAGER_CORE)
crosapi::mojom::AccountPtr ToMojoAccount(
const account_manager::Account& account);
// Returns `base::nullopt` if `mojom_account_key` cannot be parsed.
// Returns `absl::nullopt` if `mojom_account_key` cannot be parsed.
COMPONENT_EXPORT(ACCOUNT_MANAGER_CORE)
base::Optional<account_manager::AccountKey> FromMojoAccountKey(
absl::optional<account_manager::AccountKey> FromMojoAccountKey(
const crosapi::mojom::AccountKeyPtr& mojom_account_key);
COMPONENT_EXPORT(ACCOUNT_MANAGER_CORE)
crosapi::mojom::AccountKeyPtr ToMojoAccountKey(
const account_manager::AccountKey& account_key);
// Returns `base::nullopt` if `account_type` cannot be parsed.
// Returns `absl::nullopt` if `account_type` cannot be parsed.
COMPONENT_EXPORT(ACCOUNT_MANAGER_CORE)
base::Optional<account_manager::AccountType> FromMojoAccountType(
absl::optional<account_manager::AccountType> FromMojoAccountType(
const crosapi::mojom::AccountType& account_type);
COMPONENT_EXPORT(ACCOUNT_MANAGER_CORE)
crosapi::mojom::AccountType ToMojoAccountType(
const account_manager::AccountType& account_type);
// Returns `base::nullopt` if `mojo_error` cannot be parsed. This probably means
// Returns `absl::nullopt` if `mojo_error` cannot be parsed. This probably means
// that a new error type was added, so it should be considered a persistent
// error.
COMPONENT_EXPORT(ACCOUNT_MANAGER_CORE)
base::Optional<GoogleServiceAuthError> FromMojoGoogleServiceAuthError(
absl::optional<GoogleServiceAuthError> FromMojoGoogleServiceAuthError(
const crosapi::mojom::GoogleServiceAuthErrorPtr& mojo_error);
COMPONENT_EXPORT(ACCOUNT_MANAGER_CORE)
@ -53,7 +53,7 @@ crosapi::mojom::GoogleServiceAuthErrorPtr ToMojoGoogleServiceAuthError(
GoogleServiceAuthError error);
COMPONENT_EXPORT(ACCOUNT_MANAGER_CORE)
base::Optional<account_manager::AccountAdditionResult>
absl::optional<account_manager::AccountAdditionResult>
FromMojoAccountAdditionResult(
const crosapi::mojom::AccountAdditionResultPtr& mojo_result);

@ -16,10 +16,10 @@ uint16_t ParseMessageLength(base::span<const uint8_t> message, size_t offset) {
} // namespace
base::Optional<ApduCommand> ApduCommand::CreateFromMessage(
absl::optional<ApduCommand> ApduCommand::CreateFromMessage(
base::span<const uint8_t> message) {
if (message.size() < kApduMinHeader || message.size() > kApduMaxLength)
return base::nullopt;
return absl::nullopt;
uint8_t cla = message[0];
uint8_t ins = message[1];
@ -36,12 +36,12 @@ base::Optional<ApduCommand> ApduCommand::CreateFromMessage(
// Invalid encoding sizes.
case kApduMinHeader + 1:
case kApduMinHeader + 2:
return base::nullopt;
return absl::nullopt;
// No data present; response expected.
case kApduMinHeader + 3:
// Fifth byte must be 0.
if (message[4] != 0)
return base::nullopt;
return absl::nullopt;
response_length = ParseMessageLength(message, kApduCommandLengthOffset);
// Special case where response length of 0x0000 corresponds to 65536
// as defined in ISO7816-4.
@ -51,7 +51,7 @@ base::Optional<ApduCommand> ApduCommand::CreateFromMessage(
default:
// Fifth byte must be 0.
if (message[4] != 0)
return base::nullopt;
return absl::nullopt;
auto data_length = ParseMessageLength(message, kApduCommandLengthOffset);
if (message.size() == data_length + kApduCommandDataOffset) {
@ -69,7 +69,7 @@ base::Optional<ApduCommand> ApduCommand::CreateFromMessage(
if (response_length == 0)
response_length = kApduMaxResponseLength;
} else {
return base::nullopt;
return absl::nullopt;
}
break;
}

@ -13,7 +13,7 @@
#include "base/containers/span.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/optional.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace apdu {
@ -28,7 +28,7 @@ namespace apdu {
class COMPONENT_EXPORT(APDU) ApduCommand {
public:
// Constructs an APDU command from the serialized message data.
static base::Optional<ApduCommand> CreateFromMessage(
static absl::optional<ApduCommand> CreateFromMessage(
base::span<const uint8_t> message);
ApduCommand();

@ -11,11 +11,11 @@
namespace apdu {
// static
base::Optional<ApduResponse> ApduResponse::CreateFromMessage(
absl::optional<ApduResponse> ApduResponse::CreateFromMessage(
base::span<const uint8_t> data) {
// Invalid message size, data is appended by status byte.
if (data.size() < 2)
return base::nullopt;
return absl::nullopt;
uint16_t status_bytes = data[data.size() - 2] << 8;
status_bytes |= data[data.size() - 1];

@ -13,7 +13,7 @@
#include "base/containers/span.h"
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/optional.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace apdu {
@ -33,7 +33,7 @@ class COMPONENT_EXPORT(APDU) ApduResponse {
};
// Create a APDU response from the serialized message.
static base::Optional<ApduResponse> CreateFromMessage(
static absl::optional<ApduResponse> CreateFromMessage(
base::span<const uint8_t> data);
ApduResponse(std::vector<uint8_t> data, Status response_status);

@ -40,7 +40,7 @@ class ArcAppfuseBridgeFactory
};
void RunWithScopedHandle(base::OnceCallback<void(mojo::ScopedHandle)> callback,
base::Optional<base::ScopedFD> fd) {
absl::optional<base::ScopedFD> fd) {
if (!fd || !fd.value().is_valid()) {
LOG(ERROR) << "Invalid FD: fd.has_value() = " << fd.has_value();
std::move(callback).Run(mojo::ScopedHandle());

@ -27,17 +27,17 @@ constexpr const base::FilePath::CharType kArcVmFeaturesJsonFile[] =
constexpr const base::FilePath::CharType kArcFeaturesJsonFile[] =
FILE_PATH_LITERAL("/etc/arc/features.json");
base::RepeatingCallback<base::Optional<ArcFeatures>()>*
base::RepeatingCallback<absl::optional<ArcFeatures>()>*
g_arc_features_getter_for_testing = nullptr;
base::Optional<ArcFeatures> ParseFeaturesJson(base::StringPiece input_json) {
absl::optional<ArcFeatures> ParseFeaturesJson(base::StringPiece input_json) {
ArcFeatures arc_features;
base::JSONReader::ValueWithError parsed_json =
base::JSONReader::ReadAndReturnValueWithError(input_json);
if (!parsed_json.value || !parsed_json.value->is_dict()) {
LOG(ERROR) << "Error parsing feature JSON: " << parsed_json.error_message;
return base::nullopt;
return absl::nullopt;
}
// Parse each item under features.
@ -45,7 +45,7 @@ base::Optional<ArcFeatures> ParseFeaturesJson(base::StringPiece input_json) {
parsed_json.value->FindKeyOfType("features", base::Value::Type::LIST);
if (!feature_list) {
LOG(ERROR) << "No feature list in JSON.";
return base::nullopt;
return absl::nullopt;
}
for (auto& feature_item : feature_list->GetList()) {
const base::Value* feature_name =
@ -54,11 +54,11 @@ base::Optional<ArcFeatures> ParseFeaturesJson(base::StringPiece input_json) {
feature_item.FindKeyOfType("version", base::Value::Type::INTEGER);
if (!feature_name || feature_name->GetString().empty()) {
LOG(ERROR) << "Missing name in the feature.";
return base::nullopt;
return absl::nullopt;
}
if (!feature_version) {
LOG(ERROR) << "Missing version in the feature.";
return base::nullopt;
return absl::nullopt;
}
arc_features.feature_map.emplace(feature_name->GetString(),
feature_version->GetInt());
@ -70,17 +70,17 @@ base::Optional<ArcFeatures> ParseFeaturesJson(base::StringPiece input_json) {
base::Value::Type::LIST);
if (!unavailable_feature_list) {
LOG(ERROR) << "No unavailable feature list in JSON.";
return base::nullopt;
return absl::nullopt;
}
for (auto& feature_item : unavailable_feature_list->GetList()) {
if (!feature_item.is_string()) {
LOG(ERROR) << "Item in the unavailable feature list is not a string.";
return base::nullopt;
return absl::nullopt;
}
if (feature_item.GetString().empty()) {
LOG(ERROR) << "Missing name in the feature.";
return base::nullopt;
return absl::nullopt;
}
arc_features.unavailable_features.emplace_back(feature_item.GetString());
}
@ -90,12 +90,12 @@ base::Optional<ArcFeatures> ParseFeaturesJson(base::StringPiece input_json) {
"properties", base::Value::Type::DICTIONARY);
if (!properties) {
LOG(ERROR) << "No properties in JSON.";
return base::nullopt;
return absl::nullopt;
}
for (const auto& item : properties->DictItems()) {
if (!item.second.is_string()) {
LOG(ERROR) << "Item in the properties mapping is not a string.";
return base::nullopt;
return absl::nullopt;
}
arc_features.build_props.emplace(item.first, item.second.GetString());
@ -106,14 +106,14 @@ base::Optional<ArcFeatures> ParseFeaturesJson(base::StringPiece input_json) {
"play_store_version", base::Value::Type::STRING);
if (!play_version) {
LOG(ERROR) << "No Play Store version in JSON.";
return base::nullopt;
return absl::nullopt;
}
arc_features.play_store_version = play_version->GetString();
return arc_features;
}
base::Optional<ArcFeatures> ReadOnFileThread(const base::FilePath& file_path) {
absl::optional<ArcFeatures> ReadOnFileThread(const base::FilePath& file_path) {
DCHECK(!file_path.empty());
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
base::BlockingType::MAY_BLOCK);
@ -125,13 +125,13 @@ base::Optional<ArcFeatures> ReadOnFileThread(const base::FilePath& file_path) {
if (!base::ReadFileToString(file_path, &input_json)) {
PLOG(ERROR) << "Cannot read file " << file_path.value()
<< " into string.";
return base::nullopt;
return absl::nullopt;
}
}
if (input_json.empty()) {
LOG(ERROR) << "Input JSON is empty in file " << file_path.value();
return base::nullopt;
return absl::nullopt;
}
return ParseFeaturesJson(input_json);
@ -145,7 +145,7 @@ ArcFeatures::~ArcFeatures() = default;
ArcFeatures& ArcFeatures::operator=(ArcFeatures&& other) = default;
void ArcFeaturesParser::GetArcFeatures(
base::OnceCallback<void(base::Optional<ArcFeatures>)> callback) {
base::OnceCallback<void(absl::optional<ArcFeatures>)> callback) {
if (g_arc_features_getter_for_testing) {
std::move(callback).Run(g_arc_features_getter_for_testing->Run());
return;
@ -159,13 +159,13 @@ void ArcFeaturesParser::GetArcFeatures(
std::move(callback));
}
base::Optional<ArcFeatures> ArcFeaturesParser::ParseFeaturesJsonForTesting(
absl::optional<ArcFeatures> ArcFeaturesParser::ParseFeaturesJsonForTesting(
base::StringPiece input_json) {
return ParseFeaturesJson(input_json);
}
void ArcFeaturesParser::SetArcFeaturesGetterForTesting(
base::RepeatingCallback<base::Optional<ArcFeatures>()>* getter) {
base::RepeatingCallback<absl::optional<ArcFeatures>()>* getter) {
g_arc_features_getter_for_testing = getter;
}

@ -11,8 +11,8 @@
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/optional.h"
#include "base/strings/string_piece.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace arc {
@ -80,18 +80,18 @@ class ArcFeaturesParser {
public:
// Get ARC system available features.
static void GetArcFeatures(
base::OnceCallback<void(base::Optional<ArcFeatures>)> callback);
base::OnceCallback<void(absl::optional<ArcFeatures>)> callback);
// Given an input feature JSON, return ARC features. This method is for
// testing only.
static base::Optional<ArcFeatures> ParseFeaturesJsonForTesting(
static absl::optional<ArcFeatures> ParseFeaturesJsonForTesting(
base::StringPiece input_json);
// Overrides the ArcFeatures returned by GetArcFeatures, for testing only.
// Does not take ownership of |getter|, it must be alive when GetArcFeatures
// is called.
static void SetArcFeaturesGetterForTesting(
base::RepeatingCallback<base::Optional<ArcFeatures>()>* getter);
base::RepeatingCallback<absl::optional<ArcFeatures>()>* getter);
private:
DISALLOW_COPY_AND_ASSIGN(ArcFeaturesParser);

@ -81,20 +81,20 @@ constexpr const char kInvalidJsonWithMissingFields[] =
"invalid_root_third": {}})json";
TEST_F(ArcFeaturesParserTest, ParseEmptyJson) {
base::Optional<ArcFeatures> arc_features =
absl::optional<ArcFeatures> arc_features =
ArcFeaturesParser::ParseFeaturesJsonForTesting(base::StringPiece());
EXPECT_EQ(arc_features, base::nullopt);
EXPECT_EQ(arc_features, absl::nullopt);
}
TEST_F(ArcFeaturesParserTest, ParseInvalidJson) {
base::Optional<ArcFeatures> arc_features =
absl::optional<ArcFeatures> arc_features =
ArcFeaturesParser::ParseFeaturesJsonForTesting(
kInvalidJsonWithMissingFields);
EXPECT_EQ(arc_features, base::nullopt);
EXPECT_EQ(arc_features, absl::nullopt);
}
TEST_F(ArcFeaturesParserTest, ParseValidJson) {
base::Optional<ArcFeatures> arc_features =
absl::optional<ArcFeatures> arc_features =
ArcFeaturesParser::ParseFeaturesJsonForTesting(kValidJson);
auto feature_map = arc_features->feature_map;
auto unavailable_features = arc_features->unavailable_features;
@ -107,7 +107,7 @@ TEST_F(ArcFeaturesParserTest, ParseValidJson) {
}
TEST_F(ArcFeaturesParserTest, ParseValidJsonWithUnavailableFeature) {
base::Optional<ArcFeatures> arc_features =
absl::optional<ArcFeatures> arc_features =
ArcFeaturesParser::ParseFeaturesJsonForTesting(
kValidJsonWithUnavailableFeature);
auto feature_map = arc_features->feature_map;
@ -121,10 +121,10 @@ TEST_F(ArcFeaturesParserTest, ParseValidJsonWithUnavailableFeature) {
}
TEST_F(ArcFeaturesParserTest, ParseValidJsonWithEmptyFeatureName) {
base::Optional<ArcFeatures> arc_features =
absl::optional<ArcFeatures> arc_features =
ArcFeaturesParser::ParseFeaturesJsonForTesting(
kValidJsonFeatureEmptyName);
EXPECT_EQ(arc_features, base::nullopt);
EXPECT_EQ(arc_features, absl::nullopt);
}
} // namespace

@ -13,7 +13,6 @@
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/optional.h"
#include "base/process/launch.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
@ -24,6 +23,7 @@
#include "components/arc/arc_features.h"
#include "components/exo/shell_surface_util.h"
#include "components/user_manager/user_manager.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
#include "ui/display/types/display_constants.h"
@ -64,7 +64,7 @@ void SetArcCpuRestrictionCallback(
}
void OnSetArcVmCpuRestriction(
base::Optional<vm_tools::concierge::SetVmCpuRestrictionResponse> response) {
absl::optional<vm_tools::concierge::SetVmCpuRestrictionResponse> response) {
if (!response) {
LOG(ERROR) << "Failed to call SetVmCpuRestriction";
return;

@ -230,7 +230,7 @@ TEST(BluetoothTypeConverterTest, ConvertMojoSequenceAttributeToBlueZAttribute) {
sequence_mojo->sequence.push_back(std::move(value_channel));
}
sequence_mojo->type_size = sequence_mojo->sequence.size();
sequence_mojo->value = base::nullopt;
sequence_mojo->value = absl::nullopt;
auto sequence_blue_z =
sequence_mojo.To<bluez::BluetoothServiceAttributeValueBlueZ>();
@ -264,7 +264,7 @@ TEST(BluetoothTypeConverterTest,
auto mojo = arc::mojom::BluetoothSdpAttribute::New();
mojo->type = bluez::BluetoothServiceAttributeValueBlueZ::UINT;
mojo->type_size = static_cast<uint32_t>(sizeof(uint32_t));
mojo->value = base::nullopt;
mojo->value = absl::nullopt;
auto blue_z = mojo.To<bluez::BluetoothServiceAttributeValueBlueZ>();
@ -280,7 +280,7 @@ TEST(BluetoothTypeConverterTest,
auto mojo = arc::mojom::BluetoothSdpAttribute::New();
mojo->type = bluez::BluetoothServiceAttributeValueBlueZ::SEQUENCE;
mojo->type_size = 0;
mojo->value = base::nullopt;
mojo->value = absl::nullopt;
auto blue_z = mojo.To<bluez::BluetoothServiceAttributeValueBlueZ>();

@ -8,9 +8,9 @@
#include "ash/resources/vector_icons/vector_icons.h"
#include "base/notreached.h"
#include "base/optional.h"
#include "components/arc/compat_mode/resize_util.h"
#include "components/strings/grit/components_strings.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/menu/menu_item_view.h"
#include "ui/views/widget/widget.h"
@ -19,7 +19,7 @@ namespace arc {
namespace {
base::Optional<ResizeToggleMenu::CommandId> PredictCurrentMode(
absl::optional<ResizeToggleMenu::CommandId> PredictCurrentMode(
views::Widget* widget) {
const int width = widget->GetWindowBoundsInScreen().width();
const int height = widget->GetWindowBoundsInScreen().height();
@ -32,7 +32,7 @@ base::Optional<ResizeToggleMenu::CommandId> PredictCurrentMode(
return ResizeToggleMenu::CommandId::kResizePhone;
else if (width > height)
return ResizeToggleMenu::CommandId::kResizeTablet;
return base::nullopt;
return absl::nullopt;
}
} // namespace

@ -49,7 +49,7 @@ bool RunCrashReporter(const std::vector<std::string>& args, int stdin_fd) {
void RunJavaCrashReporter(const std::string& crash_type,
base::ScopedFD pipe,
std::vector<std::string> args,
base::Optional<base::TimeDelta> uptime) {
absl::optional<base::TimeDelta> uptime) {
args.push_back("--arc_java_crash=" + crash_type);
if (uptime) {
args.push_back(
@ -138,7 +138,7 @@ ArcCrashCollectorBridge::~ArcCrashCollectorBridge() {
void ArcCrashCollectorBridge::DumpCrash(
const std::string& type,
mojo::ScopedHandle pipe,
base::Optional<base::TimeDelta> uptime) {
absl::optional<base::TimeDelta> uptime) {
base::ThreadPool::PostTask(
FROM_HERE, {base::WithBaseSyncPrimitives()},
base::BindOnce(&RunJavaCrashReporter, type,
@ -172,7 +172,7 @@ void ArcCrashCollectorBridge::SetBuildProperties(
const std::string& device,
const std::string& board,
const std::string& cpu_abi,
const base::Optional<std::string>& fingerprint) {
const absl::optional<std::string>& fingerprint) {
device_ = device;
board_ = board;
cpu_abi_ = cpu_abi;

@ -43,7 +43,7 @@ class ArcCrashCollectorBridge
// mojom::CrashCollectorHost overrides.
void DumpCrash(const std::string& type,
mojo::ScopedHandle pipe,
base::Optional<base::TimeDelta> uptime) override;
absl::optional<base::TimeDelta> uptime) override;
void DumpNativeCrash(const std::string& exec_name,
int32_t pid,
int64_t timestamp,
@ -53,7 +53,7 @@ class ArcCrashCollectorBridge
const std::string& device,
const std::string& board,
const std::string& cpu_abi,
const base::Optional<std::string>& fingerprint) override;
const absl::optional<std::string>& fingerprint) override;
private:
std::vector<std::string> CreateCrashReporterArgs();
@ -63,7 +63,7 @@ class ArcCrashCollectorBridge
std::string device_;
std::string board_;
std::string cpu_abi_;
base::Optional<std::string> fingerprint_;
absl::optional<std::string> fingerprint_;
};
} // namespace arc

@ -41,9 +41,9 @@ TEST_F(ArcCrashCollectorBridgeTest, ConstructDestruct) {}
TEST_F(ArcCrashCollectorBridgeTest, SetBuildProperties) {
ASSERT_NE(nullptr, bridge());
bridge()->SetBuildProperties("device", "board", "cpu_abi",
base::Optional<std::string>());
absl::optional<std::string>());
bridge()->SetBuildProperties("device", "board", "cpu_abi",
base::Optional<std::string>("fingerprint"));
absl::optional<std::string>("fingerprint"));
}
// Tests that DumpCrash doesn't crash.
@ -51,8 +51,8 @@ TEST_F(ArcCrashCollectorBridgeTest, SetBuildProperties) {
TEST_F(ArcCrashCollectorBridgeTest, DumpCrash) {
ASSERT_NE(nullptr, bridge());
bridge()->SetBuildProperties("device", "board", "cpu_abi",
base::Optional<std::string>());
bridge()->DumpCrash("type", mojo::ScopedHandle(), base::nullopt);
absl::optional<std::string>());
bridge()->DumpCrash("type", mojo::ScopedHandle(), absl::nullopt);
}
// Tests that DumpNativeCrash doesn't crash.
@ -60,7 +60,7 @@ TEST_F(ArcCrashCollectorBridgeTest, DumpCrash) {
TEST_F(ArcCrashCollectorBridgeTest, DumpNativeCrash) {
ASSERT_NE(nullptr, bridge());
bridge()->SetBuildProperties("device", "board", "cpu_abi",
base::Optional<std::string>());
absl::optional<std::string>());
bridge()->DumpNativeCrash("exec_name", getpid(), /*timestamp=*/42,
mojo::ScopedHandle());
}
@ -70,7 +70,7 @@ TEST_F(ArcCrashCollectorBridgeTest, DumpNativeCrash) {
TEST_F(ArcCrashCollectorBridgeTest, DumpKernelCrash) {
ASSERT_NE(nullptr, bridge());
bridge()->SetBuildProperties("device", "board", "cpu_abi",
base::Optional<std::string>());
absl::optional<std::string>());
bridge()->DumpKernelCrash(mojo::ScopedHandle());
}

@ -8,11 +8,11 @@
#include "base/bind.h"
#include "base/memory/singleton.h"
#include "base/optional.h"
#include "chromeos/cryptohome/cryptohome_parameters.h"
#include "chromeos/dbus/userdataauth/arc_quota_client.h"
#include "components/arc/arc_browser_context_keyed_service_factory_base.h"
#include "components/arc/session/arc_bridge_service.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace arc {
@ -111,7 +111,7 @@ void ArcDiskQuotaBridge::IsQuotaSupported(IsQuotaSupportedCallback callback) {
user_data_auth::GetArcDiskFeaturesRequest(),
base::BindOnce(
[](IsQuotaSupportedCallback callback,
base::Optional<user_data_auth::GetArcDiskFeaturesReply> reply) {
absl::optional<user_data_auth::GetArcDiskFeaturesReply> reply) {
LOG_IF(ERROR, !reply.has_value())
<< "Failed to retrieve result from IsQuotaSupported call.";
bool result = false;
@ -132,7 +132,7 @@ void ArcDiskQuotaBridge::GetCurrentSpaceForUid(
request,
base::BindOnce(
[](GetCurrentSpaceForUidCallback callback, int uid,
base::Optional<user_data_auth::GetCurrentSpaceForArcUidReply>
absl::optional<user_data_auth::GetCurrentSpaceForArcUidReply>
reply) {
LOG_IF(ERROR, !reply.has_value())
<< "Failed to retrieve result from "
@ -156,7 +156,7 @@ void ArcDiskQuotaBridge::GetCurrentSpaceForGid(
request,
base::BindOnce(
[](GetCurrentSpaceForGidCallback callback, int gid,
base::Optional<user_data_auth::GetCurrentSpaceForArcGidReply>
absl::optional<user_data_auth::GetCurrentSpaceForArcGidReply>
reply) {
LOG_IF(ERROR, !reply.has_value())
<< "Failed to retrieve result from "
@ -180,7 +180,7 @@ void ArcDiskQuotaBridge::GetCurrentSpaceForProjectId(
request,
base::BindOnce(
[](GetCurrentSpaceForProjectIdCallback callback, int project_id,
base::Optional<user_data_auth::GetCurrentSpaceForArcProjectIdReply>
absl::optional<user_data_auth::GetCurrentSpaceForArcProjectIdReply>
reply) {
LOG_IF(ERROR, !reply.has_value())
<< "Failed to retrieve result from "
@ -220,7 +220,7 @@ void ArcDiskQuotaBridge::SetProjectId(uint32_t project_id,
[](SetProjectIdCallback callback, const int project_id,
const user_data_auth::SetProjectIdAllowedPathType parent_path,
const std::string& child_path,
base::Optional<user_data_auth::SetProjectIdReply> reply) {
absl::optional<user_data_auth::SetProjectIdReply> reply) {
LOG_IF(ERROR, !reply.has_value())
<< "Failed to set project ID " << project_id
<< " to parent_path=" << parent_path

@ -131,7 +131,7 @@ void SnapshotHoursPolicyService::UpdateTimer() {
namespace wtu = ::policy::weekly_time_utils;
const base::Time now = base::Time::Now();
const bool in_interval = wtu::Contains(now, intervals_);
const base::Optional<base::Time> update_time =
const absl::optional<base::Time> update_time =
wtu::GetNextEventTime(now, intervals_);
SetEndTime(in_interval ? update_time.value() : base::Time{});

@ -9,7 +9,6 @@
#include "base/callback_helpers.h"
#include "base/json/json_reader.h"
#include "base/optional.h"
#include "base/run_loop.h"
#include "base/test/task_environment.h"
#include "base/values.h"
@ -20,6 +19,7 @@
#include "components/user_manager/scoped_user_manager.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 arc {
namespace data_snapshotd {
@ -183,7 +183,7 @@ class SnapshotHoursPolicyServiceTest
// Enable feature and check.
void EnableSnapshot(int enabled_calls_num = 1) {
base::Optional<base::Value> policy = base::JSONReader::Read(kJsonPolicy);
absl::optional<base::Value> policy = base::JSONReader::Read(kJsonPolicy);
EXPECT_TRUE(policy.has_value());
local_state()->Set(arc::prefs::kArcSnapshotHours, policy.value());
EnsureSnapshotEnabled(enabled_calls_num);
@ -236,7 +236,7 @@ TEST_F(SnapshotHoursPolicyServiceTest, DoubleDisable) {
EnableSnapshot();
{
base::Optional<base::Value> policy_value =
absl::optional<base::Value> policy_value =
base::JSONReader::Read(kJsonPolicyEmptyIntervals);
EXPECT_TRUE(policy_value.has_value());
local_state()->Set(arc::prefs::kArcSnapshotHours, policy_value.value());
@ -246,7 +246,7 @@ TEST_F(SnapshotHoursPolicyServiceTest, DoubleDisable) {
{
// User a different JSON to ensure the policy value is updated.
base::Optional<base::Value> policy_value =
absl::optional<base::Value> policy_value =
base::JSONReader::Read(kJsonPolicyNoIntervals);
EXPECT_TRUE(policy_value.has_value());
local_state()->Set(arc::prefs::kArcSnapshotHours, policy_value.value());
@ -285,7 +285,7 @@ TEST_F(SnapshotHoursPolicyServiceTest, InsideInterval) {
// Disable snapshots.
{
base::Optional<base::Value> policy_value =
absl::optional<base::Value> policy_value =
base::JSONReader::Read(kJsonPolicyNoIntervals);
EXPECT_TRUE(policy_value.has_value());
local_state()->Set(arc::prefs::kArcSnapshotHours, policy_value.value());
@ -330,7 +330,7 @@ TEST_F(SnapshotHoursPolicyServiceTest, DisableByUserPolicyForMGS) {
TEST_P(SnapshotHoursPolicyServiceTest, DisabledByPolicy) {
EnableSnapshot();
base::Optional<base::Value> policy_value = base::JSONReader::Read(policy());
absl::optional<base::Value> policy_value = base::JSONReader::Read(policy());
EXPECT_TRUE(policy_value.has_value());
local_state()->Set(arc::prefs::kArcSnapshotHours, policy_value.value());

@ -43,7 +43,7 @@ namespace arc {
namespace {
base::Optional<double> g_override_default_device_scale_factor;
absl::optional<double> g_override_default_device_scale_factor;
// Return true when a rich text editing is available on a text field with the
// given type.
@ -674,11 +674,11 @@ bool ArcImeService::SetAutocorrectRange(const gfx::Range& range) {
return false;
}
base::Optional<ui::GrammarFragment> ArcImeService::GetGrammarFragment(
absl::optional<ui::GrammarFragment> ArcImeService::GetGrammarFragment(
const gfx::Range& range) {
// TODO(https://crbug.com/1201454): Implement this method.
NOTIMPLEMENTED_LOG_ONCE();
return base::nullopt;
return absl::nullopt;
}
bool ArcImeService::ClearGrammarFragments(const gfx::Range& range) {
@ -726,7 +726,7 @@ void ArcImeService::OnDispatchingKeyEventPostIME(ui::KeyEvent* event) {
// static
void ArcImeService::SetOverrideDefaultDeviceScaleFactorForTesting(
base::Optional<double> scale_factor) {
absl::optional<double> scale_factor) {
g_override_default_device_scale_factor = scale_factor;
}

@ -9,10 +9,10 @@
#include "ash/public/cpp/keyboard/keyboard_controller_observer.h"
#include "base/macros.h"
#include "base/optional.h"
#include "components/arc/ime/arc_ime_bridge.h"
#include "components/arc/ime/key_event_result_receiver.h"
#include "components/keyed_service/core/keyed_service.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/aura/client/focus_change_observer.h"
#include "ui/aura/env_observer.h"
#include "ui/aura/window_observer.h"
@ -155,7 +155,7 @@ class ArcImeService : public KeyedService,
gfx::Range GetAutocorrectRange() const override;
gfx::Rect GetAutocorrectCharacterBounds() const override;
bool SetAutocorrectRange(const gfx::Range& range) override;
base::Optional<ui::GrammarFragment> GetGrammarFragment(
absl::optional<ui::GrammarFragment> GetGrammarFragment(
const gfx::Range& range) override;
bool ClearGrammarFragments(const gfx::Range& range) override;
bool AddGrammarFragments(
@ -165,7 +165,7 @@ class ArcImeService : public KeyedService,
// Normally, the default device scale factor is used to convert from DPI to
// physical pixels. This method provides a way to override it for testing.
static void SetOverrideDefaultDeviceScaleFactorForTesting(
base::Optional<double> scale_factor);
absl::optional<double> scale_factor);
private:
friend class ArcImeServiceTest;

@ -240,7 +240,7 @@ class ArcImeServiceTest : public testing::Test {
}
void TearDown() override {
ArcImeService::SetOverrideDefaultDeviceScaleFactorForTesting(base::nullopt);
ArcImeService::SetOverrideDefaultDeviceScaleFactorForTesting(absl::nullopt);
arc_win_.reset();
fake_window_delegate_ = nullptr;
fake_arc_ime_bridge_ = nullptr;
@ -638,7 +638,7 @@ TEST_F(ArcImeServiceTest, SendKeyEvent) {
ui::DomKey::FromCharacter('A'),
ui::EventTimeForNow()};
{
base::Optional<bool> handled;
absl::optional<bool> handled;
auto copy = std::make_unique<ui::KeyEvent>(event);
instance_->SendKeyEvent(
std::move(copy),
@ -658,7 +658,7 @@ TEST_F(ArcImeServiceTest, SendKeyEvent) {
ui::ET_KEY_PRESSED, ui::VKEY_RETURN, ui::DomCode::ENTER, 0,
ui::DomKey::UNIDENTIFIED, ui::EventTimeForNow()};
{
base::Optional<bool> handled;
absl::optional<bool> handled;
auto copy = std::make_unique<ui::KeyEvent>(non_character_event);
instance_->SendKeyEvent(
std::move(copy),
@ -681,7 +681,7 @@ TEST_F(ArcImeServiceTest, SendKeyEvent) {
ui::DomKey::FromCharacter('A'),
ui::EventTimeForNow()};
{
base::Optional<bool> handled;
absl::optional<bool> handled;
auto copy = std::make_unique<ui::KeyEvent>(fabricated_event);
instance_->SendKeyEvent(
std::move(copy),

@ -8,10 +8,10 @@
#include "base/callback.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/optional.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "components/arc/ime/arc_ime_util.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/event.h"
#include "ui/events/event_dispatcher.h"
@ -109,7 +109,7 @@ void KeyEventResultReceiver::RecordImeLatency() {
kImeLatencyHistogramName,
base::TimeTicks::Now() - callback_set_time_.value(), kKeyEventLatencyMin,
kKeyEventLatencyMax, 50);
callback_set_time_ = base::nullopt;
callback_set_time_ = absl::nullopt;
}
} // namespace arc

@ -7,7 +7,7 @@
#include "base/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/base/ime/input_method_delegate.h"
namespace arc {
@ -36,7 +36,7 @@ class KeyEventResultReceiver {
void RecordImeLatency();
KeyEventDoneCallback callback_{};
base::Optional<base::TimeTicks> callback_set_time_{};
absl::optional<base::TimeTicks> callback_set_time_{};
base::WeakPtrFactory<KeyEventResultReceiver> weak_ptr_factory_{this};
};

@ -38,7 +38,7 @@ class KeyEventResultReceiverTest : public testing::Test {
};
TEST_F(KeyEventResultReceiverTest, ExpireCallback) {
base::Optional<bool> result;
absl::optional<bool> result;
auto callback =
base::BindLambdaForTesting([&result](bool res) { result = res; });
@ -52,7 +52,7 @@ TEST_F(KeyEventResultReceiverTest, ExpireCallback) {
}
TEST_F(KeyEventResultReceiverTest, EventStoppedPropagation) {
base::Optional<bool> result;
absl::optional<bool> result;
auto callback =
base::BindLambdaForTesting([&result](bool res) { result = res; });
@ -68,7 +68,7 @@ TEST_F(KeyEventResultReceiverTest, EventStoppedPropagation) {
}
TEST_F(KeyEventResultReceiverTest, EventConsumedByIME) {
base::Optional<bool> result;
absl::optional<bool> result;
auto callback =
base::BindLambdaForTesting([&result](bool res) { result = res; });
@ -85,7 +85,7 @@ TEST_F(KeyEventResultReceiverTest, EventConsumedByIME) {
}
TEST_F(KeyEventResultReceiverTest, EventNotCharacter) {
base::Optional<bool> result;
absl::optional<bool> result;
auto callback =
base::BindLambdaForTesting([&result](bool res) { result = res; });
@ -103,7 +103,7 @@ TEST_F(KeyEventResultReceiverTest, EventNotCharacter) {
}
TEST_F(KeyEventResultReceiverTest, UnmodifiedEnterAndBackspace) {
base::Optional<bool> result;
absl::optional<bool> result;
auto callback =
base::BindLambdaForTesting([&result](bool res) { result = res; });
@ -135,7 +135,7 @@ TEST_F(KeyEventResultReceiverTest, UnmodifiedEnterAndBackspace) {
}
TEST_F(KeyEventResultReceiverTest, ControlCharacters) {
base::Optional<bool> result;
absl::optional<bool> result;
auto callback =
base::BindLambdaForTesting([&result](bool res) { result = res; });
@ -151,7 +151,7 @@ TEST_F(KeyEventResultReceiverTest, ControlCharacters) {
}
TEST_F(KeyEventResultReceiverTest, EventWithSystemModifier) {
base::Optional<bool> result;
absl::optional<bool> result;
auto callback =
base::BindLambdaForTesting([&result](bool res) { result = res; });
@ -167,7 +167,7 @@ TEST_F(KeyEventResultReceiverTest, EventWithSystemModifier) {
}
TEST_F(KeyEventResultReceiverTest, NormalCharacters) {
base::Optional<bool> result;
absl::optional<bool> result;
auto callback =
base::BindLambdaForTesting([&result](bool res) { result = res; });

@ -14,7 +14,6 @@
#include "base/memory/singleton.h"
#include "base/memory/weak_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/optional.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/values.h"
@ -25,6 +24,7 @@
#include "components/arc/intent_helper/open_url_delegate.h"
#include "components/arc/session/arc_bridge_service.h"
#include "components/url_formatter/url_fixer.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/base/layout.h"
#include "url/url_constants.h"
@ -149,7 +149,7 @@ void ArcIntentHelperBridge::OnIntentFiltersUpdated(
intent_filters_[filter.package_name()].push_back(std::move(filter));
for (auto& observer : observer_list_)
observer.OnIntentFiltersUpdated(base::nullopt);
observer.OnIntentFiltersUpdated(absl::nullopt);
}
void ArcIntentHelperBridge::OnOpenDownloads() {

@ -10,12 +10,12 @@
#include <vector>
#include "base/memory/ptr_util.h"
#include "base/optional.h"
#include "components/arc/intent_helper/open_url_delegate.h"
#include "components/arc/mojom/intent_helper.mojom.h"
#include "components/arc/session/arc_bridge_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"
namespace arc {
@ -189,7 +189,7 @@ TEST_F(ArcIntentHelperTest, TestObserver) {
(override));
MOCK_METHOD(void,
OnIntentFiltersUpdated,
(const base::Optional<std::string>& package_name),
(const absl::optional<std::string>& package_name),
(override));
MOCK_METHOD(void, OnPreferredAppsChanged, (), (override));
};
@ -220,7 +220,7 @@ TEST_F(ArcIntentHelperTest, TestObserver) {
{
// Observer should be called when an intent filter is updated.
EXPECT_CALL(observer, OnIntentFiltersUpdated(testing::Eq(base::nullopt)));
EXPECT_CALL(observer, OnIntentFiltersUpdated(testing::Eq(absl::nullopt)));
instance_->OnIntentFiltersUpdated(/*filters=*/std::vector<IntentFilter>());
testing::Mock::VerifyAndClearExpectations(&observer);
}

@ -7,7 +7,7 @@
#include <string>
#include "base/optional.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace base {
class FilePath;
@ -27,11 +27,11 @@ class ArcIntentHelperObserver {
virtual void OnArcDownloadAdded(const base::FilePath& relative_path,
const std::string& owner_package_name) {}
// Called when intent filters are added, removed or updated.
// A base::nullopt |package_name| indicates that intent filters were updated
// A absl::nullopt |package_name| indicates that intent filters were updated
// for all packages. Otherwise, |package_name| contains the name of the
// package whose filters were changed.
virtual void OnIntentFiltersUpdated(
const base::Optional<std::string>& package_name) {}
const absl::optional<std::string>& package_name) {}
// Called when the preferred apps changed in ARC.
virtual void OnPreferredAppsChanged() {}
};

@ -8,8 +8,8 @@
#include <utility>
#include <vector>
#include "base/optional.h"
#include "base/strings/string_util.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace mojo {
@ -24,7 +24,7 @@ bool StructTraits<arc::mojom::IntentFilterDataView, arc::IntentFilter>::Read(
if (!data.ReadDataPaths(&paths))
return false;
base::Optional<std::string> package_name;
absl::optional<std::string> package_name;
if (!data.ReadPackageName(&package_name))
return false;
@ -40,11 +40,11 @@ bool StructTraits<arc::mojom::IntentFilterDataView, arc::IntentFilter>::Read(
if (!data.ReadMimeTypes(&mime_types))
return false;
base::Optional<std::string> activity_name;
absl::optional<std::string> activity_name;
if (!data.ReadActivityName(&activity_name))
return false;
base::Optional<std::string> activity_label;
absl::optional<std::string> activity_label;
if (!data.ReadActivityLabel(&activity_label))
return false;

@ -57,7 +57,7 @@ TEST_F(ArcLockScreenBridgeTest, ConstructDestruct) {
}
TEST_F(ArcLockScreenBridgeTest, OnConnectionReady) {
const base::Optional<bool>& is_locked = lock_screen_instance()->is_locked();
const absl::optional<bool>& is_locked = lock_screen_instance()->is_locked();
// The state should have been set already. See SetUp().
ASSERT_TRUE(is_locked);
// And the state should be "not locked";
@ -65,7 +65,7 @@ TEST_F(ArcLockScreenBridgeTest, OnConnectionReady) {
}
TEST_F(ArcLockScreenBridgeTest, OnSessionStateChanged) {
const base::Optional<bool>& is_locked = lock_screen_instance()->is_locked();
const absl::optional<bool>& is_locked = lock_screen_instance()->is_locked();
// The state should have been set already. See SetUp().
ASSERT_TRUE(is_locked);
// Lock the screen and check the instance state.

@ -236,7 +236,7 @@ void ArcMetricsService::ParseProcessList(
void ArcMetricsService::OnArcStartTimeRetrieved(
std::vector<mojom::BootProgressEventPtr> events,
mojom::BootType boot_type,
base::Optional<base::TimeTicks> arc_start_time) {
absl::optional<base::TimeTicks> arc_start_time) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (!arc_start_time.has_value()) {
LOG(ERROR) << "Failed to retrieve ARC start timeticks.";
@ -277,7 +277,7 @@ void ArcMetricsService::ReportBootProgress(
// For VM builds, do not call into session_manager since we don't use it
// for the builds. The upgrade time is included in the events vector so we
// can extract it here.
base::Optional<base::TimeTicks> arc_start_time =
absl::optional<base::TimeTicks> arc_start_time =
GetArcStartTimeFromEvents(events);
OnArcStartTimeRetrieved(std::move(events), boot_type, arc_start_time);
return;
@ -362,7 +362,7 @@ void ArcMetricsService::ReportArcCorePriAbiMigDowngradeDelay(
void ArcMetricsService::OnArcStartTimeForPriAbiMigration(
base::TimeTicks durationTicks,
base::Optional<base::TimeTicks> arc_start_time) {
absl::optional<base::TimeTicks> arc_start_time) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (!arc_start_time.has_value()) {
LOG(ERROR) << "Failed to retrieve ARC start timeticks.";
@ -472,7 +472,7 @@ void ArcMetricsService::RemoveUserInteractionObserver(
user_interaction_observers_.RemoveObserver(obs);
}
base::Optional<base::TimeTicks> ArcMetricsService::GetArcStartTimeFromEvents(
absl::optional<base::TimeTicks> ArcMetricsService::GetArcStartTimeFromEvents(
std::vector<mojom::BootProgressEventPtr>& events) {
mojom::BootProgressEventPtr arc_upgraded_event;
for (auto it = events.begin(); it != events.end(); ++it) {
@ -484,7 +484,7 @@ base::Optional<base::TimeTicks> ArcMetricsService::GetArcStartTimeFromEvents(
base::TimeTicks();
}
}
return base::nullopt;
return absl::nullopt;
}
ArcMetricsService::ProcessObserver::ProcessObserver(
ArcMetricsService* arc_metrics_service)

@ -14,7 +14,6 @@
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/observer_list_types.h"
#include "base/optional.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
@ -26,6 +25,7 @@
#include "components/arc/session/connection_observer.h"
#include "components/guest_os/guest_os_engagement_metrics.h"
#include "components/keyed_service/core/keyed_service.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/events/ozone/gamepad/gamepad_observer.h"
#include "ui/wm/public/activation_change_observer.h"
@ -136,9 +136,9 @@ class ArcMetricsService : public KeyedService,
// Finds the boot_progress_arc_upgraded event, removes it from |events|, and
// returns the event time. If the boot_progress_arc_upgraded event is not
// found, base::nullopt is returned. This function is public for testing
// found, absl::nullopt is returned. This function is public for testing
// purposes.
base::Optional<base::TimeTicks> GetArcStartTimeFromEvents(
absl::optional<base::TimeTicks> GetArcStartTimeFromEvents(
std::vector<mojom::BootProgressEventPtr>& events);
private:
@ -215,10 +215,10 @@ class ArcMetricsService : public KeyedService,
// DBus callbacks.
void OnArcStartTimeRetrieved(std::vector<mojom::BootProgressEventPtr> events,
mojom::BootType boot_type,
base::Optional<base::TimeTicks> arc_start_time);
absl::optional<base::TimeTicks> arc_start_time);
void OnArcStartTimeForPriAbiMigration(
base::TimeTicks durationTicks,
base::Optional<base::TimeTicks> arc_start_time);
absl::optional<base::TimeTicks> arc_start_time);
// Notify AppKillObservers.
void NotifyLowMemoryKill();

@ -12,7 +12,6 @@
#include "ash/public/cpp/app_types.h"
#include "base/metrics/histogram_samples.h"
#include "base/optional.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/test/metrics/histogram_tester.h"
@ -26,6 +25,7 @@
#include "components/session_manager/core/session_manager.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/test/test_windows.h"
#include "ui/aura/window.h"
@ -342,7 +342,7 @@ TEST_F(ArcMetricsServiceTest, GetArcStartTimeFromEvents) {
events.emplace_back(
mojom::BootProgressEvent::New(kBootProgressArcUpgraded, kArcStartTimeMs));
base::Optional<base::TimeTicks> arc_start_time =
absl::optional<base::TimeTicks> arc_start_time =
service()->GetArcStartTimeFromEvents(events);
EXPECT_TRUE(arc_start_time.has_value());
EXPECT_EQ(*arc_start_time,
@ -360,7 +360,7 @@ TEST_F(ArcMetricsServiceTest, GetArcStartTimeFromEvents_NoArcUpgradedEvent) {
std::vector<mojom::BootProgressEventPtr> events(
GetBootProgressEvents(kArcStartTimeMs, 1 /* step_in_ms */));
base::Optional<base::TimeTicks> arc_start_time =
absl::optional<base::TimeTicks> arc_start_time =
service()->GetArcStartTimeFromEvents(events);
EXPECT_FALSE(arc_start_time.has_value());
}
@ -371,7 +371,7 @@ TEST_F(ArcMetricsServiceTest, UserInteractionObserver) {
void OnUserInteraction(UserInteractionType type) override {
this->type = type;
}
base::Optional<UserInteractionType> type;
absl::optional<UserInteractionType> type;
} observer;
service()->AddUserInteractionObserver(&observer);

@ -55,11 +55,11 @@ void StabilityMetricsManager::RecordMetricsToUMA() {
return;
}
const base::Optional<bool> enabled_state = GetArcEnabledState();
const absl::optional<bool> enabled_state = GetArcEnabledState();
if (enabled_state)
UMA_STABILITY_HISTOGRAM_ENUMERATION("Arc.State", *enabled_state ? 1 : 0, 2);
const base::Optional<NativeBridgeType> native_bridge_type =
const absl::optional<NativeBridgeType> native_bridge_type =
GetArcNativeBridgeType();
if (native_bridge_type) {
UMA_STABILITY_HISTOGRAM_ENUMERATION(
@ -74,7 +74,7 @@ void StabilityMetricsManager::ResetMetrics() {
update->Clear();
}
base::Optional<bool> StabilityMetricsManager::GetArcEnabledState() {
absl::optional<bool> StabilityMetricsManager::GetArcEnabledState() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
const base::DictionaryValue* dict =
local_state_->GetDictionary(prefs::kStabilityMetrics);
@ -87,18 +87,18 @@ void StabilityMetricsManager::SetArcEnabledState(bool enabled) {
update->SetKey(kArcEnabledStateKey, base::Value(enabled));
}
base::Optional<NativeBridgeType>
absl::optional<NativeBridgeType>
StabilityMetricsManager::GetArcNativeBridgeType() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
const base::DictionaryValue* dict =
local_state_->GetDictionary(prefs::kStabilityMetrics);
base::Optional<int> native_bridge_type =
absl::optional<int> native_bridge_type =
dict->FindIntKey(kArcNativeBridgeTypeKey);
if (native_bridge_type) {
return base::make_optional(
return absl::make_optional(
static_cast<NativeBridgeType>(*native_bridge_type));
}
return base::nullopt;
return absl::nullopt;
}
void StabilityMetricsManager::SetArcNativeBridgeType(

@ -5,9 +5,9 @@
#ifndef COMPONENTS_ARC_METRICS_STABILITY_METRICS_MANAGER_H_
#define COMPONENTS_ARC_METRICS_STABILITY_METRICS_MANAGER_H_
#include "base/optional.h"
#include "base/sequence_checker.h"
#include "components/arc/metrics/arc_metrics_constants.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
class PrefService;
@ -37,13 +37,13 @@ class StabilityMetricsManager {
void ResetMetrics();
// Returns current persisted value (if exists) for Arc.State UMA histogram.
base::Optional<bool> GetArcEnabledState();
absl::optional<bool> GetArcEnabledState();
// Sets value for Arc.State UMA histogram.
void SetArcEnabledState(bool enabled);
// Returns current persisted value (if exists) for Arc.State UMA histogram.
base::Optional<NativeBridgeType> GetArcNativeBridgeType();
absl::optional<NativeBridgeType> GetArcNativeBridgeType();
// Sets value for Arc.NativeBridgeType UMA histogram.
void SetArcNativeBridgeType(NativeBridgeType native_bridge_type);

@ -216,7 +216,7 @@ bool StructTraits<arc::mojom::VideoFrameLayoutDataView,
return false;
}
base::Optional<media::VideoFrameLayout> layout =
absl::optional<media::VideoFrameLayout> layout =
media::VideoFrameLayout::CreateWithPlanes(
format, coded_size, std::move(planes), data.buffer_addr_align(),
data.modifier());

@ -31,7 +31,7 @@ TEST(VideoAcceleratorStructTraitsTest, ConvertVideoFrameLayout) {
constexpr size_t buffer_addr_align = 128;
constexpr uint64_t modifier = 0x1234;
base::Optional<media::VideoFrameLayout> layout =
absl::optional<media::VideoFrameLayout> layout =
media::VideoFrameLayout::CreateWithPlanes(kFormat, kCodedSize, planes,
buffer_addr_align, modifier);
EXPECT_TRUE(layout);

@ -4,8 +4,8 @@
#include "components/arc/mojom/video_encode_accelerator_mojom_traits.h"
#include "base/optional.h"
#include "components/arc/mojom/video_accelerator_mojom_traits.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace mojo {
@ -83,12 +83,12 @@ bool StructTraits<arc::mojom::VideoEncodeAcceleratorConfigDataView,
if (!input.ReadOutputProfile(&output_profile))
return false;
base::Optional<uint32_t> initial_framerate;
absl::optional<uint32_t> initial_framerate;
if (input.has_initial_framerate()) {
initial_framerate = input.initial_framerate();
}
base::Optional<uint8_t> h264_output_level;
absl::optional<uint8_t> h264_output_level;
if (input.has_h264_output_level()) {
h264_output_level = input.h264_output_level();
}
@ -99,7 +99,7 @@ bool StructTraits<arc::mojom::VideoEncodeAcceleratorConfigDataView,
*output = media::VideoEncodeAccelerator::Config(
input_format, input_visible_size, output_profile, input.initial_bitrate(),
initial_framerate, base::nullopt, h264_output_level, false, storage_type);
initial_framerate, absl::nullopt, h264_output_level, false, storage_type);
return true;
}

@ -23,7 +23,7 @@ const base::Value kVpnPackageValue(kVpnPackage);
void OnGetProperties(bool* success_out,
std::string* package_name_out,
base::OnceClosure callback,
base::Optional<base::Value> result) {
absl::optional<base::Value> result) {
*success_out = result.has_value();
if (result) {
const base::Value* value = result->FindKeyOfType(

@ -872,7 +872,7 @@ void ArcNetHostImpl::NetworkPropertiesUpdated(
void ArcNetHostImpl::ReceiveShillProperties(
const std::string& service_path,
base::Optional<base::Value> shill_properties) {
absl::optional<base::Value> shill_properties) {
if (!shill_properties) {
LOG(ERROR) << "Failed to get shill Service properties for " << service_path;
return;

@ -151,7 +151,7 @@ class ArcNetHostImpl : public KeyedService,
// Callback for chromeos::NetworkHandler::GetShillProperties
void ReceiveShillProperties(const std::string& service_path,
base::Optional<base::Value> shill_properties);
absl::optional<base::Value> shill_properties);
ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager.

@ -211,7 +211,7 @@ void ArcPowerBridge::OnAndroidSuspendReady(base::UnguessableToken token) {
void ArcPowerBridge::OnConciergeSuspendVmResponse(
base::UnguessableToken token,
base::Optional<vm_tools::concierge::SuspendVmResponse> reply) {
absl::optional<vm_tools::concierge::SuspendVmResponse> reply) {
if (!reply.has_value())
LOG(ERROR) << "Failed to suspend arcvm, no reply received.";
else if (!reply.value().success())
@ -234,7 +234,7 @@ void ArcPowerBridge::SuspendDone(base::TimeDelta sleep_duration) {
}
void ArcPowerBridge::OnConciergeResumeVmResponse(
base::Optional<vm_tools::concierge::ResumeVmResponse> reply) {
absl::optional<vm_tools::concierge::ResumeVmResponse> reply) {
if (!reply.has_value()) {
LOG(ERROR) << "Failed to resume arcvm, no reply received.";
return;
@ -364,7 +364,7 @@ ArcPowerBridge::WakeLockRequestor* ArcPowerBridge::GetWakeLockRequestor(
}
void ArcPowerBridge::OnGetScreenBrightnessPercent(
base::Optional<double> percent) {
absl::optional<double> percent) {
if (!percent.has_value()) {
LOG(ERROR)
<< "PowerManagerClient::GetScreenBrightnessPercent reports an error";

@ -11,7 +11,6 @@
#include "base/macros.h"
#include "base/observer_list.h"
#include "base/optional.h"
#include "base/timer/timer.h"
#include "chromeos/dbus/concierge/concierge_client.h"
#include "chromeos/dbus/power/power_manager_client.h"
@ -21,6 +20,7 @@
#include "mojo/public/cpp/bindings/remote.h"
#include "services/device/public/mojom/wake_lock.mojom.h"
#include "services/device/public/mojom/wake_lock_provider.mojom.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/display/manager/display_configurator.h"
namespace content {
@ -99,7 +99,7 @@ class ArcPowerBridge : public KeyedService,
WakeLockRequestor* GetWakeLockRequestor(device::mojom::WakeLockType type);
// Called on PowerManagerClient::GetScreenBrightnessPercent() completion.
void OnGetScreenBrightnessPercent(base::Optional<double> percent);
void OnGetScreenBrightnessPercent(absl::optional<double> percent);
// Called by Android when ready to suspend.
void OnAndroidSuspendReady(base::UnguessableToken token);
@ -108,12 +108,12 @@ class ArcPowerBridge : public KeyedService,
// SuspendVm D-Bus call.
void OnConciergeSuspendVmResponse(
base::UnguessableToken token,
base::Optional<vm_tools::concierge::SuspendVmResponse> reply);
absl::optional<vm_tools::concierge::SuspendVmResponse> reply);
// Called by ConciergeClient when a response has been receive for the
// ResumeVm D-Bus call.
void OnConciergeResumeVmResponse(
base::Optional<vm_tools::concierge::ResumeVmResponse> reply);
absl::optional<vm_tools::concierge::ResumeVmResponse> reply);
// Sends a PowerInstance::UpdateScreenBrightnessSettings mojo call to Android.
void UpdateAndroidScreenBrightness(double percent);

@ -225,7 +225,7 @@ TEST_F(ArcPowerBridgeTest, ScreenBrightness) {
}
TEST_F(ArcPowerBridgeTest, PowerSupplyInfoChanged) {
base::Optional<power_manager::PowerSupplyProperties> prop =
absl::optional<power_manager::PowerSupplyProperties> prop =
power_manager_client()->GetLastStatus();
ASSERT_TRUE(prop.has_value());
prop->set_battery_state(power_manager::PowerSupplyProperties::FULL);

@ -31,10 +31,10 @@ class FakePropertyInstance : public mojom::PropertyInstance {
minimize_on_back_ = enable;
}
base::Optional<bool> minimize_on_back() const { return minimize_on_back_; }
absl::optional<bool> minimize_on_back() const { return minimize_on_back_; }
private:
base::Optional<bool> minimize_on_back_;
absl::optional<bool> minimize_on_back_;
};
} // namespace
@ -76,7 +76,7 @@ class ArcPropertyBridgeTest : public testing::Test {
instance_ = nullptr;
}
base::Optional<bool> GetMinimizeOnBackState() const {
absl::optional<bool> GetMinimizeOnBackState() const {
return instance_->minimize_on_back();
}

@ -91,7 +91,7 @@ void ArcIioSensorBridge::SetIsTabletModeOn(bool is_tablet_mode_on) {
}
void ArcIioSensorBridge::OnGetSwitchStates(
base::Optional<chromeos::PowerManagerClient::SwitchStates> states) {
absl::optional<chromeos::PowerManagerClient::SwitchStates> states) {
if (states.has_value()) {
SetIsTabletModeOn(states->tablet_mode ==
chromeos::PowerManagerClient::TabletMode::ON);

@ -6,11 +6,11 @@
#define COMPONENTS_ARC_SENSOR_ARC_IIO_SENSOR_BRIDGE_H_
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "chromeos/dbus/power/power_manager_client.h"
#include "components/arc/mojom/iio_sensor.mojom.h"
#include "components/arc/session/connection_observer.h"
#include "components/keyed_service/core/keyed_service.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace content {
class BrowserContext;
@ -58,10 +58,10 @@ class ArcIioSensorBridge : public KeyedService,
// Called with PowerManagerClient::GetSwitchStates() result.
void OnGetSwitchStates(
base::Optional<chromeos::PowerManagerClient::SwitchStates> states);
absl::optional<chromeos::PowerManagerClient::SwitchStates> states);
ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager.
base::Optional<bool> is_tablet_mode_on_;
absl::optional<bool> is_tablet_mode_on_;
base::WeakPtrFactory<ArcIioSensorBridge> weak_ptr_factory_{this};
};

@ -41,7 +41,7 @@ void ArcDataRemover::Run(RunCallback callback) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (!pref_.GetValue()) {
VLOG(1) << "Data removal is not scheduled, skip.";
std::move(callback).Run(base::nullopt);
std::move(callback).Run(absl::nullopt);
return;
}
@ -49,7 +49,7 @@ void ArcDataRemover::Run(RunCallback callback) {
auto* upstart_client = chromeos::UpstartClient::Get();
if (!upstart_client) {
// May be null in tests
std::move(callback).Run(base::nullopt);
std::move(callback).Run(absl::nullopt);
return;
}
const std::string account_id =

@ -8,10 +8,10 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/threading/thread_checker.h"
#include "chromeos/cryptohome/cryptohome_parameters.h"
#include "components/prefs/pref_member.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
class PrefService;
@ -34,7 +34,7 @@ class ArcDataRemover {
// Executes the removing, if scheduled.
// This must run while ARC instance is stopped.
// If not scheduled, |callback| will be synchronously called with nullopt.
using RunCallback = base::OnceCallback<void(base::Optional<bool> result)>;
using RunCallback = base::OnceCallback<void(absl::optional<bool> result)>;
void Run(RunCallback callback);
private:

@ -83,8 +83,8 @@ TEST_F(ArcDataRemoverTest, NotScheduled) {
base::RunLoop loop;
data_remover.Run(base::BindOnce(
[](base::RunLoop* loop, base::Optional<bool> result) {
EXPECT_EQ(result, base::nullopt);
[](base::RunLoop* loop, absl::optional<bool> result) {
EXPECT_EQ(result, absl::nullopt);
loop->Quit();
},
&loop));
@ -99,8 +99,8 @@ TEST_F(ArcDataRemoverTest, Success) {
base::RunLoop loop;
data_remover.Run(base::BindOnce(
[](base::RunLoop* loop, base::Optional<bool> result) {
EXPECT_EQ(result, base::make_optional(true));
[](base::RunLoop* loop, absl::optional<bool> result) {
EXPECT_EQ(result, absl::make_optional(true));
loop->Quit();
},
&loop));
@ -113,8 +113,8 @@ TEST_F(ArcDataRemoverTest, Fail) {
base::RunLoop loop;
data_remover.Run(base::BindOnce(
[](base::RunLoop* loop, base::Optional<bool> result) {
EXPECT_EQ(result, base::make_optional(false));
[](base::RunLoop* loop, absl::optional<bool> result) {
EXPECT_EQ(result, absl::make_optional(false));
loop->Quit();
},
&loop));

@ -35,7 +35,7 @@ std::ostream& operator<<(std::ostream& os, ArcInstanceMode mode) {
}
std::ostream& operator<<(std::ostream& os,
base::Optional<ArcInstanceMode> mode) {
absl::optional<ArcInstanceMode> mode) {
return os << (mode.has_value() ? ArcInstanceModeToString(mode.value())
: "(nullopt)");
}

@ -7,7 +7,7 @@
#include <ostream>
#include "base/optional.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace arc {
@ -23,7 +23,7 @@ enum class ArcInstanceMode {
// Stringified output for logging purpose.
std::ostream& operator<<(std::ostream& os, ArcInstanceMode mode);
std::ostream& operator<<(std::ostream& os,
base::Optional<ArcInstanceMode> mode);
absl::optional<ArcInstanceMode> mode);
} // namespace arc

@ -6,8 +6,8 @@
#include <sstream>
#include "base/optional.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace arc {
namespace {
@ -28,14 +28,14 @@ TEST(ArcInstanceModeTest, TestLogging) {
EXPECT_TRUE(invalid.str().empty()) << invalid.str();
}
// Test that base::Optional<ArcInstanceMode> can be logged too.
// Test that absl::optional<ArcInstanceMode> can be logged too.
TEST(ArcInstanceModeTest, TestLoggingWithOptional) {
std::ostringstream nullopt;
nullopt << base::Optional<ArcInstanceMode>();
nullopt << absl::optional<ArcInstanceMode>();
EXPECT_FALSE(nullopt.str().empty());
std::ostringstream non_nullopt;
non_nullopt << base::Optional<ArcInstanceMode>(
non_nullopt << absl::optional<ArcInstanceMode>(
ArcInstanceMode::MINI_INSTANCE);
EXPECT_FALSE(non_nullopt.str().empty());
EXPECT_NE(nullopt.str(), non_nullopt.str());

@ -14,11 +14,11 @@
#include "base/files/scoped_file.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/threading/thread_checker.h"
#include "chromeos/system/scheduler_configuration_manager_base.h"
#include "components/arc/session/arc_client_adapter.h"
#include "components/arc/session/arc_session.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace ash {
class DefaultScaleFactorRetriever;

@ -15,7 +15,6 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/location.h"
#include "base/optional.h"
#include "base/path_service.h"
#include "base/process/process_metrics.h"
#include "base/run_loop.h"
@ -31,6 +30,7 @@
#include "components/arc/test/fake_arc_bridge_host.h"
#include "components/version_info/channel.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace cryptohome {
class Identification;
@ -235,7 +235,7 @@ class TestArcSessionObserver : public ArcSession::Observer {
~TestArcSessionObserver() override { arc_session_->RemoveObserver(this); }
const base::Optional<OnSessionStoppedArgs>& on_session_stopped_args() const {
const absl::optional<OnSessionStoppedArgs>& on_session_stopped_args() const {
return on_session_stopped_args_;
}
@ -252,7 +252,7 @@ class TestArcSessionObserver : public ArcSession::Observer {
private:
ArcSession* const arc_session_; // Not owned.
base::RunLoop* const run_loop_ = nullptr; // Not owned.
base::Optional<OnSessionStoppedArgs> on_session_stopped_args_;
absl::optional<OnSessionStoppedArgs> on_session_stopped_args_;
DISALLOW_COPY_AND_ASSIGN(TestArcSessionObserver);
};
@ -279,12 +279,12 @@ class FakeSchedulerConfigurationManager
obs.OnConfigurationSet(reply_->first, reply_->second);
}
base::Optional<std::pair<bool, size_t>> GetLastReply() const override {
absl::optional<std::pair<bool, size_t>> GetLastReply() const override {
return reply_;
}
private:
base::Optional<std::pair<bool, size_t>> reply_;
absl::optional<std::pair<bool, size_t>> reply_;
DISALLOW_COPY_AND_ASSIGN(FakeSchedulerConfigurationManager);
};

@ -9,9 +9,9 @@
#include "base/bind.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/optional.h"
#include "base/task_runner.h"
#include "components/arc/arc_util.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace arc {
@ -32,7 +32,7 @@ void RecordInstanceRestartAfterCrashUma(size_t restart_after_crash_count) {
// Gets an ArcContainerLifetimeEvent value to record. Returns nullopt when no
// UMA recording is needed.
base::Optional<ArcContainerLifetimeEvent> GetArcContainerLifetimeEvent(
absl::optional<ArcContainerLifetimeEvent> GetArcContainerLifetimeEvent(
size_t restart_after_crash_count,
ArcStopReason stop_reason,
bool was_running) {
@ -41,13 +41,13 @@ base::Optional<ArcContainerLifetimeEvent> GetArcContainerLifetimeEvent(
// container restart might be recorded. Each CONTAINER_STARTED event can
// be paired up to one non-START event.
if (restart_after_crash_count)
return base::nullopt;
return absl::nullopt;
switch (stop_reason) {
case ArcStopReason::SHUTDOWN:
case ArcStopReason::LOW_DISK_SPACE:
// We don't record these events.
return base::nullopt;
return absl::nullopt;
case ArcStopReason::GENERIC_BOOT_FAILURE:
return ArcContainerLifetimeEvent::CONTAINER_FAILED_TO_START;
case ArcStopReason::CRASH:
@ -56,11 +56,11 @@ base::Optional<ArcContainerLifetimeEvent> GetArcContainerLifetimeEvent(
}
NOTREACHED();
return base::nullopt;
return absl::nullopt;
}
// Returns true if restart is needed for given conditions.
bool IsRestartNeeded(base::Optional<ArcInstanceMode> target_mode,
bool IsRestartNeeded(absl::optional<ArcInstanceMode> target_mode,
ArcStopReason stop_reason,
bool was_running) {
if (!target_mode.has_value()) {
@ -95,7 +95,7 @@ bool IsRestartNeeded(base::Optional<ArcInstanceMode> target_mode,
// Returns true if the request to start/upgrade ARC instance is allowed
// operation.
bool IsRequestAllowed(const base::Optional<ArcInstanceMode>& current_mode,
bool IsRequestAllowed(const absl::optional<ArcInstanceMode>& current_mode,
ArcInstanceMode request_mode) {
if (!current_mode.has_value()) {
// This is a request to start a new ARC instance (either mini instance
@ -143,7 +143,7 @@ void ArcSessionRunner::ResumeRunner() {
resumed_ = true;
if (target_mode_) {
ArcInstanceMode original_mode = *target_mode_;
target_mode_ = base::nullopt;
target_mode_ = absl::nullopt;
RequestStart(original_mode);
}
}
@ -205,7 +205,7 @@ void ArcSessionRunner::RequestStop() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
VLOG(1) << "Session stop requested";
target_mode_ = base::nullopt;
target_mode_ = absl::nullopt;
if (arc_session_) {
// If |arc_session_| is running, stop it.
@ -226,7 +226,7 @@ void ArcSessionRunner::OnShutdown() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
VLOG(1) << "OnShutdown";
target_mode_ = base::nullopt;
target_mode_ = absl::nullopt;
restart_timer_.Stop();
if (arc_session_)
arc_session_->OnShutdown();
@ -318,7 +318,7 @@ void ArcSessionRunner::OnSessionStopped(ArcStopReason stop_reason,
arc_session_->RemoveObserver(this);
arc_session_.reset();
const base::Optional<ArcContainerLifetimeEvent> uma_to_record =
const absl::optional<ArcContainerLifetimeEvent> uma_to_record =
GetArcContainerLifetimeEvent(restart_after_crash_count_, stop_reason,
was_running);
if (uma_to_record.has_value())

@ -12,7 +12,6 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
@ -22,6 +21,7 @@
#include "components/arc/session/arc_session.h"
#include "components/arc/session/arc_stop_reason.h"
#include "components/arc/session/arc_upgrade_params.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace arc {
@ -146,7 +146,7 @@ class ArcSessionRunner : public ArcSession::Observer {
// Target ARC instance running mode. If nullopt, it means the ARC instance
// should stop eventually.
base::Optional<ArcInstanceMode> target_mode_;
absl::optional<ArcInstanceMode> target_mode_;
// Instead of immediately trying to restart the container, give it some time
// to finish tearing down in case it is still in the process of stopping.

@ -28,7 +28,6 @@
#include "base/memory/weak_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/no_destructor.h"
#include "base/optional.h"
#include "base/posix/eintr_wrapper.h"
#include "base/process/launch.h"
#include "base/strings/string_number_conversions.h"
@ -57,6 +56,7 @@
#include "components/arc/session/arc_session.h"
#include "components/arc/session/file_system_status.h"
#include "components/version_info/version_info.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace arc {
namespace {
@ -95,9 +95,9 @@ constexpr base::TimeDelta kConnectTimeoutLimit =
constexpr base::TimeDelta kConnectSleepDurationInitial =
base::TimeDelta::FromMilliseconds(100);
base::Optional<base::TimeDelta> g_connect_timeout_limit_for_testing;
base::Optional<base::TimeDelta> g_connect_sleep_duration_initial_for_testing;
base::Optional<int> g_boot_notification_server_fd;
absl::optional<base::TimeDelta> g_connect_timeout_limit_for_testing;
absl::optional<base::TimeDelta> g_connect_sleep_duration_initial_for_testing;
absl::optional<int> g_boot_notification_server_fd;
chromeos::ConciergeClient* GetConciergeClient() {
return chromeos::ConciergeClient::Get();
@ -643,7 +643,7 @@ class ArcVmClientAdapter : public ArcClientAdapter,
}
void OnGetVmReply(
base::Optional<vm_tools::concierge::GetVmInfoResponse> reply) {
absl::optional<vm_tools::concierge::GetVmInfoResponse> reply) {
vm_tools::concierge::StopVmRequest request;
request.set_name(kArcVmName);
@ -716,7 +716,7 @@ class ArcVmClientAdapter : public ArcClientAdapter,
void OnExistingMiniVmStopped(
chromeos::VoidDBusMethodCallback callback,
base::Optional<vm_tools::concierge::StopVmResponse> reply) {
absl::optional<vm_tools::concierge::StopVmResponse> reply) {
// reply->success() returns true even when there was no VM running.
if (!reply.has_value() || !reply->success()) {
LOG(ERROR) << "StopVm failed: "
@ -788,7 +788,7 @@ class ArcVmClientAdapter : public ArcClientAdapter,
void OnStartArcVmReply(
chromeos::VoidDBusMethodCallback callback,
base::Optional<vm_tools::concierge::StartVmResponse> reply) {
absl::optional<vm_tools::concierge::StartVmResponse> reply) {
if (!reply.has_value()) {
LOG(ERROR) << "Failed to start arcvm. Empty response.";
std::move(callback).Run(false);
@ -811,7 +811,7 @@ class ArcVmClientAdapter : public ArcClientAdapter,
void OnExistingFullVmStopped(
UpgradeParams params,
chromeos::VoidDBusMethodCallback callback,
base::Optional<vm_tools::concierge::StopVmResponse> reply) {
absl::optional<vm_tools::concierge::StopVmResponse> reply) {
// reply->success() returns true even when there was no VM running.
if (!reply.has_value() || !reply->success()) {
LOG(ERROR) << "StopVm failed: "
@ -894,7 +894,7 @@ class ArcVmClientAdapter : public ArcClientAdapter,
void OnSetVmId(UpgradeParams params,
chromeos::VoidDBusMethodCallback callback,
base::Optional<vm_tools::concierge::SetVmIdResponse> reply) {
absl::optional<vm_tools::concierge::SetVmIdResponse> reply) {
if (!reply.has_value()) {
LOG(ERROR) << "Failed to set VM ID. Empty response.";
StopArcInstanceInternal();
@ -971,7 +971,7 @@ class ArcVmClientAdapter : public ArcClientAdapter,
}
void OnStopVmReply(
base::Optional<vm_tools::concierge::StopVmResponse> reply) {
absl::optional<vm_tools::concierge::StopVmResponse> reply) {
// If the reply indicates the D-Bus call is successfully done, do nothing.
// Concierge will call OnVmStopped() eventually.
if (reply.has_value() && reply.value().success())
@ -986,7 +986,7 @@ class ArcVmClientAdapter : public ArcClientAdapter,
void OnTrimVmMemory(
TrimVmMemoryCallback callback,
base::Optional<vm_tools::concierge::ReclaimVmMemoryResponse> reply) {
absl::optional<vm_tools::concierge::ReclaimVmMemoryResponse> reply) {
bool success = false;
std::string failure_reason;
@ -1005,7 +1005,7 @@ class ArcVmClientAdapter : public ArcClientAdapter,
std::move(callback).Run(success, failure_reason);
}
base::Optional<bool> is_dev_mode_;
absl::optional<bool> is_dev_mode_;
// True when the *host* is running on a VM.
const bool is_host_on_vm_;
// A cryptohome ID of the primary profile.
@ -1057,7 +1057,7 @@ void SetArcVmBootNotificationServerAddressForTesting(
g_connect_sleep_duration_initial_for_testing = connect_sleep_duration_initial;
}
void SetArcVmBootNotificationServerFdForTesting(base::Optional<int> fd) {
void SetArcVmBootNotificationServerFdForTesting(absl::optional<int> fd) {
g_boot_notification_server_fd = fd;
}

@ -39,7 +39,7 @@ void SetArcVmBootNotificationServerAddressForTesting(
base::TimeDelta connect_sleep_duration_initial);
// Sets the an FD ConnectToArcVmBootNotificationServer() returns for testing.
void SetArcVmBootNotificationServerFdForTesting(base::Optional<int> fd);
void SetArcVmBootNotificationServerFdForTesting(absl::optional<int> fd);
// Generates a list of props from |upgrade_params|, each of which takes the form
// "prefix.prop_name=value"

@ -326,7 +326,7 @@ class ArcVmClientAdapterTest : public testing::Test,
// Reset to the original behavior.
RemoveUpstartStartStopJobFailures();
SetArcVmBootNotificationServerFdForTesting(base::nullopt);
SetArcVmBootNotificationServerFdForTesting(absl::nullopt);
const std::string abstract_addr(GenerateAbstractAddress());
boot_server_ = std::make_unique<TestArcVmBootNotificationServer>();
@ -1041,7 +1041,7 @@ TEST_F(ArcVmClientAdapterTest, UpgradeArc_SetVmIdEmptyReply) {
StartMiniArc();
// Inject failure
GetTestConciergeClient()->set_set_vm_id_response(base::nullopt);
GetTestConciergeClient()->set_set_vm_id_response(absl::nullopt);
UpgradeArcWithParamsAndStopVmCount(false, {}, /*run_until_stop_vm_count=*/3);
ExpectArcStopped(/*stale_full_vm_stopped=*/true);
@ -1075,7 +1075,7 @@ TEST_F(ArcVmClientAdapterTest, StartMiniArc_StopExistingVmFailure) {
TEST_F(ArcVmClientAdapterTest, StartMiniArc_StopExistingVmFailureEmptyReply) {
// Inject failure.
GetTestConciergeClient()->set_stop_vm_response(base::nullopt);
GetTestConciergeClient()->set_stop_vm_response(absl::nullopt);
StartMiniArcWithParams(false, {});
@ -1101,7 +1101,7 @@ TEST_F(ArcVmClientAdapterTest, UpgradeArc_StopExistingVmFailureEmptyReply) {
StartMiniArc();
// Inject failure.
GetTestConciergeClient()->set_stop_vm_response(base::nullopt);
GetTestConciergeClient()->set_stop_vm_response(absl::nullopt);
UpgradeArcWithParamsAndStopVmCount(false, {}, /*run_until_stop_vm_count=*/3);
ExpectArcStopped(/*stale_full_vm_stopped=*/true);
@ -1136,7 +1136,7 @@ TEST_F(ArcVmClientAdapterTest, StartMiniArc_StartArcVmFailure) {
TEST_F(ArcVmClientAdapterTest, StartMiniArc_StartArcVmFailureEmptyReply) {
SetValidUserInfo();
// Inject failure to StartArcVm(). This emulates D-Bus timeout situations.
GetTestConciergeClient()->set_start_vm_response(base::nullopt);
GetTestConciergeClient()->set_start_vm_response(absl::nullopt);
StartMiniArcWithParams(false, {});

@ -78,7 +78,7 @@ void FakeAppInstance::Init(mojo::PendingRemote<mojom::AppHost> host_remote,
void FakeAppInstance::LaunchAppDeprecated(
const std::string& package_name,
const std::string& activity,
const base::Optional<gfx::Rect>& dimension) {
const absl::optional<gfx::Rect>& dimension) {
LaunchApp(package_name, activity, 0);
}
@ -558,7 +558,7 @@ void FakeAppInstance::IsInstallable(const std::string& package_name,
void FakeAppInstance::LaunchIntentDeprecated(
const std::string& intent_uri,
const base::Optional<gfx::Rect>& dimension_on_screen) {
const absl::optional<gfx::Rect>& dimension_on_screen) {
LaunchIntent(intent_uri, 0);
}

@ -94,7 +94,7 @@ class FakeAppInstance : public mojom::AppInstance {
InitCallback callback) override;
void LaunchAppDeprecated(const std::string& package_name,
const std::string& activity,
const base::Optional<gfx::Rect>& dimension) override;
const absl::optional<gfx::Rect>& dimension) override;
void LaunchApp(const std::string& package_name,
const std::string& activity,
int64_t display_id) override;
@ -114,7 +114,7 @@ class FakeAppInstance : public mojom::AppInstance {
GetAppIconCallback callback) override;
void LaunchIntentDeprecated(
const std::string& intent_uri,
const base::Optional<gfx::Rect>& dimension_on_screen) override;
const absl::optional<gfx::Rect>& dimension_on_screen) override;
void LaunchIntent(const std::string& intent_uri, int64_t display_id) override;
void LaunchIntentWithWindowInfo(
const std::string& intent_uri,

@ -7,8 +7,8 @@
#include <string>
#include "base/optional.h"
#include "components/arc/mojom/cast_receiver.mojom.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace arc {
@ -33,12 +33,12 @@ class FakeCastReceiverInstance : public mojom::CastReceiverInstance {
base::OnceCallback<void(mojom::CastReceiverInstance::Result)>;
void SetName(const std::string& name, SetNameCallback callback) override;
const base::Optional<bool>& last_enabled() const { return last_enabled_; }
const base::Optional<std::string>& last_name() const { return last_name_; }
const absl::optional<bool>& last_enabled() const { return last_enabled_; }
const absl::optional<std::string>& last_name() const { return last_name_; }
private:
base::Optional<bool> last_enabled_;
base::Optional<std::string> last_name_;
absl::optional<bool> last_enabled_;
absl::optional<std::string> last_name_;
};
} // namespace arc

@ -19,9 +19,9 @@
#include "base/files/scoped_file.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/optional.h"
#include "base/threading/thread_task_runner_handle.h"
#include "mojo/public/cpp/system/platform_handle.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace arc {
@ -352,7 +352,7 @@ void FakeFileSystemInstance::GetMimeType(const std::string& url,
auto iter = files_.find(url);
if (iter == files_.end()) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), base::nullopt));
FROM_HERE, base::BindOnce(std::move(callback), absl::nullopt));
return;
}
const File& file = iter->second;
@ -466,7 +466,7 @@ void FakeFileSystemInstance::GetChildDocuments(
child_documents_.find(DocumentKey(authority, parent_document_id));
if (child_iter == child_documents_.end()) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), base::nullopt));
FROM_HERE, base::BindOnce(std::move(callback), absl::nullopt));
return;
}
std::vector<mojom::DocumentPtr> children;
@ -477,7 +477,7 @@ void FakeFileSystemInstance::GetChildDocuments(
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback),
base::make_optional(std::move(children))));
absl::make_optional(std::move(children))));
}
void FakeFileSystemInstance::GetRecentDocuments(
@ -488,7 +488,7 @@ void FakeFileSystemInstance::GetRecentDocuments(
auto recent_iter = recent_documents_.find(RootKey(authority, root_id));
if (recent_iter == recent_documents_.end()) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), base::nullopt));
FROM_HERE, base::BindOnce(std::move(callback), absl::nullopt));
return;
}
std::vector<mojom::DocumentPtr> recents;
@ -496,7 +496,7 @@ void FakeFileSystemInstance::GetRecentDocuments(
recents.emplace_back(MakeDocument(document));
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback),
base::make_optional(std::move(recents))));
absl::make_optional(std::move(recents))));
}
void FakeFileSystemInstance::GetRoots(GetRootsCallback callback) {
@ -506,7 +506,7 @@ void FakeFileSystemInstance::GetRoots(GetRootsCallback callback) {
roots.emplace_back(MakeRoot(root));
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback),
base::make_optional(std::move(roots))));
absl::make_optional(std::move(roots))));
}
void FakeFileSystemInstance::GetRootSize(const std::string& authority,

@ -96,7 +96,7 @@ class FakeFileSystemInstance : public mojom::FileSystemInstance {
Seekable seekable;
// Override of |content| length in bytes.
base::Optional<int64_t> size_override;
absl::optional<int64_t> size_override;
// The thumbnail of a file, which can be read by OpenThumbnail().
std::string thumbnail_content;

@ -5,8 +5,8 @@
#ifndef COMPONENTS_ARC_TEST_FAKE_LOCK_SCREEN_INSTANCE_H_
#define COMPONENTS_ARC_TEST_FAKE_LOCK_SCREEN_INSTANCE_H_
#include "base/optional.h"
#include "components/arc/mojom/lock_screen.mojom.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace arc {
@ -20,10 +20,10 @@ class FakeLockScreenInstance : public mojom::LockScreenInstance {
// mojom::LockScreenInstance overrides:
void SetDeviceLocked(bool is_locked) override;
const base::Optional<bool>& is_locked() const { return is_locked_; }
const absl::optional<bool>& is_locked() const { return is_locked_; }
private:
base::Optional<bool> is_locked_;
absl::optional<bool> is_locked_;
};
} // namespace arc

@ -18,7 +18,7 @@ class FakePipInstance : public mojom::PipInstance {
~FakePipInstance() override;
int num_closed() { return num_closed_; }
base::Optional<bool> suppressed() const { return suppressed_; }
absl::optional<bool> suppressed() const { return suppressed_; }
// mojom::PipInstance overrides:
void Init(mojo::PendingRemote<mojom::PipHost> host_remote,
@ -29,7 +29,7 @@ class FakePipInstance : public mojom::PipInstance {
private:
mojo::Remote<mojom::PipHost> host_remote_;
int num_closed_ = 0;
base::Optional<bool> suppressed_;
absl::optional<bool> suppressed_;
DISALLOW_COPY_AND_ASSIGN(FakePipInstance);
};

@ -180,7 +180,7 @@ void ArcTimerBridge::OnDeleteArcTimers(bool result) {
void ArcTimerBridge::OnCreateArcTimers(
std::vector<clockid_t> clock_ids,
CreateTimersCallback callback,
base::Optional<std::vector<TimerId>> timer_ids) {
absl::optional<std::vector<TimerId>> timer_ids) {
// Any old timers associated with the same tag are always cleared by the API
// regardless of the new timers being created successfully or not. Clear the
// cached timer ids in that case.
@ -217,11 +217,11 @@ void ArcTimerBridge::OnCreateArcTimers(
std::move(callback).Run(mojom::ArcTimerResult::SUCCESS);
}
base::Optional<ArcTimerBridge::TimerId> ArcTimerBridge::GetTimerId(
absl::optional<ArcTimerBridge::TimerId> ArcTimerBridge::GetTimerId(
clockid_t clock_id) const {
auto it = timer_ids_.find(clock_id);
return (it == timer_ids_.end()) ? base::nullopt
: base::make_optional<TimerId>(it->second);
return (it == timer_ids_.end()) ? absl::nullopt
: absl::make_optional<TimerId>(it->second);
}
} // namespace arc

@ -12,13 +12,13 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/sequenced_task_runner.h"
#include "base/time/time.h"
#include "components/arc/mojom/timer.mojom.h"
#include "components/arc/session/connection_observer.h"
#include "components/keyed_service/core/keyed_service.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
class BrowserContextKeyedServiceFactory;
@ -72,11 +72,11 @@ class ArcTimerBridge : public KeyedService,
// Callback for powerd's D-Bus API called in |CreateTimers|.
void OnCreateArcTimers(std::vector<clockid_t> clock_ids,
CreateTimersCallback callback,
base::Optional<std::vector<TimerId>> timer_ids);
absl::optional<std::vector<TimerId>> timer_ids);
// Retrieves the timer id corresponding to |clock_id|. If a mapping exists in
// |timer_ids_| then returns an int32_t >= 0. Else returns base::nullopt.
base::Optional<TimerId> GetTimerId(clockid_t clock_id) const;
// |timer_ids_| then returns an int32_t >= 0. Else returns absl::nullopt.
absl::optional<TimerId> GetTimerId(clockid_t clock_id) const;
// Owned by ArcServiceManager.
ArcBridgeService* const arc_bridge_service_;

@ -11,7 +11,6 @@
#include "base/callback_helpers.h"
#include "base/files/file_descriptor_watcher_posix.h"
#include "base/files/scoped_file.h"
#include "base/optional.h"
#include "base/posix/unix_domain_socket.h"
#include "base/run_loop.h"
#include "base/time/time.h"
@ -30,6 +29,7 @@
#include "mojo/public/cpp/system/handle.h"
#include "mojo/public/cpp/system/platform_handle.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace arc {
@ -67,10 +67,10 @@ class ArcTimerStore {
void ClearTimers() { return arc_timers_.clear(); }
base::Optional<int> GetTimerReadFd(clockid_t clock_id) {
absl::optional<int> GetTimerReadFd(clockid_t clock_id) {
if (!HasTimer(clock_id))
return base::nullopt;
return base::Optional<int>(arc_timers_[clock_id].get());
return absl::nullopt;
return absl::optional<int>(arc_timers_[clock_id].get());
}
bool HasTimer(clockid_t clock_id) const {
@ -222,7 +222,7 @@ bool ArcTimerTest::WaitForExpiration(clockid_t clock_id) {
// Wait for the host to indicate expiration by watching the read end of the
// socket pair.
base::Optional<int> timer_read_fd_opt =
absl::optional<int> timer_read_fd_opt =
arc_timer_store_.GetTimerReadFd(clock_id);
// This should never happen if the timer was present in the store.
if (!timer_read_fd_opt.has_value()) {

@ -169,7 +169,7 @@ void ArcUsbHostBridge::RequestPermission(const std::string& guid,
}
void ArcUsbHostBridge::OpenDevice(const std::string& guid,
const base::Optional<std::string>& package,
const absl::optional<std::string>& package,
OpenDeviceCallback callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_);
@ -201,7 +201,7 @@ void ArcUsbHostBridge::OpenDevice(const std::string& guid,
void ArcUsbHostBridge::OpenDeviceDeprecated(
const std::string& guid,
const base::Optional<std::string>& package,
const absl::optional<std::string>& package,
OpenDeviceCallback callback) {
LOG(ERROR) << "ArcUsbHostBridge::OpenDeviceDeprecated is deprecated";
OpenDevice(guid, package, std::move(callback));

@ -70,10 +70,10 @@ class ArcUsbHostBridge : public KeyedService,
bool interactive,
RequestPermissionCallback callback) override;
void OpenDeviceDeprecated(const std::string& guid,
const base::Optional<std::string>& package,
const absl::optional<std::string>& package,
OpenDeviceCallback callback) override;
void OpenDevice(const std::string& guid,
const base::Optional<std::string>& package,
const absl::optional<std::string>& package,
OpenDeviceCallback callback) override;
void GetDeviceInfo(const std::string& guid,
GetDeviceInfoCallback callback) override;

@ -49,7 +49,7 @@ std::vector<base::ScopedFD> DuplicateFD(base::ScopedFD fd, size_t num_fds) {
return fds;
}
base::Optional<gfx::GpuMemoryBufferHandle> CreateGpuMemoryBufferHandle(
absl::optional<gfx::GpuMemoryBufferHandle> CreateGpuMemoryBufferHandle(
media::VideoPixelFormat pixel_format,
uint64_t modifier,
const gfx::Size& coded_size,
@ -65,7 +65,7 @@ base::Optional<gfx::GpuMemoryBufferHandle> CreateGpuMemoryBufferHandle(
base::CheckMul(stride, plane_height);
if (!current_size.IsValid()) {
VLOGF(1) << "Invalid stride/height";
return base::nullopt;
return absl::nullopt;
}
color_planes.emplace_back(stride, offset, current_size.ValueOrDie());
@ -75,7 +75,7 @@ base::Optional<gfx::GpuMemoryBufferHandle> CreateGpuMemoryBufferHandle(
std::move(scoped_fds), color_planes);
}
base::Optional<gfx::GpuMemoryBufferHandle> CreateGpuMemoryBufferHandle(
absl::optional<gfx::GpuMemoryBufferHandle> CreateGpuMemoryBufferHandle(
media::VideoPixelFormat pixel_format,
uint64_t modifier,
const gfx::Size& coded_size,
@ -85,12 +85,12 @@ base::Optional<gfx::GpuMemoryBufferHandle> CreateGpuMemoryBufferHandle(
if (planes.size() != num_planes || planes.size() == 0) {
VLOGF(1) << "Invalid number of dmabuf planes passed: " << planes.size()
<< ", expected: " << num_planes;
return base::nullopt;
return absl::nullopt;
}
if (scoped_fds.size() != num_planes) {
VLOGF(1) << "Invalid number of fds passed: " << scoped_fds.size()
<< ", expected: " << num_planes;
return base::nullopt;
return absl::nullopt;
}
gfx::GpuMemoryBufferHandle gmb_handle;
@ -101,11 +101,11 @@ base::Optional<gfx::GpuMemoryBufferHandle> CreateGpuMemoryBufferHandle(
// offset in NativePixmapPlane are uint32_t and uint64_t, respectively.
if (!base::IsValueInRangeForNumericType<uint32_t>(planes[i].stride)) {
VLOGF(1) << "Invalid stride";
return base::nullopt;
return absl::nullopt;
}
if (!base::IsValueInRangeForNumericType<uint64_t>(planes[i].offset)) {
VLOGF(1) << "Invalid offset";
return base::nullopt;
return absl::nullopt;
}
uint32_t stride = base::checked_cast<uint32_t>(planes[i].stride);
uint64_t offset = base::checked_cast<uint64_t>(planes[i].offset);
@ -115,7 +115,7 @@ base::Optional<gfx::GpuMemoryBufferHandle> CreateGpuMemoryBufferHandle(
}
if (!media::VerifyGpuMemoryBufferHandle(pixel_format, coded_size, gmb_handle))
return base::nullopt;
return absl::nullopt;
return gmb_handle;
}

@ -9,11 +9,11 @@
#include <vector>
#include "base/files/scoped_file.h"
#include "base/optional.h"
#include "components/arc/video_accelerator/video_frame_plane.h"
#include "media/base/color_plane_layout.h"
#include "media/base/video_types.h"
#include "mojo/public/cpp/system/handle.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/gpu_memory_buffer.h"
@ -29,14 +29,14 @@ std::vector<base::ScopedFD> DuplicateFD(base::ScopedFD fd, size_t num_fds);
// Return GpuMemoryBufferHandle iff |planes| are valid for a video frame located
// on |scoped_fds| and of |pixel_format| and |coded_size|. Otherwise
// returns base::nullopt.
base::Optional<gfx::GpuMemoryBufferHandle> CreateGpuMemoryBufferHandle(
// returns absl::nullopt.
absl::optional<gfx::GpuMemoryBufferHandle> CreateGpuMemoryBufferHandle(
media::VideoPixelFormat pixel_format,
uint64_t modifier,
const gfx::Size& coded_size,
std::vector<base::ScopedFD> scoped_fds,
const std::vector<VideoFramePlane>& planes);
base::Optional<gfx::GpuMemoryBufferHandle> CreateGpuMemoryBufferHandle(
absl::optional<gfx::GpuMemoryBufferHandle> CreateGpuMemoryBufferHandle(
media::VideoPixelFormat pixel_format,
uint64_t modifier,
const gfx::Size& coded_size,

@ -356,7 +356,7 @@ void GpuArcVideoDecodeAccelerator::InitializeTask(
client_count_++;
VLOGF(2) << "Number of concurrent clients: " << client_count_;
secure_mode_ = base::nullopt;
secure_mode_ = absl::nullopt;
error_state_ = false;
pending_requests_ = {};
pending_flush_callbacks_ = {};

@ -12,7 +12,6 @@
#include "base/callback_forward.h"
#include "base/files/scoped_file.h"
#include "base/optional.h"
#include "base/threading/thread_checker.h"
#include "components/arc/mojom/video_decode_accelerator.mojom.h"
#include "gpu/config/gpu_driver_bug_workarounds.h"
@ -20,6 +19,7 @@
#include "media/video/video_decode_accelerator.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace arc {
@ -177,7 +177,7 @@ class GpuArcVideoDecodeAccelerator
size_t protected_input_buffer_count_ = 0;
base::Optional<bool> secure_mode_ = base::nullopt;
absl::optional<bool> secure_mode_ = absl::nullopt;
size_t output_buffer_count_ = 0;
DecoderState decoder_state_ = DecoderState::kDecoding;

@ -191,7 +191,7 @@ void GpuArcVideoEncodeAccelerator::Encode(
return;
}
base::Optional<gfx::BufferFormat> buffer_format =
absl::optional<gfx::BufferFormat> buffer_format =
VideoPixelFormatToGfxBufferFormat(format);
if (!format) {
DLOG(ERROR) << "Unexpected format: " << format;

@ -288,11 +288,11 @@ net::IsolationInfo ContentAutofillDriver::IsolationInfo() {
}
void ContentAutofillDriver::SetFormToBeProbablySubmitted(
const base::Optional<FormData>& raw_form) {
const absl::optional<FormData>& raw_form) {
potentially_submitted_form_ =
raw_form ? base::make_optional<FormData>(
raw_form ? absl::make_optional<FormData>(
GetFormWithFrameAndFormMetaData(*raw_form))
: base::nullopt;
: absl::nullopt;
}
void ContentAutofillDriver::FormsSeen(const std::vector<FormData>& raw_forms) {

@ -111,7 +111,7 @@ class ContentAutofillDriver : public AutofillDriver,
// mojom::AutofillDriver:
void SetFormToBeProbablySubmitted(
const base::Optional<FormData>& form) override;
const absl::optional<FormData>& form) override;
void FormsSeen(const std::vector<FormData>& forms) override;
void FormSubmitted(const FormData& form,
bool known_success,
@ -217,7 +217,7 @@ class ContentAutofillDriver : public AutofillDriver,
// The form pushed from the AutofillAgent to the AutofillDriver. When the
// ProbablyFormSubmitted() event is fired, this form is considered the
// submitted one.
base::Optional<FormData> potentially_submitted_form_;
absl::optional<FormData> potentially_submitted_form_;
// Keeps track of the forms for which FormSubmitted() event has been triggered
// to avoid duplicates fired by AutofillAgent.

@ -245,25 +245,25 @@ class FakeAutofillAgent : public mojom::AutofillAgent {
// Records data received from FillForm() call.
int32_t fill_form_id_;
base::Optional<FormData> fill_form_form_;
absl::optional<FormData> fill_form_form_;
// Records data received from PreviewForm() call.
int32_t preview_form_id_;
base::Optional<FormData> preview_form_form_;
absl::optional<FormData> preview_form_form_;
// Records data received from FieldTypePredictionsAvailable() call.
base::Optional<std::vector<FormDataPredictions>> predictions_;
absl::optional<std::vector<FormDataPredictions>> predictions_;
// Records whether ClearSection() got called.
bool called_clear_section_;
// Records whether ClearPreviewedForm() got called.
bool called_clear_previewed_form_;
// Records the ID received from FillFieldWithValue(), PreviewFieldWithValue(),
// SetSuggestionAvailability(), or AcceptDataListSuggestion().
base::Optional<FieldRendererId> value_renderer_id_;
absl::optional<FieldRendererId> value_renderer_id_;
// Records string received from FillFieldWithValue() call.
base::Optional<std::u16string> value_fill_field_;
absl::optional<std::u16string> value_fill_field_;
// Records string received from PreviewFieldWithValue() call.
base::Optional<std::u16string> value_preview_field_;
absl::optional<std::u16string> value_preview_field_;
// Records string received from AcceptDataListSuggestion() call.
base::Optional<std::u16string> value_accept_data_;
absl::optional<std::u16string> value_accept_data_;
// Records bool received from SetSuggestionAvailability() call.
bool suggestions_available_;
};

@ -16,7 +16,6 @@
#include "base/i18n/case_conversion.h"
#include "base/location.h"
#include "base/metrics/field_trial.h"
#include "base/optional.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_split.h"
@ -49,6 +48,7 @@
#include "content/public/renderer/render_view.h"
#include "net/cert/cert_status_flags.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/input/web_keyboard_event.h"
#include "third_party/blink/public/platform/web_url_request.h"
@ -1038,7 +1038,7 @@ void AutofillAgent::OnProvisionallySaveForm(
}
formless_elements_user_edited_.insert(
FieldRendererId(element.UniqueRendererFormControlId()));
provisionally_saved_form_ = base::make_optional<FormData>();
provisionally_saved_form_ = absl::make_optional<FormData>();
if (!CollectFormlessElements(&provisionally_saved_form_.value())) {
provisionally_saved_form_.reset();
} else {
@ -1064,7 +1064,7 @@ void AutofillAgent::OnProvisionallySaveForm(
}
void AutofillAgent::OnProbablyFormSubmitted() {
base::Optional<FormData> form_data = GetSubmittedForm();
absl::optional<FormData> form_data = GetSubmittedForm();
if (form_data.has_value()) {
FireHostSubmitEvents(form_data.value(), /*known_success=*/false,
SubmissionSource::PROBABLY_FORM_SUBMITTED);
@ -1104,7 +1104,7 @@ void AutofillAgent::OnInferredFormSubmission(SubmissionSource source) {
FireHostSubmitEvents(provisionally_saved_form_.value(),
/*known_success=*/true, source);
} else {
base::Optional<FormData> form_data = GetSubmittedForm();
absl::optional<FormData> form_data = GetSubmittedForm();
if (form_data.has_value())
FireHostSubmitEvents(form_data.value(), /*known_success=*/true, source);
}
@ -1126,14 +1126,14 @@ void AutofillAgent::TrackAutofilledElement(
form_tracker_.TrackAutofilledElement(element);
}
base::Optional<FormData> AutofillAgent::GetSubmittedForm() const {
absl::optional<FormData> AutofillAgent::GetSubmittedForm() const {
if (!last_interacted_form_.IsNull()) {
FormData form;
if (form_util::ExtractFormData(last_interacted_form_,
*field_data_manager_.get(), &form)) {
return base::make_optional(form);
return absl::make_optional(form);
} else if (provisionally_saved_form_.has_value()) {
return base::make_optional(provisionally_saved_form_.value());
return absl::make_optional(provisionally_saved_form_.value());
}
} else if (formless_elements_user_edited_.size() != 0 &&
!form_util::IsSomeControlElementVisible(
@ -1145,12 +1145,12 @@ base::Optional<FormData> AutofillAgent::GetSubmittedForm() const {
// construct form.
FormData form;
if (CollectFormlessElements(&form)) {
return base::make_optional(form);
return absl::make_optional(form);
} else if (provisionally_saved_form_.has_value()) {
return base::make_optional(provisionally_saved_form_.value());
return absl::make_optional(provisionally_saved_form_.value());
}
}
return base::nullopt;
return absl::nullopt;
}
void AutofillAgent::SendPotentiallySubmittedFormToBrowser() {
@ -1166,7 +1166,7 @@ void AutofillAgent::ResetLastInteractedElements() {
void AutofillAgent::UpdateLastInteractedForm(blink::WebFormElement form) {
last_interacted_form_ = form;
provisionally_saved_form_ = base::make_optional<FormData>();
provisionally_saved_form_ = absl::make_optional<FormData>();
if (!form_util::ExtractFormData(last_interacted_form_,
*field_data_manager_.get(),
&provisionally_saved_form_.value())) {

@ -12,7 +12,6 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/timer/timer.h"
#include "components/autofill/content/common/mojom/autofill_agent.mojom.h"
#include "components/autofill/content/common/mojom/autofill_driver.mojom.h"
@ -22,6 +21,7 @@
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
#include "third_party/blink/public/web/web_autofill_client.h"
#include "third_party/blink/public/web/web_form_control_element.h"
@ -254,7 +254,7 @@ class AutofillAgent : public content::RenderFrameObserver,
// Attempt to get submitted FormData from last_interacted_form_ or
// provisionally_saved_form_, return true if |form| is set.
base::Optional<FormData> GetSubmittedForm() const;
absl::optional<FormData> GetSubmittedForm() const;
// Pushes the value of GetSubmittedForm() to the AutofillDriver.
void SendPotentiallySubmittedFormToBrowser();
@ -319,7 +319,7 @@ class AutofillAgent : public content::RenderFrameObserver,
// The form user interacted, it is used if last_interacted_form_ or formless
// form can't be converted to FormData at the time of form submission.
base::Optional<FormData> provisionally_saved_form_;
absl::optional<FormData> provisionally_saved_form_;
// Keeps track of the forms for which form submitted event has been sent to
// AutofillDriver. We use it to avoid fire duplicated submission event when

@ -155,7 +155,7 @@ void FormTracker::DidFinishSameDocumentNavigation() {
void FormTracker::DidStartNavigation(
const GURL& url,
base::Optional<blink::WebNavigationType> navigation_type) {
absl::optional<blink::WebNavigationType> navigation_type) {
DCHECK_CALLED_ON_VALID_SEQUENCE(form_tracker_sequence_checker_);
blink::WebLocalFrame* navigated_frame = render_frame()->GetWebFrame();
// Ony handle main frame.

@ -97,7 +97,7 @@ class FormTracker : public content::RenderFrameObserver {
void DidFinishSameDocumentNavigation() override;
void DidStartNavigation(
const GURL& url,
base::Optional<blink::WebNavigationType> navigation_type) override;
absl::optional<blink::WebNavigationType> navigation_type) override;
void WillDetach() override;
void WillSendSubmitEvent(const blink::WebFormElement& form) override;
void WillSubmitForm(const blink::WebFormElement& form) override;

@ -316,7 +316,7 @@ void PasswordGenerationAgent::TriggeredGeneratePassword(
std::move(callback).Run(std::move(password_generation_ui_data));
current_generation_item_->generation_popup_shown_ = true;
} else {
std::move(callback).Run(base::nullopt);
std::move(callback).Run(absl::nullopt);
}
}

@ -4,7 +4,6 @@
#include "components/autofill/content/renderer/renderer_save_password_progress_logger.h"
#include "base/optional.h"
#include "base/run_loop.h"
#include "base/test/task_environment.h"
#include "components/autofill/content/common/mojom/autofill_driver.mojom.h"
@ -13,6 +12,7 @@
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace autofill {
@ -86,7 +86,7 @@ class FakeContentPasswordManagerDriver : public mojom::PasswordManagerDriver {
// Records whether RecordSavePasswordProgress() gets called.
bool called_record_save_;
// Records data received via RecordSavePasswordProgress() call.
base::Optional<std::string> log_;
absl::optional<std::string> log_;
mojo::Receiver<mojom::PasswordManagerDriver> receiver_{this};
};

@ -76,7 +76,7 @@ class AddressProfileSaveManager {
PersonalDataManager* const personal_data_manager_{nullptr};
// Data including the request id for the currently ongoing profile import.
base::Optional<ProfileImportProcess> pending_import_;
absl::optional<ProfileImportProcess> pending_import_;
base::WeakPtrFactory<AddressProfileSaveManager> weak_ptr_factory_{this};
};

@ -60,7 +60,7 @@ class TestAddressProfileSaveManager : public AddressProfileSaveManager {
// Mocks the function that initiates the UI prompt for testing purposes.
MOCK_METHOD(void, OfferSavePrompt, (), (override));
// Returns a copy of the last finished import process or 'base::nullopt' if no
// Returns a copy of the last finished import process or 'absl::nullopt' if no
// import process was finished.
ProfileImportProcess* last_import();
@ -74,7 +74,7 @@ class TestAddressProfileSaveManager : public AddressProfileSaveManager {
void ClearPendingImport() override;
// Profile that is passed from the emulated UI respones in case the user
// edited the import candidate.
base::Optional<ProfileImportProcess> last_import_;
absl::optional<ProfileImportProcess> last_import_;
};
TestAddressProfileSaveManager::TestAddressProfileSaveManager(
@ -102,8 +102,8 @@ struct ImportScenarioTestCase {
AutofillProfile edited_profile;
AutofillProfileImportType expected_import_type;
bool is_profile_change_expected;
base::Optional<AutofillProfile> merge_candidate;
base::Optional<AutofillProfile> import_candidate;
absl::optional<AutofillProfile> merge_candidate;
absl::optional<AutofillProfile> import_candidate;
std::vector<AutofillProfile> expected_final_profiles;
std::vector<AutofillMetrics::EditedFieldTypeForMetrics>
expected_edited_types_for_metrics;
@ -274,7 +274,7 @@ TEST_F(AddressProfileSaveManagerTest, SaveNewProfile) {
.user_decision = UserDecision::kAccepted,
.expected_import_type = AutofillProfileImportType::kNewProfile,
.is_profile_change_expected = true,
.merge_candidate = base::nullopt,
.merge_candidate = absl::nullopt,
.import_candidate = observed_profile,
.expected_final_profiles = {observed_profile}};
@ -293,8 +293,8 @@ TEST_F(AddressProfileSaveManagerTest, SaveNewProfileOnBlockedDomain) {
.user_decision = UserDecision::kUserNotAsked,
.expected_import_type = AutofillProfileImportType::kSuppressedNewProfile,
.is_profile_change_expected = false,
.merge_candidate = base::nullopt,
.import_candidate = base::nullopt,
.merge_candidate = absl::nullopt,
.import_candidate = absl::nullopt,
.expected_final_profiles = {},
.new_profiles_suppresssed_for_domain = true};
@ -314,7 +314,7 @@ TEST_F(AddressProfileSaveManagerTest, SaveNewProfile_UserNotAskedFallback) {
.user_decision = UserDecision::kUserNotAsked,
.expected_import_type = AutofillProfileImportType::kNewProfile,
.is_profile_change_expected = true,
.merge_candidate = base::nullopt,
.merge_candidate = absl::nullopt,
.import_candidate = observed_profile,
.expected_final_profiles = {observed_profile}};
@ -337,7 +337,7 @@ TEST_F(AddressProfileSaveManagerTest, SaveNewProfile_Edited) {
.edited_profile = edited_profile,
.expected_import_type = AutofillProfileImportType::kNewProfile,
.is_profile_change_expected = true,
.merge_candidate = base::nullopt,
.merge_candidate = absl::nullopt,
.import_candidate = observed_profile,
.expected_final_profiles = {edited_profile},
.expected_edited_types_for_metrics = {
@ -360,7 +360,7 @@ TEST_F(AddressProfileSaveManagerTest, SaveNewProfile_Declined) {
.user_decision = UserDecision::kDeclined,
.expected_import_type = AutofillProfileImportType::kNewProfile,
.is_profile_change_expected = false,
.merge_candidate = base::nullopt,
.merge_candidate = absl::nullopt,
.import_candidate = observed_profile,
.expected_final_profiles = {}};
@ -380,8 +380,8 @@ TEST_F(AddressProfileSaveManagerTest, ImportDuplicateProfile) {
.user_decision = UserDecision::kAccepted,
.expected_import_type = AutofillProfileImportType::kDuplicateImport,
.is_profile_change_expected = false,
.merge_candidate = base::nullopt,
.import_candidate = base::nullopt,
.merge_candidate = absl::nullopt,
.import_candidate = absl::nullopt,
.expected_final_profiles = {existing_profile}};
TestImportScenario(test_scenario);
@ -401,8 +401,8 @@ TEST_F(AddressProfileSaveManagerTest, SilentlyUpdateProfile) {
.is_prompt_expected = false,
.expected_import_type = AutofillProfileImportType::kSilentUpdate,
.is_profile_change_expected = true,
.merge_candidate = base::nullopt,
.import_candidate = base::nullopt,
.merge_candidate = absl::nullopt,
.import_candidate = absl::nullopt,
.expected_final_profiles = {final_profile}};
TestImportScenario(test_scenario);
}
@ -422,8 +422,8 @@ TEST_F(AddressProfileSaveManagerTest, SilentlyUpdateProfileOnBlockedDomain) {
.is_prompt_expected = false,
.expected_import_type = AutofillProfileImportType::kSilentUpdate,
.is_profile_change_expected = true,
.merge_candidate = base::nullopt,
.import_candidate = base::nullopt,
.merge_candidate = absl::nullopt,
.import_candidate = absl::nullopt,
.expected_final_profiles = {final_profile},
.new_profiles_suppresssed_for_domain = true};
TestImportScenario(test_scenario);
@ -448,8 +448,8 @@ TEST_F(AddressProfileSaveManagerTest, SilentlyUpdateVerifiedProfile) {
.is_prompt_expected = false,
.expected_import_type = AutofillProfileImportType::kSilentUpdate,
.is_profile_change_expected = true,
.merge_candidate = base::nullopt,
.import_candidate = base::nullopt,
.merge_candidate = absl::nullopt,
.import_candidate = absl::nullopt,
.expected_final_profiles = {final_profile}};
TestImportScenario(test_scenario);
}

@ -13,7 +13,6 @@
#include <vector>
#include "base/macros.h"
#include "base/optional.h"
#include "components/autofill/core/browser/autofill_type.h"
#include "components/autofill/core/browser/data_model/autofill_profile.h"
#include "components/autofill/core/browser/field_types.h"
@ -21,6 +20,7 @@
#include "components/autofill/core/browser/proto/password_requirements.pb.h"
#include "components/autofill/core/common/form_field_data.h"
#include "components/autofill/core/common/signatures.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace autofill {
@ -158,7 +158,7 @@ class AutofillField : public FormFieldData {
bool IsFieldFillable() const;
void set_initial_value_hash(uint32_t value) { initial_value_hash_ = value; }
base::Optional<uint32_t> initial_value_hash() { return initial_value_hash_; }
absl::optional<uint32_t> initial_value_hash() { return initial_value_hash_; }
void set_credit_card_number_offset(size_t position) {
credit_card_number_offset_ = position;
@ -191,7 +191,7 @@ class AutofillField : public FormFieldData {
}
void SetPasswordRequirements(PasswordRequirementsSpec spec);
const base::Optional<PasswordRequirementsSpec>& password_requirements()
const absl::optional<PasswordRequirementsSpec>& password_requirements()
const {
return password_requirements_;
}
@ -219,7 +219,7 @@ class AutofillField : public FormFieldData {
// Whether the heuristics or server predict a credit card field.
bool IsCreditCardPrediction() const;
base::Optional<FieldSignature> field_signature_;
absl::optional<FieldSignature> field_signature_;
// The unique name of this field, generated by Autofill.
std::u16string unique_name_;
@ -241,7 +241,7 @@ class AutofillField : public FormFieldData {
// Requirements the site imposes to passwords (for password generation).
// Corresponds to the requirements determined by the Autofill server.
base::Optional<PasswordRequirementsSpec> password_requirements_;
absl::optional<PasswordRequirementsSpec> password_requirements_;
// The type of the field, as determined by the local heuristics.
ServerFieldType heuristic_type_ = UNKNOWN_TYPE;
@ -270,7 +270,7 @@ class AutofillField : public FormFieldData {
// A low-entropy hash of the field's initial value before user-interactions or
// automatic fillings. This field is used to detect static placeholders.
base::Optional<uint32_t> initial_value_hash_;
absl::optional<uint32_t> initial_value_hash_;
// Used to hold the position of the first digit to be copied as a substring
// from credit card number.

@ -4,8 +4,8 @@
#include "components/autofill/core/browser/autofill_form_test_utils.h"
#include "base/optional.h"
#include "components/autofill/core/browser/form_structure.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace autofill {

@ -7,13 +7,13 @@
#include <vector>
#include "base/optional.h"
#include "base/strings/string_piece.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/common/form_data.h"
#include "components/autofill/core/common/form_field_data.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace autofill {
namespace test {
@ -43,11 +43,11 @@ struct FieldDataDescription {
bool is_focusable = true;
const base::StringPiece16 label = kLabelText;
const base::StringPiece16 name = kNameText;
base::Optional<const char16_t*> value;
absl::optional<const char16_t*> value;
const base::StringPiece autocomplete_attribute;
const base::StringPiece form_control_type = "text";
bool should_autocomplete = true;
base::Optional<bool> is_autofilled;
absl::optional<bool> is_autofilled;
};
// Attributes provided to the test form.
@ -55,11 +55,11 @@ template <typename = void>
struct TestFormAttributes {
const base::StringPiece description_for_logging;
std::vector<FieldDataDescription<>> fields;
base::Optional<FormRendererId> unique_renderer_id;
absl::optional<FormRendererId> unique_renderer_id;
const base::StringPiece16 name = u"TestForm";
const base::StringPiece url = kFormUrl;
const base::StringPiece action = kFormActionUrl;
base::Optional<url::Origin> main_frame_origin;
absl::optional<url::Origin> main_frame_origin;
bool is_form_tag = true;
};
@ -80,11 +80,11 @@ struct TestFormFlags {
// first value denotes whether the comparison is to be done while second
// denotes EXPECT_TRUE for true and EXPECT_FALSE for false.
std::pair<bool, bool> is_complete_credit_card_form = {false, false};
// The implicit default value `base::nullopt` means no checking.
base::Optional<int> field_count;
base::Optional<int> autofill_count;
base::Optional<int> section_count;
base::Optional<int> response_field_count;
// The implicit default value `absl::nullopt` means no checking.
absl::optional<int> field_count;
absl::optional<int> autofill_count;
absl::optional<int> section_count;
absl::optional<int> response_field_count;
};
// Expected field type values to be verified with the test form.

@ -292,7 +292,7 @@ void AutofillMergeTest::MergeProfiles(const std::string& profiles,
// Import the profile.
std::unique_ptr<CreditCard> imported_credit_card;
base::Optional<std::string> unused_imported_upi_id;
absl::optional<std::string> unused_imported_upi_id;
form_data_importer_->ImportFormData(form_structure,
true, // address autofill enabled,
true, // credit card autofill enabled

@ -503,7 +503,7 @@ void AutofillMetricsTest::SetFidoEligibility(bool is_verifiable) {
->AllowFidoRegistration(true);
access_manager->is_authentication_in_progress_ = false;
access_manager->can_fetch_unmask_details_.Signal();
access_manager->is_user_verifiable_ = base::nullopt;
access_manager->is_user_verifiable_ = absl::nullopt;
}
void AutofillMetricsTest::OnDidGetRealPan(

@ -164,7 +164,7 @@ std::vector<AutofillProfile> ProfileImportProcess::GetResultingProfiles() {
void ProfileImportProcess::SetUserDecision(
UserDecision decision,
base::Optional<AutofillProfile> edited_profile) {
absl::optional<AutofillProfile> edited_profile) {
// A user decision should only be supplied once.
DCHECK_EQ(user_decision_, UserDecision::kUndefined);
DCHECK(!confirmed_import_candidate_.has_value());
@ -215,7 +215,7 @@ void ProfileImportProcess::AcceptWithoutEdits() {
}
void ProfileImportProcess::AcceptWithEdits(AutofillProfile edited_profile) {
SetUserDecision(UserDecision::kEdited, base::make_optional(edited_profile));
SetUserDecision(UserDecision::kEdited, absl::make_optional(edited_profile));
}
void ProfileImportProcess::Declined() {

@ -83,11 +83,11 @@ class ProfileImportProcess {
// a merge candidate exists.
bool ImportIsMerge() const;
const base::Optional<AutofillProfile>& import_candidate() const {
const absl::optional<AutofillProfile>& import_candidate() const {
return import_candidate_;
}
const base::Optional<AutofillProfile>& merge_candidate() const {
const absl::optional<AutofillProfile>& merge_candidate() const {
return merge_candidate_;
}
@ -140,7 +140,7 @@ class ProfileImportProcess {
// |edited_profile| reflect user edits to the import candidate.
void SetUserDecision(
AutofillClient::SaveAddressProfileOfferUserDecision decision,
base::Optional<AutofillProfile> edited_profile = base::nullopt);
absl::optional<AutofillProfile> edited_profile = absl::nullopt);
// Records UMA metrics. Should only be called after a user decision was
// supplied.
@ -172,10 +172,10 @@ class ProfileImportProcess {
// A profile in its original state that can be merged with the observed
// profile.
base::Optional<AutofillProfile> merge_candidate_;
absl::optional<AutofillProfile> merge_candidate_;
// The import candidate that is presented to the user.
base::Optional<AutofillProfile> import_candidate_;
absl::optional<AutofillProfile> import_candidate_;
// The type of the import indicates if the profile is just a duplicate of an
// existing profile, if an existing profile can be silently updated, or if
@ -186,7 +186,7 @@ class ProfileImportProcess {
// The profile as it was confirmed by the user or as it should be imported if
// user interactions are disabled.
base::Optional<AutofillProfile> confirmed_import_candidate_;
absl::optional<AutofillProfile> confirmed_import_candidate_;
// The decision the user made when prompted.
AutofillClient::SaveAddressProfileOfferUserDecision user_decision_{

Some files were not shown because too many files have changed in this diff Show More