From 068d29106afcc2435307d2d2067a014a018d8ec7 Mon Sep 17 00:00:00 2001 From: Anton Bikineev Date: Sat, 15 May 2021 20:43:52 +0000 Subject: [PATCH] net: 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: I27d6f81f415e213c1a4997a55c35935a57ba88a4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2896994 Auto-Submit: Anton Bikineev Commit-Queue: Anton Bikineev Reviewed-by: Peter Kasting Owners-Override: Peter Kasting Cr-Commit-Position: refs/heads/master@{#883294} --- net/android/cellular_signal_strength.cc | 4 +- net/android/cellular_signal_strength.h | 4 +- .../cellular_signal_strength_unittest.cc | 4 +- net/android/network_activation_request.h | 4 +- net/android/network_library.cc | 4 +- net/android/network_library.h | 2 +- net/android/network_library_unittest.cc | 2 +- net/base/address_tracker_linux.cc | 4 +- net/base/backoff_entry_serializer_fuzzer.cc | 8 +- net/base/isolation_info.cc | 38 +- net/base/isolation_info.h | 30 +- net/base/isolation_info_unittest.cc | 36 +- net/base/network_change_notifier.cc | 4 +- net/base/network_change_notifier_fuchsia.cc | 6 +- net/base/network_delegate.cc | 4 +- net/base/network_delegate.h | 10 +- net/base/network_delegate_impl.cc | 4 +- net/base/network_delegate_impl.h | 6 +- net/base/network_interfaces_fuchsia.cc | 18 +- net/base/network_interfaces_fuchsia.h | 6 +- net/base/network_isolation_key.cc | 16 +- net/base/network_isolation_key.h | 12 +- .../registry_controlled_domain.cc | 2 +- .../registry_controlled_domain.h | 4 +- net/base/schemeful_site.cc | 12 +- net/base/schemeful_site.h | 8 +- net/base/schemeful_site_fuzzer.cc | 4 +- net/base/schemeful_site_unittest.cc | 10 +- net/cert/cert_verify_proc_builtin_unittest.cc | 2 +- net/cert/ct_log_response_parser_unittest.cc | 24 +- net/cert/internal/crl.cc | 16 +- net/cert/internal/crl.h | 10 +- .../crl_getcrlstatusforcert_fuzzer.cc | 2 +- net/cert/internal/parse_certificate.h | 8 +- net/cert/internal/parsed_certificate.cc | 4 +- net/cert/internal/parsed_certificate.h | 8 +- net/cert/internal/revocation_util.h | 2 +- net/cookies/canonical_cookie.cc | 4 +- net/cookies/canonical_cookie.h | 8 +- net/cookies/canonical_cookie_unittest.cc | 46 +- net/cookies/cookie_access_delegate.h | 4 +- net/cookies/cookie_deletion_info.h | 10 +- net/cookies/cookie_deletion_info_unittest.cc | 2 +- net/cookies/cookie_monster.h | 2 +- net/cookies/cookie_monster_perftest.cc | 4 +- net/cookies/cookie_monster_unittest.cc | 70 +- net/cookies/cookie_options.h | 2 +- net/cookies/cookie_store.h | 2 +- net/cookies/cookie_store_test_helpers.h | 2 +- net/cookies/cookie_store_unittest.h | 20 +- net/cookies/cookie_util.cc | 16 +- net/cookies/cookie_util.h | 8 +- net/cookies/cookie_util_unittest.cc | 88 +- net/cookies/test_cookie_access_delegate.cc | 4 +- net/cookies/test_cookie_access_delegate.h | 6 +- net/der/parser.cc | 8 +- net/der/parser.h | 6 +- net/der/parser_unittest.cc | 4 +- net/dns/address_info.cc | 10 +- net/dns/address_info.h | 6 +- net/dns/address_info_unittest.cc | 18 +- net/dns/context_host_resolver.cc | 22 +- net/dns/context_host_resolver.h | 2 +- net/dns/context_host_resolver_unittest.cc | 28 +- net/dns/dns_client.cc | 18 +- net/dns/dns_client.h | 6 +- net/dns/dns_config_service.cc | 8 +- net/dns/dns_config_service.h | 10 +- net/dns/dns_config_service_android.cc | 4 +- net/dns/dns_config_service_linux.cc | 22 +- net/dns/dns_config_service_linux_unittest.cc | 64 +- net/dns/dns_config_service_posix.cc | 26 +- net/dns/dns_config_service_posix.h | 4 +- net/dns/dns_config_service_posix_unittest.cc | 4 +- net/dns/dns_config_service_win.cc | 54 +- net/dns/dns_config_service_win.h | 2 +- net/dns/dns_config_service_win_unittest.cc | 6 +- net/dns/dns_query.cc | 10 +- net/dns/dns_response.cc | 12 +- net/dns/dns_response.h | 8 +- net/dns/dns_response_fuzzer.cc | 6 +- net/dns/dns_response_result_extractor.cc | 18 +- .../dns_response_result_extractor_unittest.cc | 4 +- net/dns/dns_response_unittest.cc | 24 +- net/dns/dns_server_iterator.cc | 6 +- net/dns/dns_test_util.cc | 28 +- net/dns/dns_test_util.h | 16 +- net/dns/dns_transaction.cc | 6 +- net/dns/dns_transaction.h | 2 +- net/dns/dns_transaction_unittest.cc | 10 +- net/dns/dns_util.cc | 16 +- net/dns/dns_util.h | 6 +- net/dns/dns_util_unittest.cc | 66 +- net/dns/host_cache.cc | 42 +- net/dns/host_cache.h | 44 +- net/dns/host_cache_fuzzer.cc | 4 +- net/dns/host_resolver.cc | 26 +- net/dns/host_resolver.h | 24 +- net/dns/host_resolver_manager.cc | 100 +- net/dns/host_resolver_manager.h | 20 +- net/dns/host_resolver_manager_unittest.cc | 538 +++--- net/dns/host_resolver_proc.cc | 2 +- net/dns/https_record_rdata.cc | 18 +- net/dns/https_record_rdata.h | 8 +- net/dns/https_record_rdata_unittest.cc | 8 +- net/dns/httpssvc_metrics.cc | 10 +- net/dns/httpssvc_metrics.h | 30 +- net/dns/httpssvc_metrics_unittest.cc | 212 +-- net/dns/integrity_record_fuzzer.cc | 8 +- net/dns/mapped_host_resolver.cc | 2 +- net/dns/mapped_host_resolver.h | 2 +- net/dns/mapped_host_resolver_unittest.cc | 20 +- net/dns/mock_host_resolver.cc | 52 +- net/dns/mock_host_resolver.h | 16 +- net/dns/public/dns_config_overrides.h | 30 +- net/dns/public/doh_provider_entry.cc | 28 +- net/dns/public/doh_provider_entry.h | 8 +- net/dns/record_rdata.cc | 4 +- net/dns/record_rdata.h | 6 +- net/dns/record_rdata_unittest.cc | 12 +- net/dns/resolve_context.h | 2 +- net/dns/system_dns_config_change_notifier.cc | 12 +- net/dns/system_dns_config_change_notifier.h | 6 +- ...tem_dns_config_change_notifier_unittest.cc | 10 +- net/dns/test_dns_config_service.cc | 6 +- net/dns/test_dns_config_service.h | 4 +- .../sqlite/sqlite_persistent_cookie_store.cc | 48 +- ...sqlite_persistent_cookie_store_unittest.cc | 14 +- ...lite_persistent_reporting_and_nel_store.cc | 34 +- .../sqlite_persistent_store_backend_base.cc | 2 +- .../sqlite_persistent_store_backend_base.h | 6 +- net/ftp/ftp_network_transaction.cc | 2 +- net/http/http_auth_controller.cc | 4 +- net/http/http_auth_controller.h | 6 +- .../http_auth_handler_factory_unittest.cc | 2 +- net/http/http_cache_transaction.h | 2 +- net/http/http_network_session.h | 4 +- net/http/http_network_transaction_unittest.cc | 40 +- net/http/http_proxy_connect_job.cc | 6 +- net/http/http_request_info.h | 4 +- net/http/http_response_info.h | 4 +- net/http/http_server_properties.h | 10 +- net/http/http_server_properties_manager.cc | 12 +- net/http/http_stream_factory_unittest.cc | 8 +- net/http/structured_headers.cc | 204 +-- net/http/structured_headers.h | 22 +- .../structured_headers_generated_unittest.cc | 1466 ++++++++--------- net/http/structured_headers_unittest.cc | 84 +- net/http/transport_security_persister.cc | 18 +- net/http/transport_security_state.cc | 6 +- net/http/transport_security_state_unittest.cc | 6 +- net/log/file_net_log_observer.cc | 16 +- net/log/file_net_log_observer.h | 4 +- net/log/net_log_unittest.cc | 2 +- net/log/test_net_log_util.cc | 16 +- net/log/test_net_log_util.h | 10 +- .../network_error_logging_service.cc | 12 +- net/nqe/connectivity_monitor.cc | 6 +- net/nqe/connectivity_monitor.h | 6 +- net/nqe/connectivity_monitor_unittest.cc | 14 +- net/nqe/effective_connection_type.cc | 4 +- net/nqe/effective_connection_type.h | 4 +- net/nqe/effective_connection_type_unittest.cc | 4 +- net/nqe/network_qualities_prefs_manager.cc | 4 +- net/nqe/network_quality_estimator.cc | 44 +- net/nqe/network_quality_estimator.h | 24 +- net/nqe/network_quality_estimator_params.cc | 10 +- net/nqe/network_quality_estimator_params.h | 6 +- ...twork_quality_estimator_params_unittest.cc | 4 +- .../network_quality_estimator_test_util.cc | 6 +- net/nqe/network_quality_estimator_test_util.h | 32 +- net/nqe/network_quality_estimator_unittest.cc | 12 +- ...network_quality_estimator_util_unittest.cc | 10 +- net/nqe/network_quality_observation.cc | 4 +- net/nqe/network_quality_observation.h | 8 +- net/nqe/observation_buffer.cc | 4 +- net/nqe/observation_buffer.h | 4 +- net/nqe/observation_buffer_unittest.cc | 19 +- net/nqe/socket_watcher.cc | 4 +- net/nqe/socket_watcher.h | 6 +- net/nqe/socket_watcher_factory.h | 4 +- net/nqe/socket_watcher_unittest.cc | 14 +- net/nqe/throughput_analyzer.h | 2 +- net/nqe/throughput_analyzer_unittest.cc | 8 +- .../configured_proxy_resolution_service.cc | 6 +- .../configured_proxy_resolution_service.h | 10 +- ...etwork_delegate_error_observer_unittest.cc | 4 +- .../pac_file_fetcher_impl_unittest.cc | 4 +- .../proxy_config_service_linux.cc | 32 +- .../proxy_config_service_linux.h | 16 +- .../dedicated_web_transport_http3_client.cc | 8 +- .../dedicated_web_transport_http3_client.h | 2 +- net/quic/platform/impl/quic_flags_impl.h | 4 +- net/quic/platform/impl/quic_flags_test.cc | 2 +- net/quic/quic_connectivity_monitor.cc | 4 +- net/quic/quic_connectivity_monitor.h | 2 +- net/quic/quic_network_transaction_unittest.cc | 2 +- net/quic/quic_transport_client.cc | 6 +- net/quic/quic_transport_end_to_end_test.cc | 2 +- net/quic/web_transport_client.h | 4 +- net/reporting/reporting_cache_impl.cc | 16 +- net/reporting/reporting_cache_impl.h | 10 +- .../reporting_header_parser_unittest.cc | 2 +- net/reporting/reporting_report.h | 2 +- net/reporting/reporting_service.cc | 4 +- net/reporting/reporting_uploader_unittest.cc | 2 +- net/socket/client_socket_handle.cc | 2 +- net/socket/client_socket_handle.h | 4 +- net/socket/client_socket_pool.cc | 2 +- net/socket/client_socket_pool.h | 8 +- .../client_socket_pool_base_unittest.cc | 380 ++--- net/socket/client_socket_pool_manager.cc | 8 +- net/socket/connect_job.cc | 6 +- net/socket/connect_job.h | 6 +- net/socket/connect_job_unittest.cc | 2 +- net/socket/socket_test_util.cc | 4 +- net/socket/socket_test_util.h | 20 +- net/socket/socks_connect_job.cc | 2 +- net/socket/ssl_client_socket_impl.cc | 12 +- net/socket/ssl_client_socket_impl.h | 6 +- net/socket/ssl_client_socket_unittest.cc | 8 +- net/socket/ssl_server_socket_impl.cc | 8 +- net/socket/stream_socket.cc | 4 +- net/socket/stream_socket.h | 4 +- net/socket/tcp_client_socket.cc | 8 +- net/socket/tcp_client_socket.h | 2 +- net/socket/transport_client_socket_pool.cc | 14 +- net/socket/transport_client_socket_pool.h | 18 +- .../transport_client_socket_pool_unittest.cc | 98 +- .../websocket_transport_client_socket_pool.cc | 6 +- .../websocket_transport_client_socket_pool.h | 10 +- ...t_transport_client_socket_pool_unittest.cc | 48 +- net/spdy/spdy_network_transaction_unittest.cc | 22 +- net/spdy/spdy_session.cc | 2 +- net/spdy/spdy_session.h | 6 +- net/spdy/spdy_session_pool.cc | 2 +- net/spdy/spdy_session_pool.h | 6 +- net/spdy/spdy_session_unittest.cc | 12 +- net/spdy/spdy_test_util_common.cc | 4 +- net/spdy/spdy_test_util_common.h | 2 +- net/ssl/ssl_client_session_cache.h | 4 +- net/ssl/ssl_config.h | 6 +- net/ssl/ssl_platform_key_android.cc | 6 +- net/ssl/ssl_platform_key_mac.cc | 6 +- net/ssl/ssl_platform_key_util.cc | 6 +- net/ssl/ssl_platform_key_util.h | 4 +- net/ssl/ssl_server_config.h | 6 +- net/test/embedded_test_server/http_request.h | 4 +- .../spawned_test_server/base_test_server.cc | 2 +- .../spawned_test_server/base_test_server.h | 4 +- .../spawned_test_server/local_test_server.cc | 6 +- .../spawned_test_server/local_test_server.h | 4 +- .../spawned_test_server/remote_test_server.cc | 2 +- .../url_request/url_request_mock_data_job.h | 4 +- net/tools/quic/synchronous_host_resolver.cc | 4 +- net/tools/testserver/run_testserver.cc | 2 +- net/url_request/redirect_info.cc | 4 +- net/url_request/redirect_info.h | 2 +- net/url_request/redirect_info_unittest.cc | 6 +- net/url_request/redirect_util.cc | 10 +- net/url_request/redirect_util.h | 10 +- net/url_request/redirect_util_unittest.cc | 14 +- net/url_request/test_url_fetcher_factory.cc | 2 +- net/url_request/test_url_fetcher_factory.h | 2 +- net/url_request/url_fetcher.h | 2 +- net/url_request/url_fetcher_core.cc | 6 +- net/url_request/url_fetcher_core.h | 6 +- net/url_request/url_fetcher_impl.cc | 2 +- net/url_request/url_fetcher_impl.h | 2 +- net/url_request/url_request.cc | 12 +- net/url_request/url_request.h | 24 +- .../url_request_context_builder.cc | 2 +- .../url_request_context_builder_unittest.cc | 2 +- net/url_request/url_request_http_job.cc | 12 +- net/url_request/url_request_http_job.h | 8 +- .../url_request_http_job_unittest.cc | 10 +- net/url_request/url_request_job.cc | 14 +- net/url_request/url_request_job.h | 12 +- net/url_request/url_request_netlog_params.cc | 2 +- net/url_request/url_request_netlog_params.h | 4 +- net/url_request/url_request_test_util.cc | 4 +- net/url_request/url_request_test_util.h | 8 +- net/url_request/url_request_unittest.cc | 84 +- .../websocket_basic_handshake_stream.cc | 10 +- .../websocket_basic_handshake_stream.h | 6 +- .../websocket_basic_stream_adapters_test.cc | 2 +- net/websockets/websocket_basic_stream_test.cc | 4 +- net/websockets/websocket_channel.cc | 12 +- net/websockets/websocket_channel.h | 6 +- net/websockets/websocket_channel_test.cc | 18 +- net/websockets/websocket_end_to_end_test.cc | 10 +- net/websockets/websocket_event_interface.h | 8 +- ...ket_handshake_stream_create_helper_test.cc | 12 +- .../websocket_http2_handshake_stream.cc | 10 +- .../websocket_http2_handshake_stream.h | 4 +- net/websockets/websocket_stream.cc | 22 +- net/websockets/websocket_stream.h | 8 +- .../websocket_stream_cookie_test.cc | 2 +- .../websocket_stream_create_test_base.cc | 4 +- .../websocket_stream_create_test_base.h | 2 +- net/websockets/websocket_test_util.cc | 2 +- net/websockets/websocket_test_util.h | 8 +- 302 files changed, 3120 insertions(+), 3121 deletions(-) diff --git a/net/android/cellular_signal_strength.cc b/net/android/cellular_signal_strength.cc index 35254402a9e2f0..24ce9f7e288f49 100644 --- a/net/android/cellular_signal_strength.cc +++ b/net/android/cellular_signal_strength.cc @@ -29,12 +29,12 @@ static_assert( } // namespace -base::Optional GetSignalStrengthLevel() { +absl::optional GetSignalStrengthLevel() { int32_t signal_strength_level = Java_AndroidCellularSignalStrength_getSignalStrengthLevel( base::android::AttachCurrentThread()); if (signal_strength_level == ERROR_NOT_SUPPORTED) - return base::nullopt; + return absl::nullopt; // |signal_strength_level| is expected to be between 0 and 4 (both inclusive). // See diff --git a/net/android/cellular_signal_strength.h b/net/android/cellular_signal_strength.h index 367161c5a09025..e1f3bb501315c5 100644 --- a/net/android/cellular_signal_strength.h +++ b/net/android/cellular_signal_strength.h @@ -8,8 +8,8 @@ #include #include -#include "base/optional.h" #include "net/base/net_export.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -22,7 +22,7 @@ namespace cellular_signal_strength { // empty value is returned. If the signal strength value returned by platform // API is less than 0, this method returns 0. If the platform API returns a // value larger than 4, then this method returns 4. -NET_EXPORT_PRIVATE base::Optional GetSignalStrengthLevel(); +NET_EXPORT_PRIVATE absl::optional GetSignalStrengthLevel(); } // namespace cellular_signal_strength diff --git a/net/android/cellular_signal_strength_unittest.cc b/net/android/cellular_signal_strength_unittest.cc index 86e96976c00131..1ce273eb462a03 100644 --- a/net/android/cellular_signal_strength_unittest.cc +++ b/net/android/cellular_signal_strength_unittest.cc @@ -6,16 +6,16 @@ #include -#include "base/optional.h" #include "net/base/network_change_notifier.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { namespace { TEST(CellularSignalStrengthAndroidTest, SignalStrengthLevelTest) { - base::Optional signal_strength = + absl::optional signal_strength = android::cellular_signal_strength::GetSignalStrengthLevel(); // Signal strength is unavailable if the device does not have an active diff --git a/net/android/network_activation_request.h b/net/android/network_activation_request.h index 784460354c122c..8ce8edd7d81bf2 100644 --- a/net/android/network_activation_request.h +++ b/net/android/network_activation_request.h @@ -38,7 +38,7 @@ class NET_EXPORT_PRIVATE NetworkActivationRequest { // Exposes a handle to the network currently activated by the system on behalf // of this request, if any. - const base::Optional& activated_network() const { + const absl::optional& activated_network() const { return activated_network_; } @@ -53,7 +53,7 @@ class NET_EXPORT_PRIVATE NetworkActivationRequest { const scoped_refptr task_runner_; base::WeakPtr weak_self_; base::android::ScopedJavaGlobalRef java_request_; - base::Optional activated_network_; + absl::optional activated_network_; base::WeakPtrFactory weak_ptr_factory_{this}; }; diff --git a/net/android/network_library.cc b/net/android/network_library.cc index fa302cdf0bf838..8ac66005cc8299 100644 --- a/net/android/network_library.cc +++ b/net/android/network_library.cc @@ -123,12 +123,12 @@ std::string GetWifiSSID() { base::android::AttachCurrentThread())); } -base::Optional GetWifiSignalLevel() { +absl::optional GetWifiSignalLevel() { const int count_buckets = 5; int signal_strength = Java_AndroidNetworkLibrary_getWifiSignalLevel( base::android::AttachCurrentThread(), count_buckets); if (signal_strength < 0) - return base::nullopt; + return absl::nullopt; DCHECK_LE(0, signal_strength); DCHECK_GE(count_buckets - 1, signal_strength); diff --git a/net/android/network_library.h b/net/android/network_library.h index f2ae1c0a015ca0..ee5678066e5fdf 100644 --- a/net/android/network_library.h +++ b/net/android/network_library.h @@ -85,7 +85,7 @@ NET_EXPORT_PRIVATE std::string GetWifiSSID(); // Returns the signal strength level (between 0 and 4, both inclusive) of the // currently registered Wifi connection. If the value is unavailable, an // empty value is returned. -NET_EXPORT_PRIVATE base::Optional GetWifiSignalLevel(); +NET_EXPORT_PRIVATE absl::optional GetWifiSignalLevel(); // Gets the DNS servers and puts them in |dns_servers|. Sets // |dns_over_tls_active| and |dns_over_tls_hostname| based on the private DNS diff --git a/net/android/network_library_unittest.cc b/net/android/network_library_unittest.cc index 713364d19aa629..37e93905719c31 100644 --- a/net/android/network_library_unittest.cc +++ b/net/android/network_library_unittest.cc @@ -20,7 +20,7 @@ TEST(NetworkLibraryTest, CaptivePortal) { } TEST(NetworkLibraryTest, GetWifiSignalLevel) { - base::Optional signal_strength = android::GetWifiSignalLevel(); + absl::optional signal_strength = android::GetWifiSignalLevel(); if (!signal_strength.has_value()) return; EXPECT_LE(0, signal_strength.value()); diff --git a/net/base/address_tracker_linux.cc b/net/base/address_tracker_linux.cc index 03537a91c111ed..a7a6290ecc4970 100644 --- a/net/base/address_tracker_linux.cc +++ b/net/base/address_tracker_linux.cc @@ -13,12 +13,12 @@ #include "base/callback_helpers.h" #include "base/files/scoped_file.h" #include "base/logging.h" -#include "base/optional.h" #include "base/posix/eintr_wrapper.h" #include "base/task/current_thread.h" #include "base/threading/scoped_blocking_call.h" #include "build/build_config.h" #include "net/base/network_interfaces_linux.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #if defined(OS_ANDROID) #include "base/android/build_info.h" @@ -327,7 +327,7 @@ void AddressTrackerLinux::ReadMessages(bool* address_changed, char buffer[4096]; bool first_loop = true; { - base::Optional blocking_call; + absl::optional blocking_call; if (tracking_) { // If the loop below takes a long time to run, a new thread should added // to the current thread pool to ensure forward progress of all tasks. diff --git a/net/base/backoff_entry_serializer_fuzzer.cc b/net/base/backoff_entry_serializer_fuzzer.cc index 516d714a18a2ba..f4877bf40b2397 100644 --- a/net/base/backoff_entry_serializer_fuzzer.cc +++ b/net/base/backoff_entry_serializer_fuzzer.cc @@ -9,7 +9,6 @@ #include "base/json/json_reader.h" #include "base/logging.h" -#include "base/optional.h" #include "base/strings/string_piece_forward.h" #include "base/time/tick_clock.h" #include "base/time/time.h" @@ -18,6 +17,7 @@ #include "net/base/backoff_entry_serializer_fuzzer_input.pb.h" #include "testing/libfuzzer/proto/json_proto_converter.h" #include "testing/libfuzzer/proto/lpm_interface.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -50,10 +50,10 @@ class ProtoTranslator { return base::TimeTicks() + base::TimeDelta::FromMicroseconds(input_.now_ticks()); } - base::Optional serialized_entry() const { + absl::optional serialized_entry() const { json_proto::JsonProtoConverter converter; std::string json_array = converter.Convert(input_.serialized_entry()); - base::Optional value = base::JSONReader::Read(json_array); + absl::optional value = base::JSONReader::Read(json_array); return value; } @@ -91,7 +91,7 @@ class MockClock : public base::TickClock { // we check that the parsed BackoffEntry values are equivalent. void TestDeserialize(const ProtoTranslator& translator) { // Attempt to convert the json_proto.ArrayValue to a base::Value. - base::Optional value = translator.serialized_entry(); + absl::optional value = translator.serialized_entry(); if (!value) return; DCHECK(value->is_list()); diff --git a/net/base/isolation_info.cc b/net/base/isolation_info.cc index e51644b222cefa..5cd54540dafc80 100644 --- a/net/base/isolation_info.cc +++ b/net/base/isolation_info.cc @@ -37,11 +37,11 @@ bool ValidateSameSite(const url::Origin& origin, // 0-argument constructor. Additionally, |opaque_and_non_transient| can only be // true if both origins are opaque and |site_for_cookies| is null. bool IsConsistent(IsolationInfo::RequestType request_type, - const base::Optional& top_frame_origin, - const base::Optional& frame_origin, + const absl::optional& top_frame_origin, + const absl::optional& frame_origin, const SiteForCookies& site_for_cookies, bool opaque_and_non_transient, - base::Optional> party_context) { + absl::optional> party_context) { // Check for the default-constructed case. if (!top_frame_origin) { return request_type == IsolationInfo::RequestType::kOther && @@ -92,11 +92,11 @@ bool IsConsistent(IsolationInfo::RequestType request_type, IsolationInfo::IsolationInfo() : IsolationInfo(RequestType::kOther, - base::nullopt, - base::nullopt, + absl::nullopt, + absl::nullopt, SiteForCookies(), false /* opaque_and_non_transient */, - base::nullopt) {} + absl::nullopt) {} IsolationInfo::IsolationInfo(const IsolationInfo&) = default; IsolationInfo::IsolationInfo(IsolationInfo&&) = default; @@ -116,14 +116,14 @@ IsolationInfo IsolationInfo::CreateTransient() { url::Origin opaque_origin; return IsolationInfo(RequestType::kOther, opaque_origin, opaque_origin, SiteForCookies(), false /* opaque_and_non_transient */, - base::nullopt /* party_context */); + absl::nullopt /* party_context */); } IsolationInfo IsolationInfo::CreateOpaqueAndNonTransient() { url::Origin opaque_origin; return IsolationInfo(RequestType::kOther, opaque_origin, opaque_origin, SiteForCookies(), true /* opaque_and_non_transient */, - base::nullopt /* party_context */); + absl::nullopt /* party_context */); } IsolationInfo IsolationInfo::Create( @@ -131,7 +131,7 @@ IsolationInfo IsolationInfo::Create( const url::Origin& top_frame_origin, const url::Origin& frame_origin, const SiteForCookies& site_for_cookies, - base::Optional> party_context) { + absl::optional> party_context) { return IsolationInfo(request_type, top_frame_origin, frame_origin, site_for_cookies, false /* opaque_and_non_transient */, std::move(party_context)); @@ -161,20 +161,20 @@ IsolationInfo IsolationInfo::CreatePartial( return IsolationInfo(request_type, top_frame_origin, frame_origin, SiteForCookies(), opaque_and_non_transient, - base::nullopt /* party_context */); + absl::nullopt /* party_context */); } -base::Optional IsolationInfo::CreateIfConsistent( +absl::optional IsolationInfo::CreateIfConsistent( RequestType request_type, - const base::Optional& top_frame_origin, - const base::Optional& frame_origin, + const absl::optional& top_frame_origin, + const absl::optional& frame_origin, const SiteForCookies& site_for_cookies, bool opaque_and_non_transient, - base::Optional> party_context) { + absl::optional> party_context) { if (!IsConsistent(request_type, top_frame_origin, frame_origin, site_for_cookies, opaque_and_non_transient, party_context)) { - return base::nullopt; + return absl::nullopt; } return IsolationInfo(request_type, top_frame_origin, frame_origin, site_for_cookies, opaque_and_non_transient, @@ -221,11 +221,11 @@ IsolationInfo IsolationInfo::ToDoUseTopFrameOriginAsWell( IsolationInfo::IsolationInfo( RequestType request_type, - const base::Optional& top_frame_origin, - const base::Optional& frame_origin, + const absl::optional& top_frame_origin, + const absl::optional& frame_origin, const SiteForCookies& site_for_cookies, bool opaque_and_non_transient, - base::Optional> party_context) + absl::optional> party_context) : request_type_(request_type), top_frame_origin_(top_frame_origin), frame_origin_(frame_origin), @@ -239,7 +239,7 @@ IsolationInfo::IsolationInfo( opaque_and_non_transient_(opaque_and_non_transient), party_context_(party_context.has_value() && party_context->size() > kPartyContextMaxSize - ? base::nullopt + ? absl::nullopt : party_context) { DCHECK(IsConsistent(request_type_, top_frame_origin_, frame_origin_, site_for_cookies_, opaque_and_non_transient_, diff --git a/net/base/isolation_info.h b/net/base/isolation_info.h index 28d6b1c7f71928..129d9c992ae8f7 100644 --- a/net/base/isolation_info.h +++ b/net/base/isolation_info.h @@ -7,10 +7,10 @@ #include -#include "base/optional.h" #include "net/base/net_export.h" #include "net/base/network_isolation_key.h" #include "net/cookies/site_for_cookies.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/origin.h" namespace network { @@ -116,7 +116,7 @@ class NET_EXPORT IsolationInfo { const url::Origin& top_frame_origin, const url::Origin& frame_origin, const SiteForCookies& site_for_cookies, - base::Optional> party_context = base::nullopt); + absl::optional> party_context = absl::nullopt); // Create an IsolationInfos that may not be fully correct - in particular, // the SiteForCookies will always set to null, and if the NetworkIsolationKey @@ -136,13 +136,13 @@ class NET_EXPORT IsolationInfo { // considered consistent. // // Intended for use by cross-process deserialization. - static base::Optional CreateIfConsistent( + static absl::optional CreateIfConsistent( RequestType request_type, - const base::Optional& top_frame_origin, - const base::Optional& frame_origin, + const absl::optional& top_frame_origin, + const absl::optional& frame_origin, const SiteForCookies& site_for_cookies, bool opaque_and_non_transient, - base::Optional> party_context = base::nullopt); + absl::optional> party_context = absl::nullopt); // Create a new IsolationInfo for a redirect to the supplied origin. |this| is // unmodified. @@ -166,10 +166,10 @@ class NET_EXPORT IsolationInfo { // Note that these are the values the IsolationInfo was created with. In the // case an IsolationInfo was created from a NetworkIsolationKey, they may be // scheme + eTLD+1 instead of actual origins. - const base::Optional& top_frame_origin() const { + const absl::optional& top_frame_origin() const { return top_frame_origin_; } - const base::Optional& frame_origin() const { + const absl::optional& frame_origin() const { return frame_origin_; } @@ -192,7 +192,7 @@ class NET_EXPORT IsolationInfo { // TODO(mmenke): Make this function PartyContextForTesting() after switching // RenderFrameHostImpl to use the parent IsolationInfo to create the child // IsolationInfo instead of walking through all parent frames. - const base::Optional>& party_context() const { + const absl::optional>& party_context() const { return party_context_; } @@ -200,16 +200,16 @@ class NET_EXPORT IsolationInfo { private: IsolationInfo(RequestType request_type, - const base::Optional& top_frame_origin, - const base::Optional& frame_origin, + const absl::optional& top_frame_origin, + const absl::optional& frame_origin, const SiteForCookies& site_for_cookies, bool opaque_and_non_transient, - base::Optional> party_context); + absl::optional> party_context); RequestType request_type_; - base::Optional top_frame_origin_; - base::Optional frame_origin_; + absl::optional top_frame_origin_; + absl::optional frame_origin_; // This can be deduced from the two origins above, but keep a cached version // to avoid repeated eTLD+1 calculations, when this is using eTLD+1. @@ -236,7 +236,7 @@ class NET_EXPORT IsolationInfo { // is still included in the set. The top frame's site is excluded because it // is redundant with the |top_frame_origin_| field. The current frame is // excluded to make it easier to update on subframe redirects. - base::Optional> party_context_; + absl::optional> party_context_; // Mojo serialization code needs to access internal party_context_ field. friend struct mojo::StructTraits duplicate_isolation_info = + absl::optional duplicate_isolation_info = IsolationInfo::CreateIfConsistent( isolation_info.request_type(), isolation_info.top_frame_origin(), isolation_info.frame_origin(), isolation_info.site_for_cookies(), @@ -38,15 +38,15 @@ class IsolationInfoTest : public testing::Test { const url::Origin kOrigin3 = url::Origin::Create(GURL("https://c.baz.test")); const url::Origin kOpaqueOrigin; - const base::Optional> kPartyContextNull = - base::nullopt; - const base::Optional> kPartyContextEmpty = + const absl::optional> kPartyContextNull = + absl::nullopt; + const absl::optional> kPartyContextEmpty = std::set(); - const base::Optional> kPartyContext1 = + const absl::optional> kPartyContext1 = std::set{net::SchemefulSite(kOrigin1)}; - const base::Optional> kPartyContext2 = + const absl::optional> kPartyContext2 = std::set{net::SchemefulSite(kOrigin2)}; - const base::Optional> kPartyContext3 = + const absl::optional> kPartyContext3 = std::set{net::SchemefulSite(kOrigin3)}; }; @@ -415,7 +415,7 @@ TEST_F(IsolationInfoTest, CreateIfConsistentFails) { // |opaque_and_non_transient| with empty origins. EXPECT_FALSE(IsolationInfo::CreateIfConsistent( - IsolationInfo::RequestType::kOther, base::nullopt, base::nullopt, + IsolationInfo::RequestType::kOther, absl::nullopt, absl::nullopt, SiteForCookies(), true /* opaque_and_non_transient */)); // |opaque_and_non_transient| with non-opaque origins. @@ -425,40 +425,40 @@ TEST_F(IsolationInfoTest, CreateIfConsistentFails) { // Correctly have empty/non-empty origins: EXPECT_TRUE(IsolationInfo::CreateIfConsistent( - IsolationInfo::RequestType::kOther, base::nullopt, base::nullopt, + IsolationInfo::RequestType::kOther, absl::nullopt, absl::nullopt, SiteForCookies(), false /* opaque_and_non_transient */)); // Incorrectly have empty/non-empty origins: EXPECT_FALSE(IsolationInfo::CreateIfConsistent( - IsolationInfo::RequestType::kOther, base::nullopt, kOrigin1, + IsolationInfo::RequestType::kOther, absl::nullopt, kOrigin1, SiteForCookies(), false /* opaque_and_non_transient */)); EXPECT_FALSE(IsolationInfo::CreateIfConsistent( - IsolationInfo::RequestType::kOther, kOrigin1, base::nullopt, + IsolationInfo::RequestType::kOther, kOrigin1, absl::nullopt, SiteForCookies(), false /* opaque_and_non_transient */)); EXPECT_FALSE(IsolationInfo::CreateIfConsistent( - IsolationInfo::RequestType::kMainFrame, base::nullopt, kOrigin1, + IsolationInfo::RequestType::kMainFrame, absl::nullopt, kOrigin1, SiteForCookies::FromOrigin(kOrigin1), false /* opaque_and_non_transient */)); EXPECT_FALSE(IsolationInfo::CreateIfConsistent( - IsolationInfo::RequestType::kMainFrame, kOrigin1, base::nullopt, + IsolationInfo::RequestType::kMainFrame, kOrigin1, absl::nullopt, SiteForCookies::FromOrigin(kOrigin1), false /* opaque_and_non_transient */)); EXPECT_FALSE(IsolationInfo::CreateIfConsistent( - IsolationInfo::RequestType::kSubFrame, base::nullopt, kOrigin2, + IsolationInfo::RequestType::kSubFrame, absl::nullopt, kOrigin2, SiteForCookies(), false /* opaque_and_non_transient */)); EXPECT_FALSE(IsolationInfo::CreateIfConsistent( - IsolationInfo::RequestType::kSubFrame, kOrigin1, base::nullopt, + IsolationInfo::RequestType::kSubFrame, kOrigin1, absl::nullopt, SiteForCookies(), false /* opaque_and_non_transient */)); // No origins with non-null SiteForCookies. EXPECT_FALSE(IsolationInfo::CreateIfConsistent( - IsolationInfo::RequestType::kOther, base::nullopt, base::nullopt, + IsolationInfo::RequestType::kOther, absl::nullopt, absl::nullopt, SiteForCookies::FromOrigin(kOrigin1), false /* opaque_and_non_transient */)); // No origins with non-null party_context. EXPECT_FALSE(IsolationInfo::CreateIfConsistent( - IsolationInfo::RequestType::kOther, base::nullopt, base::nullopt, + IsolationInfo::RequestType::kOther, absl::nullopt, absl::nullopt, SiteForCookies(), false /* opaque_and_non_transient */, kPartyContextEmpty)); } diff --git a/net/base/network_change_notifier.cc b/net/base/network_change_notifier.cc index f98d4a7038cb86..be3a257892157c 100644 --- a/net/base/network_change_notifier.cc +++ b/net/base/network_change_notifier.cc @@ -12,7 +12,6 @@ #include "base/memory/ref_counted.h" #include "base/metrics/histogram_macros.h" #include "base/no_destructor.h" -#include "base/optional.h" #include "base/sequence_checker.h" #include "base/stl_util.h" #include "base/strings/string_util.h" @@ -28,6 +27,7 @@ #include "net/dns/dns_config_service.h" #include "net/dns/system_dns_config_change_notifier.h" #include "net/url_request/url_request.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #if defined(OS_WIN) @@ -188,7 +188,7 @@ class NetworkChangeNotifier::SystemDnsConfigObserver public: virtual ~SystemDnsConfigObserver() = default; - void OnSystemDnsConfigChanged(base::Optional config) override { + void OnSystemDnsConfigChanged(absl::optional config) override { NotifyObserversOfDNSChange(); } }; diff --git a/net/base/network_change_notifier_fuchsia.cc b/net/base/network_change_notifier_fuchsia.cc index b710800f3a1433..f49a4f93357013 100644 --- a/net/base/network_change_notifier_fuchsia.cc +++ b/net/base/network_change_notifier_fuchsia.cc @@ -12,8 +12,8 @@ #include "base/bind.h" #include "base/fuchsia/fuchsia_logging.h" -#include "base/optional.h" #include "base/strings/stringprintf.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -37,7 +37,7 @@ NetworkChangeNotifierFuchsia::NetworkChangeNotifierFuchsia( }); fuchsia::net::interfaces::WatcherSyncPtr watcher = handle.BindSync(); - base::Optional interfaces = + absl::optional interfaces = internal::GetExistingInterfaces(watcher); if (!interfaces) return; @@ -107,7 +107,7 @@ void NetworkChangeNotifierFuchsia::OnInterfacesEvent( void NetworkChangeNotifierFuchsia::OnInterfaceAdded( fuchsia::net::interfaces::Properties properties) { uint64_t id = properties.id(); - base::Optional cache_entry = + absl::optional cache_entry = internal::InterfaceProperties::VerifyAndCreate(std::move(properties)); if (!cache_entry) { OnWatcherError("OnInterfaceAdded: incomplete interface properties."); diff --git a/net/base/network_delegate.cc b/net/base/network_delegate.cc index e8a345b195cb28..2f352781bc0093 100644 --- a/net/base/network_delegate.cc +++ b/net/base/network_delegate.cc @@ -51,7 +51,7 @@ int NetworkDelegate::NotifyHeadersReceived( const HttpResponseHeaders* original_response_headers, scoped_refptr* override_response_headers, const IPEndPoint& endpoint, - base::Optional* preserve_fragment_on_redirect_url) { + absl::optional* preserve_fragment_on_redirect_url) { TRACE_EVENT0(NetTracingCategory(), "NetworkDelegate::NotifyHeadersReceived"); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK(original_response_headers); @@ -119,7 +119,7 @@ bool NetworkDelegate::CanSetCookie(const URLRequest& request, bool NetworkDelegate::ForcePrivacyMode( const GURL& url, const SiteForCookies& site_for_cookies, - const base::Optional& top_frame_origin) const { + const absl::optional& top_frame_origin) const { TRACE_EVENT0(NetTracingCategory(), "NetworkDelegate::ForcePrivacyMode"); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); return OnForcePrivacyMode(url, site_for_cookies, top_frame_origin); diff --git a/net/base/network_delegate.h b/net/base/network_delegate.h index f93f91c0bd3af2..d2427fb33135bb 100644 --- a/net/base/network_delegate.h +++ b/net/base/network_delegate.h @@ -11,7 +11,6 @@ #include #include "base/callback.h" -#include "base/optional.h" #include "base/threading/thread_checker.h" #include "net/base/auth.h" #include "net/base/completion_once_callback.h" @@ -19,6 +18,7 @@ #include "net/cookies/canonical_cookie.h" #include "net/cookies/site_for_cookies.h" #include "net/proxy_resolution/proxy_retry_info.h" +#include "third_party/abseil-cpp/absl/types/optional.h" class GURL; @@ -64,7 +64,7 @@ class NET_EXPORT NetworkDelegate { const HttpResponseHeaders* original_response_headers, scoped_refptr* override_response_headers, const IPEndPoint& remote_endpoint, - base::Optional* preserve_fragment_on_redirect_url); + absl::optional* preserve_fragment_on_redirect_url); void NotifyBeforeRedirect(URLRequest* request, const GURL& new_location); void NotifyResponseStarted(URLRequest* request, int net_error); @@ -80,7 +80,7 @@ class NET_EXPORT NetworkDelegate { bool ForcePrivacyMode( const GURL& url, const SiteForCookies& site_for_cookies, - const base::Optional& top_frame_origin) const; + const absl::optional& top_frame_origin) const; bool CancelURLRequestWithPolicyViolatingReferrerHeader( const URLRequest& request, @@ -171,7 +171,7 @@ class NET_EXPORT NetworkDelegate { const HttpResponseHeaders* original_response_headers, scoped_refptr* override_response_headers, const IPEndPoint& remote_endpoint, - base::Optional* preserve_fragment_on_redirect_url) = 0; + absl::optional* preserve_fragment_on_redirect_url) = 0; // Called right after a redirect response code was received. |new_location| is // only valid for the duration of the call. @@ -223,7 +223,7 @@ class NET_EXPORT NetworkDelegate { virtual bool OnForcePrivacyMode( const GURL& url, const SiteForCookies& site_for_cookies, - const base::Optional& top_frame_origin) const = 0; + const absl::optional& top_frame_origin) const = 0; // Called when the |referrer_url| for requesting |target_url| during handling // of the |request| is does not comply with the referrer policy (e.g. a diff --git a/net/base/network_delegate_impl.cc b/net/base/network_delegate_impl.cc index b944aae5f8dcb8..fedbd3c892addd 100644 --- a/net/base/network_delegate_impl.cc +++ b/net/base/network_delegate_impl.cc @@ -27,7 +27,7 @@ int NetworkDelegateImpl::OnHeadersReceived( const HttpResponseHeaders* original_response_headers, scoped_refptr* override_response_headers, const IPEndPoint& endpoint, - base::Optional* preserve_fragment_on_redirect_url) { + absl::optional* preserve_fragment_on_redirect_url) { return OK; } @@ -62,7 +62,7 @@ bool NetworkDelegateImpl::OnCanSetCookie(const URLRequest& request, bool NetworkDelegateImpl::OnForcePrivacyMode( const GURL& url, const SiteForCookies& site_for_cookies, - const base::Optional& top_frame_origin) const { + const absl::optional& top_frame_origin) const { return false; } diff --git a/net/base/network_delegate_impl.h b/net/base/network_delegate_impl.h index 5c33624ee828d7..4acc13af8e4a00 100644 --- a/net/base/network_delegate_impl.h +++ b/net/base/network_delegate_impl.h @@ -10,12 +10,12 @@ #include #include -#include "base/optional.h" #include "net/base/completion_once_callback.h" #include "net/base/net_export.h" #include "net/base/network_delegate.h" #include "net/cookies/canonical_cookie.h" #include "net/proxy_resolution/proxy_retry_info.h" +#include "third_party/abseil-cpp/absl/types/optional.h" class GURL; @@ -49,7 +49,7 @@ class NET_EXPORT NetworkDelegateImpl : public NetworkDelegate { const HttpResponseHeaders* original_response_headers, scoped_refptr* override_response_headers, const IPEndPoint& endpoint, - base::Optional* preserve_fragment_on_redirect_url) override; + absl::optional* preserve_fragment_on_redirect_url) override; void OnBeforeRedirect(URLRequest* request, const GURL& new_location) override; @@ -72,7 +72,7 @@ class NET_EXPORT NetworkDelegateImpl : public NetworkDelegate { bool OnForcePrivacyMode( const GURL& url, const SiteForCookies& site_for_cookies, - const base::Optional& top_frame_origin) const override; + const absl::optional& top_frame_origin) const override; bool OnCancelURLRequestWithPolicyViolatingReferrerHeader( const URLRequest& request, diff --git a/net/base/network_interfaces_fuchsia.cc b/net/base/network_interfaces_fuchsia.cc index 68f7de700d1f12..48db0c3566be35 100644 --- a/net/base/network_interfaces_fuchsia.cc +++ b/net/base/network_interfaces_fuchsia.cc @@ -32,11 +32,11 @@ IPAddress FuchsiaIpAddressToIPAddress(const fuchsia::net::IpAddress& address) { } // namespace // static -base::Optional InterfaceProperties::VerifyAndCreate( +absl::optional InterfaceProperties::VerifyAndCreate( fuchsia::net::interfaces::Properties properties) { if (!internal::VerifyCompleteInterfaceProperties(properties)) - return base::nullopt; - return base::make_optional(InterfaceProperties(std::move(properties))); + return absl::nullopt; + return absl::make_optional(InterfaceProperties(std::move(properties))); } InterfaceProperties::InterfaceProperties( @@ -168,7 +168,7 @@ bool VerifyCompleteInterfaceProperties( return true; } -base::Optional GetExistingInterfaces( +absl::optional GetExistingInterfaces( const fuchsia::net::interfaces::WatcherSyncPtr& watcher) { ExistingInterfaceProperties existing_interfaces; for (;;) { @@ -176,16 +176,16 @@ base::Optional GetExistingInterfaces( zx_status_t status = watcher->Watch(&event); if (status != ZX_OK) { ZX_LOG(ERROR, status) << "GetExistingInterfaces: Watch() failed"; - return base::nullopt; + return absl::nullopt; } switch (event.Which()) { case fuchsia::net::interfaces::Event::Tag::kExisting: { - base::Optional interface = + absl::optional interface = InterfaceProperties::VerifyAndCreate(std::move(event.existing())); if (!interface) { LOG(ERROR) << "GetExistingInterfaces: Invalid kExisting event."; - return base::nullopt; + return absl::nullopt; } uint64_t id = interface->id(); existing_interfaces.emplace_back(id, std::move(*interface)); @@ -197,7 +197,7 @@ base::Optional GetExistingInterfaces( return existing_interfaces; default: LOG(ERROR) << "GetExistingInterfaces: Unexpected event received."; - return base::nullopt; + return absl::nullopt; } } } @@ -212,7 +212,7 @@ bool GetNetworkList(NetworkInterfaceList* networks, int policy) { // TODO(crbug.com/1131238): Use NetworkChangeNotifier's cached interface // list. - base::Optional existing_interfaces = + absl::optional existing_interfaces = internal::GetExistingInterfaces(watcher); if (!existing_interfaces) return false; diff --git a/net/base/network_interfaces_fuchsia.h b/net/base/network_interfaces_fuchsia.h index 38ced901d75032..eb95adcd765049 100644 --- a/net/base/network_interfaces_fuchsia.h +++ b/net/base/network_interfaces_fuchsia.h @@ -22,7 +22,7 @@ class InterfaceProperties final { public: // Creates an |InterfaceProperties| if |properties| are valid complete // properties as reported by |VerifyCompleteInterfaceProperties|. - static base::Optional VerifyAndCreate( + static absl::optional VerifyAndCreate( fuchsia::net::interfaces::Properties properties); InterfaceProperties(InterfaceProperties&& interface); InterfaceProperties& operator=(InterfaceProperties&& interface); @@ -76,9 +76,9 @@ bool VerifyCompleteInterfaceProperties( // Consumes events describing existing interfaces from |watcher| and // returns a vector of interface Id & properties pairs. |watcher| must // be a newly-connected Watcher channel. -// Returns base::nullopt if any protocol error is encountered, e.g. +// Returns absl::nullopt if any protocol error is encountered, e.g. // |watcher| supplies an invalid event, or disconnects. -base::Optional GetExistingInterfaces( +absl::optional GetExistingInterfaces( const fuchsia::net::interfaces::WatcherSyncPtr& watcher); } // namespace internal diff --git a/net/base/network_isolation_key.cc b/net/base/network_isolation_key.cc index 58963cbfda0d9f..09528d96cd3fb4 100644 --- a/net/base/network_isolation_key.cc +++ b/net/base/network_isolation_key.cc @@ -15,7 +15,7 @@ namespace net { namespace { -std::string GetSiteDebugString(const base::Optional& site) { +std::string GetSiteDebugString(const absl::optional& site) { return site ? site->GetDebugString() : "null"; } @@ -87,9 +87,9 @@ std::string NetworkIsolationKey::ToString() const { if (IsOpaque()) { // This key is opaque but not transient. - base::Optional serialized_top_frame_site = + absl::optional serialized_top_frame_site = SerializeSiteWithNonce(top_frame_site_.value()); - base::Optional serialized_frame_site = + absl::optional serialized_frame_site = SerializeSiteWithNonce(frame_site_.value()); // SerializeSiteWithNonce() can't fail for valid origins, and only valid @@ -140,14 +140,14 @@ bool NetworkIsolationKey::ToValue(base::Value* out_value) const { if (IsTransient()) return false; - base::Optional top_frame_value = + absl::optional top_frame_value = SerializeSiteWithNonce(*top_frame_site_); if (!top_frame_value) return false; *out_value = base::Value(base::Value::Type::LIST); out_value->Append(std::move(*top_frame_value)); - base::Optional frame_value = + absl::optional frame_value = SerializeSiteWithNonce(*frame_site_); if (!frame_value) return false; @@ -171,7 +171,7 @@ bool NetworkIsolationKey::FromValue( if (list.size() != 2 || !list[0].is_string() || !list[1].is_string()) return false; - base::Optional top_frame_site = + absl::optional top_frame_site = SchemefulSite::DeserializeWithNonce(list[0].GetString()); if (!top_frame_site) return false; @@ -181,7 +181,7 @@ bool NetworkIsolationKey::FromValue( // |opaque_and_non_transient_| must be true. bool opaque_and_non_transient = top_frame_site->opaque(); - base::Optional frame_site = + absl::optional frame_site = SchemefulSite::DeserializeWithNonce(list[1].GetString()); if (!frame_site) return false; @@ -212,7 +212,7 @@ bool NetworkIsolationKey::IsOpaque() const { return top_frame_site_->opaque() || frame_site_->opaque(); } -base::Optional NetworkIsolationKey::SerializeSiteWithNonce( +absl::optional NetworkIsolationKey::SerializeSiteWithNonce( const SchemefulSite& site) { return *(const_cast(site).SerializeWithNonce()); } diff --git a/net/base/network_isolation_key.h b/net/base/network_isolation_key.h index af67c7979fdd3c..855746ee61635c 100644 --- a/net/base/network_isolation_key.h +++ b/net/base/network_isolation_key.h @@ -9,10 +9,10 @@ #include "base/gtest_prod_util.h" #include "base/macros.h" -#include "base/optional.h" #include "base/values.h" #include "net/base/net_export.h" #include "net/base/schemeful_site.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace network { namespace mojom { @@ -138,10 +138,10 @@ class NET_EXPORT NetworkIsolationKey { // Getters for the top frame and frame sites. These accessors are primarily // intended for IPC calls, and to be able to create an IsolationInfo from a // NetworkIsolationKey. - const base::Optional& GetTopFrameSite() const { + const absl::optional& GetTopFrameSite() const { return top_frame_site_; } - const base::Optional& GetFrameSite() const { + const absl::optional& GetFrameSite() const { return frame_site_; } @@ -175,7 +175,7 @@ class NET_EXPORT NetworkIsolationKey { // SchemefulSite::Serialize() is not const, as it may initialize the nonce. // Need this to call it on a const |site|. - static base::Optional SerializeSiteWithNonce( + static absl::optional SerializeSiteWithNonce( const SchemefulSite& site); // Whether opaque origins cause the key to be transient. Always false, unless @@ -183,10 +183,10 @@ class NET_EXPORT NetworkIsolationKey { bool opaque_and_non_transient_ = false; // The origin/etld+1 of the top frame of the page making the request. - base::Optional top_frame_site_; + absl::optional top_frame_site_; // The origin/etld+1 of the frame that initiates the request. - base::Optional frame_site_; + absl::optional frame_site_; }; } // namespace net diff --git a/net/base/registry_controlled_domains/registry_controlled_domain.cc b/net/base/registry_controlled_domains/registry_controlled_domain.cc index 6bd1d460f9731c..ee783ac86ee752 100644 --- a/net/base/registry_controlled_domains/registry_controlled_domain.cc +++ b/net/base/registry_controlled_domains/registry_controlled_domain.cc @@ -380,7 +380,7 @@ bool SameDomainOrHost(const url::Origin& origin1, } bool SameDomainOrHost(const url::Origin& origin1, - const base::Optional& origin2, + const absl::optional& origin2, PrivateRegistryFilter filter) { return origin2.has_value() && SameDomainOrHost(origin1, origin2.value(), filter); diff --git a/net/base/registry_controlled_domains/registry_controlled_domain.h b/net/base/registry_controlled_domains/registry_controlled_domain.h index 998819ca878228..be82a1a3386188 100644 --- a/net/base/registry_controlled_domains/registry_controlled_domain.h +++ b/net/base/registry_controlled_domains/registry_controlled_domain.h @@ -117,9 +117,9 @@ #include -#include "base/optional.h" #include "base/strings/string_piece.h" #include "net/base/net_export.h" +#include "third_party/abseil-cpp/absl/types/optional.h" class GURL; @@ -208,7 +208,7 @@ NET_EXPORT bool SameDomainOrHost(const url::Origin& origin1, PrivateRegistryFilter filter); // Note: this returns false if |origin2| is not set. NET_EXPORT bool SameDomainOrHost(const url::Origin& origin1, - const base::Optional& origin2, + const absl::optional& origin2, PrivateRegistryFilter filter); NET_EXPORT bool SameDomainOrHost(const GURL& gurl, const url::Origin& origin, diff --git a/net/base/schemeful_site.cc b/net/base/schemeful_site.cc index 5d7fb942e5af74..59067609bcdb72 100644 --- a/net/base/schemeful_site.cc +++ b/net/base/schemeful_site.cc @@ -112,11 +112,11 @@ bool SchemefulSite::FromWire(const url::Origin& site_as_origin, return true; } -base::Optional SchemefulSite::CreateIfHasRegisterableDomain( +absl::optional SchemefulSite::CreateIfHasRegisterableDomain( const url::Origin& origin) { ObtainASiteResult result = ObtainASite(origin); if (!result.used_registerable_domain) - return base::nullopt; + return absl::nullopt; return SchemefulSite(std::move(result)); } @@ -164,15 +164,15 @@ bool SchemefulSite::operator<(const SchemefulSite& other) const { } // static -base::Optional SchemefulSite::DeserializeWithNonce( +absl::optional SchemefulSite::DeserializeWithNonce( const std::string& value) { - base::Optional result = url::Origin::Deserialize(value); + absl::optional result = url::Origin::Deserialize(value); if (!result) - return base::nullopt; + return absl::nullopt; return SchemefulSite(result.value()); } -base::Optional SchemefulSite::SerializeWithNonce() { +absl::optional SchemefulSite::SerializeWithNonce() { return site_as_origin_.SerializeWithNonceAndInitIfNeeded(); } diff --git a/net/base/schemeful_site.h b/net/base/schemeful_site.h index 17ff10de036dd7..37f917e9b87405 100644 --- a/net/base/schemeful_site.h +++ b/net/base/schemeful_site.h @@ -9,8 +9,8 @@ #include #include "base/gtest_prod_util.h" -#include "base/optional.h" #include "net/base/net_export.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/origin.h" class GURL; @@ -76,7 +76,7 @@ class NET_EXPORT SchemefulSite { static bool FromWire(const url::Origin& site_as_origin, SchemefulSite* out); // Creates a SchemefulSite iff the passed-in origin has a registerable domain. - static base::Optional CreateIfHasRegisterableDomain( + static absl::optional CreateIfHasRegisterableDomain( const url::Origin&); // If the scheme is ws or wss, it is converted to http or https, respectively. @@ -158,13 +158,13 @@ class NET_EXPORT SchemefulSite { // Deserializes a string obtained from `SerializeWithNonce()` to a // `SchemefulSite`. Returns nullopt if the value was invalid in any way. - static base::Optional DeserializeWithNonce( + static absl::optional DeserializeWithNonce( const std::string& value); // Returns a serialized version of `site_as_origin_`. For an opaque // `site_as_origin_`, this serializes with the nonce. See // `url::origin::SerializeWithNonce()` for usage information. - base::Optional SerializeWithNonce(); + absl::optional SerializeWithNonce(); // Returns whether `this` and `other` share a host or registrable domain. // Should NOT be used to check equality or equivalence. This is only used diff --git a/net/base/schemeful_site_fuzzer.cc b/net/base/schemeful_site_fuzzer.cc index 0bf4709ee6a3ea..2e6cd2e6471983 100644 --- a/net/base/schemeful_site_fuzzer.cc +++ b/net/base/schemeful_site_fuzzer.cc @@ -8,10 +8,10 @@ #include #include -#include "base/optional.h" #include "testing/libfuzzer/proto/lpm_interface.h" #include "testing/libfuzzer/proto/url.pb.h" #include "testing/libfuzzer/proto/url_proto_converter.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/origin.h" @@ -31,7 +31,7 @@ DEFINE_PROTO_FUZZER(const url_proto::Url& url_message) { net::SchemefulSite site(origin); - base::Optional site_with_registrable_domain = + absl::optional site_with_registrable_domain = net::SchemefulSite::CreateIfHasRegisterableDomain(origin); if (site_with_registrable_domain) { diff --git a/net/base/schemeful_site_unittest.cc b/net/base/schemeful_site_unittest.cc index f7f025c4216cc8..669dc147c1f924 100644 --- a/net/base/schemeful_site_unittest.cc +++ b/net/base/schemeful_site_unittest.cc @@ -160,7 +160,7 @@ TEST(SchemefulSiteTest, SchemeWithNetworkHost) { ASSERT_TRUE(IsStandardSchemeWithNetworkHost("network")); ASSERT_FALSE(IsStandardSchemeWithNetworkHost("non-network")); - base::Optional network_host_site = + absl::optional network_host_site = SchemefulSite::CreateIfHasRegisterableDomain( url::Origin::Create(GURL("network://site.example.test:1337"))); EXPECT_TRUE(network_host_site.has_value()); @@ -169,7 +169,7 @@ TEST(SchemefulSiteTest, SchemeWithNetworkHost) { EXPECT_EQ("example.test", network_host_site->GetInternalOriginForTesting().host()); - base::Optional non_network_host_site_null = + absl::optional non_network_host_site_null = SchemefulSite::CreateIfHasRegisterableDomain( url::Origin::Create(GURL("non-network://site.example.test"))); EXPECT_FALSE(non_network_host_site_null.has_value()); @@ -227,7 +227,7 @@ TEST(SchemefulSiteTest, SerializationConsistent) { SCOPED_TRACE(site.GetDebugString()); EXPECT_FALSE(site.GetInternalOriginForTesting().opaque()); - base::Optional deserialized_site = + absl::optional deserialized_site = SchemefulSite::Deserialize(site.Serialize()); EXPECT_TRUE(deserialized_site); EXPECT_EQ(site, deserialized_site); @@ -241,7 +241,7 @@ TEST(SchemefulSiteTest, OpaqueSerialization) { SchemefulSite(GURL("data:text/html,Hello World"))}; for (auto& site : kTestSites) { - base::Optional deserialized_site = + absl::optional deserialized_site = SchemefulSite::DeserializeWithNonce(*site.SerializeWithNonce()); EXPECT_TRUE(deserialized_site); EXPECT_EQ(site, *deserialized_site); @@ -294,7 +294,7 @@ TEST(SchemefulSiteTest, CreateIfHasRegisterableDomain) { }) { url::Origin origin = url::Origin::Create(GURL(site)); EXPECT_EQ(SchemefulSite::CreateIfHasRegisterableDomain(origin), - base::nullopt) + absl::nullopt) << "site = \"" << site << "\""; } } diff --git a/net/cert/cert_verify_proc_builtin_unittest.cc b/net/cert/cert_verify_proc_builtin_unittest.cc index 6ad2a40a84daa2..1861eb956c06d2 100644 --- a/net/cert/cert_verify_proc_builtin_unittest.cc +++ b/net/cert/cert_verify_proc_builtin_unittest.cc @@ -418,7 +418,7 @@ TEST_F(CertVerifyProcBuiltinTest, EVRevocationCheckDeadline) { ASSERT_NE(event, events.end()); EXPECT_EQ(net::NetLogEventPhase::BEGIN, event->phase); ASSERT_TRUE(event->params.is_dict()); - EXPECT_EQ(base::nullopt, event->params.FindBoolKey("is_ev_attempt")); + EXPECT_EQ(absl::nullopt, event->params.FindBoolKey("is_ev_attempt")); event = std::find_if(++event, events.end(), [](const auto& e) { return e.type == NetLogEventType::CERT_VERIFY_PROC_PATH_BUILT; diff --git a/net/cert/ct_log_response_parser_unittest.cc b/net/cert/ct_log_response_parser_unittest.cc index 4388e77bc534d3..d7c7e6c87c487f 100644 --- a/net/cert/ct_log_response_parser_unittest.cc +++ b/net/cert/ct_log_response_parser_unittest.cc @@ -21,7 +21,7 @@ namespace net { namespace ct { TEST(CTLogResponseParserTest, ParsesValidJsonSTH) { - base::Optional sample_sth_json = + absl::optional sample_sth_json = base::JSONReader::Read(GetSampleSTHAsJson()); SignedTreeHead tree_head; EXPECT_TRUE(FillSignedTreeHead(*sample_sth_json, &tree_head)); @@ -52,14 +52,14 @@ TEST(CTLogResponseParserTest, ParsesValidJsonSTH) { } TEST(CTLogResponseParserTest, FailsToParseMissingFields) { - base::Optional missing_signature_sth = base::JSONReader::Read( + absl::optional missing_signature_sth = base::JSONReader::Read( CreateSignedTreeHeadJsonString(1 /* tree_size */, 123456u /* timestamp */, GetSampleSTHSHA256RootHash(), "")); SignedTreeHead tree_head; ASSERT_FALSE(FillSignedTreeHead(*missing_signature_sth, &tree_head)); - base::Optional missing_root_hash_sth = base::JSONReader::Read( + absl::optional missing_root_hash_sth = base::JSONReader::Read( CreateSignedTreeHeadJsonString(1 /* tree_size */, 123456u /* timestamp */, "", GetSampleSTHTreeHeadSignature())); ASSERT_FALSE(FillSignedTreeHead(*missing_root_hash_sth, &tree_head)); @@ -72,7 +72,7 @@ TEST(CTLogResponseParserTest, FailsToParseIncorrectLengthRootHash) { base::Base64Decode( base::StringPiece("/WHFMgXtI/umKKuACJIN0Bb73TcILm9WkeU6qszvoArK\n"), &too_long_hash); - base::Optional too_long_hash_json = + absl::optional too_long_hash_json = base::JSONReader::Read(CreateSignedTreeHeadJsonString( 1 /* tree_size */, 123456u /* timestamp */, GetSampleSTHSHA256RootHash(), too_long_hash)); @@ -82,7 +82,7 @@ TEST(CTLogResponseParserTest, FailsToParseIncorrectLengthRootHash) { base::Base64Decode( base::StringPiece("/WHFMgXtI/umKKuACJIN0Bb73TcILm9WkeU6qszvoA==\n"), &too_short_hash); - base::Optional too_short_hash_json = + absl::optional too_short_hash_json = base::JSONReader::Read(CreateSignedTreeHeadJsonString( 1 /* tree_size */, 123456u /* timestamp */, GetSampleSTHSHA256RootHash(), too_short_hash)); @@ -92,7 +92,7 @@ TEST(CTLogResponseParserTest, FailsToParseIncorrectLengthRootHash) { TEST(CTLogResponseParserTest, ParsesJsonSTHWithLargeTimestamp) { SignedTreeHead tree_head; - base::Optional large_timestamp_json = + absl::optional large_timestamp_json = base::JSONReader::Read(CreateSignedTreeHeadJsonString( 100, INT64_C(1) << 34, GetSampleSTHSHA256RootHash(), GetSampleSTHTreeHeadSignature())); @@ -115,7 +115,7 @@ TEST(CTLogResponseParserTest, ParsesConsistencyProofSuccessfully) { raw_nodes.push_back(first); raw_nodes.push_back(second); raw_nodes.push_back(third); - base::Optional sample_consistency_proof = + absl::optional sample_consistency_proof = base::JSONReader::Read(CreateConsistencyProofJsonString(raw_nodes)); std::vector output; @@ -130,19 +130,19 @@ TEST(CTLogResponseParserTest, ParsesConsistencyProofSuccessfully) { TEST(CTLogResponseParserTest, FailsOnInvalidProofJson) { std::vector output; - base::Optional badly_encoded = + absl::optional badly_encoded = base::JSONReader::Read(std::string("{\"consistency\": [\"notbase64\"]}")); EXPECT_FALSE(FillConsistencyProof(*badly_encoded, &output)); - base::Optional not_a_string = + absl::optional not_a_string = base::JSONReader::Read(std::string("{\"consistency\": [42, 16]}")); EXPECT_FALSE(FillConsistencyProof(*badly_encoded, &output)); - base::Optional missing_consistency = + absl::optional missing_consistency = base::JSONReader::Read(std::string("{}")); EXPECT_FALSE(FillConsistencyProof(*missing_consistency, &output)); - base::Optional not_a_dict = + absl::optional not_a_dict = base::JSONReader::Read(std::string("[]")); EXPECT_FALSE(FillConsistencyProof(*not_a_dict, &output)); } @@ -150,7 +150,7 @@ TEST(CTLogResponseParserTest, FailsOnInvalidProofJson) { TEST(CTLogResponseParserTest, ParsesProofJsonWithExtraFields) { std::vector output; - base::Optional badly_encoded = base::JSONReader::Read( + absl::optional badly_encoded = base::JSONReader::Read( std::string("{\"consistency\": [], \"somethingelse\": 3}")); EXPECT_TRUE(FillConsistencyProof(*badly_encoded, &output)); } diff --git a/net/cert/internal/crl.cc b/net/cert/internal/crl.cc index 1e580ad7678865..4da8000facb685 100644 --- a/net/cert/internal/crl.cc +++ b/net/cert/internal/crl.cc @@ -91,7 +91,7 @@ bool ParseCrlTbsCertList(const der::Input& tbs_tlv, ParsedCrlTbsCertList* out) { // version Version OPTIONAL, // -- if present, MUST be v2 - base::Optional version_der; + absl::optional version_der; if (!tbs_parser.ReadOptionalTag(der::kInteger, &version_der)) return false; if (version_der.has_value()) { @@ -132,7 +132,7 @@ bool ParseCrlTbsCertList(const der::Input& tbs_tlv, ParsedCrlTbsCertList* out) { return false; out->next_update = next_update_time; } else { - out->next_update = base::nullopt; + out->next_update = absl::nullopt; } // revokedCertificates SEQUENCE OF SEQUENCE { ... } OPTIONAL, @@ -146,7 +146,7 @@ bool ParseCrlTbsCertList(const der::Input& tbs_tlv, ParsedCrlTbsCertList* out) { return false; out->revoked_certificates_tlv = revoked_certificates_tlv; } else { - out->revoked_certificates_tlv = base::nullopt; + out->revoked_certificates_tlv = absl::nullopt; } // crlExtensions [0] EXPLICIT Extensions OPTIONAL @@ -190,7 +190,7 @@ bool ParseIssuingDistributionPoint( return false; // distributionPoint [0] DistributionPointName OPTIONAL, - base::Optional distribution_point; + absl::optional distribution_point; if (!idp_parser.ReadOptionalTag( der::kTagContextSpecific | der::kTagConstructed | 0, &distribution_point)) { @@ -202,7 +202,7 @@ bool ParseIssuingDistributionPoint( der::Parser dp_name_parser(*distribution_point); // fullName [0] GeneralNames, // nameRelativeToCRLIssuer [1] RelativeDistinguishedName } - base::Optional der_full_name; + absl::optional der_full_name; if (!dp_name_parser.ReadOptionalTag( der::kTagContextSpecific | der::kTagConstructed | 0, &der_full_name)) { @@ -227,7 +227,7 @@ bool ParseIssuingDistributionPoint( *out_only_contains_cert_type = ContainedCertsType::ANY_CERTS; // onlyContainsUserCerts [1] BOOLEAN DEFAULT FALSE, - base::Optional only_contains_user_certs; + absl::optional only_contains_user_certs; if (!idp_parser.ReadOptionalTag(der::kTagContextSpecific | 1, &only_contains_user_certs)) { return false; @@ -242,7 +242,7 @@ bool ParseIssuingDistributionPoint( } // onlyContainsCACerts [2] BOOLEAN DEFAULT FALSE, - base::Optional only_contains_ca_certs; + absl::optional only_contains_ca_certs; if (!idp_parser.ReadOptionalTag(der::kTagContextSpecific | 2, &only_contains_ca_certs)) { return false; @@ -275,7 +275,7 @@ bool ParseIssuingDistributionPoint( CRLRevocationStatus GetCRLStatusForCert( const der::Input& cert_serial, CrlVersion crl_version, - const base::Optional& revoked_certificates_tlv) { + const absl::optional& revoked_certificates_tlv) { if (!revoked_certificates_tlv.has_value()) { // RFC 5280 Section 5.1.2.6: "When there are no revoked certificates, the // revoked certificates list MUST be absent." diff --git a/net/cert/internal/crl.h b/net/cert/internal/crl.h index a61b2156fafa51..bd3dd9d04e8009 100644 --- a/net/cert/internal/crl.h +++ b/net/cert/internal/crl.h @@ -5,7 +5,6 @@ #ifndef NET_CERT_INTERNAL_CRL_H_ #define NET_CERT_INTERNAL_CRL_H_ -#include "base/optional.h" #include "base/strings/string_piece_forward.h" #include "base/time/time.h" #include "net/base/net_export.h" @@ -13,6 +12,7 @@ #include "net/cert/internal/parsed_certificate.h" #include "net/der/input.h" #include "net/der/parse_values.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -122,7 +122,7 @@ struct NET_EXPORT_PRIVATE ParsedCrlTbsCertList { // values. For instance notAfter could be before notBefore, or the dates // could indicate an expired CRL. der::GeneralizedTime this_update; - base::Optional next_update; + absl::optional next_update; // revokedCertificates SEQUENCE OF SEQUENCE { // userCertificate CertificateSerialNumber, @@ -133,7 +133,7 @@ struct NET_EXPORT_PRIVATE ParsedCrlTbsCertList { // // This contains the full (unverified) Tag-Length-Value for a SEQUENCE. No // guarantees are made regarding the value of this SEQUENCE. - base::Optional revoked_certificates_tlv; + absl::optional revoked_certificates_tlv; // crlExtensions [0] EXPLICIT Extensions OPTIONAL // -- if present, version MUST be v2 @@ -143,7 +143,7 @@ struct NET_EXPORT_PRIVATE ParsedCrlTbsCertList { // EXPLICIT outer tag is stripped.) // // Parsing guarantees that if extensions is present the version is v2. - base::Optional crl_extensions_tlv; + absl::optional crl_extensions_tlv; }; // Represents the IssuingDistributionPoint certificate type constraints: @@ -189,7 +189,7 @@ NET_EXPORT_PRIVATE bool ParseIssuingDistributionPoint( NET_EXPORT_PRIVATE CRLRevocationStatus GetCRLStatusForCert(const der::Input& cert_serial, CrlVersion crl_version, - const base::Optional& revoked_certificates_tlv); + const absl::optional& revoked_certificates_tlv); // Checks the revocation status of the certificate |cert| by using the // DER-encoded |raw_crl|. |cert| must already have passed certificate path diff --git a/net/cert/internal/crl_getcrlstatusforcert_fuzzer.cc b/net/cert/internal/crl_getcrlstatusforcert_fuzzer.cc index a02ad88cb56edf..56bb3bf05adfec 100644 --- a/net/cert/internal/crl_getcrlstatusforcert_fuzzer.cc +++ b/net/cert/internal/crl_getcrlstatusforcert_fuzzer.cc @@ -22,7 +22,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { reinterpret_cast(data_hash.data() + 2), serial_len); net::GetCRLStatusForCert(cert_serial, crl_version, - base::make_optional(input_der)); + absl::make_optional(input_der)); return 0; } diff --git a/net/cert/internal/parse_certificate.h b/net/cert/internal/parse_certificate.h index d865a43d2a2398..d0858b5f937416 100644 --- a/net/cert/internal/parse_certificate.h +++ b/net/cert/internal/parse_certificate.h @@ -12,10 +12,10 @@ #include #include "base/compiler_specific.h" -#include "base/optional.h" #include "net/base/net_export.h" #include "net/der/input.h" #include "net/der/parse_values.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -574,16 +574,16 @@ struct NET_EXPORT ParsedAuthorityKeyIdentifier { ParsedAuthorityKeyIdentifier& operator=(ParsedAuthorityKeyIdentifier&& other); // The keyIdentifier, which is an OCTET STRING. - base::Optional key_identifier; + absl::optional key_identifier; // The authorityCertIssuer, which should be a GeneralNames, but this is not // enforced by ParseAuthorityKeyIdentifier. - base::Optional authority_cert_issuer; + absl::optional authority_cert_issuer; // The DER authorityCertSerialNumber, which should be a // CertificateSerialNumber (an INTEGER) but this is not enforced by // ParseAuthorityKeyIdentifier. - base::Optional authority_cert_serial_number; + absl::optional authority_cert_serial_number; }; // Parses the value of an authorityKeyIdentifier extension. Returns true on diff --git a/net/cert/internal/parsed_certificate.cc b/net/cert/internal/parsed_certificate.cc index 4b27233f83d7d4..098d17a8db068d 100644 --- a/net/cert/internal/parsed_certificate.cc +++ b/net/cert/internal/parsed_certificate.cc @@ -295,7 +295,7 @@ scoped_refptr ParsedCertificate::CreateInternal( // Subject Key Identifier. if (result->GetExtension(SubjectKeyIdentifierOid(), &extension)) { - result->subject_key_identifier_ = base::make_optional(); + result->subject_key_identifier_ = absl::make_optional(); if (!ParseSubjectKeyIdentifier( extension.value, &result->subject_key_identifier_.value())) { errors->AddError(kFailedParsingSubjectKeyIdentifier); @@ -306,7 +306,7 @@ scoped_refptr ParsedCertificate::CreateInternal( // Authority Key Identifier. if (result->GetExtension(AuthorityKeyIdentifierOid(), &extension)) { result->authority_key_identifier_ = - base::make_optional(); + absl::make_optional(); if (!ParseAuthorityKeyIdentifier( extension.value, &result->authority_key_identifier_.value())) { errors->AddError(kFailedParsingAuthorityKeyIdentifier); diff --git a/net/cert/internal/parsed_certificate.h b/net/cert/internal/parsed_certificate.h index a5ad843e0015fd..23f88dacf08e85 100644 --- a/net/cert/internal/parsed_certificate.h +++ b/net/cert/internal/parsed_certificate.h @@ -231,14 +231,14 @@ class NET_EXPORT ParsedCertificate // Returns the AuthorityKeyIdentifier extension, or nullopt if there wasn't // one. - const base::Optional& authority_key_identifier() + const absl::optional& authority_key_identifier() const { return authority_key_identifier_; } // Returns the SubjectKeyIdentifier extension, or nullopt if there wasn't // one. - const base::Optional& subject_key_identifier() const { + const absl::optional& subject_key_identifier() const { return subject_key_identifier_; } @@ -331,10 +331,10 @@ class NET_EXPORT ParsedCertificate uint8_t inhibit_any_policy_; // AuthorityKeyIdentifier extension. - base::Optional authority_key_identifier_; + absl::optional authority_key_identifier_; // SubjectKeyIdentifier extension. - base::Optional subject_key_identifier_; + absl::optional subject_key_identifier_; // All of the extensions. ExtensionsMap extensions_; diff --git a/net/cert/internal/revocation_util.h b/net/cert/internal/revocation_util.h index 7e27c1592eb713..f39482c1a0e817 100644 --- a/net/cert/internal/revocation_util.h +++ b/net/cert/internal/revocation_util.h @@ -6,8 +6,8 @@ #define NET_CERT_INTERNAL_REVOCATION_UTIL_H_ #include "base/compiler_specific.h" -#include "base/optional.h" #include "net/base/net_export.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { class Time; diff --git a/net/cookies/canonical_cookie.cc b/net/cookies/canonical_cookie.cc index 8af2c1b14b443e..00c7a7ba8f312d 100644 --- a/net/cookies/canonical_cookie.cc +++ b/net/cookies/canonical_cookie.cc @@ -380,7 +380,7 @@ std::unique_ptr CanonicalCookie::Create( const GURL& url, const std::string& cookie_line, const base::Time& creation_time, - base::Optional server_time, + absl::optional server_time, CookieInclusionStatus* status) { // Put a pointer on the stack so the rest of the function can assign to it if // the default nullptr is passed in. @@ -1232,7 +1232,7 @@ bool CanonicalCookie::IsCookieSamePartyValid(bool is_same_party, CookieAndLineWithAccessResult::CookieAndLineWithAccessResult() = default; CookieAndLineWithAccessResult::CookieAndLineWithAccessResult( - base::Optional cookie, + absl::optional cookie, std::string cookie_string, CookieAccessResult access_result) : cookie(std::move(cookie)), diff --git a/net/cookies/canonical_cookie.h b/net/cookies/canonical_cookie.h index 38808e473f778e..f716ed3f17a551 100644 --- a/net/cookies/canonical_cookie.h +++ b/net/cookies/canonical_cookie.h @@ -11,13 +11,13 @@ #include #include "base/gtest_prod_util.h" -#include "base/optional.h" #include "base/time/time.h" #include "net/base/net_export.h" #include "net/cookies/cookie_access_result.h" #include "net/cookies/cookie_constants.h" #include "net/cookies/cookie_inclusion_status.h" #include "net/cookies/cookie_options.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/third_party/mozilla/url_parse.h" class GURL; @@ -84,7 +84,7 @@ class NET_EXPORT CanonicalCookie { const GURL& url, const std::string& cookie_line, const base::Time& creation_time, - base::Optional server_time, + absl::optional server_time, CookieInclusionStatus* status = nullptr); // Create a canonical cookie based on sanitizing the passed inputs in the @@ -449,7 +449,7 @@ class NET_EXPORT CanonicalCookie { // canonical cookie object may not be available. struct NET_EXPORT CookieAndLineWithAccessResult { CookieAndLineWithAccessResult(); - CookieAndLineWithAccessResult(base::Optional cookie, + CookieAndLineWithAccessResult(absl::optional cookie, std::string cookie_string, CookieAccessResult access_result); CookieAndLineWithAccessResult( @@ -463,7 +463,7 @@ struct NET_EXPORT CookieAndLineWithAccessResult { ~CookieAndLineWithAccessResult(); - base::Optional cookie; + absl::optional cookie; std::string cookie_string; CookieAccessResult access_result; }; diff --git a/net/cookies/canonical_cookie_unittest.cc b/net/cookies/canonical_cookie_unittest.cc index d42132030c8724..b21dada3ed90f0 100644 --- a/net/cookies/canonical_cookie_unittest.cc +++ b/net/cookies/canonical_cookie_unittest.cc @@ -4,7 +4,6 @@ #include "net/cookies/canonical_cookie.h" -#include "base/optional.h" #include "base/test/metrics/histogram_tester.h" #include "base/test/scoped_feature_list.h" #include "build/build_config.h" @@ -15,6 +14,7 @@ #include "testing/gmock/include/gmock/gmock-matchers.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/third_party/mozilla/url_parse.h" @@ -182,7 +182,7 @@ TEST(CanonicalCookieTest, Constructor) { TEST(CanonicalCookie, CreationCornerCases) { base::Time creation_time = base::Time::Now(); std::unique_ptr cookie; - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; // Space in name. cookie = CanonicalCookie::Create(GURL("http://www.example.com/test/foo.html"), @@ -216,7 +216,7 @@ TEST(CanonicalCookieTest, Create) { GURL url("http://www.example.com/test/foo.html"); GURL https_url("https://www.example.com/test/foo.html"); base::Time creation_time = base::Time::Now(); - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; std::unique_ptr cookie( CanonicalCookie::Create(url, "A=2", creation_time, server_time)); @@ -345,7 +345,7 @@ TEST(CanonicalCookieTest, CreateNonStandardSameSite) { GURL url("http://www.example.com/test/foo.html"); base::Time now = base::Time::Now(); std::unique_ptr cookie; - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; // Non-standard value for the SameSite attribute. cookie = CanonicalCookie::Create(url, "A=2; SameSite=NonStandard", now, @@ -363,7 +363,7 @@ TEST(CanonicalCookieTest, CreateSameSiteInCrossSiteContexts) { GURL url("http://www.example.com/test/foo.html"); base::Time now = base::Time::Now(); std::unique_ptr cookie; - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; // A cookie can be created from any SameSiteContext regardless of SameSite // value (it is upon setting the cookie that the SameSiteContext comes into @@ -382,7 +382,7 @@ TEST(CanonicalCookieTest, CreateSameSiteInCrossSiteContexts) { TEST(CanonicalCookieTest, CreateHttpOnly) { GURL url("http://www.example.com/test/foo.html"); base::Time now = base::Time::Now(); - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; CookieInclusionStatus status; // An HttpOnly cookie can be created. @@ -395,7 +395,7 @@ TEST(CanonicalCookieTest, CreateHttpOnly) { TEST(CanonicalCookieTest, CreateWithInvalidDomain) { GURL url("http://www.example.com/test/foo.html"); base::Time now = base::Time::Now(); - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; CookieInclusionStatus status; std::unique_ptr cookie = CanonicalCookie::Create( @@ -409,7 +409,7 @@ TEST(CanonicalCookieTest, CreateSameParty) { GURL url("http://www.example.com/test/foo.html"); GURL https_url("https://www.example.com/test/foo.html"); base::Time creation_time = base::Time::Now(); - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; CookieInclusionStatus status; std::unique_ptr cookie = CanonicalCookie::Create( @@ -455,7 +455,7 @@ TEST(CanonicalCookieTest, CreateSameParty) { TEST(CanonicalCookieTest, CreateWithMaxAge) { GURL url("http://www.example.com/test/foo.html"); base::Time creation_time = base::Time::Now(); - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; // Max-age with positive integer. std::unique_ptr cookie = CanonicalCookie::Create( @@ -538,7 +538,7 @@ TEST(CanonicalCookieTest, CreateWithMaxAge) { TEST(CanonicalCookieTest, EmptyExpiry) { GURL url("http://www7.ipdl.inpit.go.jp/Tokujitu/tjkta.ipdl?N0000=108"); base::Time creation_time = base::Time::Now(); - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; std::string cookie_line = "ACSTM=20130308043820420042; path=/; domain=ipdl.inpit.go.jp; Expires="; @@ -757,7 +757,7 @@ TEST(CanonicalCookieTest, IsEquivalentForSecureCookieMatching) { TEST(CanonicalCookieTest, IsDomainMatch) { GURL url("http://www.example.com/test/foo.html"); base::Time creation_time = base::Time::Now(); - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; std::unique_ptr cookie( CanonicalCookie::Create(url, "A=2", creation_time, server_time)); @@ -788,7 +788,7 @@ TEST(CanonicalCookieTest, IsDomainMatch) { TEST(CanonicalCookieTest, IsOnPath) { base::Time creation_time = base::Time::Now(); - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; std::unique_ptr cookie(CanonicalCookie::Create( GURL("http://www.example.com"), "A=2", creation_time, server_time)); @@ -947,7 +947,7 @@ TEST(CanonicalCookieTest, IncludeForRequestURL) { GURL url("http://www.example.com"); base::Time creation_time = base::Time::Now(); CookieOptions options = CookieOptions::MakeAllInclusive(); - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; std::unique_ptr cookie( CanonicalCookie::Create(url, "A=2", creation_time, server_time)); @@ -1136,7 +1136,7 @@ void VerifyIncludeForRequestURLTestCases( base::Time creation_time = base::Time::Now() - test.creation_time_delta; std::unique_ptr cookie = CanonicalCookie::Create( - url, test.cookie_line, creation_time, base::nullopt /* server_time */); + url, test.cookie_line, creation_time, absl::nullopt /* server_time */); EXPECT_EQ(test.expected_samesite, cookie->SameSite()); CookieOptions request_options; @@ -1521,7 +1521,7 @@ TEST(CanonicalCookieTest, IncludeForRequestURLSameSite) { TEST(CanonicalCookieTest, IncludeCookiesWithoutSameSiteMustBeSecure) { GURL url("https://www.example.com"); base::Time creation_time = base::Time::Now(); - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; CookieOptions options; std::unique_ptr cookie; @@ -1613,7 +1613,7 @@ TEST(CanonicalCookieTest, IncludeCookiesWithoutSameSiteMustBeSecure) { TEST(CanonicalCookieTest, IncludeForRequestURLSameParty) { GURL url("https://www.example.com"); base::Time creation_time = base::Time::Now(); - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; CookieOptions options; // SameSite is not specified. @@ -1683,7 +1683,7 @@ TEST(CanonicalCookieTest, IncludeForRequestURLSameParty) { TEST(CanonicalCookieTest, MultipleExclusionReasons) { GURL url("http://www.not-secure.com/foo"); base::Time creation_time = base::Time::Now(); - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; CookieOptions options; options.set_exclude_httponly(); options.set_same_site_cookie_context(CookieOptions::SameSiteCookieContext( @@ -1743,7 +1743,7 @@ TEST(CanonicalCookieTest, MultipleExclusionReasons) { TEST(CanonicalCookieTest, PartialCompare) { GURL url("http://www.example.com"); base::Time creation_time = base::Time::Now(); - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; std::unique_ptr cookie( CanonicalCookie::Create(url, "a=b", creation_time, server_time)); std::unique_ptr cookie_different_path( @@ -1772,7 +1772,7 @@ TEST(CanonicalCookieTest, SecureCookiePrefix) { GURL https_url("https://www.example.test"); GURL http_url("http://www.example.test"); base::Time creation_time = base::Time::Now(); - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; CookieInclusionStatus status; // A __Secure- cookie must be Secure. @@ -1807,7 +1807,7 @@ TEST(CanonicalCookieTest, HostCookiePrefix) { GURL https_url("https://www.example.test"); GURL http_url("http://www.example.test"); base::Time creation_time = base::Time::Now(); - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; std::string domain = https_url.host(); CookieInclusionStatus status; @@ -1883,7 +1883,7 @@ TEST(CanonicalCookieTest, CanCreateSecureCookiesFromAnyScheme) { GURL http_url("http://www.example.com"); GURL https_url("https://www.example.com"); base::Time creation_time = base::Time::Now(); - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; std::unique_ptr http_cookie_no_secure( CanonicalCookie::Create(http_url, "a=b", creation_time, server_time)); @@ -2193,7 +2193,7 @@ TEST(CanonicalCookieTest, TestPrefixHistograms) { const char kCookiePrefixBlockedHistogram[] = "Cookie.CookiePrefixBlocked"; GURL https_url("https://www.example.test"); base::Time creation_time = base::Time::Now(); - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; EXPECT_FALSE(CanonicalCookie::Create(https_url, "__Host-A=B;", creation_time, server_time)); @@ -2241,7 +2241,7 @@ TEST(CanonicalCookieTest, BuildCookieLine) { std::vector> cookies; GURL url("https://example.com/"); base::Time now = base::Time::Now(); - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; MatchCookieLineToVector("", cookies); cookies.push_back(CanonicalCookie::Create(url, "A=B", now, server_time)); diff --git a/net/cookies/cookie_access_delegate.h b/net/cookies/cookie_access_delegate.h index b715f6ffaca455..70f8b488b3b6aa 100644 --- a/net/cookies/cookie_access_delegate.h +++ b/net/cookies/cookie_access_delegate.h @@ -43,7 +43,7 @@ class NET_EXPORT CookieAccessDelegate { // checked only against `party_context`. virtual bool IsContextSamePartyWithSite( const net::SchemefulSite& site, - const base::Optional& top_frame_site, + const absl::optional& top_frame_site, const std::set& party_context) const = 0; // Returns whether `site` belongs to a non-singleton First-Party Set. @@ -52,7 +52,7 @@ class NET_EXPORT CookieAccessDelegate { virtual FirstPartySetsContextType ComputeFirstPartySetsContextType( const SchemefulSite& site, - const base::Optional& top_frame_site, + const absl::optional& top_frame_site, const std::set& party_context) const = 0; // Returns the First-Party Sets. diff --git a/net/cookies/cookie_deletion_info.h b/net/cookies/cookie_deletion_info.h index 13865421490472..30c46a63cd8042 100644 --- a/net/cookies/cookie_deletion_info.h +++ b/net/cookies/cookie_deletion_info.h @@ -8,10 +8,10 @@ #include #include -#include "base/optional.h" #include "base/time/time.h" #include "net/cookies/canonical_cookie.h" #include "net/cookies/cookie_constants.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -110,14 +110,14 @@ struct NET_EXPORT CookieDeletionInfo { SessionControl session_control = SessionControl::IGNORE_CONTROL; // If has a value then cookie.Host() must equal |host|. - base::Optional host; + absl::optional host; // If has a value then cookie.Name() must equal |name|. - base::Optional name; + absl::optional name; // If has a value then will match if the cookie being evaluated would be // included for a request of |url|. - base::Optional url; + absl::optional url; // If this is not empty then any cookie with a domain/ip contained in this // will be deleted (assuming other fields match). @@ -138,7 +138,7 @@ struct NET_EXPORT CookieDeletionInfo { std::set domains_and_ips_to_ignore; // Used only for testing purposes. - base::Optional value_for_testing; + absl::optional value_for_testing; }; } // namespace net diff --git a/net/cookies/cookie_deletion_info_unittest.cc b/net/cookies/cookie_deletion_info_unittest.cc index 164dfffadfb685..75686868906388 100644 --- a/net/cookies/cookie_deletion_info_unittest.cc +++ b/net/cookies/cookie_deletion_info_unittest.cc @@ -509,7 +509,7 @@ TEST(CookieDeletionInfoTest, MatchesWithCookieAccessSemantics) { // Cookie with unspecified SameSite. auto cookie = CanonicalCookie::Create(GURL("https://www.example.com"), "cookie=1", - base::Time::Now(), base::nullopt); + base::Time::Now(), absl::nullopt); { // With SameSite features off. diff --git a/net/cookies/cookie_monster.h b/net/cookies/cookie_monster.h index 95029cb503f1a7..ef391b3cb94f14 100644 --- a/net/cookies/cookie_monster.h +++ b/net/cookies/cookie_monster.h @@ -23,7 +23,6 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "base/strings/string_piece.h" #include "base/threading/thread_checker.h" #include "base/time/time.h" @@ -35,6 +34,7 @@ #include "net/cookies/cookie_monster_change_dispatcher.h" #include "net/cookies/cookie_store.h" #include "net/log/net_log_with_source.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace net { diff --git a/net/cookies/cookie_monster_perftest.cc b/net/cookies/cookie_monster_perftest.cc index 10c79a1f191a97..c8ff8b5c826f98 100644 --- a/net/cookies/cookie_monster_perftest.cc +++ b/net/cookies/cookie_monster_perftest.cc @@ -7,7 +7,6 @@ #include "base/bind.h" #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "base/run_loop.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" @@ -21,6 +20,7 @@ #include "net/cookies/parsed_cookie.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/perf/perf_result_reporter.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace net { @@ -96,7 +96,7 @@ class SetCookieCallback : public CookieTestCallback { const GURL& gurl, const std::string& cookie_line) { auto cookie = CanonicalCookie::Create(gurl, cookie_line, base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); cm->SetCanonicalCookieAsync( std::move(cookie), gurl, options_, base::BindOnce(&SetCookieCallback::Run, base::Unretained(this))); diff --git a/net/cookies/cookie_monster_unittest.cc b/net/cookies/cookie_monster_unittest.cc index f96ccd762c6c44..4c7ed97862c3db 100644 --- a/net/cookies/cookie_monster_unittest.cc +++ b/net/cookies/cookie_monster_unittest.cc @@ -18,7 +18,6 @@ #include "base/memory/ref_counted.h" #include "base/metrics/histogram.h" #include "base/metrics/histogram_samples.h" -#include "base/optional.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/strings/strcat.h" @@ -55,6 +54,7 @@ #include "testing/gmock/include/gmock/gmock-matchers.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/third_party/mozilla/url_parse.h" #include "url/url_constants.h" @@ -173,7 +173,7 @@ class CookieMonsterTestBase : public CookieStoreTest { ResultSavingCookieCallback callback; cm->SetCanonicalCookieAsync( CanonicalCookie::Create(url, cookie_line, creation_time, - base::nullopt /* server_time */), + absl::nullopt /* server_time */), url, CookieOptions::MakeAllInclusive(), callback.MakeCallback()); callback.WaitUntilDone(); return callback.result().status.IsInclude(); @@ -1038,7 +1038,7 @@ TEST_F(DeferredCookieTaskTest, DeferredSetCookie) { ResultSavingCookieCallback call1; cookie_monster_->SetCanonicalCookieAsync( CanonicalCookie::Create(http_www_foo_.url(), "A=B", base::Time::Now(), - base::nullopt /* server_time */), + absl::nullopt /* server_time */), http_www_foo_.url(), CookieOptions::MakeAllInclusive(), call1.MakeCallback()); base::RunLoop().RunUntilIdle(); @@ -1052,7 +1052,7 @@ TEST_F(DeferredCookieTaskTest, DeferredSetCookie) { ResultSavingCookieCallback call2; cookie_monster_->SetCanonicalCookieAsync( CanonicalCookie::Create(http_www_foo_.url(), "X=Y", base::Time::Now(), - base::nullopt /* server_time */), + absl::nullopt /* server_time */), http_www_foo_.url(), CookieOptions::MakeAllInclusive(), call2.MakeCallback()); ASSERT_TRUE(call2.was_run()); @@ -1337,7 +1337,7 @@ TEST_F(DeferredCookieTaskTest, DeferredTaskOrder) { cookie_monster_->SetCanonicalCookieAsync( CanonicalCookie::Create(http_www_foo_.url(), "A=B", base::Time::Now(), - base::nullopt /* server_time */), + absl::nullopt /* server_time */), http_www_foo_.url(), CookieOptions::MakeAllInclusive(), set_cookies_callback.MakeCallback()); @@ -1620,7 +1620,7 @@ TEST_F(CookieMonsterTest, SetCookieableSchemes) { GURL http_url("http://host/path"); base::Time now = base::Time::Now(); - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; EXPECT_TRUE( CreateAndSetCookieReturnStatus(cm.get(), http_url, "x=1").IsInclude()); EXPECT_TRUE(SetCanonicalCookieReturnAccessResult( @@ -2367,7 +2367,7 @@ TEST_F(CookieMonsterTest, WhileLoadingLoadCompletesBeforeKeyLoadCompletes) { std::unique_ptr cm(new CookieMonster(store.get(), &net_log_)); auto cookie = CanonicalCookie::Create(kUrl, "a=b", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); ResultSavingCookieCallback set_cookie_callback; cm->SetCanonicalCookieAsync(std::move(cookie), kUrl, CookieOptions::MakeAllInclusive(), @@ -2429,7 +2429,7 @@ TEST_F(CookieMonsterTest, WhileLoadingDeleteAllGetForURL) { // When passed to the CookieMonster, it takes ownership of the pointed to // cookies. cookies.push_back(CanonicalCookie::Create(kUrl, "a=b", base::Time::Now(), - base::nullopt /* server_time */)); + absl::nullopt /* server_time */)); ASSERT_TRUE(cookies[0]); store->TakeCallbackAt(0).Run(std::move(cookies)); @@ -2455,7 +2455,7 @@ TEST_F(CookieMonsterTest, WhileLoadingGetAllSetGetAll) { cm->GetAllCookiesAsync(get_cookies_callback1.MakeCallback()); auto cookie = CanonicalCookie::Create(kUrl, "a=b", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); ResultSavingCookieCallback set_cookie_callback; cm->SetCanonicalCookieAsync(std::move(cookie), kUrl, CookieOptions::MakeAllInclusive(), @@ -2502,7 +2502,7 @@ TEST_F(CookieMonsterTest, CheckOrderOfCookieTaskQueueWhenLoadingCompletes) { // Get all cookies task that queues a task to set a cookie when executed. auto cookie = CanonicalCookie::Create(kUrl, "a=b", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); ResultSavingCookieCallback set_cookie_callback; cm->GetAllCookiesAsync(base::BindOnce( &RunClosureOnAllCookiesReceived, @@ -2715,7 +2715,7 @@ TEST_F(CookieMonsterTest, InvalidExpiryTime) { std::string(kValidCookieLine) + "; expires=Blarg arg arg"; std::unique_ptr cookie( CanonicalCookie::Create(http_www_foo_.url(), cookie_line, Time::Now(), - base::nullopt /* server_time */)); + absl::nullopt /* server_time */)); ASSERT_FALSE(cookie->IsPersistent()); } @@ -2918,16 +2918,16 @@ TEST_F(CookieMonsterTest, NumKeysHistogram) { scoped_refptr store(new MockPersistentCookieStore); std::vector> initial_cookies; initial_cookies.push_back(CanonicalCookie::Create( - GURL("http://domain1.test"), "A=1", base::Time::Now(), base::nullopt)); + GURL("http://domain1.test"), "A=1", base::Time::Now(), absl::nullopt)); initial_cookies.push_back(CanonicalCookie::Create( - GURL("http://domain2.test"), "A=1", base::Time::Now(), base::nullopt)); + GURL("http://domain2.test"), "A=1", base::Time::Now(), absl::nullopt)); initial_cookies.push_back( CanonicalCookie::Create(GURL("http://sub.domain2.test"), "A=1", - base::Time::Now(), base::nullopt)); + base::Time::Now(), absl::nullopt)); initial_cookies.push_back(CanonicalCookie::Create( - GURL("http://domain3.test"), "A=1", base::Time::Now(), base::nullopt)); + GURL("http://domain3.test"), "A=1", base::Time::Now(), absl::nullopt)); initial_cookies.push_back(CanonicalCookie::Create( - GURL("http://domain3.test"), "B=1", base::Time::Now(), base::nullopt)); + GURL("http://domain3.test"), "B=1", base::Time::Now(), absl::nullopt)); store->SetLoadExpectation(true /* return_value */, std::move(initial_cookies)); auto cm = std::make_unique(store.get(), &net_log_); @@ -3011,7 +3011,7 @@ TEST_F(CookieMonsterTest, SecureCookieLocalhost) { { auto cookie = CanonicalCookie::Create(insecure_localhost, "from_insecure_localhost=1; Secure", - base::Time::Now(), base::nullopt); + base::Time::Now(), absl::nullopt); ASSERT_TRUE(cookie); CookieInclusionStatus status = SetCanonicalCookieReturnAccessResult(cm.get(), std::move(cookie), @@ -3027,7 +3027,7 @@ TEST_F(CookieMonsterTest, SecureCookieLocalhost) { { auto cookie = CanonicalCookie::Create(insecure_localhost, "from_secure_localhost=1; Secure", - base::Time::Now(), base::nullopt); + base::Time::Now(), absl::nullopt); ASSERT_TRUE(cookie); CookieInclusionStatus status = SetCanonicalCookieReturnAccessResult(cm.get(), std::move(cookie), @@ -3078,7 +3078,7 @@ TEST_F(CookieMonsterTest, MaybeDeleteEquivalentCookieAndUpdateStatus) { // Set a secure, httponly cookie from a secure origin auto preexisting_cookie = CanonicalCookie::Create( https_www_foo_.url(), "A=B;Secure;HttpOnly", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); CookieAccessResult access_result = SetCanonicalCookieReturnAccessResult( cm.get(), std::move(preexisting_cookie), https_www_foo_.url(), true /* can_modify_httponly */); @@ -3096,7 +3096,7 @@ TEST_F(CookieMonsterTest, MaybeDeleteEquivalentCookieAndUpdateStatus) { // equivalent to the pre-existing Secure cookie. auto bad_cookie = CanonicalCookie::Create(http_www_foo_.url(), "A=D", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); // Allow modifying HttpOnly, so that we don't skip preexisting cookies for // being HttpOnly. access_result = SetCanonicalCookieReturnAccessResult( @@ -3127,7 +3127,7 @@ TEST_F(CookieMonsterTest, MaybeDeleteEquivalentCookieAndUpdateStatus) { // trying to shadow a secure cookie. bad_cookie = CanonicalCookie::Create( http_www_foo_.url(), "A=E; path=/some/path", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); // Allow modifying HttpOnly, so that we don't skip preexisting cookies for // being HttpOnly. access_result = SetCanonicalCookieReturnAccessResult( @@ -3157,7 +3157,7 @@ TEST_F(CookieMonsterTest, MaybeDeleteEquivalentCookieAndUpdateStatus) { // Test skipping equivalent cookie for HttpOnly only. bad_cookie = CanonicalCookie::Create(https_www_foo_.url(), "A=E; Secure", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); access_result = SetCanonicalCookieReturnAccessResult( cm.get(), std::move(bad_cookie), https_www_foo_.url(), false /* can_modify_httponly */); @@ -3181,7 +3181,7 @@ TEST_F(CookieMonsterTest, SkipDontOverwriteForMultipleReasons) { // Set a secure, httponly cookie from a secure origin auto preexisting_cookie = CanonicalCookie::Create( https_www_foo_.url(), "A=B;Secure;HttpOnly", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); CookieAccessResult access_result = SetCanonicalCookieReturnAccessResult( cm.get(), std::move(preexisting_cookie), https_www_foo_.url(), true /* can_modify_httponly */); @@ -3191,7 +3191,7 @@ TEST_F(CookieMonsterTest, SkipDontOverwriteForMultipleReasons) { // Httponly from an insecure scheme. auto cookie = CanonicalCookie::Create(http_www_foo_.url(), "A=B", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); access_result = SetCanonicalCookieReturnAccessResult( cm.get(), std::move(cookie), http_www_foo_.url(), false /* can_modify_httponly */); @@ -3216,7 +3216,7 @@ TEST_F(CookieMonsterTest, DontDeleteEquivalentCookieIfSetIsRejected) { auto preexisting_cookie = CanonicalCookie::Create( http_www_foo_.url(), "cookie=foo", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); CookieAccessResult access_result = SetCanonicalCookieReturnAccessResult( cm.get(), std::move(preexisting_cookie), http_www_foo_.url(), false /* can_modify_httponly */); @@ -3224,7 +3224,7 @@ TEST_F(CookieMonsterTest, DontDeleteEquivalentCookieIfSetIsRejected) { auto bad_cookie = CanonicalCookie::Create( http_www_foo_.url(), "cookie=bar;secure", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); CookieAccessResult access_result2 = SetCanonicalCookieReturnAccessResult( cm.get(), std::move(bad_cookie), http_www_foo_.url(), false /* can_modify_httponly */); @@ -3891,7 +3891,7 @@ TEST_F(CookieMonsterTest, SetCanonicalCookieDoesNotBlockForLoadAll) { GURL cookie_url("http://a.com/"); cm.SetCanonicalCookieAsync( CanonicalCookie::Create(cookie_url, "A=B", base::Time::Now(), - base::nullopt /* server_time */), + absl::nullopt /* server_time */), cookie_url, CookieOptions::MakeAllInclusive(), callback_set.MakeCallback()); @@ -3968,7 +3968,7 @@ TEST_F(CookieMonsterTest, DeleteCookieWithInheritedTimestamps) { GURL url("http://www.example.com"); std::string cookie_line = "foo=bar"; CookieOptions options = CookieOptions::MakeAllInclusive(); - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; CookieMonster cm(nullptr, nullptr); // Write a cookie created at |t1|. @@ -4008,7 +4008,7 @@ TEST_F(CookieMonsterTest, RejectCreatedSameSiteCookieOnSet) { // Cookie can be created successfully; SameSite is not checked on Creation. auto cookie = CanonicalCookie::Create(url, cookie_line, base::Time::Now(), - base::nullopt /* server_time */, &status); + absl::nullopt /* server_time */, &status); ASSERT_TRUE(cookie != nullptr); ASSERT_TRUE(status.IsInclude()); @@ -4031,7 +4031,7 @@ TEST_F(CookieMonsterTest, RejectCreatedSecureCookieOnSet) { // on Create. auto cookie = CanonicalCookie::Create(http_url, cookie_line, base::Time::Now(), - base::nullopt /* server_time */, &status); + absl::nullopt /* server_time */, &status); ASSERT_TRUE(cookie != nullptr); ASSERT_TRUE(status.IsInclude()); @@ -4055,7 +4055,7 @@ TEST_F(CookieMonsterTest, RejectCreatedHttpOnlyCookieOnSet) { // Cookie can be created successfully; HttpOnly is not checked on Create. auto cookie = CanonicalCookie::Create(url, cookie_line, base::Time::Now(), - base::nullopt /* server_time */, &status); + absl::nullopt /* server_time */, &status); ASSERT_TRUE(cookie != nullptr); ASSERT_TRUE(status.IsInclude()); @@ -4181,7 +4181,7 @@ TEST_F(CookieMonsterTest, CookiesWithoutSameSiteMustBeSecure) { GURL url = test.is_url_secure ? secure_url : insecure_url; base::Time creation_time = base::Time::Now() - test.creation_time_delta; auto cookie = CanonicalCookie::Create(url, test.cookie_line, creation_time, - base::nullopt /* server_time */); + absl::nullopt /* server_time */); // Make a copy so we can delete it after the test. CanonicalCookie cookie_copy = *cookie; CookieAccessResult result = SetCanonicalCookieReturnAccessResult( @@ -4304,7 +4304,7 @@ TEST_F(CookieMonsterNotificationTest, NoNotificationOnLoad) { std::vector> initial_cookies; GURL url("http://www.foo.com"); initial_cookies.push_back(CanonicalCookie::Create( - url, "X=1; path=/", base::Time::Now(), base::nullopt)); + url, "X=1; path=/", base::Time::Now(), absl::nullopt)); // Execute the load store->TakeCallbackAt(0).Run(std::move(initial_cookies)); @@ -4724,7 +4724,7 @@ TEST_F(CookieMonsterTest, CookiePortReadDiffersFromSetHistogram) { auto unspecified_cookie = CanonicalCookie::Create( GURL("https://www.foo.com/withoutport"), "C=D; Path=/withoutport", - base::Time::Now(), base::nullopt); + base::Time::Now(), absl::nullopt); // Force to be unspecified. unspecified_cookie->SetSourcePort(url::PORT_UNSPECIFIED); EXPECT_TRUE(SetCanonicalCookieReturnAccessResult( @@ -4735,7 +4735,7 @@ TEST_F(CookieMonsterTest, CookiePortReadDiffersFromSetHistogram) { auto invalid_cookie = CanonicalCookie::Create( GURL("https://www.foo.com/invalidport"), "E=F; Path=/invalidport", - base::Time::Now(), base::nullopt); + base::Time::Now(), absl::nullopt); // Force to be invalid. invalid_cookie->SetSourcePort(99999); EXPECT_TRUE(SetCanonicalCookieReturnAccessResult( diff --git a/net/cookies/cookie_options.h b/net/cookies/cookie_options.h index b62cbe5351b4e0..e0783435edc86e 100644 --- a/net/cookies/cookie_options.h +++ b/net/cookies/cookie_options.h @@ -10,10 +10,10 @@ #include #include -#include "base/optional.h" #include "net/base/net_export.h" #include "net/cookies/cookie_constants.h" #include "net/cookies/cookie_inclusion_status.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace net { diff --git a/net/cookies/cookie_store.h b/net/cookies/cookie_store.h index 2af6abbc55840f..afa99e255bdf13 100644 --- a/net/cookies/cookie_store.h +++ b/net/cookies/cookie_store.h @@ -14,13 +14,13 @@ #include #include "base/callback_forward.h" -#include "base/optional.h" #include "net/base/net_export.h" #include "net/cookies/canonical_cookie.h" #include "net/cookies/cookie_access_delegate.h" #include "net/cookies/cookie_access_result.h" #include "net/cookies/cookie_deletion_info.h" #include "net/cookies/cookie_options.h" +#include "third_party/abseil-cpp/absl/types/optional.h" class GURL; diff --git a/net/cookies/cookie_store_test_helpers.h b/net/cookies/cookie_store_test_helpers.h index bed5c9b1862b2f..ec0ab7b203092b 100644 --- a/net/cookies/cookie_store_test_helpers.h +++ b/net/cookies/cookie_store_test_helpers.h @@ -12,11 +12,11 @@ #include "base/callback_forward.h" #include "base/macros.h" -#include "base/optional.h" #include "base/synchronization/lock.h" #include "net/cookies/cookie_change_dispatcher.h" #include "net/log/net_log_with_source.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" class GURL; diff --git a/net/cookies/cookie_store_unittest.h b/net/cookies/cookie_store_unittest.h index 31f702c2d25cde..de52e7baad451f 100644 --- a/net/cookies/cookie_store_unittest.h +++ b/net/cookies/cookie_store_unittest.h @@ -195,8 +195,8 @@ class CookieStoreTest : public testing::Test { const GURL& url, const std::string& cookie_line, const CookieOptions& options, - base::Optional server_time = base::nullopt, - base::Optional system_time = base::nullopt) { + absl::optional server_time = absl::nullopt, + absl::optional system_time = absl::nullopt) { auto cookie = CanonicalCookie::Create( url, cookie_line, system_time.value_or(base::Time::Now()), server_time); @@ -236,8 +236,8 @@ class CookieStoreTest : public testing::Test { options.set_include_httponly(); options.set_same_site_cookie_context( net::CookieOptions::SameSiteCookieContext::MakeInclusive()); - return CreateAndSetCookie(cs, url, cookie_line, options, base::nullopt, - base::make_optional(system_time)); + return CreateAndSetCookie(cs, url, cookie_line, options, absl::nullopt, + absl::make_optional(system_time)); } bool SetCookieWithServerTime(CookieStore* cs, @@ -250,7 +250,7 @@ class CookieStoreTest : public testing::Test { options.set_same_site_cookie_context( net::CookieOptions::SameSiteCookieContext::MakeInclusive()); return CreateAndSetCookie(cs, url, cookie_line, options, - base::make_optional(server_time)); + absl::make_optional(server_time)); } bool SetCookie(CookieStore* cs, @@ -270,7 +270,7 @@ class CookieStoreTest : public testing::Test { const std::string& cookie_line) { CookieInclusionStatus create_status; auto cookie = CanonicalCookie::Create(url, cookie_line, base::Time::Now(), - base::nullopt /* server_time */, + absl::nullopt /* server_time */, &create_status); if (!cookie) return create_status; @@ -595,7 +595,7 @@ TYPED_TEST_P(CookieStoreTest, SetCanonicalCookieTest) { CookieInclusionStatus status; auto cookie = CanonicalCookie::Create( this->http_www_foo_.url(), "foo=1; Secure", base::Time::Now(), - base::nullopt /* server_time */, &status); + absl::nullopt /* server_time */, &status); EXPECT_TRUE(cookie->IsSecure()); EXPECT_TRUE(status.IsInclude()); EXPECT_TRUE(this->SetCanonicalCookieReturnAccessResult( @@ -644,7 +644,7 @@ TYPED_TEST_P(CookieStoreTest, SetCanonicalCookieTest) { CookieInclusionStatus create_status; auto c = CanonicalCookie::Create( this->http_www_foo_.url(), "bar=1; HttpOnly", base::Time::Now(), - base::nullopt /* server_time */, &create_status); + absl::nullopt /* server_time */, &create_status); EXPECT_TRUE(c->IsHttpOnly()); EXPECT_TRUE(create_status.IsInclude()); EXPECT_TRUE(this->SetCanonicalCookieReturnAccessResult( @@ -1266,8 +1266,8 @@ TYPED_TEST_P(CookieStoreTest, EmptyExpires) { this->MatchCookieLines(cookie_line, this->GetCookiesWithOptions(cs, url, options)); - base::Optional server_time = - base::make_optional(base::Time::Now() - base::TimeDelta::FromHours(1)); + absl::optional server_time = + absl::make_optional(base::Time::Now() - base::TimeDelta::FromHours(1)); this->CreateAndSetCookie(cs, url, set_cookie_line, options, server_time); this->MatchCookieLines(cookie_line, this->GetCookiesWithOptions(cs, url, options)); diff --git a/net/cookies/cookie_util.cc b/net/cookies/cookie_util.cc index 4db4711f958f61..e1ecfcbd5a78b8 100644 --- a/net/cookies/cookie_util.cc +++ b/net/cookies/cookie_util.cc @@ -105,7 +105,7 @@ bool SaturatedTimeFromUTCExploded(const base::Time::Exploded& exploded, std::pair ComputeSameSiteContext( const std::vector& url_chain, const SiteForCookies& site_for_cookies, - const base::Optional& initiator, + const absl::optional& initiator, bool is_http, bool is_main_frame_navigation, bool compute_schemefully) { @@ -167,7 +167,7 @@ std::pair ComputeSameSiteContext( CookieOptions::SameSiteCookieContext ComputeSameSiteContextForSet( const std::vector& url_chain, const SiteForCookies& site_for_cookies, - const base::Optional& initiator, + const absl::optional& initiator, bool is_http, bool is_main_frame_navigation) { CookieOptions::SameSiteCookieContext same_site_context; @@ -534,7 +534,7 @@ CookieOptions::SameSiteCookieContext ComputeSameSiteContextForRequest( const std::string& http_method, const std::vector& url_chain, const SiteForCookies& site_for_cookies, - const base::Optional& initiator, + const absl::optional& initiator, bool is_main_frame_navigation, bool force_ignore_site_for_cookies) { // Set SameSiteCookieContext according to the rules laid out in @@ -593,7 +593,7 @@ CookieOptions::SameSiteCookieContext ComputeSameSiteContextForRequest( NET_EXPORT CookieOptions::SameSiteCookieContext ComputeSameSiteContextForScriptGet(const GURL& url, const SiteForCookies& site_for_cookies, - const base::Optional& initiator, + const absl::optional& initiator, bool force_ignore_site_for_cookies) { if (force_ignore_site_for_cookies) return CookieOptions::SameSiteCookieContext::MakeInclusive(); @@ -615,7 +615,7 @@ ComputeSameSiteContextForScriptGet(const GURL& url, CookieOptions::SameSiteCookieContext ComputeSameSiteContextForResponse( const std::vector& url_chain, const SiteForCookies& site_for_cookies, - const base::Optional& initiator, + const absl::optional& initiator, bool is_main_frame_navigation, bool force_ignore_site_for_cookies) { if (force_ignore_site_for_cookies) @@ -650,7 +650,7 @@ CookieOptions::SameSiteCookieContext ComputeSameSiteContextForScriptSet( // with the url. We don't check the redirect chain for script access to // cookies (only the URL itself). return ComputeSameSiteContextForSet( - {url}, site_for_cookies, base::nullopt /* initiator */, + {url}, site_for_cookies, absl::nullopt /* initiator */, false /* is_http */, false /* is_main_frame_navigation */); } @@ -711,7 +711,7 @@ CookieOptions::SamePartyCookieContextType ComputeSamePartyContext( cookie_access_delegate->IsContextSamePartyWithSite( request_site, force_ignore_top_frame_party - ? base::nullopt + ? absl::nullopt : isolation_info.network_isolation_key().GetTopFrameSite(), isolation_info.party_context().value())) { return CookieOptions::SamePartyCookieContextType::kSameParty; @@ -745,7 +745,7 @@ FirstPartySetsContextType ComputeFirstPartySetsContextType( return cookie_access_delegate->ComputeFirstPartySetsContextType( request_site, force_ignore_top_frame_party - ? base::nullopt + ? absl::nullopt : isolation_info.network_isolation_key().GetTopFrameSite(), isolation_info.party_context().value()); } diff --git a/net/cookies/cookie_util.h b/net/cookies/cookie_util.h index 173be4ab8bac5f..94e7dbf52c9c2d 100644 --- a/net/cookies/cookie_util.h +++ b/net/cookies/cookie_util.h @@ -159,7 +159,7 @@ NET_EXPORT std::string SerializeRequestCookieLine( // `initiator` is the origin ultimately responsible for getting the request // issued. It may be different from `site_for_cookies`. // -// base::nullopt for `initiator` denotes that the navigation was initiated by +// absl::nullopt for `initiator` denotes that the navigation was initiated by // the user directly interacting with the browser UI, e.g. entering a URL // or selecting a bookmark. // @@ -184,7 +184,7 @@ NET_EXPORT CookieOptions::SameSiteCookieContext ComputeSameSiteContextForRequest(const std::string& http_method, const std::vector& url_chain, const SiteForCookies& site_for_cookies, - const base::Optional& initiator, + const absl::optional& initiator, bool is_main_frame_navigation, bool force_ignore_site_for_cookies); @@ -194,7 +194,7 @@ ComputeSameSiteContextForRequest(const std::string& http_method, NET_EXPORT CookieOptions::SameSiteCookieContext ComputeSameSiteContextForScriptGet(const GURL& url, const SiteForCookies& site_for_cookies, - const base::Optional& initiator, + const absl::optional& initiator, bool force_ignore_site_for_cookies); // Determines which of the cookies for the request URL can be set from a network @@ -212,7 +212,7 @@ ComputeSameSiteContextForScriptGet(const GURL& url, NET_EXPORT CookieOptions::SameSiteCookieContext ComputeSameSiteContextForResponse(const std::vector& url_chain, const SiteForCookies& site_for_cookies, - const base::Optional& initiator, + const absl::optional& initiator, bool is_main_frame_navigation, bool force_ignore_site_for_cookies); diff --git a/net/cookies/cookie_util_unittest.cc b/net/cookies/cookie_util_unittest.cc index 0ecd7f3626d26b..166b39748bd6fd 100644 --- a/net/cookies/cookie_util_unittest.cc +++ b/net/cookies/cookie_util_unittest.cc @@ -8,7 +8,6 @@ #include "base/callback.h" #include "base/containers/contains.h" -#include "base/optional.h" #include "base/strings/strcat.h" #include "base/strings/string_split.h" #include "base/test/bind.h" @@ -19,6 +18,7 @@ #include "net/cookies/cookie_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/origin.h" namespace net { @@ -306,12 +306,12 @@ TEST(CookieUtilTest, SimulatedCookieSource) { std::vector> cookies; // It shouldn't depend on the cookie's secureness or actual source scheme. cookies.push_back(CanonicalCookie::Create( - insecure_url, test.cookie, base::Time::Now(), base::nullopt)); + insecure_url, test.cookie, base::Time::Now(), absl::nullopt)); cookies.push_back(CanonicalCookie::Create( - secure_url, test.cookie, base::Time::Now(), base::nullopt)); + secure_url, test.cookie, base::Time::Now(), absl::nullopt)); cookies.push_back( CanonicalCookie::Create(secure_url, test.cookie + "; Secure", - base::Time::Now(), base::nullopt)); + base::Time::Now(), absl::nullopt)); for (const auto& cookie : cookies) { GURL simulated_source = cookie_util::SimulatedCookieSource(*cookie, test.source_scheme); @@ -456,7 +456,7 @@ class CookieUtilComputeSameSiteContextTest return cross_site_sfc; } - std::vector> GetAllInitiators() const { + std::vector> GetAllInitiators() const { return {kBrowserInitiated, kOpaqueInitiator, kSiteInitiator, kSecureSiteInitiator, kCrossSiteInitiator, kSecureCrossSiteInitiator, @@ -464,8 +464,8 @@ class CookieUtilComputeSameSiteContextTest kUnrelatedInitiator}; } - std::vector> GetSameSiteInitiators() const { - std::vector> same_site_initiators{ + std::vector> GetSameSiteInitiators() const { + std::vector> same_site_initiators{ kBrowserInitiated, kSiteInitiator, kSubdomainInitiator}; // If schemeless, the cross-scheme origins are also same-site. if (!IsSchemeful()) { @@ -475,11 +475,11 @@ class CookieUtilComputeSameSiteContextTest return same_site_initiators; } - std::vector> GetCrossSiteInitiators() const { - std::vector> cross_site_initiators; - std::vector> same_site_initiators = + std::vector> GetCrossSiteInitiators() const { + std::vector> cross_site_initiators; + std::vector> same_site_initiators = GetSameSiteInitiators(); - for (const base::Optional& initiator : GetAllInitiators()) { + for (const absl::optional& initiator : GetAllInitiators()) { if (!base::Contains(same_site_initiators, initiator)) cross_site_initiators.push_back(initiator); } @@ -553,23 +553,23 @@ class CookieUtilComputeSameSiteContextTest const SiteForCookies kSecureCrossSiteForCookies = SiteForCookies::FromUrl(kSecureCrossSiteUrl); // Initiator origin. - const base::Optional kBrowserInitiated = base::nullopt; - const base::Optional kOpaqueInitiator = - base::make_optional(url::Origin()); - const base::Optional kSiteInitiator = - base::make_optional(url::Origin::Create(kSiteUrl)); - const base::Optional kSecureSiteInitiator = - base::make_optional(url::Origin::Create(kSecureSiteUrl)); - const base::Optional kCrossSiteInitiator = - base::make_optional(url::Origin::Create(kCrossSiteUrl)); - const base::Optional kSecureCrossSiteInitiator = - base::make_optional(url::Origin::Create(kSecureCrossSiteUrl)); - const base::Optional kSubdomainInitiator = - base::make_optional(url::Origin::Create(kSubdomainUrl)); - const base::Optional kSecureSubdomainInitiator = - base::make_optional(url::Origin::Create(kSecureSubdomainUrl)); - const base::Optional kUnrelatedInitiator = - base::make_optional(url::Origin::Create(GURL("https://unrelated.test/"))); + const absl::optional kBrowserInitiated = absl::nullopt; + const absl::optional kOpaqueInitiator = + absl::make_optional(url::Origin()); + const absl::optional kSiteInitiator = + absl::make_optional(url::Origin::Create(kSiteUrl)); + const absl::optional kSecureSiteInitiator = + absl::make_optional(url::Origin::Create(kSecureSiteUrl)); + const absl::optional kCrossSiteInitiator = + absl::make_optional(url::Origin::Create(kCrossSiteUrl)); + const absl::optional kSecureCrossSiteInitiator = + absl::make_optional(url::Origin::Create(kSecureCrossSiteUrl)); + const absl::optional kSubdomainInitiator = + absl::make_optional(url::Origin::Create(kSubdomainUrl)); + const absl::optional kSecureSubdomainInitiator = + absl::make_optional(url::Origin::Create(kSecureSubdomainUrl)); + const absl::optional kUnrelatedInitiator = + absl::make_optional(url::Origin::Create(GURL("https://unrelated.test/"))); protected: base::test::ScopedFeatureList feature_list_; @@ -581,7 +581,7 @@ TEST_P(CookieUtilComputeSameSiteContextTest, UrlAndSiteForCookiesCrossSite) { for (const GURL& url : GetSameSiteUrls()) { for (const SiteForCookies& site_for_cookies : GetCrossSiteSitesForCookies()) { - for (const base::Optional& initiator : GetAllInitiators()) { + for (const absl::optional& initiator : GetAllInitiators()) { for (const std::string& method : {"GET", "POST", "PUT", "HEAD"}) { EXPECT_THAT(cookie_util::ComputeSameSiteContextForScriptGet( url, site_for_cookies, initiator, @@ -642,7 +642,7 @@ TEST_P(CookieUtilComputeSameSiteContextTest, SiteForCookiesNotSchemefullySame) { for (const GURL& url : GetSameSiteUrls()) { for (const SiteForCookies& site_for_cookies : sites_for_cookies) { - for (const base::Optional& initiator : GetAllInitiators()) { + for (const absl::optional& initiator : GetAllInitiators()) { for (const std::string& method : {"GET", "POST", "PUT", "HEAD"}) { EXPECT_THAT(cookie_util::ComputeSameSiteContextForScriptGet( url, site_for_cookies, initiator, @@ -683,7 +683,7 @@ TEST_P(CookieUtilComputeSameSiteContextTest, ForScriptGet) { for (const SiteForCookies& site_for_cookies : GetSameSiteSitesForCookies()) { // Cross-site initiator -> it's same-site lax. - for (const base::Optional& initiator : + for (const absl::optional& initiator : GetCrossSiteInitiators()) { EXPECT_THAT(cookie_util::ComputeSameSiteContextForScriptGet( url, site_for_cookies, initiator, @@ -692,7 +692,7 @@ TEST_P(CookieUtilComputeSameSiteContextTest, ForScriptGet) { } // Same-site initiator -> it's same-site strict. - for (const base::Optional& initiator : + for (const absl::optional& initiator : GetSameSiteInitiators()) { EXPECT_THAT(cookie_util::ComputeSameSiteContextForScriptGet( url, site_for_cookies, initiator, @@ -757,7 +757,7 @@ TEST_P(CookieUtilComputeSameSiteContextTest, ForRequest) { for (const SiteForCookies& site_for_cookies : GetSameSiteSitesForCookies()) { // Same-Site initiator -> it's same-site strict. - for (const base::Optional& initiator : + for (const absl::optional& initiator : GetSameSiteInitiators()) { for (const std::string& method : {"GET", "POST", "PUT", "HEAD"}) { for (bool is_main_frame_navigation : @@ -772,7 +772,7 @@ TEST_P(CookieUtilComputeSameSiteContextTest, ForRequest) { } // Cross-Site initiator -> it's same-site lax iff the method is safe. - for (const base::Optional& initiator : + for (const absl::optional& initiator : GetCrossSiteInitiators()) { // For main frame navigations, the context is Lax (or Lax-unsafe). for (const std::string& method : {"GET", "HEAD"}) { @@ -1008,12 +1008,12 @@ TEST_P(CookieUtilComputeSameSiteContextTest, ForRequest_Redirect) { std::vector sites_for_cookies = test_case.site_for_cookies_is_same_site ? GetSameSiteSitesForCookies() : GetCrossSiteSitesForCookies(); - std::vector> initiators = + std::vector> initiators = test_case.initiator_is_same_site ? GetSameSiteInitiators() : GetCrossSiteInitiators(); for (const std::vector& url_chain : url_chains) { for (const SiteForCookies& site_for_cookies : sites_for_cookies) { - for (const base::Optional& initiator : initiators) { + for (const absl::optional& initiator : initiators) { EXPECT_THAT(cookie_util::ComputeSameSiteContextForRequest( test_case.method, url_chain, site_for_cookies, initiator, false /* is_main_frame_navigation */, @@ -1090,7 +1090,7 @@ TEST_P(CookieUtilComputeSameSiteContextTest, ForResponse) { GetSameSiteSitesForCookies()) { // For main frame navigations, setting all SameSite cookies is allowed // regardless of initiator. - for (const base::Optional& initiator : GetAllInitiators()) { + for (const absl::optional& initiator : GetAllInitiators()) { if (!CanBeMainFrameNavigation(url, site_for_cookies)) break; EXPECT_THAT(cookie_util::ComputeSameSiteContextForResponse( @@ -1103,7 +1103,7 @@ TEST_P(CookieUtilComputeSameSiteContextTest, ForResponse) { // For non-main-frame-navigation requests, the context should be lax iff // the initiator is same-site, and cross-site otherwise. If the old // (incorrect) behavior is in effect, it is always lax. - for (const base::Optional& initiator : + for (const absl::optional& initiator : GetSameSiteInitiators()) { EXPECT_THAT(cookie_util::ComputeSameSiteContextForResponse( {url}, site_for_cookies, initiator, @@ -1111,7 +1111,7 @@ TEST_P(CookieUtilComputeSameSiteContextTest, ForResponse) { false /* force_ignore_site_for_cookies */), ContextTypeIs(ContextType::SAME_SITE_LAX)); } - for (const base::Optional& initiator : + for (const absl::optional& initiator : GetCrossSiteInitiators()) { ContextType incorrectly_lax = IsBugfix1166211Enabled() ? ContextType::CROSS_SITE @@ -1188,7 +1188,7 @@ TEST_P(CookieUtilComputeSameSiteContextTest, ForResponse_WebSocketSchemes) { // (ws/wss requests cannot be main frame navigations.) // Same-site initiators. - for (const base::Optional& initiator : GetSameSiteInitiators()) { + for (const absl::optional& initiator : GetSameSiteInitiators()) { EXPECT_THAT(cookie_util::ComputeSameSiteContextForResponse( {kWsUrl}, kSiteForCookies, initiator, false /* is_main_frame_navigation */, @@ -1196,7 +1196,7 @@ TEST_P(CookieUtilComputeSameSiteContextTest, ForResponse_WebSocketSchemes) { ContextTypeIs(ContextType::SAME_SITE_LAX)); } // Cross-site initiators. - for (const base::Optional& initiator : + for (const absl::optional& initiator : GetCrossSiteInitiators()) { ContextType incorrectly_lax = IsBugfix1166211Enabled() ? ContextType::CROSS_SITE @@ -1240,12 +1240,12 @@ TEST_P(CookieUtilComputeSameSiteContextTest, ForResponse_Redirect) { std::vector sites_for_cookies = test_case.site_for_cookies_is_same_site ? GetSameSiteSitesForCookies() : GetCrossSiteSitesForCookies(); - std::vector> initiators = + std::vector> initiators = test_case.initiator_is_same_site ? GetSameSiteInitiators() : GetCrossSiteInitiators(); for (const std::vector& url_chain : url_chains) { for (const SiteForCookies& site_for_cookies : sites_for_cookies) { - for (const base::Optional& initiator : initiators) { + for (const absl::optional& initiator : initiators) { EXPECT_THAT(cookie_util::ComputeSameSiteContextForResponse( url_chain, site_for_cookies, initiator, false /* is_main_frame_navigation */, @@ -1319,7 +1319,7 @@ TEST_P(CookieUtilComputeSameSiteContextTest, ForceIgnoreSiteForCookies) { // (STRICT for get or LAX for set). for (const GURL& url : GetAllUrls()) { for (const SiteForCookies& site_for_cookies : GetAllSitesForCookies()) { - for (const base::Optional& initiator : GetAllInitiators()) { + for (const absl::optional& initiator : GetAllInitiators()) { for (const std::string& method : {"GET", "POST", "PUT", "HEAD"}) { EXPECT_THAT(cookie_util::ComputeSameSiteContextForScriptGet( url, site_for_cookies, initiator, diff --git a/net/cookies/test_cookie_access_delegate.cc b/net/cookies/test_cookie_access_delegate.cc index d3b360a4cf8bb2..eb8c5d66dba35d 100644 --- a/net/cookies/test_cookie_access_delegate.cc +++ b/net/cookies/test_cookie_access_delegate.cc @@ -36,7 +36,7 @@ bool TestCookieAccessDelegate::ShouldIgnoreSameSiteRestrictions( bool TestCookieAccessDelegate::IsContextSamePartyWithSite( const net::SchemefulSite& site, - const base::Optional& top_frame_site, + const absl::optional& top_frame_site, const std::set& party_context) const { return false; } @@ -44,7 +44,7 @@ bool TestCookieAccessDelegate::IsContextSamePartyWithSite( FirstPartySetsContextType TestCookieAccessDelegate::ComputeFirstPartySetsContextType( const net::SchemefulSite& site, - const base::Optional& top_frame_site, + const absl::optional& top_frame_site, const std::set& party_context) const { return FirstPartySetsContextType::kUnknown; } diff --git a/net/cookies/test_cookie_access_delegate.h b/net/cookies/test_cookie_access_delegate.h index fa5ff20383fe2e..674b389480a1ad 100644 --- a/net/cookies/test_cookie_access_delegate.h +++ b/net/cookies/test_cookie_access_delegate.h @@ -7,9 +7,9 @@ #include -#include "base/optional.h" #include "net/cookies/cookie_access_delegate.h" #include "net/cookies/cookie_constants.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -31,11 +31,11 @@ class TestCookieAccessDelegate : public CookieAccessDelegate { const SiteForCookies& site_for_cookies) const override; bool IsContextSamePartyWithSite( const net::SchemefulSite& site, - const base::Optional& top_frame_site, + const absl::optional& top_frame_site, const std::set& party_context) const override; FirstPartySetsContextType ComputeFirstPartySetsContextType( const net::SchemefulSite& site, - const base::Optional& top_frame_site, + const absl::optional& top_frame_site, const std::set& party_context) const override; bool IsInNontrivialFirstPartySet( const net::SchemefulSite& site) const override; diff --git a/net/der/parser.cc b/net/der/parser.cc index f12ed83085a5bd..e226313b072d74 100644 --- a/net/der/parser.cc +++ b/net/der/parser.cc @@ -61,9 +61,9 @@ bool Parser::ReadTagAndValue(Tag* tag, Input* out) { return true; } -bool Parser::ReadOptionalTag(Tag tag, base::Optional* out) { +bool Parser::ReadOptionalTag(Tag tag, absl::optional* out) { if (!HasMore()) { - *out = base::nullopt; + *out = absl::nullopt; return true; } Tag actual_tag; @@ -76,13 +76,13 @@ bool Parser::ReadOptionalTag(Tag tag, base::Optional* out) { *out = value; } else { advance_len_ = 0; - *out = base::nullopt; + *out = absl::nullopt; } return true; } bool Parser::ReadOptionalTag(Tag tag, Input* out, bool* present) { - base::Optional tmp_out; + absl::optional tmp_out; if (!ReadOptionalTag(tag, &tmp_out)) return false; *present = tmp_out.has_value(); diff --git a/net/der/parser.h b/net/der/parser.h index 410a5aeb3d1adb..7c8e24bf632099 100644 --- a/net/der/parser.h +++ b/net/der/parser.h @@ -9,10 +9,10 @@ #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/optional.h" #include "net/base/net_export.h" #include "net/der/input.h" #include "net/der/tag.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/boringssl/src/include/openssl/bytestring.h" namespace net { @@ -122,14 +122,14 @@ class NET_EXPORT Parser { // something else, then |out| is set to nullopt and the input is not // advanced. Like ReadTagAndValue, it returns false if the encoding is // invalid and does not advance the input. - bool ReadOptionalTag(Tag tag, base::Optional* out) WARN_UNUSED_RESULT; + bool ReadOptionalTag(Tag tag, absl::optional* out) WARN_UNUSED_RESULT; // If the current tag in the input is |tag|, it puts the corresponding value // in |out|, sets |was_present| to true, and advances the input to the next // TLV. If the current tag is something else, then |was_present| is set to // false and the input is not advanced. Like ReadTagAndValue, it returns // false if the encoding is invalid and does not advance the input. - // DEPRECATED: use the base::Optional version above in new code. + // DEPRECATED: use the absl::optional version above in new code. // TODO(mattm): convert the existing callers and remove this override. bool ReadOptionalTag(Tag tag, Input* out, diff --git a/net/der/parser_unittest.cc b/net/der/parser_unittest.cc index 7c51b0e0f1e535..142dc0600399ca 100644 --- a/net/der/parser_unittest.cc +++ b/net/der/parser_unittest.cc @@ -95,7 +95,7 @@ TEST(ParserTest, ReadOptionalTag2Present) { const uint8_t der[] = {0x02, 0x01, 0x01, 0x04, 0x01, 0x02}; Parser parser((Input(der))); - base::Optional optional_value; + absl::optional optional_value; ASSERT_TRUE(parser.ReadOptionalTag(kInteger, &optional_value)); ASSERT_TRUE(optional_value.has_value()); const uint8_t expected_int_value[] = {0x01}; @@ -137,7 +137,7 @@ TEST(ParserTest, ReadOptionalTag2NotPresent) { const uint8_t der[] = {0x04, 0x01, 0x02}; Parser parser((Input(der))); - base::Optional optional_value; + absl::optional optional_value; ASSERT_TRUE(parser.ReadOptionalTag(kInteger, &optional_value)); ASSERT_FALSE(optional_value.has_value()); diff --git a/net/dns/address_info.cc b/net/dns/address_info.cc index 9e7e1a5ede9207..ce412d2012dc83 100644 --- a/net/dns/address_info.cc +++ b/net/dns/address_info.cc @@ -73,11 +73,11 @@ AddressInfo::AddressInfoAndResult AddressInfo::Get( err = ERR_NAME_RESOLUTION_FAILED; #endif - return AddressInfoAndResult(base::Optional(), err, os_error); + return AddressInfoAndResult(absl::optional(), err, os_error); } return AddressInfoAndResult( - base::Optional(AddressInfo(ai, std::move(getter))), OK, 0); + absl::optional(AddressInfo(ai, std::move(getter))), OK, 0); } AddressInfo::AddressInfo(AddressInfo&& other) @@ -107,10 +107,10 @@ AddressInfo::const_iterator AddressInfo::end() const { return const_iterator(nullptr); } -base::Optional AddressInfo::GetCanonicalName() const { +absl::optional AddressInfo::GetCanonicalName() const { return (ai_->ai_canonname != nullptr) - ? base::Optional(std::string(ai_->ai_canonname)) - : base::Optional(); + ? absl::optional(std::string(ai_->ai_canonname)) + : absl::optional(); } bool AddressInfo::IsAllLocalhostOfOneFamily() const { diff --git a/net/dns/address_info.h b/net/dns/address_info.h index 95bc277c30bae6..93de5725cf1120 100644 --- a/net/dns/address_info.h +++ b/net/dns/address_info.h @@ -10,11 +10,11 @@ #include #include "base/macros.h" -#include "base/optional.h" #include "build/build_config.h" #include "net/base/address_family.h" #include "net/base/net_export.h" #include "net/base/sys_addrinfo.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -47,7 +47,7 @@ class NET_EXPORT_PRIVATE AddressInfo { // Constructors using AddressInfoAndResult = std:: - tuple, int /* err */, int /* os_error */>; + tuple, int /* err */, int /* os_error */>; // Invokes AddrInfoGetter with provided |host| and |hints|. If |getter| is // null, the system's getaddrinfo will be invoked. (A non-null |getter| is // primarily for tests). @@ -65,7 +65,7 @@ class NET_EXPORT_PRIVATE AddressInfo { const_iterator end() const; // Methods - base::Optional GetCanonicalName() const; + absl::optional GetCanonicalName() const; bool IsAllLocalhostOfOneFamily() const; AddressList CreateAddressList() const; diff --git a/net/dns/address_info_unittest.cc b/net/dns/address_info_unittest.cc index 45e39879f8ce2b..bf7bb9ab86ef62 100644 --- a/net/dns/address_info_unittest.cc +++ b/net/dns/address_info_unittest.cc @@ -96,7 +96,7 @@ std::unique_ptr MakeHints(AddressFamily address_family, } TEST(AddressInfoTest, Failure) { - base::Optional ai; + absl::optional ai; int err; int os_error; auto getter = std::make_unique(); @@ -112,7 +112,7 @@ TEST(AddressInfoTest, Failure) { #if defined(OS_WIN) // Note: this test is descriptive, not prescriptive. TEST(AddressInfoTest, FailureWin) { - base::Optional ai; + absl::optional ai; int err; int os_error; auto getter = std::make_unique(); @@ -129,7 +129,7 @@ TEST(AddressInfoTest, FailureWin) { #if defined(OS_ANDROID) // Note: this test is descriptive, not prescriptive. TEST(AddressInfoTest, FailureAndroid) { - base::Optional ai; + absl::optional ai; int err; int os_error; auto getter = std::make_unique(); @@ -144,7 +144,7 @@ TEST(AddressInfoTest, FailureAndroid) { #endif // OS_ANDROID TEST(AddressInfoTest, Canonical) { - base::Optional ai; + absl::optional ai; int err; int os_error; std::tie(ai, err, os_error) = @@ -156,11 +156,11 @@ TEST(AddressInfoTest, Canonical) { EXPECT_EQ(err, OK); EXPECT_EQ(os_error, 0); EXPECT_THAT(ai->GetCanonicalName(), - base::Optional("canonical.bar.com")); + absl::optional("canonical.bar.com")); } TEST(AddressInfoTest, Iteration) { - base::Optional ai; + absl::optional ai; int err; int os_error; std::tie(ai, err, os_error) = @@ -196,7 +196,7 @@ TEST(AddressInfoTest, Iteration) { } TEST(AddressInfoTest, IsAllLocalhostOfOneFamily) { - base::Optional ai; + absl::optional ai; int err; int os_error; std::tie(ai, err, os_error) = @@ -211,7 +211,7 @@ TEST(AddressInfoTest, IsAllLocalhostOfOneFamily) { } TEST(AddressInfoTest, IsAllLocalhostOfOneFamilyFalse) { - base::Optional ai; + absl::optional ai; int err; int os_error; std::tie(ai, err, os_error) = @@ -226,7 +226,7 @@ TEST(AddressInfoTest, IsAllLocalhostOfOneFamilyFalse) { } TEST(AddressInfoTest, CreateAddressList) { - base::Optional ai; + absl::optional ai; int err; int os_error; std::tie(ai, err, os_error) = diff --git a/net/dns/context_host_resolver.cc b/net/dns/context_host_resolver.cc index f34bcc49d85d39..915bc744d15ac8 100644 --- a/net/dns/context_host_resolver.cc +++ b/net/dns/context_host_resolver.cc @@ -120,19 +120,19 @@ class ContextHostResolver::WrappedResolveHostRequest return inner_request_->Start(std::move(callback)); } - const base::Optional& GetAddressResults() const override { + const absl::optional& GetAddressResults() const override { if (!inner_request_) { - static base::NoDestructor> nullopt_result; + static base::NoDestructor> nullopt_result; return *nullopt_result; } return inner_request_->GetAddressResults(); } - const base::Optional>& GetTextResults() + const absl::optional>& GetTextResults() const override { if (!inner_request_) { - static const base::NoDestructor>> + static const base::NoDestructor>> nullopt_result; return *nullopt_result; } @@ -140,10 +140,10 @@ class ContextHostResolver::WrappedResolveHostRequest return inner_request_->GetTextResults(); } - const base::Optional>& GetHostnameResults() + const absl::optional>& GetHostnameResults() const override { if (!inner_request_) { - static const base::NoDestructor>> + static const base::NoDestructor>> nullopt_result; return *nullopt_result; } @@ -151,10 +151,10 @@ class ContextHostResolver::WrappedResolveHostRequest return inner_request_->GetHostnameResults(); } - const base::Optional>& GetDnsAliasResults() + const absl::optional>& GetDnsAliasResults() const override { if (!inner_request_) { - static const base::NoDestructor>> + static const base::NoDestructor>> nullopt_result; return *nullopt_result; } @@ -169,10 +169,10 @@ class ContextHostResolver::WrappedResolveHostRequest return inner_request_->GetResolveErrorInfo(); } - const base::Optional& GetStaleInfo() + const absl::optional& GetStaleInfo() const override { if (!inner_request_) { - static const base::NoDestructor> + static const base::NoDestructor> nullopt_result; return *nullopt_result; } @@ -296,7 +296,7 @@ ContextHostResolver::CreateRequest( const HostPortPair& host, const NetworkIsolationKey& network_isolation_key, const NetLogWithSource& source_net_log, - const base::Optional& optional_parameters) { + const absl::optional& optional_parameters) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); std::unique_ptr diff --git a/net/dns/context_host_resolver.h b/net/dns/context_host_resolver.h index 708e7a2aa969d3..5faba8daedb2ce 100644 --- a/net/dns/context_host_resolver.h +++ b/net/dns/context_host_resolver.h @@ -48,7 +48,7 @@ class NET_EXPORT ContextHostResolver : public HostResolver { const HostPortPair& host, const NetworkIsolationKey& network_isolation_key, const NetLogWithSource& net_log, - const base::Optional& optional_parameters) + const absl::optional& optional_parameters) override; std::unique_ptr CreateDohProbeRequest() override; std::unique_ptr CreateMdnsListener( diff --git a/net/dns/context_host_resolver_unittest.cc b/net/dns/context_host_resolver_unittest.cc index 6792f1308c5399..c4a51e56a9e63f 100644 --- a/net/dns/context_host_resolver_unittest.cc +++ b/net/dns/context_host_resolver_unittest.cc @@ -7,7 +7,6 @@ #include #include "base/bind.h" -#include "base/optional.h" #include "base/run_loop.h" #include "base/test/scoped_feature_list.h" #include "base/test/simple_test_tick_clock.h" @@ -36,6 +35,7 @@ #include "net/url_request/url_request_context.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace net { @@ -113,7 +113,7 @@ TEST_F(ContextHostResolverTest, Resolve) { std::unique_ptr request = resolver->CreateRequest(HostPortPair("example.com", 100), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); TestCompletionCallback callback; int rv = request->Start(callback.callback()); @@ -143,7 +143,7 @@ TEST_F(ContextHostResolverTest, DestroyRequest) { std::unique_ptr request = resolver->CreateRequest(HostPortPair("example.com", 100), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); EXPECT_EQ(1u, resolver->GetNumActiveRequestsForTesting()); TestCompletionCallback callback; @@ -246,7 +246,7 @@ TEST_F(ContextHostResolverTest, DestroyResolver) { std::unique_ptr request1 = resolver1->CreateRequest(HostPortPair("example.com", 100), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); auto resolver2 = std::make_unique( manager_.get(), std::make_unique(nullptr /* url_request_context */, @@ -254,7 +254,7 @@ TEST_F(ContextHostResolverTest, DestroyResolver) { std::unique_ptr request2 = resolver2->CreateRequest(HostPortPair("google.com", 100), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); TestCompletionCallback callback1; int rv1 = request1->Start(callback1.callback()); @@ -295,7 +295,7 @@ TEST_F(ContextHostResolverTest, DestroyResolver_CompletedRequests) { std::unique_ptr request = resolver->CreateRequest(HostPortPair("example.com", 100), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); // Complete request and then destroy the resolver. TestCompletionCallback callback; @@ -350,7 +350,7 @@ TEST_F(ContextHostResolverTest, DestroyResolver_DelayedStartRequest) { std::unique_ptr request = resolver->CreateRequest(HostPortPair("example.com", 100), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); resolver = nullptr; @@ -402,7 +402,7 @@ TEST_F(ContextHostResolverTest, OnShutdown_PendingRequest) { std::unique_ptr request = resolver->CreateRequest(HostPortPair("example.com", 100), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); TestCompletionCallback callback; int rv = request->Start(callback.callback()); @@ -458,7 +458,7 @@ TEST_F(ContextHostResolverTest, OnShutdown_CompletedRequests) { std::unique_ptr request = resolver->CreateRequest(HostPortPair("example.com", 100), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); // Complete request and then shutdown the resolver. TestCompletionCallback callback; @@ -483,11 +483,11 @@ TEST_F(ContextHostResolverTest, OnShutdown_SubsequentRequests) { std::unique_ptr request1 = resolver->CreateRequest(HostPortPair("example.com", 100), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); std::unique_ptr request2 = resolver->CreateRequest(HostPortPair("127.0.0.1", 100), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); TestCompletionCallback callback1; int rv1 = request1->Start(callback1.callback()); @@ -543,7 +543,7 @@ TEST_F(ContextHostResolverTest, OnShutdown_DelayedStartRequest) { std::unique_ptr request = resolver->CreateRequest(HostPortPair("example.com", 100), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); resolver->OnShutdown(); @@ -639,7 +639,7 @@ TEST_F(ContextHostResolverTest, ResultsAddedToCache) { std::unique_ptr caching_request = resolver->CreateRequest(HostPortPair("example.com", 103), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); TestCompletionCallback caching_callback; int rv = caching_request->Start(caching_callback.callback()); EXPECT_THAT(caching_callback.GetResult(rv), test::IsOk()); @@ -688,7 +688,7 @@ TEST_F(ContextHostResolverTest, ResultsAddedToCacheWithNetworkIsolationKey) { std::unique_ptr caching_request = resolver->CreateRequest(HostPortPair("example.com", 103), kNetworkIsolationKey, NetLogWithSource(), - base::nullopt); + absl::nullopt); TestCompletionCallback caching_callback; int rv = caching_request->Start(caching_callback.callback()); EXPECT_THAT(caching_callback.GetResult(rv), test::IsOk()); diff --git a/net/dns/dns_client.cc b/net/dns/dns_client.cc index 54011767e6f3c5..486581f18d1bbe 100644 --- a/net/dns/dns_client.cc +++ b/net/dns/dns_client.cc @@ -33,7 +33,7 @@ base::Value NetLogDnsConfigParams(const DnsConfig* config) { return config->ToValue(); } -bool IsEqual(const base::Optional& c1, const DnsConfig* c2) { +bool IsEqual(const absl::optional& c1, const DnsConfig* c2) { if (!c1.has_value() && c2 == nullptr) return true; @@ -133,7 +133,7 @@ class DnsClientImpl : public DnsClient { insecure_fallback_failures_ >= kMaxInsecureFallbackFailures; } - bool SetSystemConfig(base::Optional system_config) override { + bool SetSystemConfig(absl::optional system_config) override { if (system_config == system_config_) return false; @@ -190,7 +190,7 @@ class DnsClientImpl : public DnsClient { insecure_fallback_failures_ = 0; } - base::Optional GetSystemConfigForTesting() const override { + absl::optional GetSystemConfigForTesting() const override { return system_config_; } @@ -204,13 +204,13 @@ class DnsClientImpl : public DnsClient { } private: - base::Optional BuildEffectiveConfig() const { + absl::optional BuildEffectiveConfig() const { DnsConfig config; if (config_overrides_.OverridesEverything()) { config = config_overrides_.ApplyOverrides(DnsConfig()); } else { if (!system_config_) - return base::nullopt; + return absl::nullopt; config = config_overrides_.ApplyOverrides(system_config_.value()); } @@ -226,13 +226,13 @@ class DnsClientImpl : public DnsClient { config.nameservers.clear(); if (!config.IsValid()) - return base::nullopt; + return absl::nullopt; return config; } bool UpdateDnsConfig() { - base::Optional new_effective_config = BuildEffectiveConfig(); + absl::optional new_effective_config = BuildEffectiveConfig(); if (IsEqual(new_effective_config, GetEffectiveConfig())) return false; @@ -249,7 +249,7 @@ class DnsClientImpl : public DnsClient { return true; } - void UpdateSession(base::Optional new_effective_config) { + void UpdateSession(absl::optional new_effective_config) { factory_.reset(); session_ = nullptr; @@ -269,7 +269,7 @@ class DnsClientImpl : public DnsClient { bool can_query_additional_types_via_insecure_ = false; int insecure_fallback_failures_ = 0; - base::Optional system_config_; + absl::optional system_config_; DnsConfigOverrides config_overrides_; scoped_refptr session_; diff --git a/net/dns/dns_client.h b/net/dns/dns_client.h index f9c41ed1b8a5fd..6eb4ca7086e509 100644 --- a/net/dns/dns_client.h +++ b/net/dns/dns_client.h @@ -7,12 +7,12 @@ #include -#include "base/optional.h" #include "net/base/net_export.h" #include "net/base/rand_callback.h" #include "net/dns/dns_config.h" #include "net/dns/dns_hosts.h" #include "net/dns/public/dns_config_overrides.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -59,7 +59,7 @@ class NET_EXPORT DnsClient { // config, unless it is invalid or has |unhandled_options|. // // Returns whether or not the effective config changed. - virtual bool SetSystemConfig(base::Optional system_config) = 0; + virtual bool SetSystemConfig(absl::optional system_config) = 0; virtual bool SetConfigOverrides(DnsConfigOverrides config_overrides) = 0; // If there is a current session, forces replacement with a new current @@ -88,7 +88,7 @@ class NET_EXPORT DnsClient { virtual void IncrementInsecureFallbackFailures() = 0; virtual void ClearInsecureFallbackFailures() = 0; - virtual base::Optional GetSystemConfigForTesting() const = 0; + virtual absl::optional GetSystemConfigForTesting() const = 0; virtual DnsConfigOverrides GetConfigOverridesForTesting() const = 0; virtual void SetTransactionFactoryForTesting( diff --git a/net/dns/dns_config_service.cc b/net/dns/dns_config_service.cc index 3ae325c7b9ee47..9b21f6a8b181bb 100644 --- a/net/dns/dns_config_service.cc +++ b/net/dns/dns_config_service.cc @@ -13,13 +13,13 @@ #include "base/logging.h" #include "base/memory/scoped_refptr.h" #include "base/notreached.h" -#include "base/optional.h" #include "base/sequence_checker.h" #include "base/threading/scoped_blocking_call.h" #include "base/threading/sequenced_task_runner_handle.h" #include "base/time/time.h" #include "net/dns/dns_hosts.h" #include "net/dns/serial_worker.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -29,7 +29,7 @@ const base::TimeDelta DnsConfigService::kInvalidationTimeout = DnsConfigService::DnsConfigService( base::FilePath::StringPieceType hosts_file_path, - base::Optional config_change_delay) + absl::optional config_change_delay) : watch_failed_(false), have_config_(false), have_hosts_(false), @@ -98,13 +98,13 @@ DnsConfigService::HostsReader::HostsReader( DnsConfigService::HostsReader::~HostsReader() = default; -base::Optional DnsConfigService::HostsReader::ReadHosts() { +absl::optional DnsConfigService::HostsReader::ReadHosts() { base::ScopedBlockingCall scoped_blocking_call(FROM_HERE, base::BlockingType::MAY_BLOCK); DCHECK(!hosts_file_path_.empty()); DnsHosts dns_hosts; if (!ParseHostsFile(hosts_file_path_, &dns_hosts)) - return base::nullopt; + return absl::nullopt; return dns_hosts; } diff --git a/net/dns/dns_config_service.h b/net/dns/dns_config_service.h index d674225bf25a4d..e0103146b1256b 100644 --- a/net/dns/dns_config_service.h +++ b/net/dns/dns_config_service.h @@ -12,7 +12,6 @@ #include "base/macros.h" #include "base/memory/scoped_refptr.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "base/sequence_checker.h" #include "base/time/time.h" #include "base/timer/timer.h" @@ -20,6 +19,7 @@ #include "net/dns/dns_config.h" #include "net/dns/dns_hosts.h" #include "net/dns/serial_worker.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace net { @@ -49,7 +49,7 @@ class NET_EXPORT_PRIVATE DnsConfigService { // the config is stabilized and ready to be read. explicit DnsConfigService( base::FilePath::StringPieceType hosts_file_path, - base::Optional config_change_delay = + absl::optional config_change_delay = base::TimeDelta::FromMilliseconds(50)); virtual ~DnsConfigService(); @@ -127,7 +127,7 @@ class NET_EXPORT_PRIVATE DnsConfigService { // // Override if needed to implement platform-specific behavior, e.g. for a // platform-specific HOSTS format. - virtual base::Optional ReadHosts(); + virtual absl::optional ReadHosts(); // Adds any necessary additional entries to the given `DnsHosts`. Returns // false on failure. Will be called on a separate blockable ThreadPool @@ -146,7 +146,7 @@ class NET_EXPORT_PRIVATE DnsConfigService { // running on worker thread. DnsConfigService* const service_; // Written in DoWork, read in OnWorkFinished, no locking necessary. - base::Optional hosts_; + absl::optional hosts_; const base::FilePath hosts_file_path_; }; @@ -198,7 +198,7 @@ class NET_EXPORT_PRIVATE DnsConfigService { // Set when |timer_| expires. bool last_sent_empty_; - const base::Optional config_change_delay_; + const absl::optional config_change_delay_; const base::FilePath hosts_file_path_; // Created only if needed in ReadHostsNow() to avoid creating unnecessarily if diff --git a/net/dns/dns_config_service_android.cc b/net/dns/dns_config_service_android.cc index 25afa68b421cce..c5e9d3664cdc56 100644 --- a/net/dns/dns_config_service_android.cc +++ b/net/dns/dns_config_service_android.cc @@ -14,7 +14,6 @@ #include "base/bind.h" #include "base/files/file_path.h" #include "base/logging.h" -#include "base/optional.h" #include "base/sequence_checker.h" #include "base/time/time.h" #include "net/android/network_library.h" @@ -27,6 +26,7 @@ #include "net/dns/dns_config_service.h" #include "net/dns/public/dns_protocol.h" #include "net/dns/serial_worker.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { namespace internal { @@ -164,7 +164,7 @@ class DnsConfigServiceAndroid::ConfigReader : public SerialWorker { // on worker thread. DnsConfigServiceAndroid* const service_; // Written in DoWork, read in OnWorkFinished, no locking necessary. - base::Optional dns_config_; + absl::optional dns_config_; }; DnsConfigServiceAndroid::DnsConfigServiceAndroid() diff --git a/net/dns/dns_config_service_linux.cc b/net/dns/dns_config_service_linux.cc index 2c8c2dedc9f729..f29c5e8d9713f8 100644 --- a/net/dns/dns_config_service_linux.cc +++ b/net/dns/dns_config_service_linux.cc @@ -26,7 +26,6 @@ #include "base/logging.h" #include "base/memory/scoped_refptr.h" #include "base/metrics/histogram_macros.h" -#include "base/optional.h" #include "base/sequence_checker.h" #include "base/threading/scoped_blocking_call.h" #include "base/time/time.h" @@ -34,6 +33,7 @@ #include "net/dns/dns_config.h" #include "net/dns/nsswitch_reader.h" #include "net/dns/serial_worker.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -56,13 +56,13 @@ constexpr base::FilePath::CharType kFilePathResolv[] = _PATH_RESCONF; constexpr base::FilePath::CharType kFilePathNsswitch[] = _PATH_NSSWITCH_CONF; -base::Optional ConvertResStateToDnsConfig( +absl::optional ConvertResStateToDnsConfig( const struct __res_state& res) { DnsConfig dns_config; dns_config.unhandled_options = false; if (!(res.options & RES_INIT)) - return base::nullopt; + return absl::nullopt; static_assert(std::extent() >= MAXNS && std::extent() >= MAXNS, @@ -82,10 +82,10 @@ base::Optional ConvertResStateToDnsConfig( addr = reinterpret_cast(res._u._ext.nsaddrs[i]); addr_len = sizeof *res._u._ext.nsaddrs[i]; } else { - return base::nullopt; + return absl::nullopt; } if (!ipe.FromSockAddr(addr, addr_len)) - return base::nullopt; + return absl::nullopt; dns_config.nameservers.push_back(ipe); } @@ -121,12 +121,12 @@ base::Optional ConvertResStateToDnsConfig( } if (dns_config.nameservers.empty()) - return base::nullopt; + return absl::nullopt; // If any name server is 0.0.0.0, assume the configuration is invalid. for (const IPEndPoint& nameserver : dns_config.nameservers) { if (nameserver.address().IsZero()) - return base::nullopt; + return absl::nullopt; } return dns_config; } @@ -221,7 +221,7 @@ enum class IncompatibleNsswitchReason { void RecordIncompatibleNsswitchReason( IncompatibleNsswitchReason reason, - base::Optional service_token) { + absl::optional service_token) { UMA_HISTOGRAM_ENUMERATION("Net.DNS.DnsConfig.Nsswitch.IncompatibleReason", reason); if (service_token) { @@ -271,7 +271,7 @@ bool IsNsswitchConfigCompatible( if (!files_found) { RecordIncompatibleNsswitchReason( IncompatibleNsswitchReason::kFilesMissing, - /*service_token=*/base::nullopt); + /*service_token=*/absl::nullopt); return false; } // Chrome will always stop if DNS finds a result or will otherwise @@ -339,7 +339,7 @@ bool IsNsswitchConfigCompatible( } RecordIncompatibleNsswitchReason(IncompatibleNsswitchReason::kDnsMissing, - /*service_token=*/base::nullopt); + /*service_token=*/absl::nullopt); return false; } @@ -479,7 +479,7 @@ class DnsConfigServiceLinux::ConfigReader : public SerialWorker { // on worker thread. DnsConfigServiceLinux* const service_; // Written/accessed in DoWork, read in OnWorkFinished, no locking necessary. - base::Optional dns_config_; + absl::optional dns_config_; std::unique_ptr resolv_reader_; std::unique_ptr nsswitch_reader_; }; diff --git a/net/dns/dns_config_service_linux_unittest.cc b/net/dns/dns_config_service_linux_unittest.cc index 30cacaabb39ac9..de79588bf158b6 100644 --- a/net/dns/dns_config_service_linux_unittest.cc +++ b/net/dns/dns_config_service_linux_unittest.cc @@ -15,7 +15,6 @@ #include "base/cancelable_callback.h" #include "base/check.h" #include "base/files/file_util.h" -#include "base/optional.h" #include "base/run_loop.h" #include "base/sequenced_task_runner.h" #include "base/stl_util.h" @@ -32,6 +31,7 @@ #include "net/dns/public/dns_protocol.h" #include "net/test/test_with_task_environment.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -133,13 +133,13 @@ void InitializeExpectedConfig(DnsConfig* config) { class CallbackHelper { public: - base::Optional WaitForResult() { + absl::optional WaitForResult() { run_loop_.Run(); return GetResult(); } - base::Optional GetResult() { - base::Optional result = std::move(config_); + absl::optional GetResult() { + absl::optional result = std::move(config_); return result; } @@ -154,7 +154,7 @@ class CallbackHelper { run_loop_.Quit(); } - base::Optional config_; + absl::optional config_; base::RunLoop run_loop_; }; @@ -240,7 +240,7 @@ TEST_F(DnsConfigServiceLinuxTest, ConvertResStateToDnsConfig) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); ASSERT_TRUE(config.has_value()); EXPECT_TRUE(config->IsValid()); @@ -275,7 +275,7 @@ TEST_F(DnsConfigServiceLinuxTest, RejectEmptyNameserver) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); RunUntilIdle(); - base::Optional config = callback_helper.GetResult(); + absl::optional config = callback_helper.GetResult(); EXPECT_FALSE(config.has_value()); EXPECT_TRUE(resolv_reader_->closed()); @@ -302,7 +302,7 @@ TEST_F(DnsConfigServiceLinuxTest, AcceptNonEmptyNameserver) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(config.has_value()); EXPECT_TRUE(resolv_reader_->closed()); @@ -343,7 +343,7 @@ TEST_F(DnsConfigServiceLinuxTest, AcceptsBasicNsswitchConfig) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -361,7 +361,7 @@ TEST_F(DnsConfigServiceLinuxTest, CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -379,7 +379,7 @@ TEST_F(DnsConfigServiceLinuxTest, RejectsNsswitchWithoutFiles) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -399,7 +399,7 @@ TEST_F(DnsConfigServiceLinuxTest, RejectsWithExtraFiles) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -428,7 +428,7 @@ TEST_F(DnsConfigServiceLinuxTest, IgnoresRedundantActions) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -452,7 +452,7 @@ TEST_F(DnsConfigServiceLinuxTest, RejectsInconsistentActions) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -474,7 +474,7 @@ TEST_F(DnsConfigServiceLinuxTest, RejectsWithBadFilesSuccessAction) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -496,7 +496,7 @@ TEST_F(DnsConfigServiceLinuxTest, RejectsWithBadFilesNotFoundAction) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -514,7 +514,7 @@ TEST_F(DnsConfigServiceLinuxTest, RejectsNsswitchWithoutDns) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -536,7 +536,7 @@ TEST_F(DnsConfigServiceLinuxTest, RejectsWithBadDnsSuccessAction) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -555,7 +555,7 @@ TEST_F(DnsConfigServiceLinuxTest, RejectsNsswitchWithMisorderedServices) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -575,7 +575,7 @@ TEST_F(DnsConfigServiceLinuxTest, AcceptsIncompatibleNsswitchServicesAfterDns) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -595,7 +595,7 @@ TEST_F(DnsConfigServiceLinuxTest, RejectsNsswitchMdns) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -615,7 +615,7 @@ TEST_F(DnsConfigServiceLinuxTest, RejectsNsswitchMdns4) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -635,7 +635,7 @@ TEST_F(DnsConfigServiceLinuxTest, RejectsNsswitchMdns6) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -660,7 +660,7 @@ TEST_F(DnsConfigServiceLinuxTest, AcceptsNsswitchMdnsMinimal) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -693,7 +693,7 @@ TEST_F(DnsConfigServiceLinuxTest, AcceptsNsswitchMdnsMinimalWithCommonActions) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -716,7 +716,7 @@ TEST_F(DnsConfigServiceLinuxTest, RejectsWithBadMdnsMinimalUnavailableAction) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -737,7 +737,7 @@ TEST_F(DnsConfigServiceLinuxTest, AcceptsNsswitchMyHostname) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -760,7 +760,7 @@ TEST_F(DnsConfigServiceLinuxTest, RejectsWithBadMyHostnameNotFoundAction) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -780,7 +780,7 @@ TEST_F(DnsConfigServiceLinuxTest, RejectsNsswitchResolve) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -800,7 +800,7 @@ TEST_F(DnsConfigServiceLinuxTest, AcceptsNsswitchNis) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -823,7 +823,7 @@ TEST_F(DnsConfigServiceLinuxTest, RejectsWithBadNisNotFoundAction) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); @@ -843,7 +843,7 @@ TEST_F(DnsConfigServiceLinuxTest, RejectsNsswitchUnknown) { CallbackHelper callback_helper; service_.ReadConfig(callback_helper.GetCallback()); - base::Optional config = callback_helper.WaitForResult(); + absl::optional config = callback_helper.WaitForResult(); EXPECT_TRUE(resolv_reader_->closed()); ASSERT_TRUE(config.has_value()); diff --git a/net/dns/dns_config_service_posix.cc b/net/dns/dns_config_service_posix.cc index 0bb9da11b80dc0..2de14574f1b7e8 100644 --- a/net/dns/dns_config_service_posix.cc +++ b/net/dns/dns_config_service_posix.cc @@ -16,7 +16,6 @@ #include "base/lazy_instance.h" #include "base/location.h" #include "base/logging.h" -#include "base/optional.h" #include "base/sequence_checker.h" #include "base/single_thread_task_runner.h" #include "base/threading/scoped_blocking_call.h" @@ -27,6 +26,7 @@ #include "net/dns/dns_hosts.h" #include "net/dns/notify_watcher_mac.h" #include "net/dns/serial_worker.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #if defined(OS_MAC) #include "net/dns/dns_config_watcher_mac.h" @@ -87,11 +87,11 @@ class DnsConfigWatcher { }; #endif // defined(OS_IOS) -base::Optional ReadDnsConfig() { +absl::optional ReadDnsConfig() { base::ScopedBlockingCall scoped_blocking_call(FROM_HERE, base::BlockingType::MAY_BLOCK); - base::Optional dns_config; + absl::optional dns_config; // TODO(fuchsia): Use res_ninit() when it's implemented on Fuchsia. #if defined(OS_OPENBSD) || defined(OS_FUCHSIA) // Note: res_ninit in glibc always returns 0 and sets RES_INIT. @@ -118,7 +118,7 @@ base::Optional ReadDnsConfig() { #if defined(OS_MAC) if (!DnsConfigWatcher::CheckDnsConfig( dns_config->unhandled_options /* out_unhandled_options */)) { - return base::nullopt; + return absl::nullopt; } #endif // defined(OS_MAC) // Override |fallback_period| value to match default setting on Windows. @@ -201,7 +201,7 @@ class DnsConfigServicePosix::ConfigReader : public SerialWorker { // on worker thread. DnsConfigServicePosix* const service_; // Written in DoWork, read in OnWorkFinished, no locking necessary. - base::Optional dns_config_; + absl::optional dns_config_; DISALLOW_COPY_AND_ASSIGN(ConfigReader); }; @@ -241,13 +241,13 @@ void DnsConfigServicePosix::CreateReader() { config_reader_ = base::MakeRefCounted(*this); } -base::Optional ConvertResStateToDnsConfig( +absl::optional ConvertResStateToDnsConfig( const struct __res_state& res) { DnsConfig dns_config; dns_config.unhandled_options = false; if (!(res.options & RES_INIT)) - return base::nullopt; + return absl::nullopt; #if defined(OS_APPLE) || defined(OS_FREEBSD) union res_sockaddr_union addresses[MAXNS]; @@ -259,7 +259,7 @@ base::Optional ConvertResStateToDnsConfig( if (!ipe.FromSockAddr( reinterpret_cast(&addresses[i]), sizeof addresses[i])) { - return base::nullopt; + return absl::nullopt; } dns_config.nameservers.push_back(ipe); } @@ -282,10 +282,10 @@ base::Optional ConvertResStateToDnsConfig( addr = reinterpret_cast(res._u._ext.nsaddrs[i]); addr_len = sizeof *res._u._ext.nsaddrs[i]; } else { - return base::nullopt; + return absl::nullopt; } if (!ipe.FromSockAddr(addr, addr_len)) - return base::nullopt; + return absl::nullopt; dns_config.nameservers.push_back(ipe); } #else // !(defined(OS_CHROMEOS) || defined(OS_APPLE) || defined(OS_FREEBSD)) @@ -295,7 +295,7 @@ base::Optional ConvertResStateToDnsConfig( if (!ipe.FromSockAddr( reinterpret_cast(&res.nsaddr_list[i]), sizeof res.nsaddr_list[i])) { - return base::nullopt; + return absl::nullopt; } dns_config.nameservers.push_back(ipe); } @@ -333,13 +333,13 @@ base::Optional ConvertResStateToDnsConfig( } if (dns_config.nameservers.empty()) - return base::nullopt; + return absl::nullopt; // If any name server is 0.0.0.0, assume the configuration is invalid. // TODO(szym): Measure how often this happens. http://crbug.com/125599 for (const IPEndPoint& nameserver : dns_config.nameservers) { if (nameserver.address().IsZero()) - return base::nullopt; + return absl::nullopt; } return dns_config; } diff --git a/net/dns/dns_config_service_posix.h b/net/dns/dns_config_service_posix.h index 8f0f9e0e5a172d..d59134e80cf417 100644 --- a/net/dns/dns_config_service_posix.h +++ b/net/dns/dns_config_service_posix.h @@ -14,9 +14,9 @@ #include "base/compiler_specific.h" #include "base/gtest_prod_util.h" #include "base/macros.h" -#include "base/optional.h" #include "net/base/net_export.h" #include "net/dns/dns_config_service.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { struct DnsConfig; @@ -58,7 +58,7 @@ class NET_EXPORT_PRIVATE DnsConfigServicePosix : public DnsConfigService { }; // Returns nullopt iff a valid config could not be determined. -base::Optional NET_EXPORT_PRIVATE +absl::optional NET_EXPORT_PRIVATE ConvertResStateToDnsConfig(const struct __res_state& res); } // namespace internal diff --git a/net/dns/dns_config_service_posix_unittest.cc b/net/dns/dns_config_service_posix_unittest.cc index 1436b11113471d..003032d902ecce 100644 --- a/net/dns/dns_config_service_posix_unittest.cc +++ b/net/dns/dns_config_service_posix_unittest.cc @@ -8,7 +8,6 @@ #include "base/cancelable_callback.h" #include "base/files/file_util.h" -#include "base/optional.h" #include "base/run_loop.h" #include "base/sequenced_task_runner.h" #include "base/stl_util.h" @@ -21,6 +20,7 @@ #include "net/dns/dns_config.h" #include "net/dns/dns_config_service_posix.h" #include "net/dns/public/dns_protocol.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "base/bind.h" #include "base/task/thread_pool.h" @@ -156,7 +156,7 @@ TEST(DnsConfigServicePosixTest, CreateAndDestroy) { TEST(DnsConfigServicePosixTest, ConvertResStateToDnsConfig) { struct __res_state res; InitializeResState(&res); - base::Optional config = internal::ConvertResStateToDnsConfig(res); + absl::optional config = internal::ConvertResStateToDnsConfig(res); CloseResState(&res); ASSERT_TRUE(config.has_value()); EXPECT_TRUE(config->IsValid()); diff --git a/net/dns/dns_config_service_win.cc b/net/dns/dns_config_service_win.cc index 35ee208d017c69..b6f751bb1068c4 100644 --- a/net/dns/dns_config_service_win.cc +++ b/net/dns/dns_config_service_win.cc @@ -81,7 +81,7 @@ class RegistryReader { ~RegistryReader() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); } - base::Optional ReadString( + absl::optional ReadString( const wchar_t name[]) const { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DnsSystemSettings::RegString reg_string; @@ -99,10 +99,10 @@ class RegistryReader { if (result == ERROR_FILE_NOT_FOUND) return reg_string; - return base::nullopt; + return absl::nullopt; } - base::Optional ReadDword( + absl::optional ReadDword( const wchar_t name[]) const { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DnsSystemSettings::RegDword reg_dword; @@ -120,7 +120,7 @@ class RegistryReader { if (result == ERROR_FILE_NOT_FOUND) return reg_dword; - return base::nullopt; + return absl::nullopt; } private: @@ -152,26 +152,26 @@ std::unique_ptr ReadIpHelper( return out; } -base::Optional ReadDevolutionSetting( +absl::optional ReadDevolutionSetting( const RegistryReader& reader) { DnsSystemSettings::DevolutionSetting setting; - base::Optional reg_value = + absl::optional reg_value = reader.ReadDword(L"UseDomainNameDevolution"); if (!reg_value) - return base::nullopt; + return absl::nullopt; setting.enabled = reg_value.value(); reg_value = reader.ReadDword(L"DomainNameDevolutionLevel"); if (!reg_value) - return base::nullopt; + return absl::nullopt; setting.level = reg_value.value(); return setting; } // Reads DnsSystemSettings from IpHelper and registry. -base::Optional ReadSystemSettings() { +absl::optional ReadSystemSettings() { base::ScopedBlockingCall scoped_blocking_call(FROM_HERE, base::BlockingType::MAY_BLOCK); DnsSystemSettings settings; @@ -180,7 +180,7 @@ base::Optional ReadSystemSettings() { ReadIpHelper(GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_UNICAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_FRIENDLY_NAME); if (!settings.addresses.get()) - return base::nullopt; + return absl::nullopt; RegistryReader tcpip_reader(kTcpipPath); RegistryReader tcpip6_reader(kTcpip6Path); @@ -188,47 +188,47 @@ base::Optional ReadSystemSettings() { RegistryReader policy_reader(kPolicyPath); RegistryReader primary_dns_suffix_reader(kPrimaryDnsSuffixPath); - base::Optional reg_string = + absl::optional reg_string = policy_reader.ReadString(L"SearchList"); if (!reg_string) - return base::nullopt; + return absl::nullopt; settings.policy_search_list = std::move(reg_string).value(); reg_string = tcpip_reader.ReadString(L"SearchList"); if (!reg_string) - return base::nullopt; + return absl::nullopt; settings.tcpip_search_list = std::move(reg_string).value(); reg_string = tcpip_reader.ReadString(L"Domain"); if (!reg_string) - return base::nullopt; + return absl::nullopt; settings.tcpip_domain = std::move(reg_string).value(); - base::Optional devolution_setting = + absl::optional devolution_setting = ReadDevolutionSetting(policy_reader); if (!devolution_setting) - return base::nullopt; + return absl::nullopt; settings.policy_devolution = devolution_setting.value(); devolution_setting = ReadDevolutionSetting(dnscache_reader); if (!devolution_setting) - return base::nullopt; + return absl::nullopt; settings.dnscache_devolution = devolution_setting.value(); devolution_setting = ReadDevolutionSetting(tcpip_reader); if (!devolution_setting) - return base::nullopt; + return absl::nullopt; settings.tcpip_devolution = devolution_setting.value(); - base::Optional reg_dword = + absl::optional reg_dword = policy_reader.ReadDword(L"AppendToMultiLabelName"); if (!reg_dword) - return base::nullopt; + return absl::nullopt; settings.append_to_multi_label_name = reg_dword.value(); reg_string = primary_dns_suffix_reader.ReadString(L"PrimaryDnsSuffix"); if (!reg_string) { - return base::nullopt; + return absl::nullopt; } settings.primary_dns_suffix = std::move(reg_string).value(); @@ -541,7 +541,7 @@ std::vector ParseSearchList(base::WStringPiece value) { return output; } -base::Optional ConvertSettingsToDnsConfig( +absl::optional ConvertSettingsToDnsConfig( const DnsSystemSettings& settings) { bool uses_vpn = false; @@ -579,7 +579,7 @@ base::Optional ConvertSettingsToDnsConfig( ipe = IPEndPoint(ipe.address(), dns_protocol::kDefaultPort); dns_config.nameservers.push_back(ipe); } else { - return base::nullopt; + return absl::nullopt; } } @@ -594,7 +594,7 @@ base::Optional ConvertSettingsToDnsConfig( } if (dns_config.nameservers.empty()) - return base::nullopt; // No point continuing. + return absl::nullopt; // No point continuing. // Windows always tries a multi-label name "as is" before using suffixes. dns_config.ndots = 1; @@ -698,7 +698,7 @@ class DnsConfigServiceWin::ConfigReader : public SerialWorker { ~ConfigReader() override {} void DoWork() override { - base::Optional settings = ReadSystemSettings(); + absl::optional settings = ReadSystemSettings(); if (settings.has_value()) dns_config_ = ConvertSettingsToDnsConfig(settings.value()); } @@ -719,7 +719,7 @@ class DnsConfigServiceWin::ConfigReader : public SerialWorker { DnsConfigServiceWin* service_; // Written in DoWork(), read in OnWorkFinished(). No locking required. - base::Optional dns_config_; + absl::optional dns_config_; }; // Extension of DnsConfigService::HostsReader that fills in localhost and local @@ -745,7 +745,7 @@ class DnsConfigServiceWin::HostsReader : public DnsConfigService::HostsReader { DnsConfigServiceWin::DnsConfigServiceWin() : DnsConfigService(GetHostsPath().value(), - base::nullopt /* config_change_delay */) { + absl::nullopt /* config_change_delay */) { // Allow constructing on one sequence and living on another. DETACH_FROM_SEQUENCE(sequence_checker_); } diff --git a/net/dns/dns_config_service_win.h b/net/dns/dns_config_service_win.h index cd90ff4c78c176..566f7e4ea8b1d2 100644 --- a/net/dns/dns_config_service_win.h +++ b/net/dns/dns_config_service_win.h @@ -116,7 +116,7 @@ struct NET_EXPORT_PRIVATE DnsSystemSettings { // Fills in |dns_config| from |settings|. Exposed for tests. Returns nullopt if // a valid config could not be determined. -base::Optional NET_EXPORT_PRIVATE +absl::optional NET_EXPORT_PRIVATE ConvertSettingsToDnsConfig(const DnsSystemSettings& settings); // Service for reading and watching Windows system DNS settings. This object is diff --git a/net/dns/dns_config_service_win_unittest.cc b/net/dns/dns_config_service_win_unittest.cc index 7b99086240f2a4..dfb207bbc2677a 100644 --- a/net/dns/dns_config_service_win_unittest.cc +++ b/net/dns/dns_config_service_win_unittest.cc @@ -9,12 +9,12 @@ #include "base/check.h" #include "base/memory/free_deleter.h" -#include "base/optional.h" #include "net/base/ip_address.h" #include "net/base/ip_endpoint.h" #include "net/dns/public/dns_protocol.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 net { @@ -177,7 +177,7 @@ TEST(DnsConfigServiceWinTest, ConvertAdapterAddresses) { expected_nameservers.push_back(IPEndPoint(ip, port)); } - base::Optional config = + absl::optional config = internal::ConvertSettingsToDnsConfig(settings); bool expected_success = !expected_nameservers.empty(); EXPECT_EQ(expected_success, config.has_value()); @@ -432,7 +432,7 @@ TEST(DnsConfigServiceWinTest, HaveNRPT) { internal::DnsSystemSettings settings; settings.addresses = CreateAdapterAddresses(infos); settings.have_name_resolution_policy = t.have_nrpt; - base::Optional config = + absl::optional config = internal::ConvertSettingsToDnsConfig(settings); ASSERT_TRUE(config.has_value()); EXPECT_EQ(t.unhandled_options, config->unhandled_options); diff --git a/net/dns/dns_query.cc b/net/dns/dns_query.cc index eb6d6e756da2af..746a962a89f617 100644 --- a/net/dns/dns_query.cc +++ b/net/dns/dns_query.cc @@ -10,12 +10,12 @@ #include "base/logging.h" #include "base/memory/ptr_util.h" #include "base/numerics/safe_conversions.h" -#include "base/optional.h" #include "base/sys_byteorder.h" #include "net/base/io_buffer.h" #include "net/dns/dns_util.h" #include "net/dns/public/dns_protocol.h" #include "net/dns/record_rdata.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -58,13 +58,13 @@ size_t DeterminePaddingSize(size_t unpadded_size, } } -base::Optional AddPaddingIfNecessary( +absl::optional AddPaddingIfNecessary( const OptRecordRdata* opt_rdata, DnsQuery::PaddingStrategy padding_strategy, size_t no_opt_buffer_size) { // If no input OPT record rdata and no padding, no OPT record rdata needed. if (!opt_rdata && padding_strategy == DnsQuery::PaddingStrategy::NONE) - return base::nullopt; + return absl::nullopt; OptRecordRdata merged_opt_rdata; if (opt_rdata) @@ -101,12 +101,12 @@ DnsQuery::DnsQuery(uint16_t id, PaddingStrategy padding_strategy) : qname_size_(qname.size()) { #if DCHECK_IS_ON() - base::Optional dotted_name = DnsDomainToString(qname); + absl::optional dotted_name = DnsDomainToString(qname); DCHECK(dotted_name && !dotted_name.value().empty()); #endif // DCHECK_IS_ON() size_t buffer_size = kHeaderSize + QuestionSize(qname_size_); - base::Optional merged_opt_rdata = + absl::optional merged_opt_rdata = AddPaddingIfNecessary(opt_rdata, padding_strategy, buffer_size); if (merged_opt_rdata) buffer_size += OptRecordSize(&merged_opt_rdata.value()); diff --git a/net/dns/dns_response.cc b/net/dns/dns_response.cc index d249068d4595b0..2706bbe88af517 100644 --- a/net/dns/dns_response.cc +++ b/net/dns/dns_response.cc @@ -13,7 +13,6 @@ #include "base/big_endian.h" #include "base/logging.h" #include "base/numerics/safe_conversions.h" -#include "base/optional.h" #include "base/strings/string_util.h" #include "base/sys_byteorder.h" #include "net/base/io_buffer.h" @@ -23,6 +22,7 @@ #include "net/dns/dns_util.h" #include "net/dns/public/dns_protocol.h" #include "net/dns/record_rdata.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -271,7 +271,7 @@ DnsResponse::DnsResponse( const std::vector& answers, const std::vector& authority_records, const std::vector& additional_records, - const base::Optional& query, + const absl::optional& query, uint8_t rcode, bool validate_records) { bool has_query = query.has_value(); @@ -407,7 +407,7 @@ bool DnsResponse::InitParse(size_t nbytes, const DnsQuery& query) { return false; } - base::Optional dotted_qname = DnsDomainToString(query.qname()); + absl::optional dotted_qname = DnsDomainToString(query.qname()); if (!dotted_qname.has_value()) return false; dotted_qnames_.push_back(std::move(dotted_qname).value()); @@ -459,9 +459,9 @@ bool DnsResponse::InitParseWithoutQuery(size_t nbytes) { return true; } -base::Optional DnsResponse::id() const { +absl::optional DnsResponse::id() const { if (!id_available_) - return base::nullopt; + return absl::nullopt; return base::NetToHost16(header()->id); } @@ -562,7 +562,7 @@ bool DnsResponse::WriteRecord(base::BigEndianWriter* writer, bool DnsResponse::WriteAnswer(base::BigEndianWriter* writer, const DnsResourceRecord& answer, - const base::Optional& query, + const absl::optional& query, bool validate_record) { // Generally assumed to be a mistake if we write answers that don't match the // query type, except CNAME answers which can always be added. diff --git a/net/dns/dns_response.h b/net/dns/dns_response.h index ebc3eec93c9532..2640c7e3c684f7 100644 --- a/net/dns/dns_response.h +++ b/net/dns/dns_response.h @@ -13,11 +13,11 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "base/strings/string_piece.h" #include "net/base/net_export.h" #include "net/dns/dns_response_result_extractor.h" #include "net/dns/public/dns_protocol.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { class BigEndianWriter; @@ -135,7 +135,7 @@ class NET_EXPORT_PRIVATE DnsResponse { const std::vector& answers, const std::vector& authority_records, const std::vector& additional_records, - const base::Optional& query, + const absl::optional& query, uint8_t rcode = dns_protocol::kRcodeNOERROR, bool validate_records = true); @@ -176,7 +176,7 @@ class NET_EXPORT_PRIVATE DnsResponse { // nullopt if the ID is unknown. The ID will only be known if the response is // successfully constructed from data or if InitParse...() has been able to // parse at least as far as the ID (not necessarily a fully successful parse). - base::Optional id() const; + absl::optional id() const; // Returns true if response is valid, that is, after successful InitParse, or // after successful construction of a new response from data. @@ -224,7 +224,7 @@ class NET_EXPORT_PRIVATE DnsResponse { bool validate_record); bool WriteAnswer(base::BigEndianWriter* writer, const DnsResourceRecord& answer, - const base::Optional& query, + const absl::optional& query, bool validate_record); // Convenience for header access. diff --git a/net/dns/dns_response_fuzzer.cc b/net/dns/dns_response_fuzzer.cc index 1c989a7e9c525a..346d22c39934d2 100644 --- a/net/dns/dns_response_fuzzer.cc +++ b/net/dns/dns_response_fuzzer.cc @@ -8,7 +8,6 @@ #include #include "base/check.h" -#include "base/optional.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_piece.h" #include "net/base/io_buffer.h" @@ -16,13 +15,14 @@ #include "net/dns/dns_response.h" #include "net/dns/dns_util.h" #include "net/dns/public/dns_protocol.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace { void ValidateParsedResponse( net::DnsResponse& response, const net::IOBufferWithSize& packet, - base::Optional query = base::nullopt) { + absl::optional query = absl::nullopt) { CHECK_EQ(response.io_buffer(), &packet); CHECK_EQ(static_cast(response.io_buffer_size()), packet.size()); @@ -63,7 +63,7 @@ void ValidateParsedResponse( if (query) { CHECK_EQ(response.question_count(), 1u); CHECK_EQ(response.id().value(), query->id()); - base::Optional dotted_qname = + absl::optional dotted_qname = net::DnsDomainToString(query->qname(), /*require_complete=*/true); CHECK(dotted_qname.has_value()); CHECK_EQ(response.GetSingleDottedName(), dotted_qname.value()); diff --git a/net/dns/dns_response_result_extractor.cc b/net/dns/dns_response_result_extractor.cc index c09863bf67637b..5aea3c8c0ab5a3 100644 --- a/net/dns/dns_response_result_extractor.cc +++ b/net/dns/dns_response_result_extractor.cc @@ -19,7 +19,6 @@ #include "base/metrics/histogram_macros.h" #include "base/notreached.h" #include "base/numerics/checked_math.h" -#include "base/optional.h" #include "base/rand_util.h" #include "base/strings/string_piece.h" #include "base/strings/string_util.h" @@ -37,6 +36,7 @@ #include "net/dns/public/dns_query_type.h" #include "net/dns/record_parsed.h" #include "net/dns/record_rdata.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -181,14 +181,14 @@ ExtractionError ExtractResponseRecords( const DnsResponse& response, uint16_t result_qtype, std::vector>* out_records, - base::Optional* out_response_ttl, + absl::optional* out_response_ttl, std::vector* out_aliases) { DCHECK_EQ(response.question_count(), 1u); DCHECK(out_records); DCHECK(out_response_ttl); std::vector> records; - base::Optional response_ttl; + absl::optional response_ttl; DnsRecordParser parser = response.Parser(); @@ -285,7 +285,7 @@ ExtractionError ExtractAddressResults(const DnsResponse& response, DCHECK(out_results); std::vector> records; - base::Optional response_ttl; + absl::optional response_ttl; std::vector aliases; ExtractionError extraction_error = ExtractResponseRecords( response, address_qtype, &records, &response_ttl, &aliases); @@ -349,7 +349,7 @@ ExtractionError ExtractTxtResults(const DnsResponse& response, DCHECK(out_results); std::vector> records; - base::Optional response_ttl; + absl::optional response_ttl; ExtractionError extraction_error = ExtractResponseRecords(response, dns_protocol::kTypeTXT, &records, &response_ttl, nullptr /* out_aliases */); @@ -378,7 +378,7 @@ ExtractionError ExtractPointerResults(const DnsResponse& response, DCHECK(out_results); std::vector> records; - base::Optional response_ttl; + absl::optional response_ttl; ExtractionError extraction_error = ExtractResponseRecords(response, dns_protocol::kTypePTR, &records, &response_ttl, nullptr /* out_aliases */); @@ -410,7 +410,7 @@ ExtractionError ExtractServiceResults(const DnsResponse& response, DCHECK(out_results); std::vector> records; - base::Optional response_ttl; + absl::optional response_ttl; ExtractionError extraction_error = ExtractResponseRecords(response, dns_protocol::kTypeSRV, &records, &response_ttl, nullptr /* out_aliases */); @@ -444,7 +444,7 @@ ExtractionError ExtractIntegrityResults(const DnsResponse& response, HostCache::Entry* out_results) { DCHECK(out_results); - base::Optional response_ttl; + absl::optional response_ttl; std::vector> records; ExtractionError extraction_error = ExtractResponseRecords( response, dns_protocol::kExperimentalTypeIntegrity, &records, @@ -492,7 +492,7 @@ ExtractionError ExtractHttpsResults(const DnsResponse& response, HostCache::Entry* out_results) { DCHECK(out_results); - base::Optional response_ttl; + absl::optional response_ttl; std::vector> records; ExtractionError extraction_error = ExtractResponseRecords(response, dns_protocol::kTypeHttps, &records, diff --git a/net/dns/dns_response_result_extractor_unittest.cc b/net/dns/dns_response_result_extractor_unittest.cc index 6a0e32fd60cdc6..86306844594875 100644 --- a/net/dns/dns_response_result_extractor_unittest.cc +++ b/net/dns/dns_response_result_extractor_unittest.cc @@ -8,7 +8,6 @@ #include #include -#include "base/optional.h" #include "net/base/host_port_pair.h" #include "net/base/ip_address.h" #include "net/base/ip_endpoint.h" @@ -22,6 +21,7 @@ #include "net/test/gtest_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { namespace { @@ -468,7 +468,7 @@ TEST(DnsResponseResultExtractorTest, ExtractsSrvResponses) { EXPECT_THAT(results.error(), test::IsOk()); // Expect ordered by priority, and random within a priority. - base::Optional> result_hosts = results.hostnames(); + absl::optional> result_hosts = results.hostnames(); ASSERT_THAT( result_hosts, testing::Optional(testing::UnorderedElementsAre( diff --git a/net/dns/dns_response_unittest.cc b/net/dns/dns_response_unittest.cc index 88451e004f2eff..bb30e0ddc8895e 100644 --- a/net/dns/dns_response_unittest.cc +++ b/net/dns/dns_response_unittest.cc @@ -11,7 +11,6 @@ #include "base/big_endian.h" #include "base/check.h" -#include "base/optional.h" #include "base/stl_util.h" #include "base/strings/string_piece.h" #include "base/time/time.h" @@ -23,6 +22,7 @@ #include "net/dns/record_rdata.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 net { @@ -1251,7 +1251,7 @@ TEST(DnsResponseWriteTest, SingleARecordAnswer) { std::vector answers(1, answer); DnsResponse response(0x1234 /* response_id */, true /* is_authoritative*/, answers, {} /* authority_records */, - {} /* additional records */, base::nullopt); + {} /* additional records */, absl::nullopt); ASSERT_NE(nullptr, response.io_buffer()); EXPECT_TRUE(response.IsValid()); std::string expected_response(response_data, sizeof(response_data)); @@ -1286,7 +1286,7 @@ TEST(DnsResponseWriteTest, SingleARecordAnswerWithFinalDotInName) { std::vector answers(1, answer); DnsResponse response(0x1234 /* response_id */, true /* is_authoritative*/, answers, {} /* authority_records */, - {} /* additional records */, base::nullopt); + {} /* additional records */, absl::nullopt); ASSERT_NE(nullptr, response.io_buffer()); EXPECT_TRUE(response.IsValid()); std::string expected_response(response_data, sizeof(response_data)); @@ -1322,7 +1322,7 @@ TEST(DnsResponseWriteTest, SingleARecordAnswerWithQuestion) { ASSERT_TRUE(DNSDomainFromDot(dotted_name, &dns_name)); OptRecordRdata opt_rdata; opt_rdata.AddOpt(OptRecordRdata::Opt(255, "\xde\xad\xbe\xef")); - base::Optional query; + absl::optional query; query.emplace(0x1234 /* id */, dns_name, dns_protocol::kTypeA, &opt_rdata); net::DnsResourceRecord answer; answer.name = dotted_name; @@ -1385,7 +1385,7 @@ TEST(DnsResponseWriteTest, writer.WriteU16(dns_protocol::kTypeA); // qtype writer.WriteU16(dns_protocol::kClassIN); // qclass // buf contains 10 extra zero bytes. - base::Optional query; + absl::optional query; query.emplace(buf); query->Parse(buf_size); net::DnsResourceRecord answer; @@ -1434,7 +1434,7 @@ TEST(DnsResponseWriteTest, SingleQuadARecordAnswer) { std::vector answers(1, answer); DnsResponse response(0x1234 /* id */, true /* is_authoritative*/, answers, {} /* authority_records */, {} /* additional records */, - base::nullopt); + absl::nullopt); ASSERT_NE(nullptr, response.io_buffer()); EXPECT_TRUE(response.IsValid()); std::string expected_response(response_data, sizeof(response_data)); @@ -1479,7 +1479,7 @@ TEST(DnsResponseWriteTest, std::string dotted_name("www.example.com"); std::string dns_name; ASSERT_TRUE(DNSDomainFromDot(dotted_name, &dns_name)); - base::Optional query; + absl::optional query; query.emplace(0x1234 /* id */, dns_name, dns_protocol::kTypeA); net::DnsResourceRecord answer; answer.name = dotted_name; @@ -1549,7 +1549,7 @@ TEST(DnsResponseWriteTest, TwoAnswersWithAAndQuadARecords) { answers[1] = answer2; DnsResponse response(0x1234 /* id */, true /* is_authoritative*/, answers, {} /* authority_records */, {} /* additional records */, - base::nullopt); + absl::nullopt); ASSERT_NE(nullptr, response.io_buffer()); EXPECT_TRUE(response.IsValid()); std::string expected_response(response_data, sizeof(response_data)); @@ -1584,7 +1584,7 @@ TEST(DnsResponseWriteTest, AnswerWithAuthorityRecord) { std::vector authority_records(1, record); DnsResponse response(0x1235 /* response_id */, true /* is_authoritative*/, {} /* answers */, authority_records, - {} /* additional records */, base::nullopt); + {} /* additional records */, absl::nullopt); ASSERT_NE(nullptr, response.io_buffer()); EXPECT_TRUE(response.IsValid()); std::string expected_response(response_data, sizeof(response_data)); @@ -1604,7 +1604,7 @@ TEST(DnsResponseWriteTest, AnswerWithRcode) { }; DnsResponse response(0x1212 /* response_id */, false /* is_authoritative*/, {} /* answers */, {} /* authority_records */, - {} /* additional records */, base::nullopt, + {} /* additional records */, absl::nullopt, dns_protocol::kRcodeNXDOMAIN); ASSERT_NE(nullptr, response.io_buffer()); EXPECT_TRUE(response.IsValid()); @@ -1629,7 +1629,7 @@ TEST(DnsResponseWriteTest, AAAAQuestionAndCnameAnswer) { answer.SetOwnedRdata(dns_name); std::vector answers(1, answer); - base::Optional query(absl::in_place, 114 /* id */, dns_name, + absl::optional query(absl::in_place, 114 /* id */, dns_name, dns_protocol::kTypeAAAA); DnsResponse response(114 /* response_id */, true /* is_authoritative*/, @@ -1657,7 +1657,7 @@ TEST(DnsResponseWriteTest, WrittenResponseCanBeParsed) { std::vector additional_records(1, additional_record); DnsResponse response(0x1234 /* response_id */, true /* is_authoritative*/, answers, {} /* authority_records */, additional_records, - base::nullopt); + absl::nullopt); ASSERT_NE(nullptr, response.io_buffer()); EXPECT_TRUE(response.IsValid()); EXPECT_THAT(response.id(), testing::Optional(0x1234)); diff --git a/net/dns/dns_server_iterator.cc b/net/dns/dns_server_iterator.cc index 9d25870ce53a54..fdf6b559895af0 100644 --- a/net/dns/dns_server_iterator.cc +++ b/net/dns/dns_server_iterator.cc @@ -4,10 +4,10 @@ #include "net/dns/dns_server_iterator.h" -#include "base/optional.h" #include "base/time/time.h" #include "net/dns/dns_session.h" #include "net/dns/resolve_context.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { DnsServerIterator::DnsServerIterator(size_t nameservers_size, @@ -34,7 +34,7 @@ size_t DohDnsServerIterator::GetNextAttemptIndex() { // Check if the next index is available and hasn't hit its failure limit. If // not, try the next one and so on until we've tried them all. - base::Optional least_recently_failed_index; + absl::optional least_recently_failed_index; base::TimeTicks least_recently_failed_time; size_t previous_index = next_index_; @@ -108,7 +108,7 @@ size_t ClassicDnsServerIterator::GetNextAttemptIndex() { // Check if the next index is available and hasn't hit its failure limit. If // not, try the next one and so on until we've tried them all. - base::Optional least_recently_failed_index; + absl::optional least_recently_failed_index; base::TimeTicks least_recently_failed_time; size_t previous_index = next_index_; diff --git a/net/dns/dns_test_util.cc b/net/dns/dns_test_util.cc index 4868302c6493c0..4c86ee8434d143 100644 --- a/net/dns/dns_test_util.cc +++ b/net/dns/dns_test_util.cc @@ -196,7 +196,7 @@ DnsResponse BuildTestDnsResponse( std::string dns_name; CHECK(DNSDomainFromDot(name, &dns_name)); - base::Optional query(absl::in_place, 0, std::move(dns_name), type); + absl::optional query(absl::in_place, 0, std::move(dns_name), type); return DnsResponse(0, true /* is_authoritative */, answers, authority /* authority_records */, additional /* additional_records */, query, rcode, @@ -305,7 +305,7 @@ DnsResponse BuildTestDnsServiceResponse( } MockDnsClientRule::Result::Result(ResultType type, - base::Optional response) + absl::optional response) : type(type), response(std::move(response)) {} MockDnsClientRule::Result::Result(DnsResponse response) @@ -376,7 +376,7 @@ class MockDnsTransactionFactory::MockTransaction std::vector authority_records; std::string dns_name; CHECK(DNSDomainFromDot(hostname_, &dns_name)); - base::Optional query(absl::in_place, 22 /* id */, dns_name, + absl::optional query(absl::in_place, 22 /* id */, dns_name, qtype_); switch (result->type) { case MockDnsClientRule::NODOMAIN: @@ -470,27 +470,27 @@ class MockDnsTransactionFactory::MockTransaction std::move(callback_).Run( this, ERR_NAME_NOT_RESOLVED, result_.response ? &result_.response.value() : nullptr, - base::nullopt); + absl::nullopt); break; case MockDnsClientRule::EMPTY: case MockDnsClientRule::OK: case MockDnsClientRule::MALFORMED: std::move(callback_).Run( this, OK, result_.response ? &result_.response.value() : nullptr, - base::nullopt); + absl::nullopt); break; case MockDnsClientRule::TIMEOUT: std::move(callback_).Run(this, ERR_DNS_TIMED_OUT, nullptr, - base::nullopt); + absl::nullopt); break; case MockDnsClientRule::SLOW: if (result_.response) { std::move(callback_).Run( this, OK, result_.response ? &result_.response.value() : nullptr, - base::nullopt); + absl::nullopt); } else { std::move(callback_).Run(this, ERR_DNS_TIMED_OUT, nullptr, - base::nullopt); + absl::nullopt); } } } @@ -632,11 +632,11 @@ bool MockDnsClient::FallbackFromInsecureTransactionPreferred() const { fallback_failures_ >= max_fallback_failures_; } -bool MockDnsClient::SetSystemConfig(base::Optional system_config) { +bool MockDnsClient::SetSystemConfig(absl::optional system_config) { if (ignore_system_config_changes_) return false; - base::Optional before = effective_config_; + absl::optional before = effective_config_; config_ = std::move(system_config); effective_config_ = BuildEffectiveConfig(); session_ = BuildSession(); @@ -644,7 +644,7 @@ bool MockDnsClient::SetSystemConfig(base::Optional system_config) { } bool MockDnsClient::SetConfigOverrides(DnsConfigOverrides config_overrides) { - base::Optional before = effective_config_; + absl::optional before = effective_config_; overrides_ = std::move(config_overrides); effective_config_ = BuildEffectiveConfig(); session_ = BuildSession(); @@ -688,7 +688,7 @@ void MockDnsClient::ClearInsecureFallbackFailures() { fallback_failures_ = 0; } -base::Optional MockDnsClient::GetSystemConfigForTesting() const { +absl::optional MockDnsClient::GetSystemConfigForTesting() const { return config_; } @@ -714,11 +714,11 @@ void MockDnsClient::SetForceDohServerAvailable(bool available) { factory_->set_force_doh_server_available(available); } -base::Optional MockDnsClient::BuildEffectiveConfig() { +absl::optional MockDnsClient::BuildEffectiveConfig() { if (overrides_.OverridesEverything()) return overrides_.ApplyOverrides(DnsConfig()); if (!config_ || !config_.value().IsValid()) - return base::nullopt; + return absl::nullopt; return overrides_.ApplyOverrides(config_.value()); } diff --git a/net/dns/dns_test_util.h b/net/dns/dns_test_util.h index 40a2cb44ca1ced..5e2895b4964c22 100644 --- a/net/dns/dns_test_util.h +++ b/net/dns/dns_test_util.h @@ -16,7 +16,6 @@ #include "base/memory/scoped_refptr.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "base/stl_util.h" #include "base/time/time.h" #include "net/dns/dns_client.h" @@ -27,6 +26,7 @@ #include "net/dns/public/dns_protocol.h" #include "net/dns/public/secure_dns_mode.h" #include "net/socket/socket_test_util.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -291,7 +291,7 @@ struct MockDnsClientRule { struct Result { explicit Result(ResultType type, - base::Optional response = base::nullopt); + absl::optional response = absl::nullopt); explicit Result(DnsResponse response); Result(Result&& result); ~Result(); @@ -299,7 +299,7 @@ struct MockDnsClientRule { Result& operator=(Result&& result); ResultType type; - base::Optional response; + absl::optional response; }; // If |delay| is true, matching transactions will be delayed until triggered @@ -387,7 +387,7 @@ class MockDnsClient : public DnsClient { bool FallbackFromSecureTransactionPreferred( ResolveContext* resolve_context) const override; bool FallbackFromInsecureTransactionPreferred() const override; - bool SetSystemConfig(base::Optional system_config) override; + bool SetSystemConfig(absl::optional system_config) override; bool SetConfigOverrides(DnsConfigOverrides config_overrides) override; void ReplaceCurrentSession() override; DnsSession* GetCurrentSession() override; @@ -397,7 +397,7 @@ class MockDnsClient : public DnsClient { AddressSorter* GetAddressSorter() override; void IncrementInsecureFallbackFailures() override; void ClearInsecureFallbackFailures() override; - base::Optional GetSystemConfigForTesting() const override; + absl::optional GetSystemConfigForTesting() const override; DnsConfigOverrides GetConfigOverridesForTesting() const override; void SetTransactionFactoryForTesting( std::unique_ptr factory) override; @@ -422,7 +422,7 @@ class MockDnsClient : public DnsClient { MockDnsTransactionFactory* factory() { return factory_.get(); } private: - base::Optional BuildEffectiveConfig(); + absl::optional BuildEffectiveConfig(); scoped_refptr BuildSession(); bool insecure_enabled_ = false; @@ -438,10 +438,10 @@ class MockDnsClient : public DnsClient { bool force_doh_server_available_ = true; MockClientSocketFactory socket_factory_; - base::Optional config_; + absl::optional config_; scoped_refptr session_; DnsConfigOverrides overrides_; - base::Optional effective_config_; + absl::optional effective_config_; std::unique_ptr factory_; std::unique_ptr address_sorter_; }; diff --git a/net/dns/dns_transaction.cc b/net/dns/dns_transaction.cc index d44d5fa1a9f2c7..bb17713af78007 100644 --- a/net/dns/dns_transaction.cc +++ b/net/dns/dns_transaction.cc @@ -24,7 +24,6 @@ #include "base/memory/weak_ptr.h" #include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_macros.h" -#include "base/optional.h" #include "base/rand_util.h" #include "base/single_thread_task_runner.h" #include "base/stl_util.h" @@ -76,6 +75,7 @@ #include "net/url_request/url_fetcher_response_writer.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_builder.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -1200,7 +1200,7 @@ class DnsTransactionImpl : public DnsTransaction, net_log_.EndEventWithNetErrorCode(NetLogEventType::DNS_TRANSACTION, result.rv); - base::Optional doh_provider_id; + absl::optional doh_provider_id; if (secure_ && result.attempt) { size_t server_index = result.attempt->server_index(); doh_provider_id = GetDohProviderIdForHistogramFromDohConfig( @@ -1381,7 +1381,7 @@ class DnsTransactionImpl : public DnsTransaction, // Begins query for the current name. Makes the first attempt. AttemptResult StartQuery() { - base::Optional dotted_qname = + absl::optional dotted_qname = DnsDomainToString(qnames_.front()); net_log_.BeginEventWithStringParams( NetLogEventType::DNS_TRANSACTION_QUERY, "qname", diff --git a/net/dns/dns_transaction.h b/net/dns/dns_transaction.h index 3444a37117e28a..ad04ad80ac4a8d 100644 --- a/net/dns/dns_transaction.h +++ b/net/dns/dns_transaction.h @@ -87,7 +87,7 @@ class NET_EXPORT_PRIVATE DnsTransactionFactory { typedef base::OnceCallback doh_provider_id)> + absl::optional doh_provider_id)> CallbackType; DnsTransactionFactory(); diff --git a/net/dns/dns_transaction_unittest.cc b/net/dns/dns_transaction_unittest.cc index 3c77651ce78841..a7561dfbe452a2 100644 --- a/net/dns/dns_transaction_unittest.cc +++ b/net/dns/dns_transaction_unittest.cc @@ -15,7 +15,6 @@ #include "base/bind.h" #include "base/containers/circular_deque.h" #include "base/numerics/safe_math.h" -#include "base/optional.h" #include "base/rand_util.h" #include "base/run_loop.h" #include "base/stl_util.h" @@ -60,6 +59,7 @@ #include "net/url_request/url_request_test_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" using net::test::IsOk; @@ -298,8 +298,8 @@ class TestSocketFactory : public MockClientSocketFactory { explicit RemoteNameserver(DnsOverHttpsServerConfig secure_nameserver) : secure_nameserver(secure_nameserver) {} - base::Optional insecure_nameserver; - base::Optional secure_nameserver; + absl::optional insecure_nameserver; + absl::optional secure_nameserver; }; std::vector remote_endpoints_; @@ -360,7 +360,7 @@ class TransactionHelper { void OnTransactionComplete(DnsTransaction* t, int rv, const DnsResponse* response, - base::Optional doh_provider_id) { + absl::optional doh_provider_id) { EXPECT_FALSE(completed_); EXPECT_EQ(transaction_.get(), t); @@ -2411,7 +2411,7 @@ TEST_F(DnsTransactionTest, HttpsPostTestNoCookies) { config_.dns_over_https_servers[0].server_template)); auto cookie = CanonicalCookie::Create( cookie_url, "test-cookie=you-still-fail", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); request_context_->cookie_store()->SetCanonicalCookieAsync( std::move(cookie), cookie_url, CookieOptions(), base::BindOnce(&CookieCallback::SetCookieCallback, diff --git a/net/dns/dns_util.cc b/net/dns/dns_util.cc index 94735a72cfbd2b..362320ff05f2de 100644 --- a/net/dns/dns_util.cc +++ b/net/dns/dns_util.cc @@ -16,7 +16,6 @@ #include "base/containers/contains.h" #include "base/metrics/field_trial.h" #include "base/metrics/histogram_macros.h" -#include "base/optional.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" #include "build/build_config.h" @@ -26,6 +25,7 @@ #include "net/dns/public/doh_provider_entry.h" #include "net/dns/public/util.h" #include "net/third_party/uri_template/uri_template.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/url_canon.h" #if defined(OS_POSIX) @@ -147,13 +147,13 @@ bool IsValidHostLabelCharacter(char c, bool is_first_char) { (c >= '0' && c <= '9') || (!is_first_char && c == '-') || c == '_'; } -base::Optional DnsDomainToString(base::StringPiece dns_name, +absl::optional DnsDomainToString(base::StringPiece dns_name, bool require_complete) { base::BigEndianReader reader(dns_name.data(), dns_name.length()); return DnsDomainToString(reader, require_complete); } -base::Optional DnsDomainToString(base::BigEndianReader& reader, +absl::optional DnsDomainToString(base::BigEndianReader& reader, bool require_complete) { std::string ret; size_t octets_read = 0; @@ -162,20 +162,20 @@ base::Optional DnsDomainToString(base::BigEndianReader& reader, // the context of a full DNS message. if ((*reader.ptr() & dns_protocol::kLabelMask) == dns_protocol::kLabelPointer) - return base::nullopt; + return absl::nullopt; base::StringPiece label; if (!reader.ReadU8LengthPrefixed(&label)) - return base::nullopt; + return absl::nullopt; // Final zero-length label not included in size enforcement. if (label.size() != 0) octets_read += label.size() + 1; if (label.size() > dns_protocol::kMaxLabelLength) - return base::nullopt; + return absl::nullopt; if (octets_read > dns_protocol::kMaxNameLength) - return base::nullopt; + return absl::nullopt; if (label.size() == 0) return ret; @@ -187,7 +187,7 @@ base::Optional DnsDomainToString(base::BigEndianReader& reader, } if (require_complete) - return base::nullopt; + return absl::nullopt; // If terminating zero-length label was not included in the input, no need to // recheck against max name length because terminating zero-length label does diff --git a/net/dns/dns_util.h b/net/dns/dns_util.h index 33114a93db215c..0f1b57dcc93ec6 100644 --- a/net/dns/dns_util.h +++ b/net/dns/dns_util.h @@ -8,7 +8,6 @@ #include #include -#include "base/optional.h" #include "base/strings/string_piece.h" #include "base/strings/string_util.h" #include "base/time/time.h" @@ -19,6 +18,7 @@ #include "net/dns/public/dns_over_https_server_config.h" #include "net/dns/public/dns_query_type.h" #include "net/dns/public/secure_dns_mode.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { class BigEndianReader; @@ -79,10 +79,10 @@ NET_EXPORT_PRIVATE bool IsValidHostLabelCharacter(char c, bool is_first_char); // DNS name compression (see RFC 1035, section 4.1.4) is disallowed and // considered malformed. To handle a potentially compressed name, in a // DnsResponse object, use DnsRecordParser::ReadName(). -NET_EXPORT base::Optional DnsDomainToString( +NET_EXPORT absl::optional DnsDomainToString( base::StringPiece dns_name, bool require_complete = false); -NET_EXPORT base::Optional DnsDomainToString( +NET_EXPORT absl::optional DnsDomainToString( base::BigEndianReader& reader, bool require_complete = false); diff --git a/net/dns/dns_util_unittest.cc b/net/dns/dns_util_unittest.cc index 2b9087ad185142..0bcb4c8176d7bb 100644 --- a/net/dns/dns_util_unittest.cc +++ b/net/dns/dns_util_unittest.cc @@ -11,11 +11,11 @@ #include "base/big_endian.h" #include "base/numerics/safe_conversions.h" -#include "base/optional.h" #include "base/stl_util.h" #include "net/dns/public/dns_protocol.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 net { @@ -135,10 +135,10 @@ TEST_F(DNSUtilTest, DnsDomainToStringShouldRejectEmptyIncomplete) { testing::Optional(Eq(""))); EXPECT_EQ(DnsDomainToString(dns_name, true /* require_complete */), - base::nullopt); + absl::nullopt); base::BigEndianReader reader1(dns_name.c_str(), dns_name.size()); EXPECT_EQ(DnsDomainToString(reader1, true /* require_complete */), - base::nullopt); + absl::nullopt); } // Test `require_complete` functionality given an input with terminating zero- @@ -172,10 +172,10 @@ TEST_F(DNSUtilTest, DnsDomainToStringNotComplete) { testing::Optional(Eq("boo.test"))); EXPECT_EQ(DnsDomainToString(dns_name, true /* require_complete */), - base::nullopt); + absl::nullopt); base::BigEndianReader reader2(dns_name.c_str(), dns_name.size()); EXPECT_EQ(DnsDomainToString(reader2, true /* require_complete */), - base::nullopt); + absl::nullopt); } TEST_F(DNSUtilTest, DnsDomainToStringShouldRejectEmptyWhenRequiringComplete) { @@ -188,10 +188,10 @@ TEST_F(DNSUtilTest, DnsDomainToStringShouldRejectEmptyWhenRequiringComplete) { testing::Optional(Eq(""))); EXPECT_EQ(DnsDomainToString(dns_name, true /* require_complete */), - base::nullopt); + absl::nullopt); base::BigEndianReader reader1(dns_name.c_str(), dns_name.size()); EXPECT_EQ(DnsDomainToString(reader1, true /* require_complete */), - base::nullopt); + absl::nullopt); dns_name += '\0'; @@ -205,16 +205,16 @@ TEST_F(DNSUtilTest, DnsDomainToStringShouldRejectEmptyWhenRequiringComplete) { TEST_F(DNSUtilTest, DnsDomainToStringShouldRejectCompression) { std::string dns_name = CreateNamePointer(152); - EXPECT_EQ(DnsDomainToString(dns_name), base::nullopt); + EXPECT_EQ(DnsDomainToString(dns_name), absl::nullopt); base::BigEndianReader reader(dns_name.c_str(), dns_name.size()); - EXPECT_EQ(DnsDomainToString(reader), base::nullopt); + EXPECT_EQ(DnsDomainToString(reader), absl::nullopt); dns_name = "\005hello"; dns_name += CreateNamePointer(152); - EXPECT_EQ(DnsDomainToString(dns_name), base::nullopt); + EXPECT_EQ(DnsDomainToString(dns_name), absl::nullopt); base::BigEndianReader reader1(dns_name.c_str(), dns_name.size()); - EXPECT_EQ(DnsDomainToString(reader1), base::nullopt); + EXPECT_EQ(DnsDomainToString(reader1), absl::nullopt); } // Test that extra input past the terminating zero-length label are ignored. @@ -242,15 +242,15 @@ TEST_F(DNSUtilTest, DnsDomainToStringShouldHandleExcessInput) { TEST_F(DNSUtilTest, DnsDomainToStringShouldRejectTruncatedNames) { std::string dns_name = "\07cheese"; - EXPECT_EQ(DnsDomainToString(dns_name), base::nullopt); + EXPECT_EQ(DnsDomainToString(dns_name), absl::nullopt); base::BigEndianReader reader(dns_name.c_str(), dns_name.size()); - EXPECT_EQ(DnsDomainToString(reader), base::nullopt); + EXPECT_EQ(DnsDomainToString(reader), absl::nullopt); dns_name = "\006cheesy\05test"; - EXPECT_EQ(DnsDomainToString(dns_name), base::nullopt); + EXPECT_EQ(DnsDomainToString(dns_name), absl::nullopt); base::BigEndianReader reader1(dns_name.c_str(), dns_name.size()); - EXPECT_EQ(DnsDomainToString(reader1), base::nullopt); + EXPECT_EQ(DnsDomainToString(reader1), absl::nullopt); } TEST_F(DNSUtilTest, DnsDomainToStringShouldHandleLongSingleLabel) { @@ -259,9 +259,9 @@ TEST_F(DNSUtilTest, DnsDomainToStringShouldHandleLongSingleLabel) { dns_name += 'a'; } - EXPECT_NE(DnsDomainToString(dns_name), base::nullopt); + EXPECT_NE(DnsDomainToString(dns_name), absl::nullopt); base::BigEndianReader reader(dns_name.c_str(), dns_name.size()); - EXPECT_NE(DnsDomainToString(reader), base::nullopt); + EXPECT_NE(DnsDomainToString(reader), absl::nullopt); } TEST_F(DNSUtilTest, DnsDomainToStringShouldHandleLongSecondLabel) { @@ -271,9 +271,9 @@ TEST_F(DNSUtilTest, DnsDomainToStringShouldHandleLongSecondLabel) { dns_name += 'a'; } - EXPECT_NE(DnsDomainToString(dns_name), base::nullopt); + EXPECT_NE(DnsDomainToString(dns_name), absl::nullopt); base::BigEndianReader reader(dns_name.c_str(), dns_name.size()); - EXPECT_NE(DnsDomainToString(reader), base::nullopt); + EXPECT_NE(DnsDomainToString(reader), absl::nullopt); } TEST_F(DNSUtilTest, DnsDomainToStringShouldRejectTooLongSingleLabel) { @@ -282,9 +282,9 @@ TEST_F(DNSUtilTest, DnsDomainToStringShouldRejectTooLongSingleLabel) { dns_name += 'a'; } - EXPECT_EQ(DnsDomainToString(dns_name), base::nullopt); + EXPECT_EQ(DnsDomainToString(dns_name), absl::nullopt); base::BigEndianReader reader(dns_name.c_str(), dns_name.size()); - EXPECT_EQ(DnsDomainToString(reader), base::nullopt); + EXPECT_EQ(DnsDomainToString(reader), absl::nullopt); } TEST_F(DNSUtilTest, DnsDomainToStringShouldRejectTooLongSecondLabel) { @@ -294,9 +294,9 @@ TEST_F(DNSUtilTest, DnsDomainToStringShouldRejectTooLongSecondLabel) { dns_name += 'a'; } - EXPECT_EQ(DnsDomainToString(dns_name), base::nullopt); + EXPECT_EQ(DnsDomainToString(dns_name), absl::nullopt); base::BigEndianReader reader(dns_name.c_str(), dns_name.size()); - EXPECT_EQ(DnsDomainToString(reader), base::nullopt); + EXPECT_EQ(DnsDomainToString(reader), absl::nullopt); } #if CHAR_MIN < 0 @@ -313,9 +313,9 @@ TEST_F(DNSUtilTest, DnsDomainToStringShouldRejectCharMinLabels) { } } - EXPECT_EQ(DnsDomainToString(dns_name), base::nullopt); + EXPECT_EQ(DnsDomainToString(dns_name), absl::nullopt); base::BigEndianReader reader(dns_name.c_str(), dns_name.size()); - EXPECT_EQ(DnsDomainToString(reader), base::nullopt); + EXPECT_EQ(DnsDomainToString(reader), absl::nullopt); } #endif // if CHAR_MIN < 0 @@ -332,9 +332,9 @@ TEST_F(DNSUtilTest, DnsDomainToStringShouldHandleLongName) { } ASSERT_EQ(dns_name.size(), static_cast(dns_protocol::kMaxNameLength)); - EXPECT_NE(DnsDomainToString(dns_name), base::nullopt); + EXPECT_NE(DnsDomainToString(dns_name), absl::nullopt); base::BigEndianReader reader(dns_name.c_str(), dns_name.size()); - EXPECT_NE(DnsDomainToString(reader), base::nullopt); + EXPECT_NE(DnsDomainToString(reader), absl::nullopt); } TEST_F(DNSUtilTest, DnsDomainToStringShouldRejectTooLongName) { @@ -351,9 +351,9 @@ TEST_F(DNSUtilTest, DnsDomainToStringShouldRejectTooLongName) { ASSERT_EQ(dns_name.size(), static_cast(dns_protocol::kMaxNameLength + 1)); - EXPECT_EQ(DnsDomainToString(dns_name), base::nullopt); + EXPECT_EQ(DnsDomainToString(dns_name), absl::nullopt); base::BigEndianReader reader(dns_name.c_str(), dns_name.size()); - EXPECT_EQ(DnsDomainToString(reader), base::nullopt); + EXPECT_EQ(DnsDomainToString(reader), absl::nullopt); } TEST_F(DNSUtilTest, DnsDomainToStringShouldHandleLongCompleteName) { @@ -371,9 +371,9 @@ TEST_F(DNSUtilTest, DnsDomainToStringShouldHandleLongCompleteName) { ASSERT_EQ(dns_name.size(), static_cast(dns_protocol::kMaxNameLength + 1)); - EXPECT_NE(DnsDomainToString(dns_name), base::nullopt); + EXPECT_NE(DnsDomainToString(dns_name), absl::nullopt); base::BigEndianReader reader(dns_name.c_str(), dns_name.size()); - EXPECT_NE(DnsDomainToString(reader), base::nullopt); + EXPECT_NE(DnsDomainToString(reader), absl::nullopt); } TEST_F(DNSUtilTest, DnsDomainToStringShouldRejectTooLongCompleteName) { @@ -391,9 +391,9 @@ TEST_F(DNSUtilTest, DnsDomainToStringShouldRejectTooLongCompleteName) { ASSERT_EQ(dns_name.size(), static_cast(dns_protocol::kMaxNameLength + 2)); - EXPECT_EQ(DnsDomainToString(dns_name), base::nullopt); + EXPECT_EQ(DnsDomainToString(dns_name), absl::nullopt); base::BigEndianReader reader(dns_name.c_str(), dns_name.size()); - EXPECT_EQ(DnsDomainToString(reader), base::nullopt); + EXPECT_EQ(DnsDomainToString(reader), absl::nullopt); } TEST_F(DNSUtilTest, IsValidDNSDomain) { diff --git a/net/dns/host_cache.cc b/net/dns/host_cache.cc index 3f3d285958843b..17bd553e878521 100644 --- a/net/dns/host_cache.cc +++ b/net/dns/host_cache.cc @@ -13,7 +13,6 @@ #include "base/metrics/histogram_macros.h" #include "base/no_destructor.h" #include "base/numerics/safe_conversions.h" -#include "base/optional.h" #include "base/strings/string_number_conversions.h" #include "base/time/default_tick_clock.h" #include "base/trace_event/trace_event.h" @@ -23,6 +22,7 @@ #include "net/base/trace_constants.h" #include "net/dns/host_resolver.h" #include "net/log/net_log.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -56,7 +56,7 @@ const char kHostnameResultsKey[] = "hostname_results"; const char kHostPortsKey[] = "host_ports"; bool AddressListFromListValue(const base::Value* value, - base::Optional* out_list) { + absl::optional* out_list) { if (!value) { out_list->reset(); return true; @@ -76,7 +76,7 @@ bool AddressListFromListValue(const base::Value* value, } template -void MergeLists(base::Optional* target, const base::Optional& source) { +void MergeLists(absl::optional* target, const absl::optional& source) { if (target->has_value() && source) { target->value().insert(target->value().end(), source.value().begin(), source.value().end()); @@ -129,7 +129,7 @@ HostCache::Key::Key(Key&& key) = default; HostCache::Entry::Entry(int error, Source source, - base::Optional ttl) + absl::optional ttl) : error_(error), source_(source), ttl_(ttl.value_or(base::TimeDelta::FromSeconds(-1))) { @@ -144,11 +144,11 @@ HostCache::Entry::Entry(Entry&& entry) = default; HostCache::Entry::~Entry() = default; -base::Optional HostCache::Entry::GetOptionalTtl() const { +absl::optional HostCache::Entry::GetOptionalTtl() const { if (has_ttl()) return ttl(); else - return base::nullopt; + return absl::nullopt; } // static @@ -246,10 +246,10 @@ HostCache::Entry::Entry(const HostCache::Entry& entry, HostCache::Entry::Entry( int error, - const base::Optional& addresses, - base::Optional>&& text_records, - base::Optional>&& hostnames, - base::Optional>&& experimental_results, + const absl::optional& addresses, + absl::optional>&& text_records, + absl::optional>&& hostnames, + absl::optional>&& experimental_results, Source source, base::TimeTicks expires, int network_changes) @@ -545,7 +545,7 @@ void HostCache::Set(const Key& key, if (it != entries_.end()) { preserve_pin = HasActivePin(it->second); - base::Optional addresses_delta; + absl::optional addresses_delta; if (entry.addresses() || it->second.addresses()) { if (entry.addresses() && it->second.addresses()) { addresses_delta = FindAddressListDeltaType( @@ -558,7 +558,7 @@ void HostCache::Set(const Key& key, // For non-address results, delta is only considered for whole-list // equality. The meaning of partial list equality varies too much depending // on the context of a DNS record. - base::Optional nonaddress_delta; + absl::optional nonaddress_delta; if (entry.text_records() || it->second.text_records() || entry.hostnames() || it->second.hostnames()) { if (entry.text_records() == it->second.text_records() && @@ -730,7 +730,7 @@ bool HostCache::RestoreFromListValue(const base::ListValue& old_cache) { const std::string* hostname_ptr = entry_dict.FindStringKey(kHostnameKey); const std::string* expiration_ptr = entry_dict.FindStringKey(kExpirationKey); - base::Optional maybe_flags = entry_dict.FindIntKey(kFlagsKey); + absl::optional maybe_flags = entry_dict.FindIntKey(kFlagsKey); if (hostname_ptr == nullptr || expiration_ptr == nullptr || !maybe_flags.has_value()) { return false; @@ -744,13 +744,13 @@ bool HostCache::RestoreFromListValue(const base::ListValue& old_cache) { // TODO(crbug.com/846423): Remove kAddressFamilyKey support after a enough // time has passed to minimize loss-of-persistence impact from backwards // incompatibility. - base::Optional maybe_dns_query_type = + absl::optional maybe_dns_query_type = entry_dict.FindIntKey(kDnsQueryTypeKey); DnsQueryType dns_query_type; if (maybe_dns_query_type.has_value()) { dns_query_type = static_cast(maybe_dns_query_type.value()); } else { - base::Optional maybe_address_family = + absl::optional maybe_address_family = entry_dict.FindIntKey(kAddressFamilyKey); if (!maybe_address_family.has_value()) { return false; @@ -781,7 +781,7 @@ bool HostCache::RestoreFromListValue(const base::ListValue& old_cache) { const base::Value* text_records_value = nullptr; const base::Value* hostname_records_value = nullptr; const base::Value* host_ports_value = nullptr; - base::Optional maybe_error = entry_dict.FindIntKey(kNetErrorKey); + absl::optional maybe_error = entry_dict.FindIntKey(kNetErrorKey); if (maybe_error.has_value()) { error = maybe_error.value(); } else { @@ -804,12 +804,12 @@ bool HostCache::RestoreFromListValue(const base::ListValue& old_cache) { tick_clock_->NowTicks() - (base::Time::Now() - base::Time::FromInternalValue(time_internal)); - base::Optional address_list; + absl::optional address_list; if (!AddressListFromListValue(addresses_value, &address_list)) { return false; } - base::Optional> text_records; + absl::optional> text_records; if (text_records_value) { text_records.emplace(); for (const base::Value& value : text_records_value->GetList()) { @@ -819,7 +819,7 @@ bool HostCache::RestoreFromListValue(const base::ListValue& old_cache) { } } - base::Optional> hostname_records; + absl::optional> hostname_records; if (hostname_records_value) { DCHECK(host_ports_value); if (hostname_records_value->GetList().size() != @@ -843,7 +843,7 @@ bool HostCache::RestoreFromListValue(const base::ListValue& old_cache) { } // We do not intend to serialize experimental results with the host cache. - base::Optional> experimental_results; + absl::optional> experimental_results; // Assume an empty address list if we have an address type and no results. if (IsAddressType(dns_query_type) && !address_list && !text_records && @@ -894,7 +894,7 @@ std::unique_ptr HostCache::CreateDefaultCache() { bool HostCache::EvictOneEntry(base::TimeTicks now) { DCHECK_LT(0u, entries_.size()); - base::Optional oldest_it; + absl::optional oldest_it; for (auto it = entries_.begin(); it != entries_.end(); ++it) { const Entry& entry = it->second; if (HasActivePin(entry)) { diff --git a/net/dns/host_cache.h b/net/dns/host_cache.h index 3e7266c87b4cb4..0aa5e3793daaf0 100644 --- a/net/dns/host_cache.h +++ b/net/dns/host_cache.h @@ -19,7 +19,6 @@ #include "base/gtest_prod_util.h" #include "base/macros.h" #include "base/numerics/clamped_math.h" -#include "base/optional.h" #include "base/threading/thread_checker.h" #include "base/time/time.h" #include "base/values.h" @@ -34,6 +33,7 @@ #include "net/dns/host_resolver_source.h" #include "net/dns/public/dns_query_type.h" #include "net/log/net_log_capture_mode.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { class ListValue; @@ -108,12 +108,12 @@ class NET_EXPORT HostCache { SOURCE_HOSTS, }; - // |ttl=base::nullopt| for unknown TTL. + // |ttl=absl::nullopt| for unknown TTL. template Entry(int error, T&& results, Source source, - base::Optional ttl) + absl::optional ttl) : error_(error), source_(source), ttl_(ttl ? ttl.value() : base::TimeDelta::FromSeconds(-1)) { @@ -124,12 +124,12 @@ class NET_EXPORT HostCache { // Use when |ttl| is unknown. template Entry(int error, T&& results, Source source) - : Entry(error, std::forward(results), source, base::nullopt) {} + : Entry(error, std::forward(results), source, absl::nullopt) {} // For errors with no |results|. Entry(int error, Source source, - base::Optional ttl = base::nullopt); + absl::optional ttl = absl::nullopt); Entry(const Entry& entry); Entry(Entry&& entry); @@ -144,28 +144,28 @@ class NET_EXPORT HostCache { error_ != ERR_HOST_RESOLVER_QUEUE_TOO_LARGE; } void set_error(int error) { error_ = error; } - const base::Optional& addresses() const { return addresses_; } - void set_addresses(const base::Optional& addresses) { + const absl::optional& addresses() const { return addresses_; } + void set_addresses(const absl::optional& addresses) { addresses_ = addresses; } - const base::Optional>& text_records() const { + const absl::optional>& text_records() const { return text_records_; } void set_text_records( - base::Optional> text_records) { + absl::optional> text_records) { text_records_ = std::move(text_records); } - const base::Optional>& hostnames() const { + const absl::optional>& hostnames() const { return hostnames_; } - void set_hostnames(base::Optional> hostnames) { + void set_hostnames(absl::optional> hostnames) { hostnames_ = std::move(hostnames); } - const base::Optional>& experimental_results() const { + const absl::optional>& experimental_results() const { return experimental_results_; } void set_experimental_results( - base::Optional> experimental_results) { + absl::optional> experimental_results) { experimental_results_ = std::move(experimental_results); } bool pinned() const { return pinned_; } @@ -174,7 +174,7 @@ class NET_EXPORT HostCache { Source source() const { return source_; } bool has_ttl() const { return ttl_ >= base::TimeDelta(); } base::TimeDelta ttl() const { return ttl_; } - base::Optional GetOptionalTtl() const; + absl::optional GetOptionalTtl() const; void set_ttl(base::TimeDelta ttl) { ttl_ = ttl; } base::TimeTicks expires() const { return expires_; } @@ -208,10 +208,10 @@ class NET_EXPORT HostCache { int network_changes); Entry(int error, - const base::Optional& addresses, - base::Optional>&& text_results, - base::Optional>&& hostnames, - base::Optional>&& experimental_results, + const absl::optional& addresses, + absl::optional>&& text_results, + absl::optional>&& hostnames, + absl::optional>&& experimental_results, Source source, base::TimeTicks expires, int network_changes); @@ -259,10 +259,10 @@ class NET_EXPORT HostCache { // The resolve results for this entry. int error_ = ERR_FAILED; - base::Optional addresses_; - base::Optional> text_records_; - base::Optional> hostnames_; - base::Optional> experimental_results_; + absl::optional addresses_; + absl::optional> text_records_; + absl::optional> hostnames_; + absl::optional> experimental_results_; // Where results were obtained (e.g. DNS lookup, hosts file, etc). Source source_ = SOURCE_UNKNOWN; // If true, this entry cannot be evicted from the cache until after the next diff --git a/net/dns/host_cache_fuzzer.cc b/net/dns/host_cache_fuzzer.cc index 63b1057f0fe197..6bc24b21d04941 100644 --- a/net/dns/host_cache_fuzzer.cc +++ b/net/dns/host_cache_fuzzer.cc @@ -6,9 +6,9 @@ #include #include "base/json/json_reader.h" -#include "base/optional.h" #include "base/strings/string_piece_forward.h" #include "net/dns/host_cache.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -31,7 +31,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { // Attempt to read a JSON list from the fuzzed string. base::StringPiece data_view(reinterpret_cast(data), size); - base::Optional value = base::JSONReader::Read(data_view); + absl::optional value = base::JSONReader::Read(data_view); if (!value || !value->is_list()) return 0; const base::ListValue& list_input = base::Value::AsListValue(*value); diff --git a/net/dns/host_resolver.cc b/net/dns/host_resolver.cc index ff6e702c7f14be..16c6589c098940 100644 --- a/net/dns/host_resolver.cc +++ b/net/dns/host_resolver.cc @@ -40,28 +40,28 @@ class FailingRequestImpl : public HostResolver::ResolveHostRequest, int Start(CompletionOnceCallback callback) override { return error_; } int Start() override { return error_; } - const base::Optional& GetAddressResults() const override { - static base::NoDestructor> nullopt_result; + const absl::optional& GetAddressResults() const override { + static base::NoDestructor> nullopt_result; return *nullopt_result; } - const base::Optional>& GetTextResults() + const absl::optional>& GetTextResults() const override { - static const base::NoDestructor>> + static const base::NoDestructor>> nullopt_result; return *nullopt_result; } - const base::Optional>& GetHostnameResults() + const absl::optional>& GetHostnameResults() const override { - static const base::NoDestructor>> + static const base::NoDestructor>> nullopt_result; return *nullopt_result; } - const base::Optional>& GetDnsAliasResults() + const absl::optional>& GetDnsAliasResults() const override { - static const base::NoDestructor>> + static const base::NoDestructor>> nullopt_result; return *nullopt_result; } @@ -70,9 +70,9 @@ class FailingRequestImpl : public HostResolver::ResolveHostRequest, return ResolveErrorInfo(error_); } - const base::Optional& GetStaleInfo() + const absl::optional& GetStaleInfo() const override { - static const base::NoDestructor> + static const base::NoDestructor> nullopt_result; return *nullopt_result; } @@ -85,7 +85,7 @@ class FailingRequestImpl : public HostResolver::ResolveHostRequest, } // namespace -const base::Optional>& +const absl::optional>& HostResolver::ResolveHostRequest::GetExperimentalResultsForTesting() const { IMMEDIATE_CRASH(); } @@ -186,7 +186,7 @@ std::unique_ptr HostResolver::CreateResolver( // static std::unique_ptr HostResolver::CreateStandaloneResolver( NetLog* net_log, - base::Optional options, + absl::optional options, base::StringPiece host_mapping_rules, bool enable_caching) { std::unique_ptr resolver = @@ -205,7 +205,7 @@ std::unique_ptr HostResolver::CreateStandaloneResolver( std::unique_ptr HostResolver::CreateStandaloneContextResolver( NetLog* net_log, - base::Optional options, + absl::optional options, bool enable_caching) { auto resolve_context = std::make_unique( nullptr /* url_request_context */, enable_caching); diff --git a/net/dns/host_resolver.h b/net/dns/host_resolver.h index f1b8af5f0e2e53..334527d69c2a34 100644 --- a/net/dns/host_resolver.h +++ b/net/dns/host_resolver.h @@ -13,7 +13,6 @@ #include #include "base/macros.h" -#include "base/optional.h" #include "base/strings/string_piece.h" #include "net/base/address_family.h" #include "net/base/completion_once_callback.h" @@ -25,6 +24,7 @@ #include "net/dns/public/dns_query_type.h" #include "net/dns/public/resolve_error_info.h" #include "net/dns/public/secure_dns_policy.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { class Value; @@ -80,12 +80,12 @@ class NET_EXPORT HostResolver { // Address record (A or AAAA) results of the request. Should only be called // after Start() signals completion, either by invoking the callback or by // returning a result other than |ERR_IO_PENDING|. - virtual const base::Optional& GetAddressResults() const = 0; + virtual const absl::optional& GetAddressResults() const = 0; // Text record (TXT) results of the request. Should only be called after // Start() signals completion, either by invoking the callback or by // returning a result other than |ERR_IO_PENDING|. - virtual const base::Optional>& GetTextResults() + virtual const absl::optional>& GetTextResults() const = 0; // Hostname record (SRV or PTR) results of the request. For SRV results, @@ -95,7 +95,7 @@ class NET_EXPORT HostResolver { // Should only be called after Start() signals completion, either by // invoking the callback or by returning a result other than // |ERR_IO_PENDING|. - virtual const base::Optional>& + virtual const absl::optional>& GetHostnameResults() const = 0; // Any DNS record aliases, such as CNAME aliases, found as a result of an @@ -106,13 +106,13 @@ class NET_EXPORT HostResolver { // list of aliases that has been sanitized and canonicalized (as URL // hostnames), and thus may differ from the results stored directly in the // AddressList. - virtual const base::Optional>& GetDnsAliasResults() + virtual const absl::optional>& GetDnsAliasResults() const = 0; // Result of an experimental query. Meaning depends on the specific query // type, but each boolean value generally refers to a valid or invalid // record of the experimental type. - NET_EXPORT virtual const base::Optional>& + NET_EXPORT virtual const absl::optional>& GetExperimentalResultsForTesting() const; // Error info for the request. @@ -128,7 +128,7 @@ class NET_EXPORT HostResolver { // Should only be called after Start() signals completion, either by // invoking the callback or by returning a result other than // |ERR_IO_PENDING|. - virtual const base::Optional& GetStaleInfo() + virtual const absl::optional& GetStaleInfo() const = 0; // Changes the priority of the specified request. Can only be called while @@ -257,7 +257,7 @@ class NET_EXPORT HostResolver { // Set |true| iff the host resolve request is only being made speculatively // to fill the cache and the result addresses will not be used. The request // will receive special logging/observer treatment, and the result addresses - // will always be |base::nullopt|. + // will always be |absl::nullopt|. bool is_speculative = false; // If `true`, resolver may (but is not guaranteed to) take steps to avoid @@ -324,12 +324,12 @@ class NET_EXPORT HostResolver { // Profiling information for the request is saved to |net_log| if non-NULL. // // Additional parameters may be set using |optional_parameters|. Reasonable - // defaults will be used if passed |base::nullopt|. + // defaults will be used if passed |absl::nullopt|. virtual std::unique_ptr CreateRequest( const HostPortPair& host, const NetworkIsolationKey& network_isolation_key, const NetLogWithSource& net_log, - const base::Optional& optional_parameters) = 0; + const absl::optional& optional_parameters) = 0; // Creates a request to probe configured DoH servers to find which can be used // successfully. @@ -371,7 +371,7 @@ class NET_EXPORT HostResolver { // requests. See MappedHostResolver for details. static std::unique_ptr CreateStandaloneResolver( NetLog* net_log, - base::Optional options = base::nullopt, + absl::optional options = absl::nullopt, base::StringPiece host_mapping_rules = "", bool enable_caching = true); // Same, but explicitly returns the implementing ContextHostResolver. Only @@ -379,7 +379,7 @@ class NET_EXPORT HostResolver { // applied because doing so requires wrapping the ContextHostResolver. static std::unique_ptr CreateStandaloneContextResolver( NetLog* net_log, - base::Optional options = base::nullopt, + absl::optional options = absl::nullopt, bool enable_caching = true); // Helpers for interacting with HostCache and ProcResolver. diff --git a/net/dns/host_resolver_manager.cc b/net/dns/host_resolver_manager.cc index 92559fca188611..de8f73f85b409f 100644 --- a/net/dns/host_resolver_manager.cc +++ b/net/dns/host_resolver_manager.cc @@ -496,7 +496,7 @@ class HostResolverManager::RequestImpl RequestImpl(const NetLogWithSource& source_net_log, const HostPortPair& request_host, const NetworkIsolationKey& network_isolation_key, - const base::Optional& optional_parameters, + const absl::optional& optional_parameters, ResolveContext* resolve_context, HostCache* host_cache, base::WeakPtr resolver, @@ -553,38 +553,38 @@ class HostResolverManager::RequestImpl return rv; } - const base::Optional& GetAddressResults() const override { + const absl::optional& GetAddressResults() const override { DCHECK(complete_); - static const base::NoDestructor> nullopt_result; + static const base::NoDestructor> nullopt_result; return results_ ? results_.value().addresses() : *nullopt_result; } - const base::Optional>& GetTextResults() + const absl::optional>& GetTextResults() const override { DCHECK(complete_); - static const base::NoDestructor>> + static const base::NoDestructor>> nullopt_result; return results_ ? results_.value().text_records() : *nullopt_result; } - const base::Optional>& GetHostnameResults() + const absl::optional>& GetHostnameResults() const override { DCHECK(complete_); - static const base::NoDestructor>> + static const base::NoDestructor>> nullopt_result; return results_ ? results_.value().hostnames() : *nullopt_result; } - const base::Optional>& GetDnsAliasResults() + const absl::optional>& GetDnsAliasResults() const override { DCHECK(complete_); return sanitized_dns_alias_results_; } - const base::Optional>& GetExperimentalResultsForTesting() + const absl::optional>& GetExperimentalResultsForTesting() const override { DCHECK(complete_); - static const base::NoDestructor>> + static const base::NoDestructor>> nullopt_result; return results_ ? results_.value().experimental_results() : *nullopt_result; } @@ -594,7 +594,7 @@ class HostResolverManager::RequestImpl return error_info_; } - const base::Optional& GetStaleInfo() + const absl::optional& GetStaleInfo() const override { DCHECK(complete_); return stale_info_; @@ -777,9 +777,9 @@ class HostResolverManager::RequestImpl CompletionOnceCallback callback_; bool complete_; - base::Optional results_; - base::Optional stale_info_; - base::Optional> sanitized_dns_alias_results_; + absl::optional results_; + absl::optional stale_info_; + absl::optional> sanitized_dns_alias_results_; ResolveErrorInfo error_info_; const base::TickClock* const tick_clock_; @@ -1224,7 +1224,7 @@ class HostResolverManager::DnsTask : public base::SupportsWeakPtr { return trans; } - void OnExperimentalQueryTimeout(base::Optional doh_provider_id) { + void OnExperimentalQueryTimeout(absl::optional doh_provider_id) { for (std::unique_ptr& transaction : transactions_started_) { DCHECK(httpssvc_metrics_); base::TimeDelta elapsed_time = tick_clock_->NowTicks() - task_start_time_; @@ -1257,7 +1257,7 @@ class HostResolverManager::DnsTask : public base::SupportsWeakPtr { DnsTransaction* transaction, int net_error, const DnsResponse* response, - base::Optional doh_provider_id) { + absl::optional doh_provider_id) { DCHECK(transaction); // Once control leaves OnTransactionComplete, there's no further @@ -1312,13 +1312,13 @@ class HostResolverManager::DnsTask : public base::SupportsWeakPtr { } else { // Fail completely on network failure. OnFailure(net_error, DnsResponseResultExtractor::ExtractionError::kOk, - base::nullopt); + absl::nullopt); return; } if (httpssvc_metrics_) { if (dns_query_type == DnsQueryType::INTEGRITY) { - const base::Optional>& condensed = + const absl::optional>& condensed = results.experimental_results(); CHECK(condensed.has_value()); // INTEGRITY queries can time out the normal way (here), or when the @@ -1326,7 +1326,7 @@ class HostResolverManager::DnsTask : public base::SupportsWeakPtr { httpssvc_metrics_->SaveForIntegrity(doh_provider_id, rcode_for_httpssvc, *condensed, elapsed_time); } else if (dns_query_type == DnsQueryType::HTTPS) { - const base::Optional>& condensed = + const absl::optional>& condensed = results.experimental_results(); CHECK(condensed.has_value()); httpssvc_metrics_->SaveForHttps(doh_provider_id, rcode_for_httpssvc, @@ -1447,7 +1447,7 @@ class HostResolverManager::DnsTask : public base::SupportsWeakPtr { void OnFailure(int net_error, DnsResponseResultExtractor::ExtractionError extraction_error, - base::Optional ttl) { + absl::optional ttl) { if (httpssvc_metrics_) httpssvc_metrics_->SaveAddressQueryFailure(); @@ -1491,7 +1491,7 @@ class HostResolverManager::DnsTask : public base::SupportsWeakPtr { } void MaybeStartExperimentalQueryTimer( - base::Optional doh_provider_id) { + absl::optional doh_provider_id) { DCHECK(!transactions_started_.empty()); // Abort if neither HTTPSSVC nor INTEGRITY querying is enabled. @@ -1548,13 +1548,13 @@ class HostResolverManager::DnsTask : public base::SupportsWeakPtr { // Result from previously completed transactions. Only set if a transaction // has completed while others are still in progress. - base::Optional saved_results_; + absl::optional saved_results_; const base::TickClock* tick_clock_; base::TimeTicks task_start_time_; HttpssvcExperimentDomainCache httpssvc_domain_cache_; - base::Optional httpssvc_metrics_; + absl::optional httpssvc_metrics_; // Timer for early abort of experimental queries. See comments describing the // timeout parameters in net/base/features.h. @@ -1817,7 +1817,7 @@ class HostResolverManager::Job : public PrioritizedDispatcher::Job, // this Job was destroyed. bool ServeFromHosts() { DCHECK_GT(num_active_requests(), 0u); - base::Optional results = resolver_->ServeFromHosts( + absl::optional results = resolver_->ServeFromHosts( hostname_, query_type_, host_resolver_flags_ & HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6, tasks_); @@ -1838,7 +1838,7 @@ class HostResolverManager::Job : public PrioritizedDispatcher::Job, void OnRemovedFromJobMap() { DCHECK(self_iterator_); - self_iterator_ = base::nullopt; + self_iterator_ = absl::nullopt; } void RunNextTask() { @@ -2045,8 +2045,8 @@ class HostResolverManager::Job : public PrioritizedDispatcher::Job, // Insecure cache lookups for requests allowing stale results should have // occurred prior to Job creation. DCHECK(cache_usage_ != ResolveHostParameters::CacheUsage::STALE_ALLOWED); - base::Optional stale_info; - base::Optional resolved = resolver_->MaybeServeFromCache( + absl::optional stale_info; + absl::optional resolved = resolver_->MaybeServeFromCache( host_cache_, GenerateCacheKey(false), cache_usage_, false /* ignore_secure */, net_log_, &stale_info); @@ -2233,7 +2233,7 @@ class HostResolverManager::Job : public PrioritizedDispatcher::Job, } else { // MDNS uses a separate cache, so skip saving result to cache. // TODO(crbug.com/926300): Consider merging caches. - CompleteRequestsWithoutCache(results, base::nullopt /* stale_info */); + CompleteRequestsWithoutCache(results, absl::nullopt /* stale_info */); } } @@ -2392,7 +2392,7 @@ class HostResolverManager::Job : public PrioritizedDispatcher::Job, void CompleteRequestsWithoutCache( const HostCache::Entry& results, - base::Optional stale_info) { + absl::optional stale_info) { // Record the stale_info for all non-speculative requests, if it exists. if (stale_info) { for (auto* node = requests_.head(); node != requests_.end(); @@ -2492,7 +2492,7 @@ class HostResolverManager::Job : public PrioritizedDispatcher::Job, PrioritizedDispatcher::Handle handle_; // Iterator to |this| in the JobMap. |nullopt| if not owned by the JobMap. - base::Optional self_iterator_; + absl::optional self_iterator_; base::TimeDelta total_transaction_time_queued_; @@ -2575,7 +2575,7 @@ HostResolverManager::CreateRequest( const HostPortPair& host, const NetworkIsolationKey& network_isolation_key, const NetLogWithSource& net_log, - const base::Optional& optional_parameters, + const absl::optional& optional_parameters, ResolveContext* resolve_context, HostCache* host_cache) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); @@ -2767,7 +2767,7 @@ int HostResolverManager::Resolve(RequestImpl* request) { HostResolverFlags effective_host_resolver_flags; SecureDnsMode effective_secure_dns_mode; std::deque tasks; - base::Optional stale_info; + absl::optional stale_info; HostCache::Entry results = ResolveLocally( request->request_host().host(), request->network_isolation_key(), request->parameters().dns_query_type, request->parameters().source, @@ -2813,9 +2813,9 @@ HostCache::Entry HostResolverManager::ResolveLocally( HostResolverFlags* out_effective_host_resolver_flags, SecureDnsMode* out_effective_secure_dns_mode, std::deque* out_tasks, - base::Optional* out_stale_info) { + absl::optional* out_stale_info) { DCHECK(out_stale_info); - *out_stale_info = base::nullopt; + *out_stale_info = absl::nullopt; IPAddress ip_address; IPAddress* ip_address_ptr = nullptr; @@ -2857,7 +2857,7 @@ HostCache::Entry HostResolverManager::ResolveLocally( HostCache::Entry::SOURCE_UNKNOWN); } - base::Optional resolved = + absl::optional resolved = ResolveAsIP(*out_effective_query_type, resolve_canonname, ip_address_ptr); if (resolved) return resolved.value(); @@ -2951,12 +2951,12 @@ void HostResolverManager::CreateAndStartJob( } } -base::Optional HostResolverManager::ResolveAsIP( +absl::optional HostResolverManager::ResolveAsIP( DnsQueryType query_type, bool resolve_canonname, const IPAddress* ip_address) { if (ip_address == nullptr || !IsAddressType(query_type)) - return base::nullopt; + return absl::nullopt; AddressFamily family = GetAddressFamily(*ip_address); if (query_type != DnsQueryType::UNSPECIFIED && @@ -2973,21 +2973,21 @@ base::Optional HostResolverManager::ResolveAsIP( HostCache::Entry::SOURCE_UNKNOWN); } -base::Optional HostResolverManager::MaybeServeFromCache( +absl::optional HostResolverManager::MaybeServeFromCache( HostCache* cache, const HostCache::Key& key, ResolveHostParameters::CacheUsage cache_usage, bool ignore_secure, const NetLogWithSource& source_net_log, - base::Optional* out_stale_info) { + absl::optional* out_stale_info) { DCHECK(out_stale_info); - *out_stale_info = base::nullopt; + *out_stale_info = absl::nullopt; if (!cache) - return base::nullopt; + return absl::nullopt; if (cache_usage == ResolveHostParameters::CacheUsage::DISALLOWED) - return base::nullopt; + return absl::nullopt; // Local-only requests search the cache for non-local-only results. HostCache::Key effective_key = key; @@ -3012,10 +3012,10 @@ base::Optional HostResolverManager::MaybeServeFromCache( NetLogEventPhase::NONE, cache_result->second); return cache_result->second; } - return base::nullopt; + return absl::nullopt; } -base::Optional HostResolverManager::ServeFromHosts( +absl::optional HostResolverManager::ServeFromHosts( base::StringPiece hostname, DnsQueryType query_type, bool default_family_due_to_no_ipv6, @@ -3024,11 +3024,11 @@ base::Optional HostResolverManager::ServeFromHosts( // is going to be done next as part of a system lookup. if (!dns_client_ || !IsAddressType(query_type) || (!tasks.empty() && tasks.front() == TaskType::PROC)) - return base::nullopt; + return absl::nullopt; const DnsHosts* hosts = dns_client_->GetHosts(); if (!hosts || hosts->empty()) - return base::nullopt; + return absl::nullopt; // HOSTS lookups are case-insensitive. std::string effective_hostname = base::ToLowerASCII(hostname); @@ -3064,17 +3064,17 @@ base::Optional HostResolverManager::ServeFromHosts( HostCache::Entry::SOURCE_HOSTS); } - return base::nullopt; + return absl::nullopt; } -base::Optional HostResolverManager::ServeLocalhost( +absl::optional HostResolverManager::ServeLocalhost( base::StringPiece hostname, DnsQueryType query_type, bool default_family_due_to_no_ipv6) { AddressList resolved_addresses; if (!IsAddressType(query_type) || !ResolveLocalHostname(hostname, &resolved_addresses)) { - return base::nullopt; + return absl::nullopt; } AddressList filtered_addresses; @@ -3525,7 +3525,7 @@ void HostResolverManager::OnConnectionTypeChanged( } void HostResolverManager::OnSystemDnsConfigChanged( - base::Optional config) { + absl::optional config) { bool changed = false; bool transactions_allowed_before = false; if (dns_client_) { diff --git a/net/dns/host_resolver_manager.h b/net/dns/host_resolver_manager.h index 9b0ab6f721a270..7eeed606dd2c48 100644 --- a/net/dns/host_resolver_manager.h +++ b/net/dns/host_resolver_manager.h @@ -152,7 +152,7 @@ class NET_EXPORT HostResolverManager const HostPortPair& host, const NetworkIsolationKey& network_isolation_key, const NetLogWithSource& net_log, - const base::Optional& optional_parameters, + const absl::optional& optional_parameters, ResolveContext* resolve_context, HostCache* host_cache); // |resolve_context| is the context to use for the probes, and it is expected @@ -280,7 +280,7 @@ class NET_EXPORT HostResolverManager // // If results are returned from the host cache, |out_stale_info| will be // filled in with information on how stale or fresh the result is. Otherwise, - // |out_stale_info| will be set to |base::nullopt|. + // |out_stale_info| will be set to |absl::nullopt|. // // If |cache_usage == ResolveHostParameters::CacheUsage::STALE_ALLOWED|, then // stale cache entries can be returned. @@ -299,7 +299,7 @@ class NET_EXPORT HostResolverManager HostResolverFlags* out_effective_host_resolver_flags, SecureDnsMode* out_effective_secure_dns_mode, std::deque* out_tasks, - base::Optional* out_stale_info); + absl::optional* out_stale_info); // Creates and starts a Job to asynchronously attempt to resolve // |request|. @@ -311,26 +311,26 @@ class NET_EXPORT HostResolverManager // Tries to resolve |key| and its possible IP address representation, // |ip_address|. Returns a results entry iff the input can be resolved. - base::Optional ResolveAsIP(DnsQueryType query_type, + absl::optional ResolveAsIP(DnsQueryType query_type, bool resolve_canonname, const IPAddress* ip_address); // Returns the result iff |cache_usage| permits cache lookups and a positive // match is found for |key| in |cache|. |out_stale_info| must be non-null, and // will be filled in with details of the entry's staleness if an entry is - // returned, otherwise it will be set to |base::nullopt|. - base::Optional MaybeServeFromCache( + // returned, otherwise it will be set to |absl::nullopt|. + absl::optional MaybeServeFromCache( HostCache* cache, const HostCache::Key& key, ResolveHostParameters::CacheUsage cache_usage, bool ignore_secure, const NetLogWithSource& source_net_log, - base::Optional* out_stale_info); + absl::optional* out_stale_info); // Iff we have a DnsClient with a valid DnsConfig and we're not about to // attempt a system lookup, then try to resolve the query using the HOSTS // file. - base::Optional ServeFromHosts( + absl::optional ServeFromHosts( base::StringPiece hostname, DnsQueryType query_type, bool default_family_due_to_no_ipv6, @@ -338,7 +338,7 @@ class NET_EXPORT HostResolverManager // Iff |key| is for a localhost name (RFC 6761) and address DNS query type, // returns a results entry with the loopback IP. - base::Optional ServeLocalhost( + absl::optional ServeLocalhost( base::StringPiece hostname, DnsQueryType query_type, bool default_family_due_to_no_ipv6); @@ -440,7 +440,7 @@ class NET_EXPORT HostResolverManager NetworkChangeNotifier::ConnectionType type) override; // SystemDnsConfigChangeNotifier::Observer: - void OnSystemDnsConfigChanged(base::Optional config) override; + void OnSystemDnsConfigChanged(absl::optional config) override; void UpdateJobsForChangedConfig(); diff --git a/net/dns/host_resolver_manager_unittest.cc b/net/dns/host_resolver_manager_unittest.cc index f868d665632923..dd0fd46efceaf4 100644 --- a/net/dns/host_resolver_manager_unittest.cc +++ b/net/dns/host_resolver_manager_unittest.cc @@ -645,7 +645,7 @@ TEST_F(HostResolverManagerTest, AsynchronousLookup) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("just.testing", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); @@ -670,7 +670,7 @@ TEST_F(HostResolverManagerTest, JobsClearedOnCompletion) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("just.testing", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_EQ(1u, resolver_->num_jobs_for_testing()); @@ -684,11 +684,11 @@ TEST_F(HostResolverManagerTest, JobsClearedOnCompletion_MultipleRequests) { ResolveHostResponseHelper response1(resolver_->CreateRequest( HostPortPair("just.testing", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ResolveHostResponseHelper response2(resolver_->CreateRequest( HostPortPair("just.testing", 85), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_EQ(1u, resolver_->num_jobs_for_testing()); @@ -704,7 +704,7 @@ TEST_F(HostResolverManagerTest, JobsClearedOnCompletion_Failure) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("just.testing", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_EQ(1u, resolver_->num_jobs_for_testing()); @@ -717,7 +717,7 @@ TEST_F(HostResolverManagerTest, JobsClearedOnCompletion_Abort) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("just.testing", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_EQ(1u, resolver_->num_jobs_for_testing()); @@ -794,7 +794,7 @@ TEST_F(HostResolverManagerTest, LocalhostIPV4IPV6Lookup) { ResolveHostResponseHelper v4_unsp_response(resolver_->CreateRequest( HostPortPair("localhost", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(v4_unsp_response.result_error(), IsOk()); EXPECT_THAT( v4_unsp_response.request()->GetAddressResults().value().endpoints(), @@ -829,7 +829,7 @@ TEST_F(HostResolverManagerTest, EmptyListMeansNameNotResolved) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("just.testing", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); @@ -846,7 +846,7 @@ TEST_F(HostResolverManagerTest, FailedAsynchronousLookup) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("just.testing", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); EXPECT_THAT(response.top_level_result_error(), @@ -868,7 +868,7 @@ TEST_F(HostResolverManagerTest, FailedAsynchronousLookup) { TEST_F(HostResolverManagerTest, AbortedAsynchronousLookup) { ResolveHostResponseHelper response0(resolver_->CreateRequest( HostPortPair("just.testing", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_FALSE(response0.complete()); ASSERT_TRUE(proc_->WaitFor(1u)); @@ -882,7 +882,7 @@ TEST_F(HostResolverManagerTest, AbortedAsynchronousLookup) { CreateResolver(); ResolveHostResponseHelper response1(resolver_->CreateRequest( HostPortPair("just.testing", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); proc_->SignalMultiple(2u); @@ -896,7 +896,7 @@ TEST_F(HostResolverManagerTest, AbortedAsynchronousLookup) { TEST_F(HostResolverManagerTest, NumericIPv4Address) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("127.1.2.3", 5555), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); @@ -909,7 +909,7 @@ TEST_F(HostResolverManagerTest, NumericIPv6Address) { // the caller should have removed them. ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("2001:db8::1", 5555), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); @@ -920,7 +920,7 @@ TEST_F(HostResolverManagerTest, NumericIPv6Address) { TEST_F(HostResolverManagerTest, EmptyHost) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(std::string(), 5555), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); @@ -931,7 +931,7 @@ TEST_F(HostResolverManagerTest, EmptyDotsHost) { for (int i = 0; i < 16; ++i) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(std::string(i, '.'), 5555), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); @@ -942,7 +942,7 @@ TEST_F(HostResolverManagerTest, EmptyDotsHost) { TEST_F(HostResolverManagerTest, LongHost) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(std::string(4097, 'a'), 5555), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); @@ -956,27 +956,27 @@ TEST_F(HostResolverManagerTest, DeDupeRequests) { responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("a", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("b", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("b", 81), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("a", 82), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("b", 83), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); for (auto& response : responses) { @@ -995,27 +995,27 @@ TEST_F(HostResolverManagerTest, CancelMultipleRequests) { responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("a", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("b", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("b", 81), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("a", 82), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("b", 83), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); for (auto& response : responses) { @@ -1049,14 +1049,14 @@ TEST_F(HostResolverManagerTest, CanceledRequestsReleaseJobSlots) { responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair(hostname, 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); ASSERT_FALSE(responses.back()->complete()); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair(hostname, 81), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); ASSERT_FALSE(responses.back()->complete()); } @@ -1097,7 +1097,7 @@ TEST_F(HostResolverManagerTest, CancelWithinCallback) { ResolveHostResponseHelper cancelling_response( resolver_->CreateRequest(HostPortPair("a", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()), std::move(custom_callback)); @@ -1105,12 +1105,12 @@ TEST_F(HostResolverManagerTest, CancelWithinCallback) { responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("a", 81), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("a", 82), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); proc_->SignalMultiple(2u); // One for "a". One for "finalrequest". @@ -1119,7 +1119,7 @@ TEST_F(HostResolverManagerTest, CancelWithinCallback) { ResolveHostResponseHelper final_response(resolver_->CreateRequest( HostPortPair("finalrequest", 70), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(final_response.result_error(), IsOk()); @@ -1146,7 +1146,7 @@ TEST_F(HostResolverManagerTest, DeleteWithinCallback) { ResolveHostResponseHelper deleting_response( resolver_->CreateRequest(HostPortPair("a", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()), std::move(custom_callback)); @@ -1157,12 +1157,12 @@ TEST_F(HostResolverManagerTest, DeleteWithinCallback) { responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("a", 81), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("a", 82), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); proc_->SignalMultiple(3u); @@ -1193,7 +1193,7 @@ TEST_F(HostResolverManagerTest, DeleteWithinAbortedCallback) { ResolveHostResponseHelper deleting_response( resolver_->CreateRequest(HostPortPair("a", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()), std::move(custom_callback)); @@ -1201,17 +1201,17 @@ TEST_F(HostResolverManagerTest, DeleteWithinAbortedCallback) { responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("a", 81), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("b", 82), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("b", 83), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); // Wait for all calls to queue up, trigger abort via IP address change, then @@ -1234,14 +1234,14 @@ TEST_F(HostResolverManagerTest, StartWithinCallback) { new_response = std::make_unique( resolver_->CreateRequest(HostPortPair("new", 70), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); std::move(completion_callback).Run(error); }); ResolveHostResponseHelper starting_response( resolver_->CreateRequest(HostPortPair("a", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()), std::move(custom_callback)); @@ -1262,29 +1262,29 @@ TEST_F(HostResolverManagerTest, StartWithinEvictionCallback) { new_response = std::make_unique( resolver_->CreateRequest(HostPortPair("new", 70), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); std::move(completion_callback).Run(error); }); ResolveHostResponseHelper initial_response(resolver_->CreateRequest( HostPortPair("initial", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ResolveHostResponseHelper evictee1_response( resolver_->CreateRequest(HostPortPair("evictee1", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()), std::move(custom_callback)); ResolveHostResponseHelper evictee2_response(resolver_->CreateRequest( HostPortPair("evictee2", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); // Now one running request ("initial") and two queued requests ("evictee1" and // "evictee2"). Any further requests will cause evictions. ResolveHostResponseHelper evictor_response(resolver_->CreateRequest( HostPortPair("evictor", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(evictee1_response.result_error(), IsError(ERR_HOST_RESOLVER_QUEUE_TOO_LARGE)); @@ -1311,18 +1311,18 @@ TEST_F(HostResolverManagerTest, StartWithinEvictionCallback_DoubleEviction) { new_response = std::make_unique( resolver_->CreateRequest(HostPortPair("new", 70), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); std::move(completion_callback).Run(error); }); ResolveHostResponseHelper initial_response(resolver_->CreateRequest( HostPortPair("initial", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ResolveHostResponseHelper evictee_response( resolver_->CreateRequest(HostPortPair("evictee", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()), std::move(custom_callback)); @@ -1330,7 +1330,7 @@ TEST_F(HostResolverManagerTest, StartWithinEvictionCallback_DoubleEviction) { // Any further requests will cause evictions. ResolveHostResponseHelper evictor_response(resolver_->CreateRequest( HostPortPair("evictor", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(evictee_response.result_error(), IsError(ERR_HOST_RESOLVER_QUEUE_TOO_LARGE)); @@ -1354,29 +1354,29 @@ TEST_F(HostResolverManagerTest, StartWithinEvictionCallback_SameRequest) { new_response = std::make_unique( resolver_->CreateRequest(HostPortPair("evictor", 70), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); std::move(completion_callback).Run(error); }); ResolveHostResponseHelper initial_response(resolver_->CreateRequest( HostPortPair("initial", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ResolveHostResponseHelper evictee_response( resolver_->CreateRequest(HostPortPair("evictee", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()), std::move(custom_callback)); ResolveHostResponseHelper additional_response(resolver_->CreateRequest( HostPortPair("additional", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); // Now one running request ("initial") and two queued requests ("evictee" and // "additional"). Any further requests will cause evictions. ResolveHostResponseHelper evictor_response(resolver_->CreateRequest( HostPortPair("evictor", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(evictee_response.result_error(), IsError(ERR_HOST_RESOLVER_QUEUE_TOO_LARGE)); @@ -1396,13 +1396,13 @@ TEST_F(HostResolverManagerTest, BypassCache) { ResolveHostResponseHelper initial_response(resolver_->CreateRequest( HostPortPair("a", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(initial_response.result_error(), IsOk()); EXPECT_EQ(1u, proc_->GetCaptureList().size()); ResolveHostResponseHelper cached_response(resolver_->CreateRequest( HostPortPair("a", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(cached_response.result_error(), IsOk()); // Expect no increase to calls to |proc_| because result was cached. EXPECT_EQ(1u, proc_->GetCaptureList().size()); @@ -1425,13 +1425,13 @@ TEST_F(HostResolverManagerTest, FlushCacheOnIPAddressChange) { ResolveHostResponseHelper initial_response(resolver_->CreateRequest( HostPortPair("host1", 70), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(initial_response.result_error(), IsOk()); EXPECT_EQ(1u, proc_->GetCaptureList().size()); ResolveHostResponseHelper cached_response(resolver_->CreateRequest( HostPortPair("host1", 75), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(cached_response.result_error(), IsOk()); EXPECT_EQ(1u, proc_->GetCaptureList().size()); // No expected increase. @@ -1443,7 +1443,7 @@ TEST_F(HostResolverManagerTest, FlushCacheOnIPAddressChange) { // will complete asynchronously. ResolveHostResponseHelper flushed_response(resolver_->CreateRequest( HostPortPair("host1", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(flushed_response.result_error(), IsOk()); EXPECT_EQ(2u, proc_->GetCaptureList().size()); // Expected increase. } @@ -1452,7 +1452,7 @@ TEST_F(HostResolverManagerTest, FlushCacheOnIPAddressChange) { TEST_F(HostResolverManagerTest, AbortOnIPAddressChanged) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("host1", 70), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_FALSE(response.complete()); ASSERT_TRUE(proc_->WaitFor(1u)); @@ -1476,17 +1476,17 @@ TEST_F(HostResolverManagerTest, ObeyPoolConstraintsAfterIPAddressChange) { responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("a", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("b", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("c", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); for (auto& response : responses) { @@ -1521,7 +1521,7 @@ TEST_F(HostResolverManagerTest, AbortOnlyExistingRequestsOnIPAddressChange) { CompletionOnceCallback completion_callback, int error) { *next_response = std::make_unique( resolver_->CreateRequest(next_host, NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); std::move(completion_callback).Run(error); @@ -1531,7 +1531,7 @@ TEST_F(HostResolverManagerTest, AbortOnlyExistingRequestsOnIPAddressChange) { ResolveHostResponseHelper response0( resolver_->CreateRequest(HostPortPair("bbb", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()), base::BindOnce(custom_callback_template, HostPortPair("zzz", 80), @@ -1539,7 +1539,7 @@ TEST_F(HostResolverManagerTest, AbortOnlyExistingRequestsOnIPAddressChange) { ResolveHostResponseHelper response1( resolver_->CreateRequest(HostPortPair("eee", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()), base::BindOnce(custom_callback_template, HostPortPair("aaa", 80), @@ -1547,7 +1547,7 @@ TEST_F(HostResolverManagerTest, AbortOnlyExistingRequestsOnIPAddressChange) { ResolveHostResponseHelper response2( resolver_->CreateRequest(HostPortPair("ccc", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()), base::BindOnce(custom_callback_template, HostPortPair("eee", 80), @@ -1924,11 +1924,11 @@ TEST_F(HostResolverManagerTest, QueueOverflow_SelfEvict) { ResolveHostResponseHelper run_response(resolver_->CreateRequest( HostPortPair("run", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ResolveHostResponseHelper evict_response(resolver_->CreateRequest( HostPortPair("req1", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(evict_response.result_error(), IsError(ERR_HOST_RESOLVER_QUEUE_TOO_LARGE)); EXPECT_FALSE(evict_response.request()->GetAddressResults()); @@ -1962,7 +1962,7 @@ TEST_F(HostResolverManagerTest, AddressFamilyWithRawIPs) { ResolveHostResponseHelper v4_unsp_request(resolver_->CreateRequest( HostPortPair("127.0.0.1", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(v4_unsp_request.result_error(), IsOk()); EXPECT_THAT( v4_unsp_request.request()->GetAddressResults().value().endpoints(), @@ -1982,7 +1982,7 @@ TEST_F(HostResolverManagerTest, AddressFamilyWithRawIPs) { ResolveHostResponseHelper v6_unsp_request(resolver_->CreateRequest( HostPortPair("::1", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(v6_unsp_request.result_error(), IsOk()); EXPECT_THAT( v6_unsp_request.request()->GetAddressResults().value().endpoints(), @@ -2009,7 +2009,7 @@ TEST_F(HostResolverManagerTest, LocalOnly_FromCache) { // Normal query to populate the cache. ResolveHostResponseHelper normal_request(resolver_->CreateRequest( HostPortPair("just.testing", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(normal_request.result_error(), IsOk()); EXPECT_FALSE(normal_request.request()->GetStaleInfo()); @@ -2047,7 +2047,7 @@ TEST_F(HostResolverManagerTest, LocalOnly_StaleEntry) { // Normal query to populate the cache. ResolveHostResponseHelper normal_request(resolver_->CreateRequest( HostPortPair("just.testing", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(normal_request.result_error(), IsOk()); EXPECT_FALSE(normal_request.request()->GetStaleInfo()); @@ -2138,7 +2138,7 @@ TEST_F(HostResolverManagerTest, StaleAllowed) { // Normal query to populate cache ResolveHostResponseHelper normal_request(resolver_->CreateRequest( HostPortPair("just.testing", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(normal_request.result_error(), IsOk()); EXPECT_FALSE(normal_request.request()->GetStaleInfo()); @@ -2232,7 +2232,7 @@ TEST_F(HostResolverManagerTest, MultipleAttempts) { // Resolve "host1". ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("host1", 70), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_FALSE(response.complete()); resolver_proc->WaitForNAttemptsToBeBlocked(1); @@ -2296,7 +2296,7 @@ TEST_F(HostResolverManagerTest, DefaultMaxRetryAttempts) { // resolution should remain stalled until calling SetResolvedAttemptNumber(). ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("host1", 70), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_FALSE(response.complete()); // Simulate running the main thread (network task runner) for a long @@ -2337,7 +2337,7 @@ TEST_F(HostResolverManagerTest, NameCollisionIcann) { ResolveHostResponseHelper single_response(resolver_->CreateRequest( HostPortPair("single", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(single_response.result_error(), IsError(ERR_ICANN_NAME_COLLISION)); EXPECT_FALSE(single_response.request()->GetAddressResults()); @@ -2353,14 +2353,14 @@ TEST_F(HostResolverManagerTest, NameCollisionIcann) { ResolveHostResponseHelper multiple_response(resolver_->CreateRequest( HostPortPair("multiple", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(multiple_response.result_error(), IsError(ERR_ICANN_NAME_COLLISION)); // Resolving an IP literal of 127.0.53.53 however is allowed. ResolveHostResponseHelper literal_response(resolver_->CreateRequest( HostPortPair("127.0.53.53", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(literal_response.result_error(), IsOk()); @@ -2368,7 +2368,7 @@ TEST_F(HostResolverManagerTest, NameCollisionIcann) { // address. ResolveHostResponseHelper ipv6_response(resolver_->CreateRequest( HostPortPair("127.0.53.53", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(ipv6_response.result_error(), IsOk()); @@ -2376,19 +2376,19 @@ TEST_F(HostResolverManagerTest, NameCollisionIcann) { // 127.0.53.53. ResolveHostResponseHelper similar_response1(resolver_->CreateRequest( HostPortPair("not_reserved1", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(similar_response1.result_error(), IsOk()); ResolveHostResponseHelper similar_response2(resolver_->CreateRequest( HostPortPair("not_reserved2", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(similar_response2.result_error(), IsOk()); ResolveHostResponseHelper similar_response3(resolver_->CreateRequest( HostPortPair("not_reserved3", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(similar_response3.result_error(), IsOk()); } @@ -2432,7 +2432,7 @@ TEST_F(HostResolverManagerTest, IncludeCanonicalName) { resolve_context_->host_cache())); ResolveHostResponseHelper response_no_flag(resolver_->CreateRequest( HostPortPair("just.testing", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); @@ -2456,7 +2456,7 @@ TEST_F(HostResolverManagerTest, LoopbackOnly) { parameters, resolve_context_.get(), resolve_context_->host_cache())); ResolveHostResponseHelper response_no_flag(resolver_->CreateRequest( HostPortPair("otherlocal", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); EXPECT_THAT(response.request()->GetAddressResults().value().endpoints(), @@ -2487,7 +2487,7 @@ TEST_F(HostResolverManagerTest, IsSpeculative) { // cache. ResolveHostResponseHelper response2(resolver_->CreateRequest( HostPortPair("just.testing", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response2.result_error(), IsOk()); @@ -2511,7 +2511,7 @@ TEST_F(HostResolverManagerTest, AvoidMulticastResolutionParameter) { resolve_context_->host_cache())); ResolveHostResponseHelper response_no_flag(resolver_->CreateRequest( HostPortPair("avoid.multicast.test", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); @@ -3562,7 +3562,7 @@ TEST_F(HostResolverManagerTest, NetworkIsolationKeyWriteToHostCache) { // Resolve a host using kNetworkIsolationKey1. ResolveHostResponseHelper response1(resolver_->CreateRequest( HostPortPair("just.testing", 80), kNetworkIsolationKey1, - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response1.result_error(), IsOk()); EXPECT_THAT(response1.request()->GetAddressResults().value().endpoints(), @@ -3609,7 +3609,7 @@ TEST_F(HostResolverManagerTest, NetworkIsolationKeyWriteToHostCache) { } ResolveHostResponseHelper response2(resolver_->CreateRequest( HostPortPair("just.testing", 80), kNetworkIsolationKey2, - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response2.result_error(), IsOk()); if (split_cache_by_network_isolation_key) { @@ -3685,7 +3685,7 @@ TEST_F(HostResolverManagerTest, NetworkIsolationKeyReadFromHostCache) { // the NetworkIsolationKeys are being used, and cache entry 0 otherwise. ResolveHostResponseHelper response1(resolver_->CreateRequest( HostPortPair("just.testing", 80), kNetworkIsolationKey1, - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response1.result_error(), IsOk()); EXPECT_THAT(response1.request()->GetAddressResults().value().endpoints(), @@ -3699,7 +3699,7 @@ TEST_F(HostResolverManagerTest, NetworkIsolationKeyReadFromHostCache) { // the NetworkIsolationKeys are being used, and cache entry 0 otherwise. ResolveHostResponseHelper response2(resolver_->CreateRequest( HostPortPair("just.testing", 80), kNetworkIsolationKey2, - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response2.result_error(), IsOk()); EXPECT_THAT(response2.request()->GetAddressResults().value().endpoints(), @@ -3735,14 +3735,14 @@ TEST_F(HostResolverManagerTest, NetworkIsolationKeyTwoRequestsAtOnce) { // Start resolving a host using kNetworkIsolationKey1. ResolveHostResponseHelper response1(resolver_->CreateRequest( HostPortPair("just.testing", 80), kNetworkIsolationKey1, - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_FALSE(response1.complete()); // Start resolving the same host using kNetworkIsolationKey2. ResolveHostResponseHelper response2(resolver_->CreateRequest( HostPortPair("just.testing", 80), kNetworkIsolationKey2, - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_FALSE(response2.complete()); @@ -3786,7 +3786,7 @@ TEST_F(HostResolverManagerTest, ContextsNotMerged) { // Start resolving a host using |resolve_context_|. ResolveHostResponseHelper response1(resolver_->CreateRequest( HostPortPair("just.testing", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_FALSE(response1.complete()); @@ -3796,7 +3796,7 @@ TEST_F(HostResolverManagerTest, ContextsNotMerged) { resolver_->RegisterResolveContext(&resolve_context2); ResolveHostResponseHelper response2(resolver_->CreateRequest( HostPortPair("just.testing", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, &resolve_context2, + NetLogWithSource(), absl::nullopt, &resolve_context2, resolve_context2.host_cache())); EXPECT_FALSE(response2.complete()); @@ -4125,14 +4125,14 @@ TEST_F(HostResolverManagerDnsTest, FlushCacheOnDnsConfigChange) { // Resolve to populate the cache. ResolveHostResponseHelper initial_response(resolver_->CreateRequest( HostPortPair("host1", 70), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(initial_response.result_error(), IsOk()); EXPECT_EQ(1u, proc_->GetCaptureList().size()); // Result expected to come from the cache. ResolveHostResponseHelper cached_response(resolver_->CreateRequest( HostPortPair("host1", 75), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(cached_response.result_error(), IsOk()); EXPECT_EQ(1u, proc_->GetCaptureList().size()); // No expected increase. @@ -4142,7 +4142,7 @@ TEST_F(HostResolverManagerDnsTest, FlushCacheOnDnsConfigChange) { // Expect flushed from cache and therefore served from |proc_|. ResolveHostResponseHelper flushed_response(resolver_->CreateRequest( HostPortPair("host1", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(flushed_response.result_error(), IsOk()); EXPECT_EQ(2u, proc_->GetCaptureList().size()); // Expected increase. } @@ -4160,7 +4160,7 @@ TEST_F(HostResolverManagerDnsTest, DisableAndEnableInsecureDnsClient) { /*additional_dns_types_enabled*/ false); ResolveHostResponseHelper response_proc(resolver_->CreateRequest( HostPortPair("nx_succeed", 1212), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response_proc.result_error(), IsOk()); EXPECT_THAT(response_proc.request()->GetAddressResults().value().endpoints(), @@ -4170,7 +4170,7 @@ TEST_F(HostResolverManagerDnsTest, DisableAndEnableInsecureDnsClient) { /*additional_dns_types_enabled=*/true); ResolveHostResponseHelper response_dns_client(resolver_->CreateRequest( HostPortPair("ok_fail", 1212), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response_dns_client.result_error(), IsOk()); EXPECT_THAT( response_dns_client.request()->GetAddressResults().value().endpoints(), @@ -4189,7 +4189,7 @@ TEST_F(HostResolverManagerDnsTest, UseProcTaskWhenPrivateDnsActive) { ChangeDnsConfig(config); ResolveHostResponseHelper response_proc(resolver_->CreateRequest( HostPortPair("nx_succeed", 1212), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response_proc.result_error(), IsOk()); EXPECT_THAT(response_proc.request()->GetAddressResults().value().endpoints(), @@ -4206,7 +4206,7 @@ TEST_F(HostResolverManagerDnsTest, LocalhostLookup) { ResolveHostResponseHelper response0(resolver_->CreateRequest( HostPortPair("foo.localhost", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response0.result_error(), IsOk()); EXPECT_THAT(response0.request()->GetAddressResults().value().endpoints(), @@ -4215,7 +4215,7 @@ TEST_F(HostResolverManagerDnsTest, LocalhostLookup) { ResolveHostResponseHelper response1(resolver_->CreateRequest( HostPortPair("localhost", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response1.result_error(), IsOk()); EXPECT_THAT(response1.request()->GetAddressResults().value().endpoints(), testing::UnorderedElementsAre(CreateExpected("127.0.0.1", 80), @@ -4223,7 +4223,7 @@ TEST_F(HostResolverManagerDnsTest, LocalhostLookup) { ResolveHostResponseHelper response2(resolver_->CreateRequest( HostPortPair("localhost.", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response2.result_error(), IsOk()); EXPECT_THAT(response2.request()->GetAddressResults().value().endpoints(), testing::UnorderedElementsAre(CreateExpected("127.0.0.1", 80), @@ -4245,7 +4245,7 @@ TEST_F(HostResolverManagerDnsTest, LocalhostLookupWithHosts) { ResolveHostResponseHelper response0(resolver_->CreateRequest( HostPortPair("localhost", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response0.result_error(), IsOk()); EXPECT_THAT(response0.request()->GetAddressResults().value().endpoints(), testing::UnorderedElementsAre(CreateExpected("127.0.0.1", 80), @@ -4253,7 +4253,7 @@ TEST_F(HostResolverManagerDnsTest, LocalhostLookupWithHosts) { ResolveHostResponseHelper response1(resolver_->CreateRequest( HostPortPair("foo.localhost", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response1.result_error(), IsOk()); EXPECT_THAT(response1.request()->GetAddressResults().value().endpoints(), @@ -4269,7 +4269,7 @@ TEST_F(HostResolverManagerDnsTest, DnsTask) { // Initially there is no config, so client should not be invoked. ResolveHostResponseHelper initial_response(resolver_->CreateRequest( HostPortPair("ok_fail", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_FALSE(initial_response.complete()); proc_->SignalMultiple(1u); @@ -4280,13 +4280,13 @@ TEST_F(HostResolverManagerDnsTest, DnsTask) { ResolveHostResponseHelper response0(resolver_->CreateRequest( HostPortPair("ok_fail", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ResolveHostResponseHelper response1(resolver_->CreateRequest( HostPortPair("nx_fail", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ResolveHostResponseHelper response2(resolver_->CreateRequest( HostPortPair("nx_succeed", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); proc_->SignalMultiple(4u); @@ -4316,10 +4316,10 @@ TEST_F(HostResolverManagerDnsTest, NoFallbackToProcTask) { // Initially there is no config, so client should not be invoked. ResolveHostResponseHelper initial_response0(resolver_->CreateRequest( HostPortPair("ok_fail", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ResolveHostResponseHelper initial_response1(resolver_->CreateRequest( HostPortPair("nx_succeed", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); proc_->SignalMultiple(2u); EXPECT_THAT(initial_response0.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); @@ -4334,10 +4334,10 @@ TEST_F(HostResolverManagerDnsTest, NoFallbackToProcTask) { // disabled fallback to ProcTask. ResolveHostResponseHelper response0(resolver_->CreateRequest( HostPortPair("ok_fail", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ResolveHostResponseHelper response1(resolver_->CreateRequest( HostPortPair("nx_succeed", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); proc_->SignalMultiple(6u); // Resolved by MockDnsClient. @@ -4354,7 +4354,7 @@ TEST_F(HostResolverManagerDnsTest, OnDnsTaskFailureAbortedJob) { ChangeDnsConfig(CreateValidDnsConfig()); ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("nx_abort", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); // Abort all jobs here. CreateResolver(); proc_->SignalMultiple(1u); @@ -4368,7 +4368,7 @@ TEST_F(HostResolverManagerDnsTest, OnDnsTaskFailureAbortedJob) { ChangeDnsConfig(CreateValidDnsConfig()); ResolveHostResponseHelper no_fallback_response(resolver_->CreateRequest( HostPortPair("nx_abort", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); // Abort all jobs here. CreateResolver(); proc_->SignalMultiple(2u); @@ -4390,10 +4390,10 @@ TEST_F(HostResolverManagerDnsTest, FallbackBySource_Any) { ResolveHostResponseHelper response0(resolver_->CreateRequest( HostPortPair("nx_fail", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ResolveHostResponseHelper response1(resolver_->CreateRequest( HostPortPair("nx_succeed", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); proc_->SignalMultiple(2u); EXPECT_THAT(response0.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); @@ -4440,10 +4440,10 @@ TEST_F(HostResolverManagerDnsTest, FallbackOnAbortBySource_Any) { ResolveHostResponseHelper response0(resolver_->CreateRequest( HostPortPair("ok_fail", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ResolveHostResponseHelper response1(resolver_->CreateRequest( HostPortPair("nx_succeed", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); proc_->SignalMultiple(2u); // Simulate the case when the preference or policy has disabled the insecure @@ -4508,7 +4508,7 @@ TEST_F(HostResolverManagerDnsTest, ResolveHostResponseHelper response_secure(resolver_->CreateRequest( HostPortPair("automatic", 80), NetworkIsolationKey(), NetLogWithSource(), - /* optional_parameters=*/base::nullopt, resolve_context_.get(), + /* optional_parameters=*/absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_FALSE(response_secure.complete()); @@ -4535,22 +4535,22 @@ TEST_F(HostResolverManagerDnsTest, DnsTaskUnspec) { responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("4ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("6ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("4nx", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); proc_->SignalMultiple(4u); @@ -4577,7 +4577,7 @@ TEST_F(HostResolverManagerDnsTest, NameCollisionIcann) { // mapped to a special error. ResolveHostResponseHelper response_ipv4(resolver_->CreateRequest( HostPortPair("4collision", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response_ipv4.result_error(), IsError(ERR_ICANN_NAME_COLLISION)); EXPECT_FALSE(response_ipv4.request()->GetAddressResults()); @@ -4586,7 +4586,7 @@ TEST_F(HostResolverManagerDnsTest, NameCollisionIcann) { // considered special) ResolveHostResponseHelper response_ipv6(resolver_->CreateRequest( HostPortPair("6collision", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response_ipv6.result_error(), IsOk()); EXPECT_THAT(response_ipv6.request()->GetAddressResults().value().endpoints(), testing::ElementsAre(CreateExpected("::127.0.53.53", 80))); @@ -4603,7 +4603,7 @@ TEST_F(HostResolverManagerDnsTest, ServeFromHosts) { ResolveHostResponseHelper initial_response(resolver_->CreateRequest( HostPortPair("nx_ipv4", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(initial_response.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); IPAddress local_ipv4 = IPAddress::IPv4Localhost(); @@ -4621,7 +4621,7 @@ TEST_F(HostResolverManagerDnsTest, ServeFromHosts) { ResolveHostResponseHelper response_ipv4(resolver_->CreateRequest( HostPortPair("nx_ipv4", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response_ipv4.result_error(), IsOk()); EXPECT_THAT(response_ipv4.request()->GetAddressResults().value().endpoints(), testing::ElementsAre(CreateExpected("127.0.0.1", 80))); @@ -4629,7 +4629,7 @@ TEST_F(HostResolverManagerDnsTest, ServeFromHosts) { ResolveHostResponseHelper response_ipv6(resolver_->CreateRequest( HostPortPair("nx_ipv6", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response_ipv6.result_error(), IsOk()); EXPECT_THAT(response_ipv6.request()->GetAddressResults().value().endpoints(), testing::ElementsAre(CreateExpected("::1", 80))); @@ -4637,7 +4637,7 @@ TEST_F(HostResolverManagerDnsTest, ServeFromHosts) { ResolveHostResponseHelper response_both(resolver_->CreateRequest( HostPortPair("nx_both", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response_both.result_error(), IsOk()); EXPECT_THAT(response_both.request()->GetAddressResults().value().endpoints(), testing::UnorderedElementsAre(CreateExpected("127.0.0.1", 80), @@ -4674,7 +4674,7 @@ TEST_F(HostResolverManagerDnsTest, ServeFromHosts) { // Request with upper case. ResolveHostResponseHelper response_upper(resolver_->CreateRequest( HostPortPair("nx_IPV4", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response_upper.result_error(), IsOk()); EXPECT_THAT(response_upper.request()->GetAddressResults().value().endpoints(), testing::ElementsAre(CreateExpected("127.0.0.1", 80))); @@ -4701,7 +4701,7 @@ TEST_F(HostResolverManagerDnsTest, SkipHostsWithUpcomingProcTask) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("hosts", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); } @@ -4718,27 +4718,27 @@ TEST_F(HostResolverManagerDnsTest, BypassDnsTask) { responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("ok.local", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("ok.local.", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("oklocal", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("oklocal.", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); proc_->SignalMultiple(5u); @@ -4805,7 +4805,7 @@ TEST_F(HostResolverManagerDnsTest, DnsNotBypassedWhenDnsSource) { dns_parameters, resolve_context_.get(), resolve_context_->host_cache())); ResolveHostResponseHelper normal_local_response(resolver_->CreateRequest( HostPortPair("ok.local", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); proc_->SignalMultiple(3u); @@ -4822,7 +4822,7 @@ TEST_F(HostResolverManagerDnsTest, SystemOnlyBypassesDnsTask) { ResolveHostResponseHelper dns_response(resolver_->CreateRequest( HostPortPair("ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); HostResolver::ResolveHostParameters parameters; parameters.source = HostResolverSource::SYSTEM; @@ -4843,7 +4843,7 @@ TEST_F(HostResolverManagerDnsTest, // Check that DnsTask works. ResolveHostResponseHelper initial_response(resolver_->CreateRequest( HostPortPair("ok_1", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(initial_response.result_error(), IsOk()); TriggerInsecureFailureCondition(); @@ -4852,7 +4852,7 @@ TEST_F(HostResolverManagerDnsTest, // |source|. ResolveHostResponseHelper fail_response(resolver_->CreateRequest( HostPortPair("ok_2", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); HostResolver::ResolveHostParameters parameters; parameters.source = HostResolverSource::DNS; ResolveHostResponseHelper dns_response(resolver_->CreateRequest( @@ -4866,7 +4866,7 @@ TEST_F(HostResolverManagerDnsTest, ChangeDnsConfig(CreateValidDnsConfig()); ResolveHostResponseHelper reenabled_response(resolver_->CreateRequest( HostPortPair("ok_3", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(reenabled_response.result_error(), IsOk()); } @@ -4880,7 +4880,7 @@ TEST_F(HostResolverManagerDnsTest, SecureDnsWorksAfterInsecureFailure) { // Secure DnsTasks should not be affected. ResolveHostResponseHelper secure_response(resolver_->CreateRequest( HostPortPair("secure", 80), NetworkIsolationKey(), NetLogWithSource(), - /* optional_parameters=*/base::nullopt, resolve_context_.get(), + /* optional_parameters=*/absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(secure_response.result_error(), IsOk()); } @@ -4899,7 +4899,7 @@ TEST_F(HostResolverManagerDnsTest, DontDisableDnsClientOnSporadicFailure) { responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair(hostname, 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); } @@ -4914,7 +4914,7 @@ TEST_F(HostResolverManagerDnsTest, DontDisableDnsClientOnSporadicFailure) { // DnsTask should still be enabled. ResolveHostResponseHelper final_response(resolver_->CreateRequest( HostPortPair("ok_last", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(final_response.result_error(), IsOk()); } @@ -4926,7 +4926,7 @@ TEST_F(HostResolverManagerDnsTest, Ipv6Unreachable) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("ok", 500), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); // Only expect IPv4 results. @@ -4945,7 +4945,7 @@ TEST_F(HostResolverManagerDnsTest, Ipv6Unreachable_InvalidConfig) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("example.com", 500), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); EXPECT_THAT(response.request()->GetAddressResults().value().endpoints(), @@ -4964,7 +4964,7 @@ TEST_F(HostResolverManagerDnsTest, Ipv6Unreachable_UseLocalIpv6) { ResolveHostResponseHelper response1(resolver_->CreateRequest( HostPortPair("ok", 500), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response1.result_error(), IsOk()); EXPECT_THAT(response1.request()->GetAddressResults().value().endpoints(), testing::UnorderedElementsAre(CreateExpected("127.0.0.1", 500), @@ -4976,7 +4976,7 @@ TEST_F(HostResolverManagerDnsTest, Ipv6Unreachable_UseLocalIpv6) { ResolveHostResponseHelper response2(resolver_->CreateRequest( HostPortPair("ok", 500), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response2.result_error(), IsOk()); EXPECT_THAT(response2.request()->GetAddressResults().value().endpoints(), testing::UnorderedElementsAre(CreateExpected("127.0.0.1", 500))); @@ -4999,7 +4999,7 @@ TEST_F(HostResolverManagerDnsTest, Ipv6Unreachable_Localhost) { /*additional_dns_types_enabled=*/false); ResolveHostResponseHelper system_response(resolver_->CreateRequest( HostPortPair("localhost", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(system_response.result_error(), IsOk()); EXPECT_THAT( system_response.request()->GetAddressResults().value().endpoints(), @@ -5010,7 +5010,7 @@ TEST_F(HostResolverManagerDnsTest, Ipv6Unreachable_Localhost) { UseMockDnsClient(CreateValidDnsConfig(), CreateDefaultDnsRules()); ResolveHostResponseHelper builtin_response(resolver_->CreateRequest( HostPortPair("localhost", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(builtin_response.result_error(), IsOk()); EXPECT_THAT( builtin_response.request()->GetAddressResults().value().endpoints(), @@ -5024,7 +5024,7 @@ TEST_F(HostResolverManagerDnsTest, Ipv6Unreachable_Localhost) { ChangeDnsConfig(config); ResolveHostResponseHelper ipv6_disabled_response(resolver_->CreateRequest( HostPortPair("localhost", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(ipv6_disabled_response.result_error(), IsOk()); EXPECT_THAT( ipv6_disabled_response.request()->GetAddressResults().value().endpoints(), @@ -5064,7 +5064,7 @@ TEST_F(HostResolverManagerDnsTest, SeparateJobsBySecureDnsMode) { ResolveHostResponseHelper automatic_response0(resolver_->CreateRequest( HostPortPair("a", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_EQ(2u, resolver_->num_jobs_for_testing()); HostResolver::ResolveHostParameters parameters_allow_secure; @@ -5102,7 +5102,7 @@ TEST_F(HostResolverManagerDnsTest, CancelWithOneTransactionActive) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_FALSE(response.complete()); ASSERT_EQ(1u, num_running_dispatcher_jobs()); @@ -5120,7 +5120,7 @@ TEST_F(HostResolverManagerDnsTest, CancelWithOneTransactionActiveOnePending) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_EQ(1u, num_running_dispatcher_jobs()); response.CancelRequest(); @@ -5136,7 +5136,7 @@ TEST_F(HostResolverManagerDnsTest, CancelWithTwoTransactionsActive) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_EQ(2u, num_running_dispatcher_jobs()); response.CancelRequest(); @@ -5162,7 +5162,7 @@ TEST_F(HostResolverManagerDnsTest, DeleteWithActiveTransactions) { responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair(hostname, 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); } EXPECT_EQ(10u, num_running_dispatcher_jobs()); @@ -5183,7 +5183,7 @@ TEST_F(HostResolverManagerDnsTest, DeleteWithSecureTransactions) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("secure", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); DestroyResolver(); @@ -5196,7 +5196,7 @@ TEST_F(HostResolverManagerDnsTest, DeleteWithCompletedRequests) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); EXPECT_THAT(response.request()->GetAddressResults().value().endpoints(), @@ -5216,7 +5216,7 @@ TEST_F(HostResolverManagerDnsTest, ExplicitCancel) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("4slow_4ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); response.request()->Cancel(); dns_client_->CompleteDelayedTransactions(); @@ -5230,7 +5230,7 @@ TEST_F(HostResolverManagerDnsTest, ExplicitCancel_AfterManagerDestruction) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("4slow_4ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); DestroyResolver(); response.request()->Cancel(); @@ -5241,7 +5241,7 @@ TEST_F(HostResolverManagerDnsTest, ExplicitCancel_Completed) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); EXPECT_THAT(response.request()->GetAddressResults().value().endpoints(), @@ -5262,7 +5262,7 @@ TEST_F(HostResolverManagerDnsTest, CancelWithIPv6TransactionActive) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("6slow_ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_EQ(2u, num_running_dispatcher_jobs()); // The IPv4 request should complete, the IPv6 request is still pending. @@ -5283,7 +5283,7 @@ TEST_F(HostResolverManagerDnsTest, CancelWithIPv4TransactionPending) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("4slow_ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_EQ(2u, num_running_dispatcher_jobs()); // The IPv6 request should complete, the IPv4 request is still pending. @@ -5321,7 +5321,7 @@ TEST_F(HostResolverManagerDnsTest, CancelWithAutomaticModeTransactionPending) { ResolveHostResponseHelper response0(resolver_->CreateRequest( HostPortPair("secure_6slow_6nx_insecure_6slow_ok", 80), - NetworkIsolationKey(), NetLogWithSource(), base::nullopt, + NetworkIsolationKey(), NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_EQ(0u, num_running_dispatcher_jobs()); @@ -5337,7 +5337,7 @@ TEST_F(HostResolverManagerDnsTest, CancelWithAutomaticModeTransactionPending) { ResolveHostResponseHelper response1(resolver_->CreateRequest( HostPortPair("secure_6slow_6nx_insecure_6slow_ok", 80), - NetworkIsolationKey(), NetLogWithSource(), base::nullopt, + NetworkIsolationKey(), NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_EQ(0u, num_running_dispatcher_jobs()); @@ -5371,22 +5371,22 @@ TEST_F(HostResolverManagerDnsTest, AAAACompletesFirst) { responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("4slow_ok", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("4slow_4ok", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("4slow_4timeout", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("4slow_6timeout", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); base::RunLoop().RunUntilIdle(); @@ -5436,7 +5436,7 @@ TEST_F(HostResolverManagerDnsTest, AAAACompletesFirst_AutomaticMode) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("secure_slow_nx_insecure_4slow_ok", 80), - NetworkIsolationKey(), NetLogWithSource(), base::nullopt, + NetworkIsolationKey(), NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); base::RunLoop().RunUntilIdle(); EXPECT_FALSE(response.complete()); @@ -5471,7 +5471,7 @@ TEST_F(HostResolverManagerDnsTest, SecureDnsMode_Automatic) { // A successful DoH request should result in a secure cache entry. ResolveHostResponseHelper response_secure(resolver_->CreateRequest( HostPortPair("automatic", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_THAT(response_secure.result_error(), IsOk()); EXPECT_FALSE( response_secure.request()->GetResolveErrorInfo().is_secure_network_error); @@ -5490,7 +5490,7 @@ TEST_F(HostResolverManagerDnsTest, SecureDnsMode_Automatic) { // entry. ResolveHostResponseHelper response_insecure(resolver_->CreateRequest( HostPortPair("insecure_automatic", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_THAT(response_insecure.result_error(), IsOk()); EXPECT_FALSE(response_insecure.request() @@ -5510,7 +5510,7 @@ TEST_F(HostResolverManagerDnsTest, SecureDnsMode_Automatic) { // Fallback to ProcTask allowed in AUTOMATIC mode. ResolveHostResponseHelper response_proc(resolver_->CreateRequest( HostPortPair("nx_succeed", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); proc_->SignalMultiple(1u); EXPECT_THAT(response_proc.result_error(), IsOk()); EXPECT_THAT(response_proc.request()->GetAddressResults().value().endpoints(), @@ -5535,7 +5535,7 @@ TEST_F(HostResolverManagerDnsTest, SecureDnsMode_Automatic_SecureCache) { // The secure cache should be checked prior to any DoH request being sent. ResolveHostResponseHelper response_secure_cached(resolver_->CreateRequest( HostPortPair("automatic_cached", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response_secure_cached.result_error(), IsOk()); EXPECT_FALSE(response_secure_cached.request() @@ -5565,7 +5565,7 @@ TEST_F(HostResolverManagerDnsTest, SecureDnsMode_Automatic_InsecureCache) { // The insecure cache should be checked after DoH requests fail. ResolveHostResponseHelper response_insecure_cached(resolver_->CreateRequest( HostPortPair("insecure_automatic_cached", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response_insecure_cached.result_error(), IsOk()); EXPECT_FALSE(response_insecure_cached.request() @@ -5608,7 +5608,7 @@ TEST_F(HostResolverManagerDnsTest, SecureDnsMode_Automatic_Downgrade) { // The secure cache should still be checked first. ResolveHostResponseHelper response_cached(resolver_->CreateRequest( HostPortPair("automatic_cached", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response_cached.result_error(), IsOk()); EXPECT_THAT( @@ -5618,7 +5618,7 @@ TEST_F(HostResolverManagerDnsTest, SecureDnsMode_Automatic_Downgrade) { // The insecure cache should be checked before any insecure requests are sent. ResolveHostResponseHelper insecure_response_cached(resolver_->CreateRequest( HostPortPair("insecure_automatic_cached", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(insecure_response_cached.result_error(), IsOk()); EXPECT_THAT(insecure_response_cached.request() @@ -5632,7 +5632,7 @@ TEST_F(HostResolverManagerDnsTest, SecureDnsMode_Automatic_Downgrade) { // insecure cache entry. ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("automatic", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_THAT(response.result_error(), IsOk()); EXPECT_THAT(response.request()->GetAddressResults().value().endpoints(), testing::UnorderedElementsAre(CreateExpected("127.0.0.1", 80), @@ -5655,7 +5655,7 @@ TEST_F(HostResolverManagerDnsTest, SecureDnsMode_Automatic_Unavailable) { // in automatic mode. The cached result should be in the insecure cache. ResolveHostResponseHelper response_automatic(resolver_->CreateRequest( HostPortPair("automatic", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_THAT(response_automatic.result_error(), IsOk()); EXPECT_FALSE(response_automatic.request() ->GetResolveErrorInfo() @@ -5690,7 +5690,7 @@ TEST_F(HostResolverManagerDnsTest, SecureDnsMode_Automatic_Unavailable_Fail) { // Insecure requests that fail should not be cached. ResolveHostResponseHelper response_secure(resolver_->CreateRequest( HostPortPair("secure", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_THAT(response_secure.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); EXPECT_FALSE( response_secure.request()->GetResolveErrorInfo().is_secure_network_error); @@ -5745,14 +5745,14 @@ TEST_F(HostResolverManagerDnsTest, // ERR_NAME_NOT_RESOLVED. ResolveHostResponseHelper response_secure(resolver_->CreateRequest( HostPortPair("secure", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, &resolve_context1, resolve_context_->host_cache())); + absl::nullopt, &resolve_context1, resolve_context_->host_cache())); ASSERT_THAT(response_secure.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); // One available DoH server for |resolve_context2|, so expect a secure // request. Secure requests for "secure" will succeed. ResolveHostResponseHelper response_secure2(resolver_->CreateRequest( HostPortPair("secure", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, &resolve_context2, nullptr /* host_cache */)); + absl::nullopt, &resolve_context2, nullptr /* host_cache */)); ASSERT_THAT(response_secure2.result_error(), IsOk()); resolver_->DeregisterResolveContext(&resolve_context1); @@ -5807,7 +5807,7 @@ TEST_F(HostResolverManagerDnsTest, // The secure part of the dns client should be enabled. ResolveHostResponseHelper response_secure(resolver_->CreateRequest( HostPortPair("automatic", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_THAT(response_secure.result_error(), IsOk()); EXPECT_THAT( response_secure.request()->GetAddressResults().value().endpoints(), @@ -5824,7 +5824,7 @@ TEST_F(HostResolverManagerDnsTest, // should be skipped. ResolveHostResponseHelper response_insecure(resolver_->CreateRequest( HostPortPair("insecure_automatic", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); proc_->SignalMultiple(1u); ASSERT_THAT(response_insecure.result_error(), IsOk()); @@ -5849,7 +5849,7 @@ TEST_F(HostResolverManagerDnsTest, // the dns client is disabled. ResolveHostResponseHelper response_insecure_cached(resolver_->CreateRequest( HostPortPair("insecure_automatic_cached", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response_insecure_cached.result_error(), IsOk()); EXPECT_THAT(response_insecure_cached.request() @@ -5873,7 +5873,7 @@ TEST_F(HostResolverManagerDnsTest, SecureDnsMode_Automatic_DotActive) { // The secure part of the dns client should be enabled. ResolveHostResponseHelper response_secure(resolver_->CreateRequest( HostPortPair("automatic", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_THAT(response_secure.result_error(), IsOk()); EXPECT_THAT( response_secure.request()->GetAddressResults().value().endpoints(), @@ -5890,7 +5890,7 @@ TEST_F(HostResolverManagerDnsTest, SecureDnsMode_Automatic_DotActive) { // requests will be secure. ResolveHostResponseHelper response_insecure(resolver_->CreateRequest( HostPortPair("insecure_automatic", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); proc_->SignalMultiple(1u); ASSERT_THAT(response_insecure.result_error(), IsOk()); @@ -5917,7 +5917,7 @@ TEST_F(HostResolverManagerDnsTest, SecureDnsMode_Automatic_DotActive) { // The insecure cache should still be checked. ResolveHostResponseHelper response_insecure_cached(resolver_->CreateRequest( HostPortPair("insecure_automatic_cached", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response_insecure_cached.result_error(), IsOk()); EXPECT_FALSE(response_insecure_cached.request() @@ -5942,7 +5942,7 @@ TEST_F(HostResolverManagerDnsTest, SecureDnsMode_Secure) { ResolveHostResponseHelper response_secure(resolver_->CreateRequest( HostPortPair("secure", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_THAT(response_secure.result_error(), IsOk()); EXPECT_FALSE( response_secure.request()->GetResolveErrorInfo().is_secure_network_error); @@ -5955,7 +5955,7 @@ TEST_F(HostResolverManagerDnsTest, SecureDnsMode_Secure) { ResolveHostResponseHelper response_insecure(resolver_->CreateRequest( HostPortPair("ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_THAT(response_insecure.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); EXPECT_TRUE(response_insecure.request() ->GetResolveErrorInfo() @@ -5969,7 +5969,7 @@ TEST_F(HostResolverManagerDnsTest, SecureDnsMode_Secure) { // Fallback to ProcTask not allowed in SECURE mode. ResolveHostResponseHelper response_proc(resolver_->CreateRequest( HostPortPair("nx_succeed", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); proc_->SignalMultiple(1u); EXPECT_THAT(response_proc.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); EXPECT_TRUE( @@ -5992,7 +5992,7 @@ TEST_F(HostResolverManagerDnsTest, SecureDnsMode_Secure_InsecureAsyncDisabled) { // The secure part of the dns client should be enabled. ResolveHostResponseHelper response_secure(resolver_->CreateRequest( HostPortPair("secure", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_THAT(response_secure.result_error(), IsOk()); HostCache::Key secure_key = HostCache::Key( "secure", DnsQueryType::UNSPECIFIED, 0 /* host_resolver_flags */, @@ -6054,7 +6054,7 @@ TEST_F(HostResolverManagerDnsTest, SecureDnsMode_Secure_Local_CacheHit) { // secure cache. ResolveHostResponseHelper response_cached(resolver_->CreateRequest( HostPortPair("secure", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_TRUE(response_cached.complete()); EXPECT_THAT(response_cached.result_error(), IsOk()); EXPECT_FALSE( @@ -6084,13 +6084,13 @@ TEST_F(HostResolverManagerDnsTest, SlowResolve) { ResolveHostResponseHelper response0(resolver_->CreateRequest( HostPortPair("ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ResolveHostResponseHelper response1(resolver_->CreateRequest( HostPortPair("slow_fail", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ResolveHostResponseHelper response2(resolver_->CreateRequest( HostPortPair("slow_succeed", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); proc_->SignalMultiple(3u); @@ -6131,13 +6131,13 @@ TEST_F(HostResolverManagerDnsTest, SlowSecureResolve_AutomaticMode) { ResolveHostResponseHelper response0(resolver_->CreateRequest( HostPortPair("secure", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ResolveHostResponseHelper response1(resolver_->CreateRequest( HostPortPair("slow_fail", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ResolveHostResponseHelper response2(resolver_->CreateRequest( HostPortPair("slow_succeed", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response0.result_error(), IsOk()); @@ -6167,10 +6167,10 @@ TEST_F(HostResolverManagerDnsTest, SlowSecureResolve_SecureMode) { ResolveHostResponseHelper response0(resolver_->CreateRequest( HostPortPair("secure", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ResolveHostResponseHelper response1(resolver_->CreateRequest( HostPortPair("slow", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response0.result_error(), IsOk()); EXPECT_THAT(response1.result_error(), IsOk()); @@ -6184,7 +6184,7 @@ TEST_F(HostResolverManagerDnsTest, SerialResolver) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_FALSE(response.complete()); EXPECT_EQ(1u, num_running_dispatcher_jobs()); @@ -6208,11 +6208,11 @@ TEST_F(HostResolverManagerDnsTest, AAAAStartsAfterOtherJobFinishes) { ResolveHostResponseHelper response0(resolver_->CreateRequest( HostPortPair("ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_EQ(2u, num_running_dispatcher_jobs()); ResolveHostResponseHelper response1(resolver_->CreateRequest( HostPortPair("4slow_ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_EQ(3u, num_running_dispatcher_jobs()); // Request 0's transactions should complete, starting Request 1's second @@ -6246,7 +6246,7 @@ TEST_F(HostResolverManagerDnsTest, IPv4EmptyFallback) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("empty_fallback", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); EXPECT_THAT(response.request()->GetAddressResults().value().endpoints(), @@ -6262,7 +6262,7 @@ TEST_F(HostResolverManagerDnsTest, UnspecEmptyFallback) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("empty_fallback", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); @@ -6291,18 +6291,18 @@ TEST_F(HostResolverManagerDnsTest, InvalidDnsConfigWithPendingRequests) { responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("slow_nx1", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); // Next job gets one slot, and waits on another. responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("slow_nx2", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); EXPECT_EQ(3u, num_running_dispatcher_jobs()); @@ -6325,7 +6325,7 @@ TEST_F(HostResolverManagerDnsTest, DontAbortOnInitialDNSConfigRead) { // using ProcTask. ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("host1", 70), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_FALSE(response.complete()); EXPECT_TRUE(proc_->WaitFor(1u)); @@ -6411,7 +6411,7 @@ TEST_F(HostResolverManagerDnsTest, // Secure DnsTasks should not be affected. ResolveHostResponseHelper response_secure(resolver_->CreateRequest( HostPortPair("automatic", 80), NetworkIsolationKey(), - NetLogWithSource(), /* optional_parameters=*/base::nullopt, + NetLogWithSource(), /* optional_parameters=*/absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_FALSE(response_secure.complete()); @@ -6471,21 +6471,21 @@ TEST_F(HostResolverManagerDnsTest, responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("slow_ok1", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); EXPECT_FALSE(responses[0]->complete()); // Next job gets one slot, and waits on another. responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("slow_ok2", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); EXPECT_FALSE(responses[1]->complete()); // Next one is queued. responses.emplace_back( std::make_unique(resolver_->CreateRequest( HostPortPair("ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache()))); EXPECT_FALSE(responses[2]->complete()); @@ -6584,7 +6584,7 @@ TEST_F(HostResolverManagerDnsTest, NoCheckIpv6OnWifi) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("h1", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); HostResolver::ResolveHostParameters parameters; parameters.dns_query_type = DnsQueryType::A; ResolveHostResponseHelper v4_response(resolver_->CreateRequest( @@ -6617,7 +6617,7 @@ TEST_F(HostResolverManagerDnsTest, NoCheckIpv6OnWifi) { ResolveHostResponseHelper no_wifi_response(resolver_->CreateRequest( HostPortPair("h1", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); parameters.dns_query_type = DnsQueryType::A; ResolveHostResponseHelper no_wifi_v4_response(resolver_->CreateRequest( HostPortPair("h1", 80), NetworkIsolationKey(), NetLogWithSource(), @@ -6653,7 +6653,7 @@ TEST_F(HostResolverManagerDnsTest, NotFoundTTL) { // NODATA ResolveHostResponseHelper no_data_response(resolver_->CreateRequest( HostPortPair("empty", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(no_data_response.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); EXPECT_FALSE(no_data_response.request()->GetAddressResults()); HostCache::Key key("empty", DnsQueryType::UNSPECIFIED, 0, @@ -6669,7 +6669,7 @@ TEST_F(HostResolverManagerDnsTest, NotFoundTTL) { // NXDOMAIN ResolveHostResponseHelper no_domain_response(resolver_->CreateRequest( HostPortPair("nodomain", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(no_domain_response.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); EXPECT_FALSE(no_domain_response.request()->GetAddressResults()); @@ -6707,7 +6707,7 @@ TEST_F(HostResolverManagerDnsTest, CachedError) { ResolveHostResponseHelper no_domain_response_with_fallback( resolver_->CreateRequest(HostPortPair("nodomain", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(no_domain_response_with_fallback.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); @@ -6726,7 +6726,7 @@ TEST_F(HostResolverManagerDnsTest, CachedError) { // Populate cache with an error. ResolveHostResponseHelper no_domain_response(resolver_->CreateRequest( HostPortPair("nodomain", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(no_domain_response.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); @@ -6770,7 +6770,7 @@ TEST_F(HostResolverManagerDnsTest, CachedError_AutomaticMode) { // Populate both secure and insecure caches with an error. ResolveHostResponseHelper no_domain_response(resolver_->CreateRequest( HostPortPair("automatic_nodomain", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(no_domain_response.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); @@ -6812,7 +6812,7 @@ TEST_F(HostResolverManagerDnsTest, CachedError_SecureMode) { // Populate secure cache with an error. ResolveHostResponseHelper no_domain_response(resolver_->CreateRequest( HostPortPair("automatic_nodomain", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt, resolve_context_.get(), + NetLogWithSource(), absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(no_domain_response.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); @@ -6833,7 +6833,7 @@ TEST_F(HostResolverManagerDnsTest, TtlNotSharedBetweenQtypes) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("4slow_4timeout", 80), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt /* optional_parameters */, + NetLogWithSource(), absl::nullopt /* optional_parameters */, resolve_context_.get(), resolve_context_->host_cache())); // Ensure success completes before the timeout result. @@ -6860,7 +6860,7 @@ TEST_F(HostResolverManagerDnsTest, NoCanonicalName) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("alias", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_THAT(response.result_error(), IsOk()); // HostResolver may still give name, but if so, it must be correct. @@ -7090,7 +7090,7 @@ TEST_F(HostResolverManagerDnsTest, SortsAndDeduplicatesAddresses) { 3, BuildTestAddressRecord("duplicate", IPAddress::IPv4Localhost())); std::string dns_name; CHECK(DNSDomainFromDot("duplicate", &dns_name)); - base::Optional query(absl::in_place, 0, dns_name, + absl::optional query(absl::in_place, 0, dns_name, dns_protocol::kTypeA); rules.emplace_back( @@ -7107,7 +7107,7 @@ TEST_F(HostResolverManagerDnsTest, SortsAndDeduplicatesAddresses) { 3, BuildTestAddressRecord("duplicate", IPAddress::IPv6Localhost())); std::string dns_name; CHECK(DNSDomainFromDot("duplicate", &dns_name)); - base::Optional query(absl::in_place, 0, dns_name, + absl::optional query(absl::in_place, 0, dns_name, dns_protocol::kTypeAAAA); rules.emplace_back( @@ -7124,7 +7124,7 @@ TEST_F(HostResolverManagerDnsTest, SortsAndDeduplicatesAddresses) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("duplicate", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_THAT(response.result_error(), IsOk()); EXPECT_THAT( @@ -7201,7 +7201,7 @@ TEST_F(HostResolverManagerDnsTest, AddDnsOverHttpsServerAfterConfig) { EXPECT_EQ(doh_servers->GetList().size(), 1u); base::Value& server_method = doh_servers->GetList()[0]; EXPECT_TRUE(server_method.is_dict()); - base::Optional use_post = server_method.FindBoolKey("use_post"); + absl::optional use_post = server_method.FindBoolKey("use_post"); EXPECT_TRUE(use_post); const std::string* server_template = server_method.FindStringKey("server_template"); @@ -7234,7 +7234,7 @@ TEST_F(HostResolverManagerDnsTest, AddDnsOverHttpsServerBeforeConfig) { EXPECT_EQ(doh_servers->GetList().size(), 1u); base::Value& server_method = doh_servers->GetList()[0]; EXPECT_TRUE(server_method.is_dict()); - base::Optional use_post = server_method.FindBoolKey("use_post"); + absl::optional use_post = server_method.FindBoolKey("use_post"); EXPECT_TRUE(use_post); const std::string* server_template = server_method.FindStringKey("server_template"); @@ -7267,7 +7267,7 @@ TEST_F(HostResolverManagerDnsTest, AddDnsOverHttpsServerBeforeClient) { EXPECT_EQ(doh_servers->GetList().size(), 1u); base::Value& server_method = doh_servers->GetList()[0]; EXPECT_TRUE(server_method.is_dict()); - base::Optional use_post = server_method.FindBoolKey("use_post"); + absl::optional use_post = server_method.FindBoolKey("use_post"); EXPECT_TRUE(use_post); const std::string* server_template = server_method.FindStringKey("server_template"); @@ -7302,7 +7302,7 @@ TEST_F(HostResolverManagerDnsTest, AddDnsOverHttpsServerAndThenRemove) { EXPECT_EQ(doh_servers->GetList().size(), 1u); base::Value& server_method = doh_servers->GetList()[0]; EXPECT_TRUE(server_method.is_dict()); - base::Optional use_post = server_method.FindBoolKey("use_post"); + absl::optional use_post = server_method.FindBoolKey("use_post"); EXPECT_TRUE(use_post); const std::string* server_template = server_method.FindStringKey("server_template"); @@ -7611,7 +7611,7 @@ TEST_F(HostResolverManagerDnsTest, NoBaseConfig_PartialOverrides) { DnsClient* client_ptr = client.get(); resolver_->SetDnsClientForTesting(std::move(client)); - client_ptr->SetSystemConfig(base::nullopt); + client_ptr->SetSystemConfig(absl::nullopt); DnsConfigOverrides overrides; overrides.nameservers.emplace({CreateExpected("192.168.0.3", 193)}); @@ -7637,7 +7637,7 @@ TEST_F(HostResolverManagerDnsTest, NoBaseConfig_OverridesEverything) { DnsClient* client_ptr = client.get(); resolver_->SetDnsClientForTesting(std::move(client)); - client_ptr->SetSystemConfig(base::nullopt); + client_ptr->SetSystemConfig(absl::nullopt); DnsConfigOverrides overrides = DnsConfigOverrides::CreateOverridingEverythingWithDefaults(); @@ -7895,7 +7895,7 @@ TEST_F(HostResolverManagerDnsTest, FlushCacheOnDnsConfigOverridesChange) { // Populate cache. ResolveHostResponseHelper initial_response(resolver_->CreateRequest( HostPortPair("ok", 70), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(initial_response.result_error(), IsOk()); // Confirm result now cached. @@ -7957,7 +7957,7 @@ TEST_F(HostResolverManagerDnsTest, CancellationOnBaseConfigChange) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("4slow_ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_FALSE(response.complete()); DnsConfig new_config = original_config; @@ -7982,7 +7982,7 @@ TEST_F(HostResolverManagerDnsTest, ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("4slow_ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_FALSE(response.complete()); DnsConfig new_config = original_config; @@ -7999,7 +7999,7 @@ TEST_F(HostResolverManagerDnsTest, CancelQueriesOnSettingOverrides) { ChangeDnsConfig(CreateValidDnsConfig()); ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("4slow_ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_FALSE(response.complete()); DnsConfigOverrides overrides; @@ -8019,7 +8019,7 @@ TEST_F(HostResolverManagerDnsTest, ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("4slow_ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_FALSE(response.complete()); resolver_->SetDnsConfigOverrides(overrides); @@ -8038,7 +8038,7 @@ TEST_F(HostResolverManagerDnsTest, CancelQueriesOnClearingOverrides) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("4slow_ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_FALSE(response.complete()); resolver_->SetDnsConfigOverrides(DnsConfigOverrides()); @@ -8053,7 +8053,7 @@ TEST_F(HostResolverManagerDnsTest, ChangeDnsConfig(CreateValidDnsConfig()); ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("4slow_ok", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); ASSERT_FALSE(response.complete()); resolver_->SetDnsConfigOverrides(DnsConfigOverrides()); @@ -8835,7 +8835,7 @@ TEST_F(HostResolverManagerDnsTest, SrvQuery) { EXPECT_FALSE(response.request()->GetExperimentalResultsForTesting()); // Expect ordered by priority, and random within a priority. - base::Optional> results = + absl::optional> results = response.request()->GetHostnameResults(); ASSERT_THAT( results, @@ -9128,7 +9128,7 @@ TEST_F(HostResolverManagerDnsTest, SrvDnsQuery) { EXPECT_FALSE(response.request()->GetExperimentalResultsForTesting()); // Expect ordered by priority, and random within a priority. - base::Optional> results = + absl::optional> results = response.request()->GetHostnameResults(); ASSERT_THAT( results, @@ -9699,7 +9699,7 @@ TEST_F(HostResolverManagerDnsTest, HttpsInAddressQuery) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(kName, 108), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); EXPECT_TRUE(response.request()->GetAddressResults()); EXPECT_FALSE(response.request()->GetTextResults()); @@ -9741,7 +9741,7 @@ TEST_F(HostResolverManagerDnsTest, HttpsInAddressQuery_MultipleResults) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(kName, 108), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); EXPECT_TRUE(response.request()->GetAddressResults()); EXPECT_FALSE(response.request()->GetTextResults()); @@ -9778,7 +9778,7 @@ TEST_F(HostResolverManagerDnsTest, HttpsInAddressQuery_AddressesOnly) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(kName, 108), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); EXPECT_TRUE(response.request()->GetAddressResults()); EXPECT_FALSE(response.request()->GetTextResults()); @@ -9817,7 +9817,7 @@ TEST_F(HostResolverManagerDnsTest, HttpsInAddressQuery_HttpsOnly) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(kName, 108), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); EXPECT_FALSE(response.request()->GetAddressResults()); EXPECT_FALSE(response.request()->GetHostnameResults()); @@ -9856,7 +9856,7 @@ TEST_F(HostResolverManagerDnsTest, HttpsInAddressQuery_AddressError) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(kName, 108), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); EXPECT_FALSE(response.request()->GetAddressResults()); EXPECT_FALSE(response.request()->GetTextResults()); @@ -9892,7 +9892,7 @@ TEST_F(HostResolverManagerDnsTest, HttpsInAddressQuery_HttpsError) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(kName, 108), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); EXPECT_TRUE(response.request()->GetAddressResults()); EXPECT_FALSE(response.request()->GetTextResults()); @@ -9928,7 +9928,7 @@ TEST_F(HostResolverManagerDnsTest, HttpsInAddressQuery_NoData) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(kName, 108), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsError(ERR_NAME_NOT_RESOLVED)); EXPECT_FALSE(response.request()->GetAddressResults()); EXPECT_FALSE(response.request()->GetTextResults()); @@ -9967,7 +9967,7 @@ TEST_F(HostResolverManagerDnsTest, HttpsInAddressQuery_HttpsLast) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(kName, 108), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); base::RunLoop().RunUntilIdle(); ASSERT_FALSE(response.complete()); @@ -10013,7 +10013,7 @@ TEST_F(HostResolverManagerDnsTest, HttpsInAddressQuery_AddressesLast) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(kName, 108), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); base::RunLoop().RunUntilIdle(); ASSERT_FALSE(response.complete()); @@ -10059,7 +10059,7 @@ TEST_F(HostResolverManagerDnsTest, ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(kName, 108), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); EXPECT_TRUE(response.request()->GetAddressResults()); @@ -10100,7 +10100,7 @@ TEST_F(HostResolverManagerDnsTest, ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(kName, 108), NetworkIsolationKey(), NetLogWithSource(), - /*optional_parameters=*/base::nullopt, resolve_context_.get(), + /*optional_parameters=*/absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); @@ -10147,7 +10147,7 @@ TEST_F(HostResolverManagerDnsTest, ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(kName, 108), NetworkIsolationKey(), NetLogWithSource(), - /*optional_parameters=*/base::nullopt, resolve_context_.get(), + /*optional_parameters=*/absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); @@ -10193,7 +10193,7 @@ TEST_F(HostResolverManagerDnsTest, ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(kName, 108), NetworkIsolationKey(), NetLogWithSource(), - /*optional_parameters=*/base::nullopt, resolve_context_.get(), + /*optional_parameters=*/absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); @@ -10249,7 +10249,7 @@ TEST_F(HostResolverManagerDnsTest, ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(kName, 108), NetworkIsolationKey(), NetLogWithSource(), - /*optional_parameters=*/base::nullopt, resolve_context_.get(), + /*optional_parameters=*/absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); @@ -10290,7 +10290,7 @@ TEST_F(HostResolverManagerDnsTest, HttpsInAddressQuery_ExperimentalTimeout) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(kName, 108), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); base::RunLoop().RunUntilIdle(); EXPECT_FALSE(response.complete()); @@ -10336,7 +10336,7 @@ TEST_F(HostResolverManagerDnsTest, MultipleExperimentalQueries) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(kName, 108), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); EXPECT_TRUE(response.request()->GetAddressResults()); EXPECT_FALSE(response.request()->GetTextResults()); @@ -10380,7 +10380,7 @@ TEST_F(HostResolverManagerDnsTest, MultipleExperimentalQueries_Timeout) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(kName, 108), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); base::RunLoop().RunUntilIdle(); EXPECT_FALSE(response.complete()); @@ -10420,7 +10420,7 @@ TEST_F(HostResolverManagerDnsTest, UnsolicitedHttps) { ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair(kName, 108), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, resolve_context_.get(), resolve_context_->host_cache())); + absl::nullopt, resolve_context_.get(), resolve_context_->host_cache())); EXPECT_THAT(response.result_error(), IsOk()); EXPECT_TRUE(response.request()->GetAddressResults()); EXPECT_FALSE(response.request()->GetTextResults()); @@ -10462,7 +10462,7 @@ class HostResolverManagerDnsTestIntegrity : public HostResolverManagerDnsTest { std::vector GetValidIntegrityRdata() { const IntegrityRecordRdata kValidRecord({'f', 'o', 'o'}); - base::Optional> valid_serialized = + absl::optional> valid_serialized = kValidRecord.Serialize(); CHECK(valid_serialized); return *valid_serialized; @@ -10536,7 +10536,7 @@ TEST_F(HostResolverManagerDnsTestIntegrity, IntegrityQuery) { DoIntegrityQuery(true /* use_secure */); EXPECT_THAT(response->result_error(), IsOk()); - base::Optional> results = + absl::optional> results = response->request()->GetExperimentalResultsForTesting(); EXPECT_TRUE(response->request()->GetAddressResults()); @@ -10553,7 +10553,7 @@ TEST_F(HostResolverManagerDnsTestIntegrity, IntegrityQueryMangled) { DoIntegrityQuery(true /* use_secure */); EXPECT_THAT(response->result_error(), IsOk()); - base::Optional> results = + absl::optional> results = response->request()->GetExperimentalResultsForTesting(); EXPECT_TRUE(response->request()->GetAddressResults()); @@ -10573,7 +10573,7 @@ TEST_F(HostResolverManagerDnsTestIntegrity, IntegrityQueryOnlyOverSecure) { DoIntegrityQuery(false /* use_secure */); EXPECT_THAT(response->result_error(), IsOk()); - base::Optional> results = + absl::optional> results = response->request()->GetExperimentalResultsForTesting(); EXPECT_FALSE(results); @@ -11195,7 +11195,7 @@ TEST_F(HostResolverManagerDnsTest, dns_client_->GetCurrentSession()); ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("secure", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, &context, context.host_cache())); + absl::nullopt, &context, context.host_cache())); EXPECT_THAT(response.result_error(), IsOk()); resolver_->DeregisterResolveContext(&context); @@ -11234,7 +11234,7 @@ TEST_F(HostResolverManagerDnsTest, dns_client_->GetCurrentSession()); ResolveHostResponseHelper response(resolver_->CreateRequest( HostPortPair("secure", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt, &context, context.host_cache())); + absl::nullopt, &context, context.host_cache())); EXPECT_THAT(response.result_error(), IsOk()); resolver_->DeregisterResolveContext(&context); diff --git a/net/dns/host_resolver_proc.cc b/net/dns/host_resolver_proc.cc index 3da9fb43255c45..eca5fce0c955d4 100644 --- a/net/dns/host_resolver_proc.cc +++ b/net/dns/host_resolver_proc.cc @@ -180,7 +180,7 @@ int SystemHostResolverCall(const std::string& host, !defined(OS_ANDROID) && !defined(OS_FUCHSIA) DnsReloaderMaybeReload(); #endif - base::Optional ai; + absl::optional ai; int err = 0; int os_error = 0; std::tie(ai, err, os_error) = AddressInfo::Get(host, hints); diff --git a/net/dns/https_record_rdata.cc b/net/dns/https_record_rdata.cc index 94e3e1b0a3a2a0..627b2c48367ed2 100644 --- a/net/dns/https_record_rdata.cc +++ b/net/dns/https_record_rdata.cc @@ -19,17 +19,17 @@ #include "base/dcheck_is_on.h" #include "base/immediate_crash.h" #include "base/memory/ptr_util.h" -#include "base/optional.h" #include "base/strings/string_piece.h" #include "net/base/ip_address.h" #include "net/dns/dns_util.h" #include "net/dns/public/dns_protocol.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { namespace { -bool ReadNextServiceParam(base::Optional last_key, +bool ReadNextServiceParam(absl::optional last_key, base::BigEndianReader& reader, uint16_t* out_param_key, base::StringPiece* out_param_value) { @@ -215,13 +215,13 @@ std::unique_ptr AliasFormHttpsRecordRdata::Parse( if (priority != 0) return nullptr; - base::Optional alias_name = + absl::optional alias_name = DnsDomainToString(reader, true /* require_complete */); if (!alias_name.has_value()) return nullptr; // Ignore any params. - base::Optional last_param_key; + absl::optional last_param_key; while (reader.remaining() > 0) { uint16_t param_key; base::StringPiece param_value; @@ -257,7 +257,7 @@ ServiceFormHttpsRecordRdata::ServiceFormHttpsRecordRdata( std::set mandatory_keys, std::vector alpn_ids, bool default_alpn, - base::Optional port, + absl::optional port, std::vector ipv4_hint, std::string ech_config, std::vector ipv6_hint, @@ -323,7 +323,7 @@ std::unique_ptr ServiceFormHttpsRecordRdata::Parse( if (priority == 0) return nullptr; - base::Optional service_name = + absl::optional service_name = DnsDomainToString(reader, true /* require_complete */); if (!service_name.has_value()) return nullptr; @@ -333,7 +333,7 @@ std::unique_ptr ServiceFormHttpsRecordRdata::Parse( priority, std::move(service_name).value(), std::set() /* mandatory_keys */, std::vector() /* alpn_ids */, true /* default_alpn */, - base::nullopt /* port */, std::vector() /* ipv4_hint */, + absl::nullopt /* port */, std::vector() /* ipv4_hint */, std::string() /* ech_config */, std::vector() /* ipv6_hint */, std::map() /* unparsed_params */); @@ -341,7 +341,7 @@ std::unique_ptr ServiceFormHttpsRecordRdata::Parse( uint16_t param_key = 0; base::StringPiece param_value; - if (!ReadNextServiceParam(base::nullopt /* last_key */, reader, ¶m_key, + if (!ReadNextServiceParam(absl::nullopt /* last_key */, reader, ¶m_key, ¶m_value)) return nullptr; @@ -382,7 +382,7 @@ std::unique_ptr ServiceFormHttpsRecordRdata::Parse( } } - base::Optional port; + absl::optional port; if (param_key == dns_protocol::kHttpsServiceParamKeyPort) { DCHECK(IsSupportedKey(param_key)); if (param_value.size() != 2) diff --git a/net/dns/https_record_rdata.h b/net/dns/https_record_rdata.h index 2b1123b49fb9d6..5dcea96190c517 100644 --- a/net/dns/https_record_rdata.h +++ b/net/dns/https_record_rdata.h @@ -12,12 +12,12 @@ #include #include -#include "base/optional.h" #include "base/strings/string_piece.h" #include "net/base/ip_address.h" #include "net/base/net_export.h" #include "net/dns/public/dns_protocol.h" #include "net/dns/record_rdata.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -97,7 +97,7 @@ class NET_EXPORT_PRIVATE ServiceFormHttpsRecordRdata : public HttpsRecordRdata { std::set mandatory_keys, std::vector alpn_ids, bool default_alpn, - base::Optional port, + absl::optional port, std::vector ipv4_hint, std::string ech_config, std::vector ipv6_hint, @@ -115,7 +115,7 @@ class NET_EXPORT_PRIVATE ServiceFormHttpsRecordRdata : public HttpsRecordRdata { const std::set& mandatory_keys() const { return mandatory_keys_; } const std::vector& alpn_ids() const { return alpn_ids_; } bool default_alpn() const { return default_alpn_; } - base::Optional port() const { return port_; } + absl::optional port() const { return port_; } const std::vector& ipv4_hint() const { return ipv4_hint_; } base::StringPiece ech_config() const { return ech_config_; } const std::vector& ipv6_hint() const { return ipv6_hint_; } @@ -139,7 +139,7 @@ class NET_EXPORT_PRIVATE ServiceFormHttpsRecordRdata : public HttpsRecordRdata { const std::set mandatory_keys_; const std::vector alpn_ids_; const bool default_alpn_; - const base::Optional port_; + const absl::optional port_; const std::vector ipv4_hint_; const std::string ech_config_; const std::vector ipv6_hint_; diff --git a/net/dns/https_record_rdata_unittest.cc b/net/dns/https_record_rdata_unittest.cc index 402935ed454531..ada6b0a878e052 100644 --- a/net/dns/https_record_rdata_unittest.cc +++ b/net/dns/https_record_rdata_unittest.cc @@ -114,7 +114,7 @@ TEST(HttpsRecordRdataTest, ParsesService) { ServiceFormHttpsRecordRdata expected( 1 /* priority */, "chromium.org", std::set({1, 2, 3, 4, 5, 6}), std::vector({"foo", "bar"}) /* alpn_ids */, - false /* default_alpn */, base::Optional(46) /* port */, + false /* default_alpn */, absl::optional(46) /* port */, std::vector({IPAddress(8, 8, 8, 8)}) /* ipv4_hint */, "hello" /* ech_config */, std::vector({expected_ipv6}) /* ipv6_hint */, @@ -160,7 +160,7 @@ TEST(HttpsRecordRdataTest, AliasIsEqualRejectsWrongType) { AliasFormHttpsRecordRdata alias("alias.name.test"); ServiceFormHttpsRecordRdata service( 1u /* priority */, "service.name.test", {} /* mandatory_keys */, - {} /* alpn_ids */, true /* default_alpn */, base::nullopt /* port */, + {} /* alpn_ids */, true /* default_alpn */, absl::nullopt /* port */, {} /* ipv4_hint */, "" /* ech_config */, {} /* ipv6_hint */, {} /* unparsed_params */); MalformedHttpsRecordRdata malformed; @@ -174,7 +174,7 @@ TEST(HttpsRecordRdataTest, ServiceIsEqualRejectsWrongType) { AliasFormHttpsRecordRdata alias("alias.name.test"); ServiceFormHttpsRecordRdata service( 1u /* priority */, "service.name.test", {} /* mandatory_keys */, - {} /* alpn_ids */, true /* default_alpn */, base::nullopt /* port */, + {} /* alpn_ids */, true /* default_alpn */, absl::nullopt /* port */, {} /* ipv4_hint */, "" /* ech_config */, {} /* ipv6_hint */, {} /* unparsed_params */); MalformedHttpsRecordRdata malformed; @@ -188,7 +188,7 @@ TEST(HttpsRecordRdataTest, MalformedIsEqualRejectsWrongType) { AliasFormHttpsRecordRdata alias("alias.name.test"); ServiceFormHttpsRecordRdata service( 1u /* priority */, "service.name.test", {} /* mandatory_keys */, - {} /* alpn_ids */, true /* default_alpn */, base::nullopt /* port */, + {} /* alpn_ids */, true /* default_alpn */, absl::nullopt /* port */, {} /* ipv4_hint */, "" /* ech_config */, {} /* ipv6_hint */, {} /* unparsed_params */); MalformedHttpsRecordRdata malformed; diff --git a/net/dns/httpssvc_metrics.cc b/net/dns/httpssvc_metrics.cc index 3e7abe447bac31..311ea18afd106e 100644 --- a/net/dns/httpssvc_metrics.cc +++ b/net/dns/httpssvc_metrics.cc @@ -44,7 +44,7 @@ HttpssvcExperimentDomainCache::~HttpssvcExperimentDomainCache() = default; bool HttpssvcExperimentDomainCache::ListContainsDomain( const std::string& domain_list, base::StringPiece domain, - base::Optional>& in_out_cached_list) { + absl::optional>& in_out_cached_list) { if (!in_out_cached_list) { in_out_cached_list = base::SplitString( domain_list, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); @@ -76,7 +76,7 @@ HttpssvcMetrics::~HttpssvcMetrics() { } void HttpssvcMetrics::SaveForAddressQuery( - base::Optional new_doh_provider_id, + absl::optional new_doh_provider_id, base::TimeDelta resolve_time, enum HttpssvcDnsRcode rcode) { set_doh_provider_id(new_doh_provider_id); @@ -92,7 +92,7 @@ void HttpssvcMetrics::SaveAddressQueryFailure() { } void HttpssvcMetrics::SaveForIntegrity( - base::Optional new_doh_provider_id, + absl::optional new_doh_provider_id, enum HttpssvcDnsRcode rcode_integrity, const std::vector& condensed_records, base::TimeDelta integrity_resolve_time) { @@ -117,7 +117,7 @@ void HttpssvcMetrics::SaveForIntegrity( integrity_resolve_time_ = integrity_resolve_time; } -void HttpssvcMetrics::SaveForHttps(base::Optional doh_provider_id, +void HttpssvcMetrics::SaveForHttps(absl::optional doh_provider_id, enum HttpssvcDnsRcode rcode, const std::vector& condensed_records, base::TimeDelta https_resolve_time) { @@ -143,7 +143,7 @@ void HttpssvcMetrics::SaveForHttps(base::Optional doh_provider_id, } void HttpssvcMetrics::set_doh_provider_id( - base::Optional new_doh_provider_id) { + absl::optional new_doh_provider_id) { // "Other" never gets updated. if (doh_provider_id_.has_value() && *doh_provider_id_ == "Other") return; diff --git a/net/dns/httpssvc_metrics.h b/net/dns/httpssvc_metrics.h index ae4e6d7b5bce14..3d7b4a590b0bd9 100644 --- a/net/dns/httpssvc_metrics.h +++ b/net/dns/httpssvc_metrics.h @@ -9,10 +9,10 @@ #include #include "base/containers/flat_set.h" -#include "base/optional.h" #include "base/strings/string_piece_forward.h" #include "base/time/time.h" #include "net/base/net_export.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -45,10 +45,10 @@ class NET_EXPORT_PRIVATE HttpssvcExperimentDomainCache { bool ListContainsDomain( const std::string& domain_list, base::StringPiece domain, - base::Optional>& in_out_cached_list); + absl::optional>& in_out_cached_list); - base::Optional> experimental_list_; - base::Optional> control_list_; + absl::optional> experimental_list_; + absl::optional> control_list_; }; // Translate an RCODE value to the |HttpssvcDnsRcode| enum, which is used for @@ -68,7 +68,7 @@ class NET_EXPORT_PRIVATE HttpssvcMetrics { HttpssvcMetrics(HttpssvcMetrics&&) = delete; // May be called many times. - void SaveForAddressQuery(base::Optional doh_provider_id, + void SaveForAddressQuery(absl::optional doh_provider_id, base::TimeDelta resolve_time, enum HttpssvcDnsRcode rcode); @@ -77,11 +77,11 @@ class NET_EXPORT_PRIVATE HttpssvcMetrics { void SaveAddressQueryFailure(); // Must only be called once. - void SaveForIntegrity(base::Optional doh_provider_id, + void SaveForIntegrity(absl::optional doh_provider_id, enum HttpssvcDnsRcode rcode, const std::vector& condensed_records, base::TimeDelta integrity_resolve_time); - void SaveForHttps(base::Optional doh_provider_id, + void SaveForHttps(absl::optional doh_provider_id, enum HttpssvcDnsRcode rcode, const std::vector& condensed_records, base::TimeDelta https_resolve_time); @@ -98,23 +98,23 @@ class NET_EXPORT_PRIVATE HttpssvcMetrics { void RecordExpectIntactMetrics(); void RecordExpectNoerrorMetrics(); - void set_doh_provider_id(base::Optional doh_provider_id); + void set_doh_provider_id(absl::optional doh_provider_id); const bool expect_intact_; // RecordIntegrityMetrics() will do nothing when |disqualified_| is true. bool disqualified_ = false; bool already_recorded_ = false; - base::Optional doh_provider_id_; - base::Optional rcode_integrity_; - base::Optional rcode_https_; + absl::optional doh_provider_id_; + absl::optional rcode_integrity_; + absl::optional rcode_https_; size_t num_integrity_records_ = 0; size_t num_https_records_ = 0; - base::Optional is_integrity_intact_; - base::Optional is_https_parsable_; + absl::optional is_integrity_intact_; + absl::optional is_https_parsable_; // We never make multiple INTEGRITY or HTTPS queries per DnsTask, so we only // need one TimeDelta for each qtype. - base::Optional integrity_resolve_time_; - base::Optional https_resolve_time_; + absl::optional integrity_resolve_time_; + absl::optional https_resolve_time_; std::vector address_resolve_times_; }; diff --git a/net/dns/httpssvc_metrics_unittest.cc b/net/dns/httpssvc_metrics_unittest.cc index 4359a9fe1f1fe0..b55681ad73834c 100644 --- a/net/dns/httpssvc_metrics_unittest.cc +++ b/net/dns/httpssvc_metrics_unittest.cc @@ -187,7 +187,7 @@ class HttpssvcMetricsTest : public ::testing::TestWithParam { } template - void ExpectSample(base::StringPiece name, base::Optional sample) const { + void ExpectSample(base::StringPiece name, absl::optional sample) const { if (sample) histo().ExpectUniqueSample(name, *sample, 1); else @@ -195,16 +195,16 @@ class HttpssvcMetricsTest : public ::testing::TestWithParam { } void ExpectSample(base::StringPiece name, - base::Optional sample) const { - base::Optional sample_ms; + absl::optional sample) const { + absl::optional sample_ms; if (sample) sample_ms = {sample->InMilliseconds()}; ExpectSample(name, sample_ms); } void VerifyAddressResolveTimeMetric( - base::Optional expect_intact_time = base::nullopt, - base::Optional expect_noerror_time = base::nullopt) { + absl::optional expect_intact_time = absl::nullopt, + absl::optional expect_noerror_time = absl::nullopt) { const std::string kExpectIntact = base::StrCat({BuildMetricNamePrefix("RecordIntegrity", "ExpectIntact"), "ResolveTimeNonIntegrityRecord"}); @@ -217,11 +217,11 @@ class HttpssvcMetricsTest : public ::testing::TestWithParam { } void VerifyIntegrityMetricsForExpectIntact( - base::Optional rcode, - base::Optional integrity, - base::Optional record_with_error, - base::Optional resolve_time_integrity, - base::Optional resolve_time_ratio) const { + absl::optional rcode, + absl::optional integrity, + absl::optional record_with_error, + absl::optional resolve_time_integrity, + absl::optional resolve_time_ratio) const { const std::string kPrefix = BuildMetricNamePrefix("RecordIntegrity", "ExpectIntact"); const std::string kMetricDnsRcode = base::StrCat({kPrefix, "DnsRcode"}); @@ -241,11 +241,11 @@ class HttpssvcMetricsTest : public ::testing::TestWithParam { } void VerifyHttpsMetricsForExpectIntact( - base::Optional rcode = base::nullopt, - base::Optional parsable = base::nullopt, - base::Optional record_with_error = base::nullopt, - base::Optional resolve_time_https = base::nullopt, - base::Optional resolve_time_ratio = base::nullopt) const { + absl::optional rcode = absl::nullopt, + absl::optional parsable = absl::nullopt, + absl::optional record_with_error = absl::nullopt, + absl::optional resolve_time_https = absl::nullopt, + absl::optional resolve_time_ratio = absl::nullopt) const { const std::string kPrefix = BuildMetricNamePrefix("RecordHttps", "ExpectIntact"); const std::string kMetricDnsRcode = base::StrCat({kPrefix, "DnsRcode"}); @@ -265,10 +265,10 @@ class HttpssvcMetricsTest : public ::testing::TestWithParam { } void VerifyIntegrityMetricsForExpectNoerror( - base::Optional rcode, - base::Optional record_received, - base::Optional resolve_time_integrity, - base::Optional resolve_time_ratio) const { + absl::optional rcode, + absl::optional record_received, + absl::optional resolve_time_integrity, + absl::optional resolve_time_ratio) const { const std::string kPrefix = BuildMetricNamePrefix("RecordIntegrity", "ExpectNoerror"); const std::string kMetricDnsRcode = base::StrCat({kPrefix, "DnsRcode"}); @@ -286,11 +286,11 @@ class HttpssvcMetricsTest : public ::testing::TestWithParam { } void VerifyHttpsMetricsForExpectNoerror( - base::Optional rcode = base::nullopt, - base::Optional parsable = base::nullopt, - base::Optional record_with_error = base::nullopt, - base::Optional resolve_time_https = base::nullopt, - base::Optional resolve_time_ratio = base::nullopt) const { + absl::optional rcode = absl::nullopt, + absl::optional parsable = absl::nullopt, + absl::optional record_with_error = absl::nullopt, + absl::optional resolve_time_https = absl::nullopt, + absl::optional resolve_time_ratio = absl::nullopt) const { const std::string kPrefix = BuildMetricNamePrefix("RecordHttps", "ExpectNoerror"); const std::string kMetricDnsRcode = base::StrCat({kPrefix, "DnsRcode"}); @@ -312,14 +312,14 @@ class HttpssvcMetricsTest : public ::testing::TestWithParam { } void VerifyIntegrityMetricsForExpectIntact() { - VerifyIntegrityMetricsForExpectIntact(base::nullopt, base::nullopt, - base::nullopt, base::nullopt, - base::nullopt); + VerifyIntegrityMetricsForExpectIntact(absl::nullopt, absl::nullopt, + absl::nullopt, absl::nullopt, + absl::nullopt); } void VerifyIntegrityMetricsForExpectNoerror() { - VerifyIntegrityMetricsForExpectNoerror(base::nullopt, base::nullopt, - base::nullopt, base::nullopt); + VerifyIntegrityMetricsForExpectNoerror(absl::nullopt, absl::nullopt, + absl::nullopt, absl::nullopt); } const base::HistogramTester& histo() const { return histogram_; } @@ -383,8 +383,8 @@ TEST_P(HttpssvcDomainParsingTest, ParseFeatureParamIntegrityDomains) { // Only record metrics for a non-integrity query. TEST_P(HttpssvcMetricsTest, AddressAndExperimentalMissing) { const base::TimeDelta kResolveTime = base::TimeDelta::FromMilliseconds(10); - base::Optional metrics(querying_experimental_); - metrics->SaveForAddressQuery(base::nullopt, kResolveTime, + absl::optional metrics(querying_experimental_); + metrics->SaveForAddressQuery(absl::nullopt, kResolveTime, HttpssvcDnsRcode::kNoError); metrics.reset(); // Record the metrics to UMA. @@ -399,10 +399,10 @@ TEST_P(HttpssvcMetricsTest, AddressAndIntegrityIntact) { const base::TimeDelta kResolveTime = base::TimeDelta::FromMilliseconds(10); const base::TimeDelta kResolveTimeIntegrity = base::TimeDelta::FromMilliseconds(15); - base::Optional metrics(querying_experimental_); - metrics->SaveForIntegrity(base::nullopt, HttpssvcDnsRcode::kNoError, {true}, + absl::optional metrics(querying_experimental_); + metrics->SaveForIntegrity(absl::nullopt, HttpssvcDnsRcode::kNoError, {true}, kResolveTimeIntegrity); - metrics->SaveForAddressQuery(base::nullopt, kResolveTime, + metrics->SaveForAddressQuery(absl::nullopt, kResolveTime, HttpssvcDnsRcode::kNoError); metrics.reset(); // Record the metrics to UMA. @@ -412,8 +412,8 @@ TEST_P(HttpssvcMetricsTest, AddressAndIntegrityIntact) { if (querying_experimental_) { VerifyAddressResolveTimeMetric({kResolveTime} /* expect_intact_time */); VerifyIntegrityMetricsForExpectIntact( - base::nullopt /* rcode */, {true} /* integrity */, - base::nullopt /* record_with_error */, + absl::nullopt /* rcode */, {true} /* integrity */, + absl::nullopt /* record_with_error */, {kResolveTimeIntegrity} /* resolve_time_integrity */, {15} /* resolve_time_ratio */); @@ -423,7 +423,7 @@ TEST_P(HttpssvcMetricsTest, AddressAndIntegrityIntact) { VerifyIntegrityMetricsForExpectIntact(); - VerifyAddressResolveTimeMetric(base::nullopt /* expect_intact_time */, + VerifyAddressResolveTimeMetric(absl::nullopt /* expect_intact_time */, {kResolveTime} /* expect_noerror_time */); VerifyIntegrityMetricsForExpectNoerror( {HttpssvcDnsRcode::kNoError} /* rcode */, {1} /* record_received */, @@ -435,10 +435,10 @@ TEST_P(HttpssvcMetricsTest, AddressAndHttpsParsable) { const base::TimeDelta kResolveTime = base::TimeDelta::FromMilliseconds(10); const base::TimeDelta kResolveTimeHttps = base::TimeDelta::FromMilliseconds(15); - base::Optional metrics(querying_experimental_); - metrics->SaveForHttps(base::nullopt, HttpssvcDnsRcode::kNoError, {true}, + absl::optional metrics(querying_experimental_); + metrics->SaveForHttps(absl::nullopt, HttpssvcDnsRcode::kNoError, {true}, kResolveTimeHttps); - metrics->SaveForAddressQuery(base::nullopt, kResolveTime, + metrics->SaveForAddressQuery(absl::nullopt, kResolveTime, HttpssvcDnsRcode::kNoError); metrics.reset(); // Record the metrics to UMA. @@ -448,8 +448,8 @@ TEST_P(HttpssvcMetricsTest, AddressAndHttpsParsable) { if (querying_experimental_) { VerifyAddressResolveTimeMetric({kResolveTime} /* expect_intact_time */); VerifyHttpsMetricsForExpectIntact( - base::nullopt /* rcode */, {true} /* parsable */, - base::nullopt /* record_with_error */, + absl::nullopt /* rcode */, {true} /* parsable */, + absl::nullopt /* record_with_error */, {kResolveTimeHttps} /* resolve_time_https */, {15} /* resolve_time_ratio */); @@ -459,11 +459,11 @@ TEST_P(HttpssvcMetricsTest, AddressAndHttpsParsable) { VerifyHttpsMetricsForExpectIntact(); - VerifyAddressResolveTimeMetric(base::nullopt /* expect_intact_time */, + VerifyAddressResolveTimeMetric(absl::nullopt /* expect_intact_time */, {kResolveTime} /* expect_noerror_time */); VerifyHttpsMetricsForExpectNoerror( {HttpssvcDnsRcode::kNoError} /* rcode */, {true} /* parsable */, - base::nullopt /* record_with_error */, + absl::nullopt /* record_with_error */, {kResolveTimeHttps} /* resolve_time_https */, {15} /* resolve_time_ratio */); } @@ -474,25 +474,25 @@ TEST_P(HttpssvcMetricsTest, AddressAndIntegrityIntactAndHttpsParsable) { base::TimeDelta::FromMilliseconds(15); const base::TimeDelta kResolveTimeHttps = base::TimeDelta::FromMilliseconds(20); - base::Optional metrics(querying_experimental_); - metrics->SaveForIntegrity(base::nullopt, HttpssvcDnsRcode::kNoError, {true}, + absl::optional metrics(querying_experimental_); + metrics->SaveForIntegrity(absl::nullopt, HttpssvcDnsRcode::kNoError, {true}, kResolveTimeIntegrity); - metrics->SaveForHttps(base::nullopt, HttpssvcDnsRcode::kNoError, {true}, + metrics->SaveForHttps(absl::nullopt, HttpssvcDnsRcode::kNoError, {true}, kResolveTimeHttps); - metrics->SaveForAddressQuery(base::nullopt, kResolveTime, + metrics->SaveForAddressQuery(absl::nullopt, kResolveTime, HttpssvcDnsRcode::kNoError); metrics.reset(); // Record the metrics to UMA. if (querying_experimental_) { VerifyAddressResolveTimeMetric({kResolveTime} /* expect_intact_time */); VerifyIntegrityMetricsForExpectIntact( - base::nullopt /* rcode */, {true} /* integrity */, - base::nullopt /* record_with_error */, + absl::nullopt /* rcode */, {true} /* integrity */, + absl::nullopt /* record_with_error */, {kResolveTimeIntegrity} /* resolve_time_integrity */, {15} /* resolve_time_ratio */); VerifyHttpsMetricsForExpectIntact( - base::nullopt /* rcode */, {true} /* parsable */, - base::nullopt /* record_with_error */, + absl::nullopt /* rcode */, {true} /* parsable */, + absl::nullopt /* record_with_error */, {kResolveTimeHttps} /* resolve_time_https */, {20} /* resolve_time_ratio */); @@ -504,7 +504,7 @@ TEST_P(HttpssvcMetricsTest, AddressAndIntegrityIntactAndHttpsParsable) { VerifyIntegrityMetricsForExpectIntact(); VerifyHttpsMetricsForExpectIntact(); - VerifyAddressResolveTimeMetric(base::nullopt /* expect_intact_time */, + VerifyAddressResolveTimeMetric(absl::nullopt /* expect_intact_time */, {kResolveTime} /* expect_noerror_time */); VerifyIntegrityMetricsForExpectNoerror( {HttpssvcDnsRcode::kNoError} /* rcode */, {1} /* record_received */, @@ -512,7 +512,7 @@ TEST_P(HttpssvcMetricsTest, AddressAndIntegrityIntactAndHttpsParsable) { {15} /* resolve_time_ratio */); VerifyHttpsMetricsForExpectNoerror( {HttpssvcDnsRcode::kNoError} /* rcode */, {true} /* parsable */, - base::nullopt /* record_with_error */, + absl::nullopt /* record_with_error */, {kResolveTimeHttps} /* resolve_time_https */, {20} /* resolve_time_ratio */); } @@ -524,10 +524,10 @@ TEST_P(HttpssvcMetricsTest, AddressAndIntegrityMissingWithRcode) { const base::TimeDelta kResolveTimeIntegrity = base::TimeDelta::FromMilliseconds(15); - base::Optional metrics(querying_experimental_); - metrics->SaveForIntegrity(base::nullopt, HttpssvcDnsRcode::kNxDomain, {}, + absl::optional metrics(querying_experimental_); + metrics->SaveForIntegrity(absl::nullopt, HttpssvcDnsRcode::kNxDomain, {}, kResolveTimeIntegrity); - metrics->SaveForAddressQuery(base::nullopt, kResolveTime, + metrics->SaveForAddressQuery(absl::nullopt, kResolveTime, HttpssvcDnsRcode::kNoError); metrics.reset(); // Record the metrics to UMA. @@ -538,7 +538,7 @@ TEST_P(HttpssvcMetricsTest, AddressAndIntegrityMissingWithRcode) { VerifyAddressResolveTimeMetric({kResolveTime} /* expect_intact_time */); VerifyIntegrityMetricsForExpectIntact( {HttpssvcDnsRcode::kNxDomain} /* rcode */, - base::nullopt /* integrity */, base::nullopt /* record_with_error */, + absl::nullopt /* integrity */, absl::nullopt /* record_with_error */, {kResolveTimeIntegrity} /* resolve_time_integrity */, {15} /* resolve_time_ratio */); @@ -548,11 +548,11 @@ TEST_P(HttpssvcMetricsTest, AddressAndIntegrityMissingWithRcode) { VerifyIntegrityMetricsForExpectIntact(); - VerifyAddressResolveTimeMetric(base::nullopt /* expect_intact_time */, + VerifyAddressResolveTimeMetric(absl::nullopt /* expect_intact_time */, {kResolveTime} /* expect_noerror_time */); VerifyIntegrityMetricsForExpectNoerror( {HttpssvcDnsRcode::kNxDomain} /* rcode */, - base::nullopt /* record_received */, + absl::nullopt /* record_received */, {kResolveTimeIntegrity} /* resolve_time_integrity */, {15} /* resolve_time_ratio */); } @@ -564,10 +564,10 @@ TEST_P(HttpssvcMetricsTest, AddressAndHttpsMissingWithRcode) { const base::TimeDelta kResolveTimeHttps = base::TimeDelta::FromMilliseconds(15); - base::Optional metrics(querying_experimental_); - metrics->SaveForHttps(base::nullopt, HttpssvcDnsRcode::kNxDomain, {}, + absl::optional metrics(querying_experimental_); + metrics->SaveForHttps(absl::nullopt, HttpssvcDnsRcode::kNxDomain, {}, kResolveTimeHttps); - metrics->SaveForAddressQuery(base::nullopt, kResolveTime, + metrics->SaveForAddressQuery(absl::nullopt, kResolveTime, HttpssvcDnsRcode::kNoError); metrics.reset(); // Record the metrics to UMA. @@ -577,8 +577,8 @@ TEST_P(HttpssvcMetricsTest, AddressAndHttpsMissingWithRcode) { if (querying_experimental_) { VerifyAddressResolveTimeMetric({kResolveTime} /* expect_intact_time */); VerifyHttpsMetricsForExpectIntact( - {HttpssvcDnsRcode::kNxDomain} /* rcode */, base::nullopt /* parsable */, - base::nullopt /* record_with_error */, + {HttpssvcDnsRcode::kNxDomain} /* rcode */, absl::nullopt /* parsable */, + absl::nullopt /* record_with_error */, {kResolveTimeHttps} /* resolve_time_https */, {15} /* resolve_time_ratio */); @@ -588,11 +588,11 @@ TEST_P(HttpssvcMetricsTest, AddressAndHttpsMissingWithRcode) { VerifyHttpsMetricsForExpectIntact(); - VerifyAddressResolveTimeMetric(base::nullopt /* expect_intact_time */, + VerifyAddressResolveTimeMetric(absl::nullopt /* expect_intact_time */, {kResolveTime} /* expect_noerror_time */); VerifyHttpsMetricsForExpectNoerror( - {HttpssvcDnsRcode::kNxDomain} /* rcode */, base::nullopt /* parsable */, - base::nullopt /* record_with_error */, + {HttpssvcDnsRcode::kNxDomain} /* rcode */, absl::nullopt /* parsable */, + absl::nullopt /* record_with_error */, {kResolveTimeHttps} /* resolve_time_https */, {15} /* resolve_time_ratio */); } @@ -604,10 +604,10 @@ TEST_P(HttpssvcMetricsTest, AddressAndIntegrityIntactWithRcode) { const base::TimeDelta kResolveTimeIntegrity = base::TimeDelta::FromMilliseconds(15); - base::Optional metrics(querying_experimental_); - metrics->SaveForIntegrity(base::nullopt, HttpssvcDnsRcode::kNxDomain, {true}, + absl::optional metrics(querying_experimental_); + metrics->SaveForIntegrity(absl::nullopt, HttpssvcDnsRcode::kNxDomain, {true}, kResolveTimeIntegrity); - metrics->SaveForAddressQuery(base::nullopt, kResolveTime, + metrics->SaveForAddressQuery(absl::nullopt, kResolveTime, HttpssvcDnsRcode::kNoError); metrics.reset(); // Record the metrics to UMA. @@ -618,9 +618,9 @@ TEST_P(HttpssvcMetricsTest, AddressAndIntegrityIntactWithRcode) { VerifyAddressResolveTimeMetric({kResolveTime} /* expect_intact_time */); VerifyIntegrityMetricsForExpectIntact( // "DnsRcode" metric is omitted because we received an INTEGRITY record. - base::nullopt /* rcode */, + absl::nullopt /* rcode */, // "Integrity" metric is omitted because the RCODE is not NOERROR. - base::nullopt /* integrity */, {true} /* record_with_error */, + absl::nullopt /* integrity */, {true} /* record_with_error */, {kResolveTimeIntegrity} /* resolve_time_integrity */, {15} /* resolve_time_ratio */); @@ -630,7 +630,7 @@ TEST_P(HttpssvcMetricsTest, AddressAndIntegrityIntactWithRcode) { VerifyIntegrityMetricsForExpectIntact(); - VerifyAddressResolveTimeMetric(base::nullopt /* expect_intact_time */, + VerifyAddressResolveTimeMetric(absl::nullopt /* expect_intact_time */, {kResolveTime} /* expect_noerror_time */); VerifyIntegrityMetricsForExpectNoerror( {HttpssvcDnsRcode::kNxDomain} /* rcode */, {true} /* record_received */, @@ -645,10 +645,10 @@ TEST_P(HttpssvcMetricsTest, AddressAndHttpsParsableWithRcode) { const base::TimeDelta kResolveTimeHttps = base::TimeDelta::FromMilliseconds(15); - base::Optional metrics(querying_experimental_); - metrics->SaveForHttps(base::nullopt, HttpssvcDnsRcode::kNxDomain, {true}, + absl::optional metrics(querying_experimental_); + metrics->SaveForHttps(absl::nullopt, HttpssvcDnsRcode::kNxDomain, {true}, kResolveTimeHttps); - metrics->SaveForAddressQuery(base::nullopt, kResolveTime, + metrics->SaveForAddressQuery(absl::nullopt, kResolveTime, HttpssvcDnsRcode::kNoError); metrics.reset(); // Record the metrics to UMA. @@ -659,9 +659,9 @@ TEST_P(HttpssvcMetricsTest, AddressAndHttpsParsableWithRcode) { VerifyAddressResolveTimeMetric({kResolveTime} /* expect_intact_time */); VerifyHttpsMetricsForExpectIntact( // "DnsRcode" metric is omitted because we received an HTTPS record. - base::nullopt /* rcode */, + absl::nullopt /* rcode */, // "parsable" metric is omitted because the RCODE is not NOERROR. - base::nullopt /* parsable */, {true} /* record_with_error */, + absl::nullopt /* parsable */, {true} /* record_with_error */, {kResolveTimeHttps} /* resolve_time_https */, {15} /* resolve_time_ratio */); @@ -671,12 +671,12 @@ TEST_P(HttpssvcMetricsTest, AddressAndHttpsParsableWithRcode) { VerifyHttpsMetricsForExpectIntact(); - VerifyAddressResolveTimeMetric(base::nullopt /* expect_intact_time */, + VerifyAddressResolveTimeMetric(absl::nullopt /* expect_intact_time */, {kResolveTime} /* expect_noerror_time */); VerifyHttpsMetricsForExpectNoerror( {HttpssvcDnsRcode::kNxDomain} /* rcode */, // "parsable" metric is omitted because the RCODE is not NOERROR. - base::nullopt /* parsable */, {true} /* record_with_error */, + absl::nullopt /* parsable */, {true} /* record_with_error */, {kResolveTimeHttps} /* resolve_time_https */, {15} /* resolve_time_ratio */); } @@ -687,10 +687,10 @@ TEST_P(HttpssvcMetricsTest, AddressAndIntegrityMangledWithRcode) { const base::TimeDelta kResolveTime = base::TimeDelta::FromMilliseconds(10); const base::TimeDelta kResolveTimeIntegrity = base::TimeDelta::FromMilliseconds(15); - base::Optional metrics(querying_experimental_); - metrics->SaveForIntegrity(base::nullopt, HttpssvcDnsRcode::kNxDomain, {false}, + absl::optional metrics(querying_experimental_); + metrics->SaveForIntegrity(absl::nullopt, HttpssvcDnsRcode::kNxDomain, {false}, kResolveTimeIntegrity); - metrics->SaveForAddressQuery(base::nullopt, kResolveTime, + metrics->SaveForAddressQuery(absl::nullopt, kResolveTime, HttpssvcDnsRcode::kNoError); metrics.reset(); // Record the metrics to UMA. @@ -701,9 +701,9 @@ TEST_P(HttpssvcMetricsTest, AddressAndIntegrityMangledWithRcode) { VerifyAddressResolveTimeMetric({kResolveTime} /* expect_intact_time */); VerifyIntegrityMetricsForExpectIntact( // "DnsRcode" metric is omitted because we received an INTEGRITY record. - base::nullopt /* rcode */, + absl::nullopt /* rcode */, // "Integrity" metric is omitted because the RCODE is not NOERROR. - base::nullopt /* integrity */, {true} /* record_with_error */, + absl::nullopt /* integrity */, {true} /* record_with_error */, {kResolveTimeIntegrity} /* resolve_time_integrity */, {15} /* resolve_time_ratio */); @@ -713,7 +713,7 @@ TEST_P(HttpssvcMetricsTest, AddressAndIntegrityMangledWithRcode) { VerifyIntegrityMetricsForExpectIntact(); - VerifyAddressResolveTimeMetric(base::nullopt /* expect_intact_time */, + VerifyAddressResolveTimeMetric(absl::nullopt /* expect_intact_time */, {kResolveTime} /* expect_noerror_time */); VerifyIntegrityMetricsForExpectNoerror( {HttpssvcDnsRcode::kNxDomain} /* rcode */, {true} /* record_received */, @@ -727,10 +727,10 @@ TEST_P(HttpssvcMetricsTest, AddressAndHttpsMangledWithRcode) { const base::TimeDelta kResolveTime = base::TimeDelta::FromMilliseconds(10); const base::TimeDelta kResolveTimeHttps = base::TimeDelta::FromMilliseconds(15); - base::Optional metrics(querying_experimental_); - metrics->SaveForHttps(base::nullopt, HttpssvcDnsRcode::kNxDomain, {false}, + absl::optional metrics(querying_experimental_); + metrics->SaveForHttps(absl::nullopt, HttpssvcDnsRcode::kNxDomain, {false}, kResolveTimeHttps); - metrics->SaveForAddressQuery(base::nullopt, kResolveTime, + metrics->SaveForAddressQuery(absl::nullopt, kResolveTime, HttpssvcDnsRcode::kNoError); metrics.reset(); // Record the metrics to UMA. @@ -741,9 +741,9 @@ TEST_P(HttpssvcMetricsTest, AddressAndHttpsMangledWithRcode) { VerifyAddressResolveTimeMetric({kResolveTime} /* expect_intact_time */); VerifyHttpsMetricsForExpectIntact( // "DnsRcode" metric is omitted because we received an HTTPS record. - base::nullopt /* rcode */, + absl::nullopt /* rcode */, // "parsable" metric is omitted because the RCODE is not NOERROR. - base::nullopt /* parsable */, {true} /* record_with_error */, + absl::nullopt /* parsable */, {true} /* record_with_error */, {kResolveTimeHttps} /* resolve_time_https */, {15} /* resolve_time_ratio */); @@ -753,12 +753,12 @@ TEST_P(HttpssvcMetricsTest, AddressAndHttpsMangledWithRcode) { VerifyHttpsMetricsForExpectIntact(); - VerifyAddressResolveTimeMetric(base::nullopt /* expect_intact_time */, + VerifyAddressResolveTimeMetric(absl::nullopt /* expect_intact_time */, {kResolveTime} /* expect_noerror_time */); VerifyHttpsMetricsForExpectNoerror( {HttpssvcDnsRcode::kNxDomain} /* rcode */, // "parsable" metric is omitted because the RCODE is not NOERROR. - base::nullopt /* parsable */, {true} /* record_with_error */, + absl::nullopt /* parsable */, {true} /* record_with_error */, {kResolveTimeHttps} /* resolve_time_https */, {15} /* resolve_time_ratio */); } @@ -769,10 +769,10 @@ TEST_P(HttpssvcMetricsTest, AddressAndIntegrityTimedOut) { const base::TimeDelta kResolveTime = base::TimeDelta::FromMilliseconds(10); const base::TimeDelta kResolveTimeIntegrity = base::TimeDelta::FromMilliseconds(15); - base::Optional metrics(querying_experimental_); - metrics->SaveForIntegrity(base::nullopt, HttpssvcDnsRcode::kTimedOut, {}, + absl::optional metrics(querying_experimental_); + metrics->SaveForIntegrity(absl::nullopt, HttpssvcDnsRcode::kTimedOut, {}, kResolveTimeIntegrity); - metrics->SaveForAddressQuery(base::nullopt, kResolveTime, + metrics->SaveForAddressQuery(absl::nullopt, kResolveTime, HttpssvcDnsRcode::kNoError); metrics.reset(); // Record the metrics to UMA. @@ -784,7 +784,7 @@ TEST_P(HttpssvcMetricsTest, AddressAndIntegrityTimedOut) { VerifyIntegrityMetricsForExpectIntact( {HttpssvcDnsRcode::kTimedOut} /* rcode */, // "Integrity" metric is omitted because the RCODE is not NOERROR. - base::nullopt /* integrity */, base::nullopt /* record_with_error */, + absl::nullopt /* integrity */, absl::nullopt /* record_with_error */, {kResolveTimeIntegrity} /* resolve_time_integrity */, {15} /* resolve_time_ratio */); @@ -794,11 +794,11 @@ TEST_P(HttpssvcMetricsTest, AddressAndIntegrityTimedOut) { VerifyIntegrityMetricsForExpectIntact(); - VerifyAddressResolveTimeMetric(base::nullopt /* expect_intact_time */, + VerifyAddressResolveTimeMetric(absl::nullopt /* expect_intact_time */, {kResolveTime} /* expect_noerror_time */); VerifyIntegrityMetricsForExpectNoerror( {HttpssvcDnsRcode::kTimedOut} /* rcode */, - base::nullopt /* record_received */, + absl::nullopt /* record_received */, {kResolveTimeIntegrity} /* resolve_time_integrity */, {15} /* resolve_time_ratio */); } @@ -809,10 +809,10 @@ TEST_P(HttpssvcMetricsTest, AddressAndHttpsTimedOut) { const base::TimeDelta kResolveTime = base::TimeDelta::FromMilliseconds(10); const base::TimeDelta kResolveTimeHttps = base::TimeDelta::FromMilliseconds(15); - base::Optional metrics(querying_experimental_); - metrics->SaveForHttps(base::nullopt, HttpssvcDnsRcode::kTimedOut, {}, + absl::optional metrics(querying_experimental_); + metrics->SaveForHttps(absl::nullopt, HttpssvcDnsRcode::kTimedOut, {}, kResolveTimeHttps); - metrics->SaveForAddressQuery(base::nullopt, kResolveTime, + metrics->SaveForAddressQuery(absl::nullopt, kResolveTime, HttpssvcDnsRcode::kNoError); metrics.reset(); // Record the metrics to UMA. @@ -824,7 +824,7 @@ TEST_P(HttpssvcMetricsTest, AddressAndHttpsTimedOut) { VerifyHttpsMetricsForExpectIntact( {HttpssvcDnsRcode::kTimedOut} /* rcode */, // "parsable" metric is omitted because the RCODE is not NOERROR. - base::nullopt /* parsable */, base::nullopt /* record_with_error */, + absl::nullopt /* parsable */, absl::nullopt /* record_with_error */, {kResolveTimeHttps} /* resolve_time_https */, {15} /* resolve_time_ratio */); @@ -834,12 +834,12 @@ TEST_P(HttpssvcMetricsTest, AddressAndHttpsTimedOut) { VerifyHttpsMetricsForExpectIntact(); - VerifyAddressResolveTimeMetric(base::nullopt /* expect_intact_time */, + VerifyAddressResolveTimeMetric(absl::nullopt /* expect_intact_time */, {kResolveTime} /* expect_noerror_time */); VerifyHttpsMetricsForExpectNoerror( {HttpssvcDnsRcode::kTimedOut} /* rcode */, // "parsable" metric is omitted because the RCODE is not NOERROR. - base::nullopt /* parsable */, base::nullopt /* record_with_error */, + absl::nullopt /* parsable */, absl::nullopt /* record_with_error */, {kResolveTimeHttps} /* resolve_time_https */, {15} /* resolve_time_ratio */); } diff --git a/net/dns/integrity_record_fuzzer.cc b/net/dns/integrity_record_fuzzer.cc index e3091b0763c00c..f2fb575d16176b 100644 --- a/net/dns/integrity_record_fuzzer.cc +++ b/net/dns/integrity_record_fuzzer.cc @@ -8,9 +8,9 @@ #include #include "base/check_op.h" -#include "base/optional.h" #include "base/strings/string_piece.h" #include "net/dns/record_rdata.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -25,10 +25,10 @@ base::StringPiece MakeStringPiece(const std::vector& vec) { void ParseThenSerializeProperty(const std::vector& data) { auto parsed = IntegrityRecordRdata::Create(MakeStringPiece(data)); CHECK(parsed); - base::Optional> maybe_serialized = parsed->Serialize(); + absl::optional> maybe_serialized = parsed->Serialize(); // Since |data| is chosen by a fuzzer, the record's digest is unlikely to // match its nonce. As a result, |parsed->IsIntact()| may be false, and thus - // |parsed->Serialize()| may be |base::nullopt|. + // |parsed->Serialize()| may be |absl::nullopt|. CHECK_EQ(parsed->IsIntact(), !!maybe_serialized); if (maybe_serialized) { CHECK(data == *maybe_serialized); @@ -45,7 +45,7 @@ void SerializeThenParseProperty(const std::vector& data) { // Build an IntegrityRecordRdata by treating |data| as a nonce. IntegrityRecordRdata record(data); CHECK(record.IsIntact()); - base::Optional> maybe_serialized = record.Serialize(); + absl::optional> maybe_serialized = record.Serialize(); CHECK(maybe_serialized.has_value()); // Parsing |serialized| always produces a record identical to the original. diff --git a/net/dns/mapped_host_resolver.cc b/net/dns/mapped_host_resolver.cc index dec62ab1bbdc0d..be7238106a13be 100644 --- a/net/dns/mapped_host_resolver.cc +++ b/net/dns/mapped_host_resolver.cc @@ -28,7 +28,7 @@ MappedHostResolver::CreateRequest( const HostPortPair& host, const NetworkIsolationKey& network_isolation_key, const NetLogWithSource& source_net_log, - const base::Optional& optional_parameters) { + const absl::optional& optional_parameters) { HostPortPair rewritten = host; rules_.RewriteHost(&rewritten); diff --git a/net/dns/mapped_host_resolver.h b/net/dns/mapped_host_resolver.h index e420f3477a896a..f27bb71a61c64f 100644 --- a/net/dns/mapped_host_resolver.h +++ b/net/dns/mapped_host_resolver.h @@ -54,7 +54,7 @@ class NET_EXPORT MappedHostResolver : public HostResolver { const HostPortPair& host, const NetworkIsolationKey& network_isolation_key, const NetLogWithSource& net_log, - const base::Optional& optional_parameters) + const absl::optional& optional_parameters) override; std::unique_ptr CreateDohProbeRequest() override; HostCache* GetHostCache() override; diff --git a/net/dns/mapped_host_resolver_unittest.cc b/net/dns/mapped_host_resolver_unittest.cc index ecbb6bcb8b0c6f..8fb3c71f7fcabe 100644 --- a/net/dns/mapped_host_resolver_unittest.cc +++ b/net/dns/mapped_host_resolver_unittest.cc @@ -49,7 +49,7 @@ TEST(MappedHostResolverTest, Inclusion) { std::unique_ptr request = resolver->CreateRequest(HostPortPair("www.google.com", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); int rv = request->Start(callback.callback()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); rv = callback.WaitForResult(); @@ -63,7 +63,7 @@ TEST(MappedHostResolverTest, Inclusion) { // Try resolving "www.google.com:80". Should be remapped to "baz.com:80". request = resolver->CreateRequest(HostPortPair("www.google.com", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); rv = request->Start(callback.callback()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); rv = callback.WaitForResult(); @@ -76,7 +76,7 @@ TEST(MappedHostResolverTest, Inclusion) { // is "foo.com:77". request = resolver->CreateRequest(HostPortPair("foo.com", 77), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); rv = request->Start(callback.callback()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); rv = callback.WaitForResult(); @@ -91,7 +91,7 @@ TEST(MappedHostResolverTest, Inclusion) { // Try resolving "chromium.org:61". Should be remapped to "proxy:99". request = resolver->CreateRequest(HostPortPair("chromium.org", 61), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); rv = request->Start(callback.callback()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); rv = callback.WaitForResult(); @@ -125,7 +125,7 @@ TEST(MappedHostResolverTest, Exclusion) { std::unique_ptr request = resolver->CreateRequest(HostPortPair("www.google.com", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); int rv = request->Start(callback.callback()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); rv = callback.WaitForResult(); @@ -137,7 +137,7 @@ TEST(MappedHostResolverTest, Exclusion) { // Try resolving "chrome.com:80". Should be remapped to "baz:80". request = resolver->CreateRequest(HostPortPair("chrome.com", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); rv = request->Start(callback.callback()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); rv = callback.WaitForResult(); @@ -167,7 +167,7 @@ TEST(MappedHostResolverTest, SetRulesFromString) { std::unique_ptr request = resolver->CreateRequest(HostPortPair("www.google.com", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); int rv = request->Start(callback.callback()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); rv = callback.WaitForResult(); @@ -179,7 +179,7 @@ TEST(MappedHostResolverTest, SetRulesFromString) { // Try resolving "chrome.net:80". Should be remapped to "bar:60". request = resolver->CreateRequest(HostPortPair("chrome.net", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); rv = request->Start(callback.callback()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); rv = callback.WaitForResult(); @@ -224,7 +224,7 @@ TEST(MappedHostResolverTest, MapToError) { std::unique_ptr request = resolver->CreateRequest(HostPortPair("www.google.com", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); int rv = request->Start(callback1.callback()); EXPECT_THAT(rv, IsError(ERR_NAME_NOT_RESOLVED)); request.reset(); @@ -233,7 +233,7 @@ TEST(MappedHostResolverTest, MapToError) { TestCompletionCallback callback2; request = resolver->CreateRequest(HostPortPair("www.foo.com", 80), NetworkIsolationKey(), NetLogWithSource(), - base::nullopt); + absl::nullopt); rv = request->Start(callback2.callback()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); rv = callback2.WaitForResult(); diff --git a/net/dns/mock_host_resolver.cc b/net/dns/mock_host_resolver.cc index b1aa9c9ca26099..6590e6cae538d0 100644 --- a/net/dns/mock_host_resolver.cc +++ b/net/dns/mock_host_resolver.cc @@ -83,7 +83,7 @@ class MockHostResolverBase::RequestImpl public: RequestImpl(const HostPortPair& request_host, const NetworkIsolationKey& network_isolation_key, - const base::Optional& optional_parameters, + const absl::optional& optional_parameters, base::WeakPtr resolver) : request_host_(request_host), network_isolation_key_(network_isolation_key), @@ -132,28 +132,28 @@ class MockHostResolverBase::RequestImpl return rv; } - const base::Optional& GetAddressResults() const override { + const absl::optional& GetAddressResults() const override { DCHECK(complete_); return address_results_; } - const base::Optional>& GetTextResults() + const absl::optional>& GetTextResults() const override { DCHECK(complete_); - static const base::NoDestructor>> + static const base::NoDestructor>> nullopt_result; return *nullopt_result; } - const base::Optional>& GetHostnameResults() + const absl::optional>& GetHostnameResults() const override { DCHECK(complete_); - static const base::NoDestructor>> + static const base::NoDestructor>> nullopt_result; return *nullopt_result; } - const base::Optional>& GetDnsAliasResults() + const absl::optional>& GetDnsAliasResults() const override { DCHECK(complete_); return sanitized_dns_alias_results_; @@ -164,7 +164,7 @@ class MockHostResolverBase::RequestImpl return resolve_error_info_; } - const base::Optional& GetStaleInfo() + const absl::optional& GetStaleInfo() const override { DCHECK(complete_); return staleness_; @@ -181,7 +181,7 @@ class MockHostResolverBase::RequestImpl } void SetAddressResults(const AddressList& address_results, - base::Optional staleness) { + absl::optional staleness) { // Should only be called at most once and before request is marked // completed. DCHECK(!complete_); @@ -240,9 +240,9 @@ class MockHostResolverBase::RequestImpl RequestPriority priority_; int host_resolver_flags_; - base::Optional address_results_; - base::Optional> sanitized_dns_alias_results_; - base::Optional staleness_; + absl::optional address_results_; + absl::optional> sanitized_dns_alias_results_; + absl::optional staleness_; ResolveErrorInfo resolve_error_info_; // Used while stored with the resolver for async resolution. Otherwise 0. @@ -376,7 +376,7 @@ MockHostResolverBase::CreateRequest( const HostPortPair& host, const NetworkIsolationKey& network_isolation_key, const NetLogWithSource& source_net_log, - const base::Optional& optional_parameters) { + const absl::optional& optional_parameters) { return std::make_unique(host, network_isolation_key, optional_parameters, AsWeakPtr()); } @@ -399,7 +399,7 @@ HostCache* MockHostResolverBase::GetHostCache() { int MockHostResolverBase::LoadIntoCache( const HostPortPair& host, const NetworkIsolationKey& network_isolation_key, - const base::Optional& optional_parameters) { + const absl::optional& optional_parameters) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK(cache_); @@ -407,7 +407,7 @@ int MockHostResolverBase::LoadIntoCache( optional_parameters.value_or(ResolveHostParameters()); AddressList addresses; - base::Optional stale_info; + absl::optional stale_info; int rv = ResolveFromIPLiteralOrCache( host, network_isolation_key, parameters.dns_query_type, ParametersToHostResolverFlags(parameters), parameters.source, @@ -459,7 +459,7 @@ void MockHostResolverBase::ResolveNow(size_t id) { req->host_resolver_flags(), req->parameters().source, &addresses); req->SetError(error); if (error == OK && !req->parameters().is_speculative) - req->SetAddressResults(addresses, base::nullopt); + req->SetAddressResults(addresses, absl::nullopt); req->OnAsyncCompleted(id, SquashErrorCode(error)); } @@ -576,7 +576,7 @@ int MockHostResolverBase::Resolve(RequestImpl* request) { last_secure_dns_policy_ = request->parameters().secure_dns_policy; num_resolve_++; AddressList addresses; - base::Optional stale_info; + absl::optional stale_info; int rv = ResolveFromIPLiteralOrCache( request->request_host(), request->network_isolation_key(), request->parameters().dns_query_type, request->host_resolver_flags(), @@ -607,7 +607,7 @@ int MockHostResolverBase::Resolve(RequestImpl* request) { request->SetError(rv); if (rv == OK && !request->parameters().is_speculative) - request->SetAddressResults(addresses, base::nullopt); + request->SetAddressResults(addresses, absl::nullopt); return SquashErrorCode(rv); } @@ -633,10 +633,10 @@ int MockHostResolverBase::ResolveFromIPLiteralOrCache( HostResolverSource source, HostResolver::ResolveHostParameters::CacheUsage cache_usage, AddressList* addresses, - base::Optional* out_stale_info) { + absl::optional* out_stale_info) { DCHECK(addresses); DCHECK(out_stale_info); - *out_stale_info = base::nullopt; + *out_stale_info = absl::nullopt; IPAddress ip_address; if (ip_address.AssignFromIPLiteral(host.host())) { @@ -1060,21 +1060,21 @@ class HangingHostResolver::RequestImpl return ERR_IO_PENDING; } - const base::Optional& GetAddressResults() const override { + const absl::optional& GetAddressResults() const override { IMMEDIATE_CRASH(); } - const base::Optional>& GetTextResults() + const absl::optional>& GetTextResults() const override { IMMEDIATE_CRASH(); } - const base::Optional>& GetHostnameResults() + const absl::optional>& GetHostnameResults() const override { IMMEDIATE_CRASH(); } - const base::Optional>& GetDnsAliasResults() + const absl::optional>& GetDnsAliasResults() const override { IMMEDIATE_CRASH(); } @@ -1083,7 +1083,7 @@ class HangingHostResolver::RequestImpl IMMEDIATE_CRASH(); } - const base::Optional& GetStaleInfo() + const absl::optional& GetStaleInfo() const override { IMMEDIATE_CRASH(); } @@ -1112,7 +1112,7 @@ HangingHostResolver::CreateRequest( const HostPortPair& host, const NetworkIsolationKey& network_isolation_key, const NetLogWithSource& source_net_log, - const base::Optional& optional_parameters) { + const absl::optional& optional_parameters) { last_host_ = host; last_network_isolation_key_ = network_isolation_key; diff --git a/net/dns/mock_host_resolver.h b/net/dns/mock_host_resolver.h index 6ae937ddab9934..1b1214659c89ad 100644 --- a/net/dns/mock_host_resolver.h +++ b/net/dns/mock_host_resolver.h @@ -125,7 +125,7 @@ class MockHostResolverBase const HostPortPair& host, const NetworkIsolationKey& network_isolation_key, const NetLogWithSource& net_log, - const base::Optional& optional_parameters) + const absl::optional& optional_parameters) override; std::unique_ptr CreateDohProbeRequest() override; std::unique_ptr CreateMdnsListener( @@ -139,7 +139,7 @@ class MockHostResolverBase int LoadIntoCache( const HostPortPair& host, const NetworkIsolationKey& network_isolation_key, - const base::Optional& optional_parameters); + const absl::optional& optional_parameters); // Returns true if there are pending requests that can be resolved by invoking // ResolveAllPending(). @@ -197,14 +197,14 @@ class MockHostResolverBase } // Returns the NetworkIsolationKey passed in to the last call to Resolve() (or - // base::nullopt if Resolve() hasn't been called yet). - const base::Optional& + // absl::nullopt if Resolve() hasn't been called yet). + const absl::optional& last_request_network_isolation_key() { return last_request_network_isolation_key_; } // Returns the SecureDnsPolicy of the last call to Resolve() (or - // base::nullopt if Resolve() hasn't been called yet). + // absl::nullopt if Resolve() hasn't been called yet). SecureDnsPolicy last_secure_dns_policy() const { return last_secure_dns_policy_; } @@ -262,7 +262,7 @@ class MockHostResolverBase HostResolverSource source, HostResolver::ResolveHostParameters::CacheUsage cache_usage, AddressList* addresses, - base::Optional* stale_info); + absl::optional* stale_info); // Resolve via |proc_|. int ResolveProc(const HostPortPair& host, const NetworkIsolationKey& network_isolation_key, @@ -275,7 +275,7 @@ class MockHostResolverBase void RemoveCancelledListener(MdnsListenerImpl* listener); RequestPriority last_request_priority_; - base::Optional last_request_network_isolation_key_; + absl::optional last_request_network_isolation_key_; SecureDnsPolicy last_secure_dns_policy_; bool synchronous_mode_; bool ondemand_mode_; @@ -510,7 +510,7 @@ class HangingHostResolver : public HostResolver { const HostPortPair& host, const NetworkIsolationKey& network_isolation_key, const NetLogWithSource& net_log, - const base::Optional& optional_parameters) + const absl::optional& optional_parameters) override; std::unique_ptr CreateDohProbeRequest() override; diff --git a/net/dns/public/dns_config_overrides.h b/net/dns/public/dns_config_overrides.h index dcef613d0b9574..584e0c3dcb2337 100644 --- a/net/dns/public/dns_config_overrides.h +++ b/net/dns/public/dns_config_overrides.h @@ -8,12 +8,12 @@ #include #include -#include "base/optional.h" #include "base/time/time.h" #include "net/base/ip_endpoint.h" #include "net/base/net_export.h" #include "net/dns/public/dns_over_https_server_config.h" #include "net/dns/public/secure_dns_mode.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -38,7 +38,7 @@ struct NET_EXPORT DnsConfigOverrides { // Creates a new DnsConfig where any field with an overriding value in |this| // is replaced with that overriding value. Any field without an overriding - // value (|base::nullopt|) will be copied as-is from |config|. + // value (|absl::nullopt|) will be copied as-is from |config|. DnsConfig ApplyOverrides(const DnsConfig& config) const; // Returns |true| if the overriding configuration is comprehensive and would @@ -47,19 +47,19 @@ struct NET_EXPORT DnsConfigOverrides { bool OverridesEverything() const; // Overriding values. See same-named fields in DnsConfig for explanations. - base::Optional> nameservers; - base::Optional> search; - base::Optional append_to_multi_label_name; - base::Optional ndots; - base::Optional fallback_period; - base::Optional attempts; - base::Optional doh_attempts; - base::Optional rotate; - base::Optional use_local_ipv6; - base::Optional> dns_over_https_servers; - base::Optional secure_dns_mode; - base::Optional allow_dns_over_https_upgrade; - base::Optional> disabled_upgrade_providers; + absl::optional> nameservers; + absl::optional> search; + absl::optional append_to_multi_label_name; + absl::optional ndots; + absl::optional fallback_period; + absl::optional attempts; + absl::optional doh_attempts; + absl::optional rotate; + absl::optional use_local_ipv6; + absl::optional> dns_over_https_servers; + absl::optional secure_dns_mode; + absl::optional allow_dns_over_https_upgrade; + absl::optional> disabled_upgrade_providers; // |hosts| is not supported for overriding except to clear it. bool clear_hosts = false; diff --git a/net/dns/public/doh_provider_entry.cc b/net/dns/public/doh_provider_entry.cc index 6a727084e568c7..720620c3a7923c 100644 --- a/net/dns/public/doh_provider_entry.cc +++ b/net/dns/public/doh_provider_entry.cc @@ -45,7 +45,7 @@ const DohProviderEntry::List& DohProviderEntry::GetList() { {"NL"} /* display_countries */, LoggingLevel::kNormal), new DohProviderEntry( - "CleanBrowsingAdult", base::nullopt /* provider_id_for_histogram */, + "CleanBrowsingAdult", absl::nullopt /* provider_id_for_histogram */, {"185.228.168.10", "185.228.169.11", "2a0d:2a00:1::1", "2a0d:2a00:2::1"}, {"adult-filter-dns.cleanbrowsing.org"} /* dot_hostnames */, @@ -65,7 +65,7 @@ const DohProviderEntry::List& DohProviderEntry::GetList() { true /* display_globally */, {} /* display_countries */, LoggingLevel::kNormal), new DohProviderEntry( - "CleanBrowsingSecure", base::nullopt /* provider_id_for_histogram */, + "CleanBrowsingSecure", absl::nullopt /* provider_id_for_histogram */, {"185.228.168.9", "185.228.169.9", "2a0d:2a00:1::2", "2a0d:2a00:2::2"}, {"security-filter-dns.cleanbrowsing.org"} /* dot_hostnames */, @@ -86,7 +86,7 @@ const DohProviderEntry::List& DohProviderEntry::GetList() { true /* display_globally */, {} /* display_countries */, LoggingLevel::kExtra), new DohProviderEntry( - "Comcast", base::nullopt /* provider_id_for_histogram */, + "Comcast", absl::nullopt /* provider_id_for_histogram */, {"75.75.75.75", "75.75.76.76", "2001:558:feed::1", "2001:558:feed::2"}, {"dot.xfinity.com"} /* dns_over_tls_hostnames */, @@ -107,7 +107,7 @@ const DohProviderEntry::List& DohProviderEntry::GetList() { // disables EDNS Client Subnet (ECS) handling in order to match the // behavior of the upgraded-from classic DNS server. new DohProviderEntry( - "Dnssb", base::nullopt /* provider_id_for_histogram */, + "Dnssb", absl::nullopt /* provider_id_for_histogram */, {"185.222.222.222", "185.184.222.222", "2a09::", "2a09::1"}, {"dns.sb"} /* dns_over_tls_hostnames */, "https://doh.dns.sb/dns-query?no_ecs=true{&dns}", "" /* ui_name */, @@ -132,7 +132,7 @@ const DohProviderEntry::List& DohProviderEntry::GetList() { true /* display_globally */, {} /* display_countries */, LoggingLevel::kExtra), new DohProviderEntry( - "GoogleDns64", base::nullopt /* provider_id_for_histogram */, + "GoogleDns64", absl::nullopt /* provider_id_for_histogram */, {"2001:4860:4860::64", "2001:4860:4860::6464"}, {"dns64.dns.google"} /* dns_over_tls_hostnames */, "https://dns64.dns.google/dns-query{?dns}", "" /* ui_name */, @@ -164,7 +164,7 @@ const DohProviderEntry::List& DohProviderEntry::GetList() { true /* display_globally */, {} /* display_countries */, LoggingLevel::kNormal), new DohProviderEntry( - "OpenDNSFamily", base::nullopt /* provider_id_for_histogram */, + "OpenDNSFamily", absl::nullopt /* provider_id_for_histogram */, {"208.67.222.123", "208.67.220.123", "2620:119:35::123", "2620:119:53::123"}, {""} /* dns_over_tls_hostnames */, @@ -173,14 +173,14 @@ const DohProviderEntry::List& DohProviderEntry::GetList() { false /* display_globally */, {} /* display_countries */, LoggingLevel::kNormal), new DohProviderEntry( - "Quad9Cdn", base::nullopt /* provider_id_for_histogram */, + "Quad9Cdn", absl::nullopt /* provider_id_for_histogram */, {"9.9.9.11", "149.112.112.11", "2620:fe::11", "2620:fe::fe:11"}, {"dns11.quad9.net"} /* dns_over_tls_hostnames */, "https://dns11.quad9.net/dns-query", "" /* ui_name */, "" /* privacy_policy */, false /* display_globally */, {} /* display_countries */, LoggingLevel::kNormal), new DohProviderEntry( - "Quad9Insecure", base::nullopt /* provider_id_for_histogram */, + "Quad9Insecure", absl::nullopt /* provider_id_for_histogram */, {"9.9.9.10", "149.112.112.10", "2620:fe::10", "2620:fe::fe:10"}, {"dns10.quad9.net"} /* dns_over_tls_hostnames */, "https://dns10.quad9.net/dns-query", "" /* ui_name */, @@ -195,7 +195,7 @@ const DohProviderEntry::List& DohProviderEntry::GetList() { true /* display_globally */, {} /* display_countries */, LoggingLevel::kExtra), new DohProviderEntry( - "Quickline", base::nullopt /* provider_id_for_histogram */, + "Quickline", absl::nullopt /* provider_id_for_histogram */, {"212.60.61.246", "212.60.63.246", "2001:1a88:10:ffff::1", "2001:1a88:10:ffff::2"}, {"dot.quickline.ch"} /* dns_over_tls_hostnames */, @@ -203,7 +203,7 @@ const DohProviderEntry::List& DohProviderEntry::GetList() { "" /* privacy_policy */, false /* display_globally */, {} /* display_countries */, LoggingLevel::kNormal), new DohProviderEntry( - "Spectrum1", base::nullopt /* provider_id_for_histogram */, + "Spectrum1", absl::nullopt /* provider_id_for_histogram */, {"209.18.47.61", "209.18.47.62", "2001:1998:0f00:0001::1", "2001:1998:0f00:0002::1"}, {""} /* dns_over_tls_hostnames */, @@ -211,7 +211,7 @@ const DohProviderEntry::List& DohProviderEntry::GetList() { "" /* privacy_policy */, false /* display_globally */, {} /* display_countries */, LoggingLevel::kNormal), new DohProviderEntry( - "Spectrum2", base::nullopt /* provider_id_for_histogram */, + "Spectrum2", absl::nullopt /* provider_id_for_histogram */, {"209.18.47.61", "209.18.47.62", "2001:1998:0f00:0001::1", "2001:1998:0f00:0002::1"}, {""} /* dns_over_tls_hostnames */, @@ -219,7 +219,7 @@ const DohProviderEntry::List& DohProviderEntry::GetList() { "" /* privacy_policy */, false /* display_globally */, {} /* display_countries */, LoggingLevel::kNormal), new DohProviderEntry( - "Switch", base::nullopt /* provider_id_for_histogram */, + "Switch", absl::nullopt /* provider_id_for_histogram */, {"130.59.31.251", "130.59.31.248", "2001:620:0:ff::2", "2001:620:0:ff::3"}, {"dns.switch.ch"} /* dns_over_tls_hostnames */, @@ -233,7 +233,7 @@ const DohProviderEntry::List& DohProviderEntry::GetList() { // static DohProviderEntry DohProviderEntry::ConstructForTesting( std::string provider, - base::Optional provider_id_for_histogram, + absl::optional provider_id_for_histogram, std::set ip_strs, std::set dns_over_tls_hostnames, std::string dns_over_https_template, @@ -256,7 +256,7 @@ DohProviderEntry::~DohProviderEntry() = default; DohProviderEntry::DohProviderEntry( std::string provider, - base::Optional provider_id_for_histogram, + absl::optional provider_id_for_histogram, std::set ip_strs, std::set dns_over_tls_hostnames, std::string dns_over_https_template, diff --git a/net/dns/public/doh_provider_entry.h b/net/dns/public/doh_provider_entry.h index cf81ade54bdefe..d4d005f92beb7b 100644 --- a/net/dns/public/doh_provider_entry.h +++ b/net/dns/public/doh_provider_entry.h @@ -9,9 +9,9 @@ #include #include -#include "base/optional.h" #include "net/base/ip_address.h" #include "net/base/net_export.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -60,7 +60,7 @@ struct NET_EXPORT DohProviderEntry { std::string provider; // A provider_id_for_histogram is required for entries that are intended to // be visible in the UI. - base::Optional provider_id_for_histogram; + absl::optional provider_id_for_histogram; std::set ip_addresses; std::set dns_over_tls_hostnames; std::string dns_over_https_template; @@ -77,7 +77,7 @@ struct NET_EXPORT DohProviderEntry { static DohProviderEntry ConstructForTesting( std::string provider, - base::Optional provider_id_for_histogram, + absl::optional provider_id_for_histogram, std::set ip_strs, std::set dns_over_tls_hostnames, std::string dns_over_https_template, @@ -96,7 +96,7 @@ struct NET_EXPORT DohProviderEntry { private: DohProviderEntry( std::string provider, - base::Optional provider_id_for_histogram, + absl::optional provider_id_for_histogram, std::set ip_strs, std::set dns_over_tls_hostnames, std::string dns_over_https_template, diff --git a/net/dns/record_rdata.cc b/net/dns/record_rdata.cc index f57034e9466260..c2571482d07434 100644 --- a/net/dns/record_rdata.cc +++ b/net/dns/record_rdata.cc @@ -455,9 +455,9 @@ IntegrityRecordRdata IntegrityRecordRdata::Random() { return IntegrityRecordRdata(std::move(nonce)); } -base::Optional> IntegrityRecordRdata::Serialize() const { +absl::optional> IntegrityRecordRdata::Serialize() const { if (!is_intact_) { - return base::nullopt; + return absl::nullopt; } // Create backing buffer and writer. diff --git a/net/dns/record_rdata.h b/net/dns/record_rdata.h index a0996f2b78c6e5..c862389d07d7d6 100644 --- a/net/dns/record_rdata.h +++ b/net/dns/record_rdata.h @@ -14,12 +14,12 @@ #include "base/check_op.h" #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/optional.h" #include "base/strings/string_piece.h" #include "net/base/io_buffer.h" #include "net/base/ip_address.h" #include "net/base/net_export.h" #include "net/dns/public/dns_protocol.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/boringssl/src/include/openssl/sha.h" namespace net { @@ -311,9 +311,9 @@ class NET_EXPORT IntegrityRecordRdata : public RecordRdata { // Postcondition: |IsIntact()| is true. static IntegrityRecordRdata Random(); - // Serialize |this| using the INTEGRITY wire format. Returns |base::nullopt| + // Serialize |this| using the INTEGRITY wire format. Returns |absl::nullopt| // when |!IsIntact()|. - base::Optional> Serialize() const; + absl::optional> Serialize() const; // Precondition: |IsIntact()|. const Nonce& nonce() const { diff --git a/net/dns/record_rdata_unittest.cc b/net/dns/record_rdata_unittest.cc index 46e2da93659565..2f27a63d550f2a 100644 --- a/net/dns/record_rdata_unittest.cc +++ b/net/dns/record_rdata_unittest.cc @@ -9,12 +9,12 @@ #include #include "base/big_endian.h" -#include "base/optional.h" #include "net/dns/dns_response.h" #include "net/dns/dns_test_util.h" #include "net/test/gtest_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { namespace { @@ -322,7 +322,7 @@ TEST(RecordRdataTest, IntegrityParseSerializeInverseProperty) { IntegrityRecordRdata record(IntegrityRecordRdata::Random()); EXPECT_TRUE(record.IsIntact()); - base::Optional> serialized = record.Serialize(); + absl::optional> serialized = record.Serialize(); EXPECT_TRUE(serialized); std::unique_ptr reparsed = @@ -336,7 +336,7 @@ TEST(RecordRdataTest, IntegrityEmptyNonceCornerCase) { IntegrityRecordRdata record(empty_nonce); EXPECT_TRUE(record.IsIntact()); - base::Optional> serialized = record.Serialize(); + absl::optional> serialized = record.Serialize(); EXPECT_TRUE(serialized); std::unique_ptr reparsed = IntegrityRecordRdata::Create(MakeStringPiece(*serialized)); @@ -349,12 +349,12 @@ TEST(RecordRdataTest, IntegrityEmptyNonceCornerCase) { TEST(RecordRdataTest, IntegrityMoveConstructor) { IntegrityRecordRdata record_a(IntegrityRecordRdata::Random()); EXPECT_TRUE(record_a.IsIntact()); - base::Optional> serialized_a = record_a.Serialize(); + absl::optional> serialized_a = record_a.Serialize(); EXPECT_TRUE(serialized_a); IntegrityRecordRdata record_b = std::move(record_a); EXPECT_TRUE(record_b.IsIntact()); - base::Optional> serialized_b = record_b.Serialize(); + absl::optional> serialized_b = record_b.Serialize(); EXPECT_TRUE(serialized_b); EXPECT_EQ(serialized_a, serialized_b); @@ -369,7 +369,7 @@ TEST(RecordRdataTest, IntegrityRandomRecordsDiffer) { TEST(RecordRdataTest, IntegritySerialize) { IntegrityRecordRdata record({'A'}); EXPECT_TRUE(record.IsIntact()); - const base::Optional> serialized = record.Serialize(); + const absl::optional> serialized = record.Serialize(); EXPECT_TRUE(serialized); // Expected payload contains the SHA256 hash of 'A'. For the lazy: diff --git a/net/dns/resolve_context.h b/net/dns/resolve_context.h index 538690d29bac60..0af99b232b8f34 100644 --- a/net/dns/resolve_context.h +++ b/net/dns/resolve_context.h @@ -13,12 +13,12 @@ #include "base/metrics/sample_vector.h" #include "base/observer_list.h" #include "base/observer_list_types.h" -#include "base/optional.h" #include "base/time/time.h" #include "net/base/isolation_info.h" #include "net/base/net_export.h" #include "net/dns/dns_config.h" #include "net/dns/public/secure_dns_mode.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { diff --git a/net/dns/system_dns_config_change_notifier.cc b/net/dns/system_dns_config_change_notifier.cc index 9523249704371c..68472cf3da7b2d 100644 --- a/net/dns/system_dns_config_change_notifier.cc +++ b/net/dns/system_dns_config_change_notifier.cc @@ -34,14 +34,14 @@ class WrappedObserver { ~WrappedObserver() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); } - void OnNotifyThreadsafe(base::Optional config) { + void OnNotifyThreadsafe(absl::optional config) { task_runner_->PostTask( FROM_HERE, base::BindOnce(&WrappedObserver::OnNotify, weak_ptr_factory_.GetWeakPtr(), std::move(config))); } - void OnNotify(base::Optional config) { + void OnNotify(absl::optional config) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK(!config || config.value().IsValid()); @@ -146,10 +146,10 @@ class SystemDnsConfigChangeNotifier::Core { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); base::AutoLock lock(lock_); - // |config_| is |base::nullopt| if most recent config was invalid (or no + // |config_| is |absl::nullopt| if most recent config was invalid (or no // valid config has yet been read), so convert |config| to a similar form // before comparing for change. - base::Optional new_config; + absl::optional new_config; if (config.IsValid()) new_config = config; @@ -171,9 +171,9 @@ class SystemDnsConfigChangeNotifier::Core { // Fields that may be accessed from any sequence. Must protect access using // |lock_|. mutable base::Lock lock_; - // Only stores valid configs. |base::nullopt| if most recent config was + // Only stores valid configs. |absl::nullopt| if most recent config was // invalid (or no valid config has yet been read). - base::Optional config_; + absl::optional config_; std::map> wrapped_observers_; // Fields valid only on |task_runner_|. diff --git a/net/dns/system_dns_config_change_notifier.h b/net/dns/system_dns_config_change_notifier.h index 447a8d8c244fff..6ba0654cd938ff 100644 --- a/net/dns/system_dns_config_change_notifier.h +++ b/net/dns/system_dns_config_change_notifier.h @@ -9,10 +9,10 @@ #include "base/macros.h" #include "base/memory/scoped_refptr.h" -#include "base/optional.h" #include "base/sequenced_task_runner.h" #include "net/base/net_export.h" #include "net/dns/dns_config.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -34,9 +34,9 @@ class NET_EXPORT_PRIVATE SystemDnsConfigChangeNotifier { public: // Called on loading new config, including the initial read once the first // valid config has been read. If a config read encounters errors or an - // invalid config is read, will be invoked with |base::nullopt|. Only + // invalid config is read, will be invoked with |absl::nullopt|. Only // invoked when |config| changes. - virtual void OnSystemDnsConfigChanged(base::Optional config) = 0; + virtual void OnSystemDnsConfigChanged(absl::optional config) = 0; }; SystemDnsConfigChangeNotifier(); diff --git a/net/dns/system_dns_config_change_notifier_unittest.cc b/net/dns/system_dns_config_change_notifier_unittest.cc index dbca90dd1afb76..a905554f18180f 100644 --- a/net/dns/system_dns_config_change_notifier_unittest.cc +++ b/net/dns/system_dns_config_change_notifier_unittest.cc @@ -55,7 +55,7 @@ class SystemDnsConfigChangeNotifierTest : public TestWithTaskEnvironment { // expected sequence. class TestObserver : public SystemDnsConfigChangeNotifier::Observer { public: - void OnSystemDnsConfigChanged(base::Optional config) override { + void OnSystemDnsConfigChanged(absl::optional config) override { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); configs_received_.push_back(std::move(config)); @@ -80,7 +80,7 @@ class SystemDnsConfigChangeNotifierTest : public TestWithTaskEnvironment { EXPECT_TRUE(configs_received_.empty()); } - std::vector>& configs_received() { + std::vector>& configs_received() { return configs_received_; } @@ -88,7 +88,7 @@ class SystemDnsConfigChangeNotifierTest : public TestWithTaskEnvironment { int notifications_remaining_ = 0; std::unique_ptr run_loop_ = std::make_unique(); - std::vector> configs_received_; + std::vector> configs_received_; SEQUENCE_CHECKER(sequence_checker_); }; @@ -246,7 +246,7 @@ TEST_F(SystemDnsConfigChangeNotifierTest, UnloadedConfig) { observer.WaitForNotification(); EXPECT_THAT(observer.configs_received(), - testing::ElementsAre(testing::Optional(kConfig), base::nullopt)); + testing::ElementsAre(testing::Optional(kConfig), absl::nullopt)); observer.ExpectNoMoreNotifications(); notifier_->RemoveObserver(&observer); @@ -271,7 +271,7 @@ TEST_F(SystemDnsConfigChangeNotifierTest, UnloadedConfig_Multiple) { observer.WaitForNotification(); // Only 1 notification expected. EXPECT_THAT(observer.configs_received(), - testing::ElementsAre(testing::Optional(kConfig), base::nullopt)); + testing::ElementsAre(testing::Optional(kConfig), absl::nullopt)); observer.ExpectNoMoreNotifications(); notifier_->RemoveObserver(&observer); diff --git a/net/dns/test_dns_config_service.cc b/net/dns/test_dns_config_service.cc index 80f60a18c2ec9c..bb896ec93c396c 100644 --- a/net/dns/test_dns_config_service.cc +++ b/net/dns/test_dns_config_service.cc @@ -6,13 +6,13 @@ #include "base/check.h" #include "base/files/file_path.h" -#include "base/optional.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { TestDnsConfigService::TestDnsConfigService() : DnsConfigService(base::FilePath::StringPieceType() /* hosts_file_path */, - base::nullopt /* config_change_delay */) {} + absl::nullopt /* config_change_delay */) {} TestDnsConfigService::~TestDnsConfigService() = default; @@ -26,7 +26,7 @@ void TestDnsConfigService::RefreshConfig() { InvalidateHosts(); OnConfigRead(config_for_refresh_.value()); OnHostsRead(config_for_refresh_.value().hosts); - config_for_refresh_ = base::nullopt; + config_for_refresh_ = absl::nullopt; } } // namespace net diff --git a/net/dns/test_dns_config_service.h b/net/dns/test_dns_config_service.h index 3b4fb06b89a8d7..0427e763ada5f6 100644 --- a/net/dns/test_dns_config_service.h +++ b/net/dns/test_dns_config_service.h @@ -8,8 +8,8 @@ #include #include "base/check.h" -#include "base/optional.h" #include "net/dns/dns_config_service.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -45,7 +45,7 @@ class TestDnsConfigService : public DnsConfigService { } private: - base::Optional config_for_refresh_; + absl::optional config_for_refresh_; }; } // namespace net diff --git a/net/extras/sqlite/sqlite_persistent_cookie_store.cc b/net/extras/sqlite/sqlite_persistent_cookie_store.cc index 0f28f2ce28e08c..63e607af47f2b5 100644 --- a/net/extras/sqlite/sqlite_persistent_cookie_store.cc +++ b/net/extras/sqlite/sqlite_persistent_cookie_store.cc @@ -21,7 +21,6 @@ #include "base/memory/ref_counted.h" #include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_macros.h" -#include "base/optional.h" #include "base/sequenced_task_runner.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" @@ -41,6 +40,7 @@ #include "sql/meta_table.h" #include "sql/statement.h" #include "sql/transaction.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/third_party/mozilla/url_parse.h" @@ -281,7 +281,7 @@ class SQLitePersistentCookieStore::Backend } // Database upgrade statements. - base::Optional DoMigrateDatabaseSchema() override; + absl::optional DoMigrateDatabaseSchema() override; class PendingOperation { public: @@ -965,21 +965,21 @@ bool SQLitePersistentCookieStore::Backend::MakeCookiesFromSQLStatement( return ok; } -base::Optional +absl::optional SQLitePersistentCookieStore::Backend::DoMigrateDatabaseSchema() { int cur_version = meta_table()->GetVersionNumber(); if (cur_version == 9) { const base::TimeTicks start_time = base::TimeTicks::Now(); sql::Transaction transaction(db()); if (!transaction.Begin()) - return base::nullopt; + return absl::nullopt; if (!db()->Execute("ALTER TABLE cookies RENAME TO cookies_old")) - return base::nullopt; + return absl::nullopt; if (!db()->Execute("DROP INDEX IF EXISTS domain")) - return base::nullopt; + return absl::nullopt; if (!db()->Execute("DROP INDEX IF EXISTS is_transient")) - return base::nullopt; + return absl::nullopt; if (!CreateV10Schema(db())) { // Not clear what good a false return here will do since the calling @@ -988,7 +988,7 @@ SQLitePersistentCookieStore::Backend::DoMigrateDatabaseSchema() { // InitTable() just returns true if the table exists, so if // EnsureDatabaseVersion() fails, initting the table won't do any // further good. Fix? - return base::nullopt; + return absl::nullopt; } // If any cookies violate the new uniqueness constraints (no two // cookies with the same (name, domain, path)), pick the newer version, @@ -1002,10 +1002,10 @@ SQLitePersistentCookieStore::Backend::DoMigrateDatabaseSchema() { " secure, httponly, last_access_utc, has_expires, " " persistent, priority, encrypted_value, firstpartyonly " "FROM cookies_old ORDER BY creation_utc ASC")) { - return base::nullopt; + return absl::nullopt; } if (!db()->Execute("DROP TABLE cookies_old")) - return base::nullopt; + return absl::nullopt; ++cur_version; meta_table()->SetVersionNumber(cur_version); meta_table()->SetCompatibleVersionNumber( @@ -1018,15 +1018,15 @@ SQLitePersistentCookieStore::Backend::DoMigrateDatabaseSchema() { if (cur_version == 10) { sql::Transaction transaction(db()); if (!transaction.Begin()) - return base::nullopt; + return absl::nullopt; // Copy the data into a new table, renaming the firstpartyonly column to // samesite. if (!db()->Execute("DROP TABLE IF EXISTS cookies_old; " "ALTER TABLE cookies RENAME TO cookies_old")) - return base::nullopt; + return absl::nullopt; if (!CreateV11Schema(db())) - return base::nullopt; + return absl::nullopt; if (!db()->Execute( "INSERT INTO cookies " "(creation_utc, host_key, name, value, path, expires_utc, " @@ -1036,10 +1036,10 @@ SQLitePersistentCookieStore::Backend::DoMigrateDatabaseSchema() { " is_secure, is_httponly, last_access_utc, has_expires, " " is_persistent, priority, encrypted_value, firstpartyonly " "FROM cookies_old")) { - return base::nullopt; + return absl::nullopt; } if (!db()->Execute("DROP TABLE cookies_old")) - return base::nullopt; + return absl::nullopt; // Update stored SameSite values of kCookieSameSiteNoRestriction into // kCookieSameSiteUnspecified. @@ -1048,7 +1048,7 @@ SQLitePersistentCookieStore::Backend::DoMigrateDatabaseSchema() { CookieSameSiteToDBCookieSameSite(CookieSameSite::UNSPECIFIED), CookieSameSiteToDBCookieSameSite(CookieSameSite::NO_RESTRICTION))); if (!db()->Execute(update_stmt.c_str())) - return base::nullopt; + return absl::nullopt; ++cur_version; meta_table()->SetVersionNumber(cur_version); @@ -1061,14 +1061,14 @@ SQLitePersistentCookieStore::Backend::DoMigrateDatabaseSchema() { SCOPED_UMA_HISTOGRAM_TIMER("Cookie.TimeDatabaseMigrationToV12"); sql::Transaction transaction(db()); if (!transaction.Begin()) - return base::nullopt; + return absl::nullopt; std::string update_stmt( base::StringPrintf("ALTER TABLE cookies ADD COLUMN source_scheme " "INTEGER NOT NULL DEFAULT %d;", static_cast(CookieSourceScheme::kUnset))); if (!db()->Execute(update_stmt.c_str())) - return base::nullopt; + return absl::nullopt; ++cur_version; meta_table()->SetVersionNumber(cur_version); @@ -1088,7 +1088,7 @@ SQLitePersistentCookieStore::Backend::DoMigrateDatabaseSchema() { if (!transaction.Begin()) { base::UmaHistogramTimes(kMigrationFailureHistogram, base::TimeTicks::Now() - start_time); - return base::nullopt; + return absl::nullopt; } std::string update_stmt( @@ -1100,7 +1100,7 @@ SQLitePersistentCookieStore::Backend::DoMigrateDatabaseSchema() { if (!db()->Execute(update_stmt.c_str())) { base::UmaHistogramTimes(kMigrationFailureHistogram, base::TimeTicks::Now() - start_time); - return base::nullopt; + return absl::nullopt; } ++cur_version; @@ -1116,7 +1116,7 @@ SQLitePersistentCookieStore::Backend::DoMigrateDatabaseSchema() { const base::TimeTicks start_time = base::TimeTicks::Now(); sql::Transaction transaction(db()); if (!transaction.Begin()) - return base::nullopt; + return absl::nullopt; #if defined(OS_WIN) // Migration is only needed on Windows. On other platforms, this is a no-op. @@ -1134,7 +1134,7 @@ SQLitePersistentCookieStore::Backend::DoMigrateDatabaseSchema() { "rowid=?")); if (!select_statement.is_valid() || !update_statement.is_valid()) - return base::nullopt; + return absl::nullopt; bool okay = true; @@ -1164,7 +1164,7 @@ SQLitePersistentCookieStore::Backend::DoMigrateDatabaseSchema() { update_statement.BindString(0, entry.second); update_statement.BindInt64(1, entry.first); if (!update_statement.Run()) - return base::nullopt; + return absl::nullopt; } UMA_HISTOGRAM_BOOLEAN("Cookie.MigratedEncryptionKeySuccess", okay); @@ -1181,7 +1181,7 @@ SQLitePersistentCookieStore::Backend::DoMigrateDatabaseSchema() { // Put future migration cases here. - return base::make_optional(cur_version); + return absl::make_optional(cur_version); } void SQLitePersistentCookieStore::Backend::AddCookie( diff --git a/net/extras/sqlite/sqlite_persistent_cookie_store_unittest.cc b/net/extras/sqlite/sqlite_persistent_cookie_store_unittest.cc index 7b247a01b7ff97..b4cecb46e98202 100644 --- a/net/extras/sqlite/sqlite_persistent_cookie_store_unittest.cc +++ b/net/extras/sqlite/sqlite_persistent_cookie_store_unittest.cc @@ -15,7 +15,6 @@ #include "base/files/scoped_temp_dir.h" #include "base/location.h" #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "base/run_loop.h" #include "base/sequenced_task_runner.h" #include "base/strings/stringprintf.h" @@ -43,6 +42,7 @@ #include "sql/statement.h" #include "sql/transaction.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/third_party/mozilla/url_parse.h" @@ -1385,7 +1385,7 @@ TEST_F(SQLitePersistentCookieStoreTest, KeyInconsistency) { GURL ftp_url("ftp://subdomain.ftperiffic.com/page/"); auto cookie = CanonicalCookie::Create(ftp_url, "A=B; max-age=3600", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); cookie_monster->SetCanonicalCookieAsync(std::move(cookie), ftp_url, CookieOptions::MakeAllInclusive(), set_cookie_callback.MakeCallback()); @@ -1399,7 +1399,7 @@ TEST_F(SQLitePersistentCookieStoreTest, KeyInconsistency) { GURL url(base::StringPrintf("http://example%d.com/", i)); auto canonical_cookie = CanonicalCookie::Create(url, "A=B; max-age=3600", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); cookie_monster->SetCanonicalCookieAsync( std::move(canonical_cookie), url, CookieOptions::MakeAllInclusive(), set_cookie_callback2.MakeCallback()); @@ -1453,7 +1453,7 @@ TEST_F(SQLitePersistentCookieStoreTest, OpsIfInitFailed) { GURL url("http://www.example.com/"); auto cookie = CanonicalCookie::Create(url, "A=B; max-age=3600", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); cookie_monster->SetCanonicalCookieAsync(std::move(cookie), url, CookieOptions::MakeAllInclusive(), set_cookie_callback.MakeCallback()); @@ -1486,7 +1486,7 @@ TEST_F(SQLitePersistentCookieStoreTest, Coalescing) { std::unique_ptr cookie = CanonicalCookie::Create( GURL("http://www.example.com/path"), "Tasty=Yes", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); for (const TestCase& testcase : testcases) { Create(false, false, true /* want current thread to invoke the store. */); @@ -1539,11 +1539,11 @@ TEST_F(SQLitePersistentCookieStoreTest, NoCoalesceUnrelated) { std::unique_ptr cookie1 = CanonicalCookie::Create( GURL("http://www.example.com/path"), "Tasty=Yes", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); std::unique_ptr cookie2 = CanonicalCookie::Create( GURL("http://not.example.com/path"), "Tasty=No", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); // Wedge the background thread to make sure that it doesn't start consuming // the queue. diff --git a/net/extras/sqlite/sqlite_persistent_reporting_and_nel_store.cc b/net/extras/sqlite/sqlite_persistent_reporting_and_nel_store.cc index 53b40891d7d285..6f39cc484f94d9 100644 --- a/net/extras/sqlite/sqlite_persistent_reporting_and_nel_store.cc +++ b/net/extras/sqlite/sqlite_persistent_reporting_and_nel_store.cc @@ -103,7 +103,7 @@ NetworkIsolationKeyToString(const NetworkIsolationKey& network_isolation_key, bool WARN_UNUSED_RESULT NetworkIsolationKeyFromString(const std::string& string, NetworkIsolationKey* out_network_isolation_key) { - base::Optional value = base::JSONReader::Read(string); + absl::optional value = base::JSONReader::Read(string); if (!value) return false; @@ -209,7 +209,7 @@ class SQLitePersistentReportingAndNelStore::Backend // SQLitePersistentStoreBackendBase implementation bool CreateDatabaseSchema() override; - base::Optional DoMigrateDatabaseSchema() override; + absl::optional DoMigrateDatabaseSchema() override; void DoCommit() override; // Commit a pending operation pertaining to a NEL policy. @@ -720,7 +720,7 @@ bool SQLitePersistentReportingAndNelStore::Backend::CreateDatabaseSchema() { return true; } -base::Optional +absl::optional SQLitePersistentReportingAndNelStore::Backend::DoMigrateDatabaseSchema() { int cur_version = meta_table()->GetVersionNumber(); @@ -735,15 +735,15 @@ SQLitePersistentReportingAndNelStore::Backend::DoMigrateDatabaseSchema() { if (cur_version == 1) { sql::Transaction transaction(db()); if (!transaction.Begin()) - return base::nullopt; + return absl::nullopt; // Migrate NEL policies table. if (!db()->Execute("DROP TABLE IF EXISTS nel_policies_old; " "ALTER TABLE nel_policies RENAME TO nel_policies_old")) { - return base::nullopt; + return absl::nullopt; } if (!CreateV2NelPoliciesSchema(db())) - return base::nullopt; + return absl::nullopt; // clang-format off // The "report_to" field is renamed to "group_name" for consistency with // the other tables. @@ -759,18 +759,18 @@ SQLitePersistentReportingAndNelStore::Backend::DoMigrateDatabaseSchema() { "FROM nel_policies_old" ; // clang-format on if (!db()->Execute(nel_policies_migrate_stmt.c_str())) - return base::nullopt; + return absl::nullopt; if (!db()->Execute("DROP TABLE nel_policies_old")) - return base::nullopt; + return absl::nullopt; // Migrate Reporting endpoints table. if (!db()->Execute("DROP TABLE IF EXISTS reporting_endpoints_old; " "ALTER TABLE reporting_endpoints RENAME TO " "reporting_endpoints_old")) { - return base::nullopt; + return absl::nullopt; } if (!CreateV2ReportingEndpointsSchema(db())) - return base::nullopt; + return absl::nullopt; // clang-format off std::string reporting_endpoints_migrate_stmt = "INSERT INTO reporting_endpoints (nik, origin_scheme, origin_host, " @@ -780,18 +780,18 @@ SQLitePersistentReportingAndNelStore::Backend::DoMigrateDatabaseSchema() { "FROM reporting_endpoints_old" ; // clang-format on if (!db()->Execute(reporting_endpoints_migrate_stmt.c_str())) - return base::nullopt; + return absl::nullopt; if (!db()->Execute("DROP TABLE reporting_endpoints_old")) - return base::nullopt; + return absl::nullopt; // Migrate Reporting endpoint groups table. if (!db()->Execute("DROP TABLE IF EXISTS reporting_endpoint_groups_old; " "ALTER TABLE reporting_endpoint_groups RENAME TO " "reporting_endpoint_groups_old")) { - return base::nullopt; + return absl::nullopt; } if (!CreateV2ReportingEndpointGroupsSchema(db())) - return base::nullopt; + return absl::nullopt; // clang-format off std::string reporting_endpoint_groups_migrate_stmt = "INSERT INTO reporting_endpoint_groups (nik, origin_scheme, " @@ -803,9 +803,9 @@ SQLitePersistentReportingAndNelStore::Backend::DoMigrateDatabaseSchema() { "FROM reporting_endpoint_groups_old" ; // clang-format on if (!db()->Execute(reporting_endpoint_groups_migrate_stmt.c_str())) - return base::nullopt; + return absl::nullopt; if (!db()->Execute("DROP TABLE reporting_endpoint_groups_old")) - return base::nullopt; + return absl::nullopt; ++cur_version; meta_table()->SetVersionNumber(cur_version); @@ -816,7 +816,7 @@ SQLitePersistentReportingAndNelStore::Backend::DoMigrateDatabaseSchema() { // Future database upgrade statements go here. - return base::make_optional(cur_version); + return absl::make_optional(cur_version); } void SQLitePersistentReportingAndNelStore::Backend::DoCommit() { diff --git a/net/extras/sqlite/sqlite_persistent_store_backend_base.cc b/net/extras/sqlite/sqlite_persistent_store_backend_base.cc index c894fc61864b52..b47d3d5f8d3bbc 100644 --- a/net/extras/sqlite/sqlite_persistent_store_backend_base.cc +++ b/net/extras/sqlite/sqlite_persistent_store_backend_base.cc @@ -187,7 +187,7 @@ bool SQLitePersistentStoreBackendBase::MigrateDatabaseSchema() { // |cur_version| is the version that the database ends up at, after all the // database upgrade statements. - base::Optional cur_version = DoMigrateDatabaseSchema(); + absl::optional cur_version = DoMigrateDatabaseSchema(); if (!cur_version.has_value()) return false; diff --git a/net/extras/sqlite/sqlite_persistent_store_backend_base.h b/net/extras/sqlite/sqlite_persistent_store_backend_base.h index f9d93069b54a55..d22b10f39fc152 100644 --- a/net/extras/sqlite/sqlite_persistent_store_backend_base.h +++ b/net/extras/sqlite/sqlite_persistent_store_backend_base.h @@ -13,9 +13,9 @@ #include "base/files/file_path.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "base/thread_annotations.h" #include "sql/meta_table.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { class Location; @@ -93,9 +93,9 @@ class SQLitePersistentStoreBackendBase // Embedder-specific database upgrade statements. Returns the version number // that the database ends up at, or returns nullopt on error. This is called // during MigrateDatabaseSchema() which is called during InitializeDatabase(), - // and returning |base::nullopt| will cause the initialization process to fail + // and returning |absl::nullopt| will cause the initialization process to fail // and stop. - virtual base::Optional DoMigrateDatabaseSchema() = 0; + virtual absl::optional DoMigrateDatabaseSchema() = 0; // Initializes the desired table(s) of the database, e.g. by creating them or // checking that they already exist. Returns whether the tables exist. diff --git a/net/ftp/ftp_network_transaction.cc b/net/ftp/ftp_network_transaction.cc index f0b3cc21480f84..c028d31b4db88c 100644 --- a/net/ftp/ftp_network_transaction.cc +++ b/net/ftp/ftp_network_transaction.cc @@ -665,7 +665,7 @@ int FtpNetworkTransaction::DoCtrlResolveHost() { // and should go away soon. resolve_request_ = resolver_->CreateRequest(HostPortPair::FromURL(request_->url), - NetworkIsolationKey(), net_log_, base::nullopt); + NetworkIsolationKey(), net_log_, absl::nullopt); return resolve_request_->Start(base::BindOnce( &FtpNetworkTransaction::OnIOComplete, base::Unretained(this))); } diff --git a/net/http/http_auth_controller.cc b/net/http/http_auth_controller.cc index 8ffeca720c32bc..10d02bb9b9ebc8 100644 --- a/net/http/http_auth_controller.cc +++ b/net/http/http_auth_controller.cc @@ -397,7 +397,7 @@ void HttpAuthController::ResetAuth(const AuthCredentials& credentials) { identity_.credentials = credentials; // auth_info_ is no longer necessary. - auth_info_ = base::nullopt; + auth_info_ = absl::nullopt; } DCHECK(identity_.source != HttpAuth::IDENT_SRC_PATH_LOOKUP); @@ -623,7 +623,7 @@ void HttpAuthController::OnGenerateAuthTokenDone(int result) { } void HttpAuthController::TakeAuthInfo( - base::Optional* other) { + absl::optional* other) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); auth_info_.swap(*other); } diff --git a/net/http/http_auth_controller.h b/net/http/http_auth_controller.h index 318527af6e513c..1a3bac971e5c43 100644 --- a/net/http/http_auth_controller.h +++ b/net/http/http_auth_controller.h @@ -10,7 +10,6 @@ #include #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "base/threading/thread_checker.h" #include "net/base/completion_once_callback.h" #include "net/base/net_export.h" @@ -18,6 +17,7 @@ #include "net/http/http_auth.h" #include "net/http/http_auth_preferences.h" #include "net/log/net_log_with_source.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace net { @@ -123,7 +123,7 @@ class NET_EXPORT_PRIVATE HttpAuthController bool NeedsHTTP11() const; // Swaps the authentication challenge info into |other|. - void TakeAuthInfo(base::Optional* other); + void TakeAuthInfo(absl::optional* other); bool IsAuthSchemeDisabled(HttpAuth::Scheme scheme) const; void DisableAuthScheme(HttpAuth::Scheme scheme); @@ -219,7 +219,7 @@ class NET_EXPORT_PRIVATE HttpAuthController std::string auth_token_; // Contains information about the auth challenge. - base::Optional auth_info_; + absl::optional auth_info_; // True if we've used the username:password embedded in the URL. This // makes sure we use the embedded identity only once for the transaction, diff --git a/net/http/http_auth_handler_factory_unittest.cc b/net/http/http_auth_handler_factory_unittest.cc index e4182163dddba9..c56d43b553f99f 100644 --- a/net/http/http_auth_handler_factory_unittest.cc +++ b/net/http/http_auth_handler_factory_unittest.cc @@ -317,7 +317,7 @@ TEST(HttpAuthHandlerFactoryTest, LogCreateAuthHandlerResults) { const std::string* scheme = entries[0].params.FindStringKey("scheme"); ASSERT_NE(nullptr, scheme); EXPECT_STRCASEEQ(test_case.expected_scheme, scheme->data()); - base::Optional net_error = entries[0].params.FindIntKey("net_error"); + absl::optional net_error = entries[0].params.FindIntKey("net_error"); if (test_case.expected_net_error) { ASSERT_TRUE(net_error.has_value()); EXPECT_EQ(test_case.expected_net_error, net_error.value()); diff --git a/net/http/http_cache_transaction.h b/net/http/http_cache_transaction.h index ed88840bc96225..06d665c46ce597 100644 --- a/net/http/http_cache_transaction.h +++ b/net/http/http_cache_transaction.h @@ -601,7 +601,7 @@ class NET_EXPORT_PRIVATE HttpCache::Transaction : public HttpTransaction { // and modifies the members for future transactions. Then, // WriteResponseInfoToEntry() writes |updated_prefetch_response_| to the cache // entry if it is populated, or |response_| otherwise. Finally, - // WriteResponseInfoToEntry() resets this to base::nullopt. + // WriteResponseInfoToEntry() resets this to absl::nullopt. std::unique_ptr updated_prefetch_response_; const HttpResponseInfo* new_response_; diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h index d3f516e6c95122..0329622f9aba5d 100644 --- a/net/http/http_network_session.h +++ b/net/http/http_network_session.h @@ -20,7 +20,6 @@ #include "base/memory/memory_pressure_monitor.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "base/threading/thread_checker.h" #include "build/buildflag.h" #include "net/base/host_mapping_rules.h" @@ -36,6 +35,7 @@ #include "net/spdy/spdy_session_pool.h" #include "net/ssl/ssl_client_session_cache.h" #include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { class Value; @@ -119,7 +119,7 @@ class NET_EXPORT HttpNetworkSession { // https://tools.ietf.org/html/draft-bishop-httpbis-grease-00. // The same frame will be sent out on all connections to prevent the retry // logic from hiding broken servers. - base::Optional greased_http2_frame; + absl::optional greased_http2_frame; // If set, the HEADERS frame carrying a request without body will not have // the END_STREAM flag set. The stream will be closed by a subsequent empty // DATA frame with END_STREAM. Does not affect bidirectional or proxy diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index 35f78a104b5747..a2d3ceb05087af 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -23,7 +23,6 @@ #include "base/logging.h" #include "base/memory/ptr_util.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "base/run_loop.h" #include "base/stl_util.h" #include "base/strings/string_piece.h" @@ -122,6 +121,7 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #if defined(NTLM_PORTABLE) @@ -685,7 +685,7 @@ class CaptureGroupIdTransportSocketPool : public TransportClientSocketPool { int RequestSocket( const ClientSocketPool::GroupId& group_id, scoped_refptr socket_params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, RequestPriority priority, const SocketTag& socket_tag, ClientSocketPool::RespectLimits respect_limits, @@ -726,7 +726,7 @@ class CaptureGroupIdTransportSocketPool : public TransportClientSocketPool { // Helper functions for validating that AuthChallengeInfo's are correctly // configured for common cases. bool CheckBasicServerAuth( - const base::Optional& auth_challenge) { + const absl::optional& auth_challenge) { if (!auth_challenge) return false; EXPECT_FALSE(auth_challenge->is_proxy); @@ -737,7 +737,7 @@ bool CheckBasicServerAuth( } bool CheckBasicSecureServerAuth( - const base::Optional& auth_challenge) { + const absl::optional& auth_challenge) { if (!auth_challenge) return false; EXPECT_FALSE(auth_challenge->is_proxy); @@ -748,7 +748,7 @@ bool CheckBasicSecureServerAuth( } bool CheckBasicProxyAuth( - const base::Optional& auth_challenge) { + const absl::optional& auth_challenge) { if (!auth_challenge) return false; EXPECT_TRUE(auth_challenge->is_proxy); @@ -759,7 +759,7 @@ bool CheckBasicProxyAuth( } bool CheckBasicSecureProxyAuth( - const base::Optional& auth_challenge) { + const absl::optional& auth_challenge) { if (!auth_challenge) return false; EXPECT_TRUE(auth_challenge->is_proxy); @@ -770,7 +770,7 @@ bool CheckBasicSecureProxyAuth( } bool CheckDigestServerAuth( - const base::Optional& auth_challenge) { + const absl::optional& auth_challenge) { if (!auth_challenge) return false; EXPECT_FALSE(auth_challenge->is_proxy); @@ -782,7 +782,7 @@ bool CheckDigestServerAuth( #if defined(NTLM_PORTABLE) bool CheckNTLMServerAuth( - const base::Optional& auth_challenge) { + const absl::optional& auth_challenge) { if (!auth_challenge) return false; EXPECT_FALSE(auth_challenge->is_proxy); @@ -793,7 +793,7 @@ bool CheckNTLMServerAuth( } bool CheckNTLMProxyAuth( - const base::Optional& auth_challenge) { + const absl::optional& auth_challenge) { if (!auth_challenge) return false; EXPECT_TRUE(auth_challenge->is_proxy); @@ -11118,7 +11118,7 @@ TEST_F(HttpNetworkTransactionTest, ResetStateForRestart) { // Setup state in response_ HttpResponseInfo* response = &trans.response_; - response->auth_challenge = base::nullopt; + response->auth_challenge = absl::nullopt; response->ssl_info.cert_status = static_cast(-1); // Nonsensical. response->response_time = base::Time::Now(); response->was_cached = true; // (Wouldn't ever actually be true...) @@ -13711,7 +13711,7 @@ TEST_F(HttpNetworkTransactionTest, ChangeAuthRealms) { EXPECT_THAT(rv, IsOk()); const HttpResponseInfo* response = trans.GetResponseInfo(); ASSERT_TRUE(response); - base::Optional challenge = response->auth_challenge; + absl::optional challenge = response->auth_challenge; ASSERT_TRUE(challenge); EXPECT_FALSE(challenge->is_proxy); EXPECT_EQ("http://www.example.org", challenge->challenger.Serialize()); @@ -17323,8 +17323,8 @@ TEST_F(HttpNetworkTransactionTest, ClientAuthCertCache_Proxy_Fail) { StaticSocketDataProvider data1; session_deps_.socket_factory->AddSocketDataProvider(&data1); - base::Optional ssl_data2; - base::Optional data2; + absl::optional ssl_data2; + absl::optional data2; MockRead error_in_read[] = {MockRead(ASYNC, reject_error)}; if (reject_in_connect) { ssl_data2.emplace(ASYNC, reject_error); @@ -17346,8 +17346,8 @@ TEST_F(HttpNetworkTransactionTest, ClientAuthCertCache_Proxy_Fail) { // If the handshake returns ERR_SSL_PROTOCOL_ERROR, we attempt to // connect twice. - base::Optional ssl_data3; - base::Optional data3; + absl::optional ssl_data3; + absl::optional data3; if (reject_in_connect && reject_error == ERR_SSL_PROTOCOL_ERROR) { ssl_data3.emplace(ASYNC, reject_error); data3.emplace(); // There are no reads or writes. @@ -17553,7 +17553,7 @@ TEST_F(HttpNetworkTransactionTest, UseIPConnectionPooling) { // Preload mail.example.com into HostCache. rv = session_deps_.host_resolver->LoadIntoCache( HostPortPair("mail.example.com", 443), NetworkIsolationKey(), - base::nullopt); + absl::nullopt); EXPECT_THAT(rv, IsOk()); HttpRequestInfo request2; @@ -17726,7 +17726,7 @@ TEST_F(HttpNetworkTransactionTest, RetryWithoutConnectionPooling) { // Preload mail.example.org into HostCache. int rv = session_deps_.host_resolver->LoadIntoCache( HostPortPair("mail.example.com", 443), NetworkIsolationKey(), - base::nullopt); + absl::nullopt); EXPECT_THAT(rv, IsOk()); HttpRequestInfo request1; @@ -17852,7 +17852,7 @@ TEST_F(HttpNetworkTransactionTest, ReturnHTTP421OnRetry) { // Preload mail.example.org into HostCache. int rv = session_deps_.host_resolver->LoadIntoCache( HostPortPair("mail.example.com", 443), NetworkIsolationKey(), - base::nullopt); + absl::nullopt); EXPECT_THAT(rv, IsOk()); HttpRequestInfo request1; @@ -17967,7 +17967,7 @@ TEST_F(HttpNetworkTransactionTest, // Preload cache entries into HostCache. rv = session_deps_.host_resolver->LoadIntoCache( HostPortPair("mail.example.com", 443), NetworkIsolationKey(), - base::nullopt); + absl::nullopt); EXPECT_THAT(rv, IsOk()); HttpRequestInfo request2; @@ -21190,7 +21190,7 @@ TEST_F(HttpNetworkTransactionNetworkErrorLoggingTest, // Preload mail.example.org into HostCache. int rv = session_deps_.host_resolver->LoadIntoCache( HostPortPair("mail.example.com", 443), NetworkIsolationKey(), - base::nullopt); + absl::nullopt); EXPECT_THAT(rv, IsOk()); HttpRequestInfo request1; diff --git a/net/http/http_proxy_connect_job.cc b/net/http/http_proxy_connect_job.cc index 75b9f81192bfc6..2863e58a676a67 100644 --- a/net/http/http_proxy_connect_job.cc +++ b/net/http/http_proxy_connect_job.cc @@ -13,7 +13,6 @@ #include "base/metrics/histogram_macros.h" #include "base/no_destructor.h" #include "base/numerics/ranges.h" -#include "base/optional.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/threading/thread_task_runner_handle.h" @@ -38,6 +37,7 @@ #include "net/spdy/spdy_session_pool.h" #include "net/spdy/spdy_stream.h" #include "net/ssl/ssl_cert_request_info.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace net { @@ -286,7 +286,7 @@ base::TimeDelta HttpProxyConnectJob::AlternateNestedConnectionTimeout( if (!network_quality_estimator) return default_alternate_timeout; - base::Optional http_rtt_estimate = + absl::optional http_rtt_estimate = network_quality_estimator->GetHttpRTT(); if (!http_rtt_estimate) return default_alternate_timeout; @@ -797,7 +797,7 @@ void HttpProxyConnectJob::OnTimedOutInternal() { int HttpProxyConnectJob::HandleConnectResult(int result) { if (result == OK) - SetSocket(std::move(transport_socket_), base::nullopt /* dns_aliases */); + SetSocket(std::move(transport_socket_), absl::nullopt /* dns_aliases */); return result; } diff --git a/net/http/http_request_info.h b/net/http/http_request_info.h index 5c5b8415b839b3..d02d6bf45afb2f 100644 --- a/net/http/http_request_info.h +++ b/net/http/http_request_info.h @@ -7,7 +7,6 @@ #include -#include "base/optional.h" #include "net/base/idempotency.h" #include "net/base/net_export.h" #include "net/base/network_isolation_key.h" @@ -16,6 +15,7 @@ #include "net/http/http_request_headers.h" #include "net/socket/socket_tag.h" #include "net/traffic_annotation/network_traffic_annotation.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/origin.h" @@ -77,7 +77,7 @@ struct NET_EXPORT HttpRequestInfo { // TODO(https://crbug.com/1136054): Investigate migrating the one consumer of // this to NetworkIsolationKey::TopFrameSite(). That gives more consistent /// behavior, and may still provide useful metrics. - base::Optional possibly_top_frame_origin; + absl::optional possibly_top_frame_origin; // Idempotency of the request, which determines that if it is safe to enable // 0-RTT for the request. By default, 0-RTT is only enabled for safe diff --git a/net/http/http_response_info.h b/net/http/http_response_info.h index cfa4ae4f3c8031..3a450a8c76c993 100644 --- a/net/http/http_response_info.h +++ b/net/http/http_response_info.h @@ -7,7 +7,6 @@ #include -#include "base/optional.h" #include "base/time/time.h" #include "net/base/auth.h" #include "net/base/ip_endpoint.h" @@ -16,6 +15,7 @@ #include "net/dns/public/resolve_error_info.h" #include "net/http/http_vary_data.h" #include "net/ssl/ssl_info.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { class Pickle; @@ -223,7 +223,7 @@ class NET_EXPORT HttpResponseInfo { // If the response headers indicate a 401 or 407 failure, then this structure // will contain additional information about the authentication challenge. - base::Optional auth_challenge; + absl::optional auth_challenge; // The SSL client certificate request info. // TODO(wtc): does this really belong in HttpResponseInfo? I put it here diff --git a/net/http/http_server_properties.h b/net/http/http_server_properties.h index bab8f5967ad3bb..e98afc00fdabc0 100644 --- a/net/http/http_server_properties.h +++ b/net/http/http_server_properties.h @@ -19,7 +19,6 @@ #include "base/containers/mru_cache.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" @@ -35,6 +34,7 @@ #include "net/third_party/quiche/src/quic/core/quic_versions.h" #include "net/third_party/quiche/src/spdy/core/spdy_framer.h" // TODO(willchan): Reconsider this. #include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/scheme_host_port.h" namespace base { @@ -151,14 +151,14 @@ class NET_EXPORT HttpServerProperties // indicates unknown. The difference between false and not set only matters // when loading from disk, when an initialized false value will take // priority over a not set value. - base::Optional supports_spdy; + absl::optional supports_spdy; // True if the server has previously indicated it required HTTP/1.1. Unlike // other fields, not persisted to disk. - base::Optional requires_http11; + absl::optional requires_http11; - base::Optional alternative_services; - base::Optional server_network_stats; + absl::optional alternative_services; + absl::optional server_network_stats; }; struct NET_EXPORT ServerInfoMapKey { diff --git a/net/http/http_server_properties_manager.cc b/net/http/http_server_properties_manager.cc index 31998dba77266b..bc0a134f4c307e 100644 --- a/net/http/http_server_properties_manager.cc +++ b/net/http/http_server_properties_manager.cc @@ -9,7 +9,6 @@ #include "base/bind.h" #include "base/feature_list.h" #include "base/metrics/histogram_macros.h" -#include "base/optional.h" #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" #include "base/time/tick_clock.h" @@ -21,6 +20,7 @@ #include "net/base/privacy_mode.h" #include "net/http/http_server_properties.h" #include "net/third_party/quiche/src/quic/platform/api/quic_hostname_utils.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/scheme_host_port.h" @@ -66,7 +66,7 @@ const char kBrokenCountKey[] = "broken_count"; // services. Also checks if an alternative service for the same canonical suffix // has already been saved, and if so, returns an empty list. AlternativeServiceInfoVector GetAlternativeServiceToPersist( - const base::Optional& alternative_services, + const absl::optional& alternative_services, const HttpServerProperties::ServerInfoMapKey& server_info_key, base::Time now, const HttpServerPropertiesManager::GetCannonicalSuffix& @@ -237,7 +237,7 @@ void HttpServerPropertiesManager::ReadPrefs( net_log_.AddEvent(NetLogEventType::HTTP_SERVER_PROPERTIES_UPDATE_CACHE, [&] { return http_server_properties_dict->Clone(); }); - base::Optional maybe_version_number = + absl::optional maybe_version_number = http_server_properties_dict->FindIntKey(kVersionKey); if (!maybe_version_number.has_value() || *maybe_version_number != kVersionNumber) { @@ -364,7 +364,7 @@ void HttpServerPropertiesManager::AddToBrokenAlternativeServices( // Read broken-count and add an entry for |alt_service| into // |recently_broken_alternative_services|. if (broken_alt_svc_entry_dict.FindKey(kBrokenCountKey)) { - base::Optional broken_count = + absl::optional broken_count = broken_alt_svc_entry_dict.FindIntKey(kBrokenCountKey); if (!broken_count.has_value()) { DVLOG(1) << "Recently broken alternative service has malformed " @@ -488,7 +488,7 @@ bool HttpServerPropertiesManager::ParseAlternativeServiceDict( alternative_service->host = host; // Port is mandatory. - base::Optional maybe_port = dict.FindIntKey(kPortKey); + absl::optional maybe_port = dict.FindIntKey(kPortKey); if (!maybe_port.has_value() || !IsPortValid(maybe_port.value())) { DVLOG(1) << "Malformed alternative service port under: " << parsing_under; return false; @@ -630,7 +630,7 @@ void HttpServerPropertiesManager::ParseNetworkStats( if (!server_network_stats_dict) { return; } - base::Optional maybe_srtt = + absl::optional maybe_srtt = server_network_stats_dict->FindIntKey(kSrttKey); if (!maybe_srtt.has_value()) { DVLOG(1) << "Malformed ServerNetworkStats for server: " diff --git a/net/http/http_stream_factory_unittest.cc b/net/http/http_stream_factory_unittest.cc index 3f51333bea9045..4e7fceeb839144 100644 --- a/net/http/http_stream_factory_unittest.cc +++ b/net/http/http_stream_factory_unittest.cc @@ -15,7 +15,6 @@ #include "base/compiler_specific.h" #include "base/memory/ptr_util.h" #include "base/no_destructor.h" -#include "base/optional.h" #include "base/run_loop.h" #include "base/stl_util.h" #include "base/strings/strcat.h" @@ -84,6 +83,7 @@ #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" // This file can be included from net/http even though @@ -441,7 +441,7 @@ class CapturePreconnectsTransportSocketPool : public TransportClientSocketPool { int RequestSocket( const ClientSocketPool::GroupId& group_id, scoped_refptr socket_params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, RequestPriority priority, const SocketTag& socket_tag, ClientSocketPool::RespectLimits respect_limits, @@ -456,7 +456,7 @@ class CapturePreconnectsTransportSocketPool : public TransportClientSocketPool { void RequestSockets( const ClientSocketPool::GroupId& group_id, scoped_refptr socket_params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, int num_sockets, const NetLogWithSource& net_log) override { last_num_streams_ = num_sockets; @@ -1779,7 +1779,7 @@ TEST_F(HttpStreamFactoryTest, NewSpdySessionCloseIdleH2Sockets) { PrivacyMode::PRIVACY_MODE_DISABLED, NetworkIsolationKey(), SecureDnsPolicy::kAllow); int rv = connection->Init( - group_id, socket_params, base::nullopt /* proxy_annotation_tag */, + group_id, socket_params, absl::nullopt /* proxy_annotation_tag */, MEDIUM, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), session->GetSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL, diff --git a/net/http/structured_headers.cc b/net/http/structured_headers.cc index 4a23aaf505978f..da3ddd011afb3b 100644 --- a/net/http/structured_headers.cc +++ b/net/http/structured_headers.cc @@ -81,15 +81,15 @@ class StructuredHeaderParser { } // Parses a List of Lists ([SH09] 4.2.4). - base::Optional ReadListOfLists() { + absl::optional ReadListOfLists() { DCHECK_EQ(version_, kDraft09); ListOfLists result; while (true) { std::vector inner_list; while (true) { - base::Optional item(ReadBareItem()); + absl::optional item(ReadBareItem()); if (!item) - return base::nullopt; + return absl::nullopt; inner_list.push_back(std::move(*item)); SkipWhitespaces(); if (!ConsumeChar(';')) @@ -106,43 +106,43 @@ class StructuredHeaderParser { } // Parses a List ([SH15] 4.2.1). - base::Optional ReadList() { + absl::optional ReadList() { DCHECK_EQ(version_, kDraft15); List members; while (!input_.empty()) { - base::Optional member(ReadItemOrInnerList()); + absl::optional member(ReadItemOrInnerList()); if (!member) - return base::nullopt; + return absl::nullopt; members.push_back(std::move(*member)); SkipWhitespaces(); if (input_.empty()) break; if (!ConsumeChar(',')) - return base::nullopt; + return absl::nullopt; SkipWhitespaces(); if (input_.empty()) - return base::nullopt; + return absl::nullopt; } return members; } // Parses an Item ([SH15] 4.2.3). - base::Optional ReadItem() { - base::Optional item = ReadBareItem(); + absl::optional ReadItem() { + absl::optional item = ReadBareItem(); if (!item) - return base::nullopt; - base::Optional parameters = ReadParameters(); + return absl::nullopt; + absl::optional parameters = ReadParameters(); if (!parameters) - return base::nullopt; + return absl::nullopt; return ParameterizedItem(std::move(*item), std::move(*parameters)); } // Parses a bare Item ([SH15] 4.2.3.1, though this is also the algorithm for // parsing an Item from [SH09] 4.2.7). - base::Optional ReadBareItem() { + absl::optional ReadBareItem() { if (input_.empty()) { DVLOG(1) << "ReadBareItem: unexpected EOF"; - return base::nullopt; + return absl::nullopt; } switch (input_.front()) { case '"': @@ -154,7 +154,7 @@ class StructuredHeaderParser { case ':': if (version_ == kDraft15) return ReadByteSequence(); - return base::nullopt; + return absl::nullopt; case '?': return ReadBoolean(); default: @@ -162,28 +162,28 @@ class StructuredHeaderParser { return ReadNumber(); if (base::IsAsciiAlpha(input_.front())) return ReadToken(); - return base::nullopt; + return absl::nullopt; } } // Parses a Dictionary ([SH15] 4.2.2). - base::Optional ReadDictionary() { + absl::optional ReadDictionary() { DCHECK_EQ(version_, kDraft15); Dictionary members; while (!input_.empty()) { - base::Optional key(ReadKey()); + absl::optional key(ReadKey()); if (!key) - return base::nullopt; - base::Optional member; + return absl::nullopt; + absl::optional member; if (ConsumeChar('=')) { member = ReadItemOrInnerList(); if (!member) - return base::nullopt; + return absl::nullopt; } else { - base::Optional parameters; + absl::optional parameters; parameters = ReadParameters(); if (!parameters) - return base::nullopt; + return absl::nullopt; member = ParameterizedMember{Item(true), std::move(*parameters)}; } members[*key] = std::move(*member); @@ -191,23 +191,23 @@ class StructuredHeaderParser { if (input_.empty()) break; if (!ConsumeChar(',')) - return base::nullopt; + return absl::nullopt; SkipWhitespaces(); if (input_.empty()) - return base::nullopt; + return absl::nullopt; } return members; } // Parses a Parameterised List ([SH09] 4.2.5). - base::Optional ReadParameterisedList() { + absl::optional ReadParameterisedList() { DCHECK_EQ(version_, kDraft09); ParameterisedList items; while (true) { - base::Optional item = + absl::optional item = ReadParameterisedIdentifier(); if (!item) - return base::nullopt; + return absl::nullopt; items.push_back(std::move(*item)); SkipWhitespaces(); if (!ConsumeChar(',')) @@ -218,11 +218,11 @@ class StructuredHeaderParser { private: // Parses a Parameterised Identifier ([SH09] 4.2.6). - base::Optional ReadParameterisedIdentifier() { + absl::optional ReadParameterisedIdentifier() { DCHECK_EQ(version_, kDraft09); - base::Optional primary_identifier = ReadToken(); + absl::optional primary_identifier = ReadToken(); if (!primary_identifier) - return base::nullopt; + return absl::nullopt; ParameterisedIdentifier::Parameters parameters; @@ -230,21 +230,21 @@ class StructuredHeaderParser { while (ConsumeChar(';')) { SkipWhitespaces(); - base::Optional name = ReadKey(); + absl::optional name = ReadKey(); if (!name) - return base::nullopt; + return absl::nullopt; Item value; if (ConsumeChar('=')) { auto item = ReadBareItem(); if (!item) - return base::nullopt; + return absl::nullopt; value = std::move(*item); } if (!parameters.emplace(*name, value).second) { DVLOG(1) << "ReadParameterisedIdentifier: duplicated parameter: " << *name; - return base::nullopt; + return absl::nullopt; } SkipWhitespaces(); } @@ -253,7 +253,7 @@ class StructuredHeaderParser { } // Parses an Item or Inner List ([SH15] 4.2.1.1). - base::Optional ReadItemOrInnerList() { + absl::optional ReadItemOrInnerList() { DCHECK_EQ(version_, kDraft15); std::vector member; bool member_is_inner_list = (!input_.empty() && input_.front() == '('); @@ -262,30 +262,30 @@ class StructuredHeaderParser { } else { auto item = ReadItem(); if (!item) - return base::nullopt; + return absl::nullopt; return ParameterizedMember(std::move(item->item), std::move(item->params)); } } // Parses Parameters ([SH15] 4.2.3.2) - base::Optional ReadParameters() { + absl::optional ReadParameters() { Parameters parameters; base::flat_set keys; while (ConsumeChar(';')) { SkipWhitespaces(); - base::Optional name = ReadKey(); + absl::optional name = ReadKey(); if (!name) - return base::nullopt; + return absl::nullopt; bool is_duplicate_key = !keys.insert(*name).second; Item value{true}; if (ConsumeChar('=')) { auto item = ReadBareItem(); if (!item) - return base::nullopt; + return absl::nullopt; value = std::move(*item); } if (is_duplicate_key) { @@ -303,44 +303,44 @@ class StructuredHeaderParser { } // Parses an Inner List ([SH15] 4.2.1.2). - base::Optional ReadInnerList() { + absl::optional ReadInnerList() { DCHECK_EQ(version_, kDraft15); if (!ConsumeChar('(')) - return base::nullopt; + return absl::nullopt; std::vector inner_list; while (true) { SkipWhitespaces(); if (ConsumeChar(')')) { - base::Optional parameters; + absl::optional parameters; parameters = ReadParameters(); if (!parameters) - return base::nullopt; + return absl::nullopt; return ParameterizedMember(std::move(inner_list), true, std::move(*parameters)); } auto item = ReadItem(); if (!item) - return base::nullopt; + return absl::nullopt; inner_list.push_back(std::move(*item)); if (input_.empty() || (input_.front() != ' ' && input_.front() != ')')) - return base::nullopt; + return absl::nullopt; } NOTREACHED(); - return base::nullopt; + return absl::nullopt; } // Parses a Key ([SH09] 4.2.2, [SH15] 4.2.3.3). - base::Optional ReadKey() { + absl::optional ReadKey() { if (version_ == kDraft09) { if (input_.empty() || !base::IsAsciiLower(input_.front())) { LogParseError("ReadKey", "lcalpha"); - return base::nullopt; + return absl::nullopt; } } else { if (input_.empty() || (!base::IsAsciiLower(input_.front()) && input_.front() != '*')) { LogParseError("ReadKey", "lcalpha | *"); - return base::nullopt; + return absl::nullopt; } } const char* allowed_chars = @@ -354,11 +354,11 @@ class StructuredHeaderParser { } // Parses a Token ([SH09] 4.2.10, [SH15] 4.2.6). - base::Optional ReadToken() { + absl::optional ReadToken() { if (input_.empty() || !(base::IsAsciiAlpha(input_.front()) || input_.front() == '*')) { LogParseError("ReadToken", "ALPHA"); - return base::nullopt; + return absl::nullopt; } size_t len = input_.find_first_not_of(version_ == kDraft09 ? kTokenChars09 : kTokenChars15); @@ -370,7 +370,7 @@ class StructuredHeaderParser { } // Parses a Number ([SH09] 4.2.8, [SH15] 4.2.4). - base::Optional ReadNumber() { + absl::optional ReadNumber() { bool is_negative = ConsumeChar('-'); bool is_decimal = false; size_t decimal_position = 0; @@ -386,30 +386,30 @@ class StructuredHeaderParser { } if (i == 0) { LogParseError("ReadNumber", "DIGIT"); - return base::nullopt; + return absl::nullopt; } if (!is_decimal) { // [SH15] restricts the range of integers further. if (version_ == kDraft15 && i > 15) { LogParseError("ReadNumber", "integer too long"); - return base::nullopt; + return absl::nullopt; } } else { if (version_ != kDraft15 && i > 16) { LogParseError("ReadNumber", "float too long"); - return base::nullopt; + return absl::nullopt; } if (version_ == kDraft15 && decimal_position > 12) { LogParseError("ReadNumber", "decimal too long"); - return base::nullopt; + return absl::nullopt; } if (i - decimal_position > (version_ == kDraft15 ? 4 : 7)) { LogParseError("ReadNumber", "too many digits after decimal"); - return base::nullopt; + return absl::nullopt; } if (i == decimal_position) { LogParseError("ReadNumber", "no digits after decimal"); - return base::nullopt; + return absl::nullopt; } } std::string output_number_string(input_.substr(0, i)); @@ -420,50 +420,50 @@ class StructuredHeaderParser { // successful. double f; if (!base::StringToDouble(output_number_string, &f)) - return base::nullopt; + return absl::nullopt; return Item(is_negative ? -f : f); } else { // Convert to a 64-bit signed integer, and return if the conversion is // successful. int64_t n; if (!base::StringToInt64(output_number_string, &n)) - return base::nullopt; + return absl::nullopt; DCHECK(version_ != kDraft15 || (n <= kMaxInteger && n >= kMinInteger)); return Item(is_negative ? -n : n); } } // Parses a String ([SH09] 4.2.9, [SH15] 4.2.5). - base::Optional ReadString() { + absl::optional ReadString() { std::string s; if (!ConsumeChar('"')) { LogParseError("ReadString", "'\"'"); - return base::nullopt; + return absl::nullopt; } while (!ConsumeChar('"')) { size_t i = 0; for (; i < input_.size(); ++i) { if (!base::IsAsciiPrintable(input_[i])) { DVLOG(1) << "ReadString: non printable-ASCII character"; - return base::nullopt; + return absl::nullopt; } if (input_[i] == '"' || input_[i] == '\\') break; } if (i == input_.size()) { DVLOG(1) << "ReadString: missing closing '\"'"; - return base::nullopt; + return absl::nullopt; } s.append(std::string(input_.substr(0, i))); input_.remove_prefix(i); if (ConsumeChar('\\')) { if (input_.empty()) { DVLOG(1) << "ReadString: backslash at string end"; - return base::nullopt; + return absl::nullopt; } if (input_[0] != '"' && input_[0] != '\\') { DVLOG(1) << "ReadString: invalid escape"; - return base::nullopt; + return absl::nullopt; } s.push_back(input_.front()); input_.remove_prefix(1); @@ -473,16 +473,16 @@ class StructuredHeaderParser { } // Parses a Byte Sequence ([SH09] 4.2.11, [SH15] 4.2.7). - base::Optional ReadByteSequence() { + absl::optional ReadByteSequence() { char delimiter = (version_ == kDraft09 ? '*' : ':'); if (!ConsumeChar(delimiter)) { LogParseError("ReadByteSequence", "delimiter"); - return base::nullopt; + return absl::nullopt; } size_t len = input_.find(delimiter); if (len == base::StringPiece::npos) { DVLOG(1) << "ReadByteSequence: missing closing delimiter"; - return base::nullopt; + return absl::nullopt; } std::string base64(input_.substr(0, len)); // Append the necessary padding characters. @@ -491,7 +491,7 @@ class StructuredHeaderParser { std::string binary; if (!base::Base64Decode(base64, &binary)) { DVLOG(1) << "ReadByteSequence: failed to decode base64: " << base64; - return base::nullopt; + return absl::nullopt; } input_.remove_prefix(len); ConsumeChar(delimiter); @@ -501,10 +501,10 @@ class StructuredHeaderParser { // Parses a Boolean ([SH15] 4.2.8). // Note that this only parses ?0 and ?1 forms from SH version 10+, not the // previous ?F and ?T, which were not needed by any consumers of SH version 9. - base::Optional ReadBoolean() { + absl::optional ReadBoolean() { if (!ConsumeChar('?')) { LogParseError("ReadBoolean", "'?'"); - return base::nullopt; + return absl::nullopt; } if (ConsumeChar('1')) { return Item(true); @@ -512,7 +512,7 @@ class StructuredHeaderParser { if (ConsumeChar('0')) { return Item(false); } - return base::nullopt; + return absl::nullopt; } void SkipWhitespaces() { @@ -893,81 +893,81 @@ bool Dictionary::contains(base::StringPiece key) const { return false; } -base::Optional ParseItem(base::StringPiece str) { +absl::optional ParseItem(base::StringPiece str) { StructuredHeaderParser parser(str, StructuredHeaderParser::kDraft15); - base::Optional item = parser.ReadItem(); + absl::optional item = parser.ReadItem(); if (item && parser.FinishParsing()) return item; - return base::nullopt; + return absl::nullopt; } -base::Optional ParseBareItem(base::StringPiece str) { +absl::optional ParseBareItem(base::StringPiece str) { StructuredHeaderParser parser(str, StructuredHeaderParser::kDraft15); - base::Optional item = parser.ReadBareItem(); + absl::optional item = parser.ReadBareItem(); if (item && parser.FinishParsing()) return item; - return base::nullopt; + return absl::nullopt; } -base::Optional ParseParameterisedList( +absl::optional ParseParameterisedList( base::StringPiece str) { StructuredHeaderParser parser(str, StructuredHeaderParser::kDraft09); - base::Optional param_list = parser.ReadParameterisedList(); + absl::optional param_list = parser.ReadParameterisedList(); if (param_list && parser.FinishParsing()) return param_list; - return base::nullopt; + return absl::nullopt; } -base::Optional ParseListOfLists(base::StringPiece str) { +absl::optional ParseListOfLists(base::StringPiece str) { StructuredHeaderParser parser(str, StructuredHeaderParser::kDraft09); - base::Optional list_of_lists = parser.ReadListOfLists(); + absl::optional list_of_lists = parser.ReadListOfLists(); if (list_of_lists && parser.FinishParsing()) return list_of_lists; - return base::nullopt; + return absl::nullopt; } -base::Optional ParseList(base::StringPiece str) { +absl::optional ParseList(base::StringPiece str) { StructuredHeaderParser parser(str, StructuredHeaderParser::kDraft15); - base::Optional list = parser.ReadList(); + absl::optional list = parser.ReadList(); if (list && parser.FinishParsing()) return list; - return base::nullopt; + return absl::nullopt; } -base::Optional ParseDictionary(const base::StringPiece& str) { +absl::optional ParseDictionary(const base::StringPiece& str) { StructuredHeaderParser parser(str, StructuredHeaderParser::kDraft15); - base::Optional dictionary = parser.ReadDictionary(); + absl::optional dictionary = parser.ReadDictionary(); if (dictionary && parser.FinishParsing()) return dictionary; - return base::nullopt; + return absl::nullopt; } -base::Optional SerializeItem(const Item& value) { +absl::optional SerializeItem(const Item& value) { StructuredHeaderSerializer s; if (s.WriteItem(ParameterizedItem(value, {}))) return s.Output(); - return base::nullopt; + return absl::nullopt; } -base::Optional SerializeItem(const ParameterizedItem& value) { +absl::optional SerializeItem(const ParameterizedItem& value) { StructuredHeaderSerializer s; if (s.WriteItem(value)) return s.Output(); - return base::nullopt; + return absl::nullopt; } -base::Optional SerializeList(const List& value) { +absl::optional SerializeList(const List& value) { StructuredHeaderSerializer s; if (s.WriteList(value)) return s.Output(); - return base::nullopt; + return absl::nullopt; } -base::Optional SerializeDictionary(const Dictionary& value) { +absl::optional SerializeDictionary(const Dictionary& value) { StructuredHeaderSerializer s; if (s.WriteDictionary(value)) return s.Output(); - return base::nullopt; + return absl::nullopt; } } // namespace structured_headers diff --git a/net/http/structured_headers.h b/net/http/structured_headers.h index 20586ad4803780..5292f018e3bc27 100644 --- a/net/http/structured_headers.h +++ b/net/http/structured_headers.h @@ -11,9 +11,9 @@ #include #include -#include "base/optional.h" #include "base/strings/string_piece.h" #include "net/base/net_export.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { namespace structured_headers { @@ -249,12 +249,12 @@ using List = std::vector; // Returns the result of parsing the header value as an Item, if it can be // parsed as one, or nullopt if it cannot. Note that this uses the Draft 15 // parsing rules, and so applies tighter range limits to integers. -NET_EXPORT base::Optional ParseItem(base::StringPiece str); +NET_EXPORT absl::optional ParseItem(base::StringPiece str); // Returns the result of parsing the header value as an Item with no parameters, // or nullopt if it cannot. Note that this uses the Draft 15 parsing rules, and // so applies tighter range limits to integers. -NET_EXPORT base::Optional ParseBareItem(base::StringPiece str); +NET_EXPORT absl::optional ParseBareItem(base::StringPiece str); // Returns the result of parsing the header value as a Parameterised List, if it // can be parsed as one, or nullopt if it cannot. Note that parameter keys will @@ -262,7 +262,7 @@ NET_EXPORT base::Optional ParseBareItem(base::StringPiece str); // as well as parameter values, will be returned as Items. This method uses the // Draft 09 parsing rules for Items, so integers have the 64-bit int range. // Structured-Headers Draft 09 only. -NET_EXPORT base::Optional ParseParameterisedList( +NET_EXPORT absl::optional ParseParameterisedList( base::StringPiece str); // Returns the result of parsing the header value as a List of Lists, if it can @@ -270,25 +270,25 @@ NET_EXPORT base::Optional ParseParameterisedList( // as Items. This method uses the Draft 09 parsing rules for Items, so integers // have the 64-bit int range. // Structured-Headers Draft 09 only. -NET_EXPORT base::Optional ParseListOfLists(base::StringPiece str); +NET_EXPORT absl::optional ParseListOfLists(base::StringPiece str); // Returns the result of parsing the header value as a general List, if it can // be parsed as one, or nullopt if it cannot. // Structured-Headers Draft 15 only. -NET_EXPORT base::Optional ParseList(base::StringPiece str); +NET_EXPORT absl::optional ParseList(base::StringPiece str); // Returns the result of parsing the header value as a general Dictionary, if it // can be parsed as one, or nullopt if it cannot. Structured-Headers Draft 15 // only. -NET_EXPORT base::Optional ParseDictionary( +NET_EXPORT absl::optional ParseDictionary( const base::StringPiece& str); // Serialization is implemented for Structured-Headers Draft 15 only. -NET_EXPORT base::Optional SerializeItem(const Item& value); -NET_EXPORT base::Optional SerializeItem( +NET_EXPORT absl::optional SerializeItem(const Item& value); +NET_EXPORT absl::optional SerializeItem( const ParameterizedItem& value); -NET_EXPORT base::Optional SerializeList(const List& value); -NET_EXPORT base::Optional SerializeDictionary( +NET_EXPORT absl::optional SerializeList(const List& value); +NET_EXPORT absl::optional SerializeDictionary( const Dictionary& value); } // namespace structured_headers diff --git a/net/http/structured_headers_generated_unittest.cc b/net/http/structured_headers_generated_unittest.cc index 3cdcc17f151ed2..f2250839902de5 100644 --- a/net/http/structured_headers_generated_unittest.cc +++ b/net/http/structured_headers_generated_unittest.cc @@ -56,7 +56,7 @@ const struct ParameterizedItemTestCase { const char* name; const char* raw; size_t raw_len; - const base::Optional + const absl::optional expected; // nullopt if parse error is expected. const char* canonical; // nullptr if parse error is expected, or if canonical // format is identical to raw. @@ -73,10 +73,10 @@ const struct ParameterizedItemTestCase { 9, {{Item("hello", Item::kByteSequenceType), {}}}, ":aGVsbG8=:"}, - {"bad end delimiter", ":aGVsbG8=", 9, base::nullopt}, - {"extra whitespace", ":aGVsb G8=:", 11, base::nullopt}, - {"extra chars", ":aGVsbG!8=:", 11, base::nullopt}, - {"suffix chars", ":aGVsbG8=!:", 11, base::nullopt}, + {"bad end delimiter", ":aGVsbG8=", 9, absl::nullopt}, + {"extra whitespace", ":aGVsb G8=:", 11, absl::nullopt}, + {"extra chars", ":aGVsbG!8=:", 11, absl::nullopt}, + {"suffix chars", ":aGVsbG8=!:", 11, absl::nullopt}, {"non-zero pad bits", ":iZ==:", 6, @@ -86,19 +86,19 @@ const struct ParameterizedItemTestCase { ":/+Ah:", 6, {{Item("\377\340!", Item::kByteSequenceType), {}}}}, - {"base64url binary", ":_-Ah:", 6, base::nullopt}, + {"base64url binary", ":_-Ah:", 6, absl::nullopt}, // boolean.json {"basic true boolean", "?1", 2, {{Item(true), {}}}}, {"basic false boolean", "?0", 2, {{Item(false), {}}}}, - {"unknown boolean", "?Q", 2, base::nullopt}, - {"whitespace boolean", "? 1", 3, base::nullopt}, - {"negative zero boolean", "?-0", 3, base::nullopt}, - {"T boolean", "?T", 2, base::nullopt}, - {"F boolean", "?F", 2, base::nullopt}, - {"t boolean", "?t", 2, base::nullopt}, - {"f boolean", "?f", 2, base::nullopt}, - {"spelled-out True boolean", "?True", 5, base::nullopt}, - {"spelled-out False boolean", "?False", 6, base::nullopt}, + {"unknown boolean", "?Q", 2, absl::nullopt}, + {"whitespace boolean", "? 1", 3, absl::nullopt}, + {"negative zero boolean", "?-0", 3, absl::nullopt}, + {"T boolean", "?T", 2, absl::nullopt}, + {"F boolean", "?F", 2, absl::nullopt}, + {"t boolean", "?t", 2, absl::nullopt}, + {"f boolean", "?f", 2, absl::nullopt}, + {"spelled-out True boolean", "?True", 5, absl::nullopt}, + {"spelled-out False boolean", "?False", 6, absl::nullopt}, // examples.json {"Foo-Example", "2; foourl=\"https://foo.example.com/\"", @@ -128,7 +128,7 @@ const struct ParameterizedItemTestCase { {{Item("pretend this is binary content.", Item::kByteSequenceType), {}}}}, {"Example-BoolHdr", "?1", 2, {{Item(true), {}}}}, // item.json - {"empty item", "", 0, base::nullopt}, + {"empty item", "", 0, absl::nullopt}, {"leading space", " 1", 3, {{Integer(1), {}}}, "1"}, {"trailing space", "1 ", 3, {{Integer(1), {}}}, "1"}, {"leading and trailing space", " 1 ", 5, {{Integer(1), {}}}, "1"}, @@ -827,44 +827,44 @@ const struct ParameterizedItemTestCase { "999999999999.999", 16, {{Item(999999999999.999023), {}}}}, - {"too many digit 0 decimal", "000000000000000.0", 17, base::nullopt}, + {"too many digit 0 decimal", "000000000000000.0", 17, absl::nullopt}, {"too many fractional digits 0 decimal", "000000000000.0000", 17, - base::nullopt}, - {"too many digit 9 decimal", "999999999999999.9", 17, base::nullopt}, + absl::nullopt}, + {"too many digit 9 decimal", "999999999999999.9", 17, absl::nullopt}, {"too many fractional digits 9 decimal", "999999999999.9999", 17, - base::nullopt}, + absl::nullopt}, // number.json {"basic integer", "42", 2, {{Integer(42), {}}}}, {"zero integer", "0", 1, {{Integer(0), {}}}}, {"leading 0 zero", "00", 2, {{Integer(0), {}}}, "0"}, {"negative zero", "-0", 2, {{Integer(0), {}}}, "0"}, - {"double negative zero", "--0", 3, base::nullopt}, + {"double negative zero", "--0", 3, absl::nullopt}, {"negative integer", "-42", 3, {{Integer(-42), {}}}}, {"leading 0 integer", "042", 3, {{Integer(42), {}}}, "42"}, {"leading 0 negative integer", "-042", 4, {{Integer(-42), {}}}, "-42"}, {"leading 0 zero", "00", 2, {{Integer(0), {}}}, "0"}, - {"comma", "2,3", 3, base::nullopt}, - {"negative non-DIGIT first character", "-a23", 4, base::nullopt}, - {"sign out of place", "4-2", 3, base::nullopt}, - {"whitespace after sign", "- 42", 4, base::nullopt}, + {"comma", "2,3", 3, absl::nullopt}, + {"negative non-DIGIT first character", "-a23", 4, absl::nullopt}, + {"sign out of place", "4-2", 3, absl::nullopt}, + {"whitespace after sign", "- 42", 4, absl::nullopt}, {"long integer", "123456789012345", 15, {{Integer(123456789012345), {}}}}, {"long negative integer", "-123456789012345", 16, {{Integer(-123456789012345), {}}}}, - {"too long integer", "1234567890123456", 16, base::nullopt}, - {"negative too long integer", "-1234567890123456", 17, base::nullopt}, + {"too long integer", "1234567890123456", 16, absl::nullopt}, + {"negative too long integer", "-1234567890123456", 17, absl::nullopt}, {"simple decimal", "1.23", 4, {{Item(1.230000), {}}}}, {"negative decimal", "-1.23", 5, {{Item(-1.230000), {}}}}, - {"decimal, whitespace after decimal", "1. 23", 5, base::nullopt}, - {"decimal, whitespace before decimal", "1 .23", 5, base::nullopt}, - {"negative decimal, whitespace after sign", "- 1.23", 6, base::nullopt}, + {"decimal, whitespace after decimal", "1. 23", 5, absl::nullopt}, + {"decimal, whitespace before decimal", "1 .23", 5, absl::nullopt}, + {"negative decimal, whitespace after sign", "- 1.23", 6, absl::nullopt}, {"tricky precision decimal", "123456789012.1", 14, {{Item(123456789012.100006), {}}}}, - {"double decimal decimal", "1.5.4", 5, base::nullopt}, - {"adjacent double decimal decimal", "1..4", 4, base::nullopt}, + {"double decimal decimal", "1.5.4", 5, absl::nullopt}, + {"adjacent double decimal decimal", "1..4", 4, absl::nullopt}, {"decimal with three fractional digits", "1.123", 5, @@ -873,49 +873,49 @@ const struct ParameterizedItemTestCase { "-1.123", 6, {{Item(-1.123000), {}}}}, - {"decimal with four fractional digits", "1.1234", 6, base::nullopt}, + {"decimal with four fractional digits", "1.1234", 6, absl::nullopt}, {"negative decimal with four fractional digits", "-1.1234", 7, - base::nullopt}, + absl::nullopt}, {"decimal with thirteen integer digits", "1234567890123.0", 15, - base::nullopt}, + absl::nullopt}, {"negative decimal with thirteen integer digits", "-1234567890123.0", 16, - base::nullopt}, + absl::nullopt}, // string-generated.json - {"0x00 in string", "\" \000 \"", 5, base::nullopt}, - {"0x01 in string", "\" \001 \"", 5, base::nullopt}, - {"0x02 in string", "\" \002 \"", 5, base::nullopt}, - {"0x03 in string", "\" \003 \"", 5, base::nullopt}, - {"0x04 in string", "\" \004 \"", 5, base::nullopt}, - {"0x05 in string", "\" \005 \"", 5, base::nullopt}, - {"0x06 in string", "\" \006 \"", 5, base::nullopt}, - {"0x07 in string", "\" \a \"", 5, base::nullopt}, - {"0x08 in string", "\" \b \"", 5, base::nullopt}, - {"0x09 in string", "\" \t \"", 5, base::nullopt}, - {"0x0a in string", "\" \n \"", 5, base::nullopt}, - {"0x0b in string", "\" \v \"", 5, base::nullopt}, - {"0x0c in string", "\" \f \"", 5, base::nullopt}, - {"0x0d in string", "\" \r \"", 5, base::nullopt}, - {"0x0e in string", "\" \016 \"", 5, base::nullopt}, - {"0x0f in string", "\" \017 \"", 5, base::nullopt}, - {"0x10 in string", "\" \020 \"", 5, base::nullopt}, - {"0x11 in string", "\" \021 \"", 5, base::nullopt}, - {"0x12 in string", "\" \022 \"", 5, base::nullopt}, - {"0x13 in string", "\" \023 \"", 5, base::nullopt}, - {"0x14 in string", "\" \024 \"", 5, base::nullopt}, - {"0x15 in string", "\" \025 \"", 5, base::nullopt}, - {"0x16 in string", "\" \026 \"", 5, base::nullopt}, - {"0x17 in string", "\" \027 \"", 5, base::nullopt}, - {"0x18 in string", "\" \030 \"", 5, base::nullopt}, - {"0x19 in string", "\" \031 \"", 5, base::nullopt}, - {"0x1a in string", "\" \032 \"", 5, base::nullopt}, - {"0x1b in string", "\" \033 \"", 5, base::nullopt}, - {"0x1c in string", "\" \034 \"", 5, base::nullopt}, - {"0x1d in string", "\" \035 \"", 5, base::nullopt}, - {"0x1e in string", "\" \036 \"", 5, base::nullopt}, - {"0x1f in string", "\" \037 \"", 5, base::nullopt}, + {"0x00 in string", "\" \000 \"", 5, absl::nullopt}, + {"0x01 in string", "\" \001 \"", 5, absl::nullopt}, + {"0x02 in string", "\" \002 \"", 5, absl::nullopt}, + {"0x03 in string", "\" \003 \"", 5, absl::nullopt}, + {"0x04 in string", "\" \004 \"", 5, absl::nullopt}, + {"0x05 in string", "\" \005 \"", 5, absl::nullopt}, + {"0x06 in string", "\" \006 \"", 5, absl::nullopt}, + {"0x07 in string", "\" \a \"", 5, absl::nullopt}, + {"0x08 in string", "\" \b \"", 5, absl::nullopt}, + {"0x09 in string", "\" \t \"", 5, absl::nullopt}, + {"0x0a in string", "\" \n \"", 5, absl::nullopt}, + {"0x0b in string", "\" \v \"", 5, absl::nullopt}, + {"0x0c in string", "\" \f \"", 5, absl::nullopt}, + {"0x0d in string", "\" \r \"", 5, absl::nullopt}, + {"0x0e in string", "\" \016 \"", 5, absl::nullopt}, + {"0x0f in string", "\" \017 \"", 5, absl::nullopt}, + {"0x10 in string", "\" \020 \"", 5, absl::nullopt}, + {"0x11 in string", "\" \021 \"", 5, absl::nullopt}, + {"0x12 in string", "\" \022 \"", 5, absl::nullopt}, + {"0x13 in string", "\" \023 \"", 5, absl::nullopt}, + {"0x14 in string", "\" \024 \"", 5, absl::nullopt}, + {"0x15 in string", "\" \025 \"", 5, absl::nullopt}, + {"0x16 in string", "\" \026 \"", 5, absl::nullopt}, + {"0x17 in string", "\" \027 \"", 5, absl::nullopt}, + {"0x18 in string", "\" \030 \"", 5, absl::nullopt}, + {"0x19 in string", "\" \031 \"", 5, absl::nullopt}, + {"0x1a in string", "\" \032 \"", 5, absl::nullopt}, + {"0x1b in string", "\" \033 \"", 5, absl::nullopt}, + {"0x1c in string", "\" \034 \"", 5, absl::nullopt}, + {"0x1d in string", "\" \035 \"", 5, absl::nullopt}, + {"0x1e in string", "\" \036 \"", 5, absl::nullopt}, + {"0x1f in string", "\" \037 \"", 5, absl::nullopt}, {"0x20 in string", "\" \"", 5, {{Item(" "), {}}}}, {"0x21 in string", "\" ! \"", 5, {{Item(" ! "), {}}}}, - {"0x22 in string", "\" \" \"", 5, base::nullopt}, + {"0x22 in string", "\" \" \"", 5, absl::nullopt}, {"0x23 in string", "\" # \"", 5, {{Item(" # "), {}}}}, {"0x24 in string", "\" $ \"", 5, {{Item(" $ "), {}}}}, {"0x25 in string", "\" % \"", 5, {{Item(" % "), {}}}}, @@ -973,7 +973,7 @@ const struct ParameterizedItemTestCase { {"0x59 in string", "\" Y \"", 5, {{Item(" Y "), {}}}}, {"0x5a in string", "\" Z \"", 5, {{Item(" Z "), {}}}}, {"0x5b in string", "\" [ \"", 5, {{Item(" [ "), {}}}}, - {"0x5c in string", "\" \\ \"", 5, base::nullopt}, + {"0x5c in string", "\" \\ \"", 5, absl::nullopt}, {"0x5d in string", "\" ] \"", 5, {{Item(" ] "), {}}}}, {"0x5e in string", "\" ^ \"", 5, {{Item(" ^ "), {}}}}, {"0x5f in string", "\" _ \"", 5, {{Item(" _ "), {}}}}, @@ -1008,135 +1008,135 @@ const struct ParameterizedItemTestCase { {"0x7c in string", "\" | \"", 5, {{Item(" | "), {}}}}, {"0x7d in string", "\" } \"", 5, {{Item(" } "), {}}}}, {"0x7e in string", "\" ~ \"", 5, {{Item(" ~ "), {}}}}, - {"0x7f in string", "\" \177 \"", 5, base::nullopt}, - {"0x00 in string", "\"\\\000\"", 4, base::nullopt}, - {"0x01 in string", "\"\\\001\"", 4, base::nullopt}, - {"0x02 in string", "\"\\\002\"", 4, base::nullopt}, - {"0x03 in string", "\"\\\003\"", 4, base::nullopt}, - {"0x04 in string", "\"\\\004\"", 4, base::nullopt}, - {"0x05 in string", "\"\\\005\"", 4, base::nullopt}, - {"0x06 in string", "\"\\\006\"", 4, base::nullopt}, - {"0x07 in string", "\"\\\a\"", 4, base::nullopt}, - {"0x08 in string", "\"\\\b\"", 4, base::nullopt}, - {"0x09 in string", "\"\\\t\"", 4, base::nullopt}, - {"0x0a in string", "\"\\\n\"", 4, base::nullopt}, - {"0x0b in string", "\"\\\v\"", 4, base::nullopt}, - {"0x0c in string", "\"\\\f\"", 4, base::nullopt}, - {"0x0d in string", "\"\\\r\"", 4, base::nullopt}, - {"0x0e in string", "\"\\\016\"", 4, base::nullopt}, - {"0x0f in string", "\"\\\017\"", 4, base::nullopt}, - {"0x10 in string", "\"\\\020\"", 4, base::nullopt}, - {"0x11 in string", "\"\\\021\"", 4, base::nullopt}, - {"0x12 in string", "\"\\\022\"", 4, base::nullopt}, - {"0x13 in string", "\"\\\023\"", 4, base::nullopt}, - {"0x14 in string", "\"\\\024\"", 4, base::nullopt}, - {"0x15 in string", "\"\\\025\"", 4, base::nullopt}, - {"0x16 in string", "\"\\\026\"", 4, base::nullopt}, - {"0x17 in string", "\"\\\027\"", 4, base::nullopt}, - {"0x18 in string", "\"\\\030\"", 4, base::nullopt}, - {"0x19 in string", "\"\\\031\"", 4, base::nullopt}, - {"0x1a in string", "\"\\\032\"", 4, base::nullopt}, - {"0x1b in string", "\"\\\033\"", 4, base::nullopt}, - {"0x1c in string", "\"\\\034\"", 4, base::nullopt}, - {"0x1d in string", "\"\\\035\"", 4, base::nullopt}, - {"0x1e in string", "\"\\\036\"", 4, base::nullopt}, - {"0x1f in string", "\"\\\037\"", 4, base::nullopt}, - {"0x20 in string", "\"\\ \"", 4, base::nullopt}, - {"0x21 in string", "\"\\!\"", 4, base::nullopt}, + {"0x7f in string", "\" \177 \"", 5, absl::nullopt}, + {"0x00 in string", "\"\\\000\"", 4, absl::nullopt}, + {"0x01 in string", "\"\\\001\"", 4, absl::nullopt}, + {"0x02 in string", "\"\\\002\"", 4, absl::nullopt}, + {"0x03 in string", "\"\\\003\"", 4, absl::nullopt}, + {"0x04 in string", "\"\\\004\"", 4, absl::nullopt}, + {"0x05 in string", "\"\\\005\"", 4, absl::nullopt}, + {"0x06 in string", "\"\\\006\"", 4, absl::nullopt}, + {"0x07 in string", "\"\\\a\"", 4, absl::nullopt}, + {"0x08 in string", "\"\\\b\"", 4, absl::nullopt}, + {"0x09 in string", "\"\\\t\"", 4, absl::nullopt}, + {"0x0a in string", "\"\\\n\"", 4, absl::nullopt}, + {"0x0b in string", "\"\\\v\"", 4, absl::nullopt}, + {"0x0c in string", "\"\\\f\"", 4, absl::nullopt}, + {"0x0d in string", "\"\\\r\"", 4, absl::nullopt}, + {"0x0e in string", "\"\\\016\"", 4, absl::nullopt}, + {"0x0f in string", "\"\\\017\"", 4, absl::nullopt}, + {"0x10 in string", "\"\\\020\"", 4, absl::nullopt}, + {"0x11 in string", "\"\\\021\"", 4, absl::nullopt}, + {"0x12 in string", "\"\\\022\"", 4, absl::nullopt}, + {"0x13 in string", "\"\\\023\"", 4, absl::nullopt}, + {"0x14 in string", "\"\\\024\"", 4, absl::nullopt}, + {"0x15 in string", "\"\\\025\"", 4, absl::nullopt}, + {"0x16 in string", "\"\\\026\"", 4, absl::nullopt}, + {"0x17 in string", "\"\\\027\"", 4, absl::nullopt}, + {"0x18 in string", "\"\\\030\"", 4, absl::nullopt}, + {"0x19 in string", "\"\\\031\"", 4, absl::nullopt}, + {"0x1a in string", "\"\\\032\"", 4, absl::nullopt}, + {"0x1b in string", "\"\\\033\"", 4, absl::nullopt}, + {"0x1c in string", "\"\\\034\"", 4, absl::nullopt}, + {"0x1d in string", "\"\\\035\"", 4, absl::nullopt}, + {"0x1e in string", "\"\\\036\"", 4, absl::nullopt}, + {"0x1f in string", "\"\\\037\"", 4, absl::nullopt}, + {"0x20 in string", "\"\\ \"", 4, absl::nullopt}, + {"0x21 in string", "\"\\!\"", 4, absl::nullopt}, {"0x22 in string", "\"\\\"\"", 4, {{Item("\""), {}}}}, - {"0x23 in string", "\"\\#\"", 4, base::nullopt}, - {"0x24 in string", "\"\\$\"", 4, base::nullopt}, - {"0x25 in string", "\"\\%\"", 4, base::nullopt}, - {"0x26 in string", "\"\\&\"", 4, base::nullopt}, - {"0x27 in string", "\"\\'\"", 4, base::nullopt}, - {"0x28 in string", "\"\\(\"", 4, base::nullopt}, - {"0x29 in string", "\"\\)\"", 4, base::nullopt}, - {"0x2a in string", "\"\\*\"", 4, base::nullopt}, - {"0x2b in string", "\"\\+\"", 4, base::nullopt}, - {"0x2c in string", "\"\\,\"", 4, base::nullopt}, - {"0x2d in string", "\"\\-\"", 4, base::nullopt}, - {"0x2e in string", "\"\\.\"", 4, base::nullopt}, - {"0x2f in string", "\"\\/\"", 4, base::nullopt}, - {"0x30 in string", "\"\\0\"", 4, base::nullopt}, - {"0x31 in string", "\"\\1\"", 4, base::nullopt}, - {"0x32 in string", "\"\\2\"", 4, base::nullopt}, - {"0x33 in string", "\"\\3\"", 4, base::nullopt}, - {"0x34 in string", "\"\\4\"", 4, base::nullopt}, - {"0x35 in string", "\"\\5\"", 4, base::nullopt}, - {"0x36 in string", "\"\\6\"", 4, base::nullopt}, - {"0x37 in string", "\"\\7\"", 4, base::nullopt}, - {"0x38 in string", "\"\\8\"", 4, base::nullopt}, - {"0x39 in string", "\"\\9\"", 4, base::nullopt}, - {"0x3a in string", "\"\\:\"", 4, base::nullopt}, - {"0x3b in string", "\"\\;\"", 4, base::nullopt}, - {"0x3c in string", "\"\\<\"", 4, base::nullopt}, - {"0x3d in string", "\"\\=\"", 4, base::nullopt}, - {"0x3e in string", "\"\\>\"", 4, base::nullopt}, - {"0x3f in string", "\"\\?\"", 4, base::nullopt}, - {"0x40 in string", "\"\\@\"", 4, base::nullopt}, - {"0x41 in string", "\"\\A\"", 4, base::nullopt}, - {"0x42 in string", "\"\\B\"", 4, base::nullopt}, - {"0x43 in string", "\"\\C\"", 4, base::nullopt}, - {"0x44 in string", "\"\\D\"", 4, base::nullopt}, - {"0x45 in string", "\"\\E\"", 4, base::nullopt}, - {"0x46 in string", "\"\\F\"", 4, base::nullopt}, - {"0x47 in string", "\"\\G\"", 4, base::nullopt}, - {"0x48 in string", "\"\\H\"", 4, base::nullopt}, - {"0x49 in string", "\"\\I\"", 4, base::nullopt}, - {"0x4a in string", "\"\\J\"", 4, base::nullopt}, - {"0x4b in string", "\"\\K\"", 4, base::nullopt}, - {"0x4c in string", "\"\\L\"", 4, base::nullopt}, - {"0x4d in string", "\"\\M\"", 4, base::nullopt}, - {"0x4e in string", "\"\\N\"", 4, base::nullopt}, - {"0x4f in string", "\"\\O\"", 4, base::nullopt}, - {"0x50 in string", "\"\\P\"", 4, base::nullopt}, - {"0x51 in string", "\"\\Q\"", 4, base::nullopt}, - {"0x52 in string", "\"\\R\"", 4, base::nullopt}, - {"0x53 in string", "\"\\S\"", 4, base::nullopt}, - {"0x54 in string", "\"\\T\"", 4, base::nullopt}, - {"0x55 in string", "\"\\U\"", 4, base::nullopt}, - {"0x56 in string", "\"\\V\"", 4, base::nullopt}, - {"0x57 in string", "\"\\W\"", 4, base::nullopt}, - {"0x58 in string", "\"\\X\"", 4, base::nullopt}, - {"0x59 in string", "\"\\Y\"", 4, base::nullopt}, - {"0x5a in string", "\"\\Z\"", 4, base::nullopt}, - {"0x5b in string", "\"\\[\"", 4, base::nullopt}, + {"0x23 in string", "\"\\#\"", 4, absl::nullopt}, + {"0x24 in string", "\"\\$\"", 4, absl::nullopt}, + {"0x25 in string", "\"\\%\"", 4, absl::nullopt}, + {"0x26 in string", "\"\\&\"", 4, absl::nullopt}, + {"0x27 in string", "\"\\'\"", 4, absl::nullopt}, + {"0x28 in string", "\"\\(\"", 4, absl::nullopt}, + {"0x29 in string", "\"\\)\"", 4, absl::nullopt}, + {"0x2a in string", "\"\\*\"", 4, absl::nullopt}, + {"0x2b in string", "\"\\+\"", 4, absl::nullopt}, + {"0x2c in string", "\"\\,\"", 4, absl::nullopt}, + {"0x2d in string", "\"\\-\"", 4, absl::nullopt}, + {"0x2e in string", "\"\\.\"", 4, absl::nullopt}, + {"0x2f in string", "\"\\/\"", 4, absl::nullopt}, + {"0x30 in string", "\"\\0\"", 4, absl::nullopt}, + {"0x31 in string", "\"\\1\"", 4, absl::nullopt}, + {"0x32 in string", "\"\\2\"", 4, absl::nullopt}, + {"0x33 in string", "\"\\3\"", 4, absl::nullopt}, + {"0x34 in string", "\"\\4\"", 4, absl::nullopt}, + {"0x35 in string", "\"\\5\"", 4, absl::nullopt}, + {"0x36 in string", "\"\\6\"", 4, absl::nullopt}, + {"0x37 in string", "\"\\7\"", 4, absl::nullopt}, + {"0x38 in string", "\"\\8\"", 4, absl::nullopt}, + {"0x39 in string", "\"\\9\"", 4, absl::nullopt}, + {"0x3a in string", "\"\\:\"", 4, absl::nullopt}, + {"0x3b in string", "\"\\;\"", 4, absl::nullopt}, + {"0x3c in string", "\"\\<\"", 4, absl::nullopt}, + {"0x3d in string", "\"\\=\"", 4, absl::nullopt}, + {"0x3e in string", "\"\\>\"", 4, absl::nullopt}, + {"0x3f in string", "\"\\?\"", 4, absl::nullopt}, + {"0x40 in string", "\"\\@\"", 4, absl::nullopt}, + {"0x41 in string", "\"\\A\"", 4, absl::nullopt}, + {"0x42 in string", "\"\\B\"", 4, absl::nullopt}, + {"0x43 in string", "\"\\C\"", 4, absl::nullopt}, + {"0x44 in string", "\"\\D\"", 4, absl::nullopt}, + {"0x45 in string", "\"\\E\"", 4, absl::nullopt}, + {"0x46 in string", "\"\\F\"", 4, absl::nullopt}, + {"0x47 in string", "\"\\G\"", 4, absl::nullopt}, + {"0x48 in string", "\"\\H\"", 4, absl::nullopt}, + {"0x49 in string", "\"\\I\"", 4, absl::nullopt}, + {"0x4a in string", "\"\\J\"", 4, absl::nullopt}, + {"0x4b in string", "\"\\K\"", 4, absl::nullopt}, + {"0x4c in string", "\"\\L\"", 4, absl::nullopt}, + {"0x4d in string", "\"\\M\"", 4, absl::nullopt}, + {"0x4e in string", "\"\\N\"", 4, absl::nullopt}, + {"0x4f in string", "\"\\O\"", 4, absl::nullopt}, + {"0x50 in string", "\"\\P\"", 4, absl::nullopt}, + {"0x51 in string", "\"\\Q\"", 4, absl::nullopt}, + {"0x52 in string", "\"\\R\"", 4, absl::nullopt}, + {"0x53 in string", "\"\\S\"", 4, absl::nullopt}, + {"0x54 in string", "\"\\T\"", 4, absl::nullopt}, + {"0x55 in string", "\"\\U\"", 4, absl::nullopt}, + {"0x56 in string", "\"\\V\"", 4, absl::nullopt}, + {"0x57 in string", "\"\\W\"", 4, absl::nullopt}, + {"0x58 in string", "\"\\X\"", 4, absl::nullopt}, + {"0x59 in string", "\"\\Y\"", 4, absl::nullopt}, + {"0x5a in string", "\"\\Z\"", 4, absl::nullopt}, + {"0x5b in string", "\"\\[\"", 4, absl::nullopt}, {"0x5c in string", "\"\\\\\"", 4, {{Item("\\"), {}}}}, - {"0x5d in string", "\"\\]\"", 4, base::nullopt}, - {"0x5e in string", "\"\\^\"", 4, base::nullopt}, - {"0x5f in string", "\"\\_\"", 4, base::nullopt}, - {"0x60 in string", "\"\\`\"", 4, base::nullopt}, - {"0x61 in string", "\"\\a\"", 4, base::nullopt}, - {"0x62 in string", "\"\\b\"", 4, base::nullopt}, - {"0x63 in string", "\"\\c\"", 4, base::nullopt}, - {"0x64 in string", "\"\\d\"", 4, base::nullopt}, - {"0x65 in string", "\"\\e\"", 4, base::nullopt}, - {"0x66 in string", "\"\\f\"", 4, base::nullopt}, - {"0x67 in string", "\"\\g\"", 4, base::nullopt}, - {"0x68 in string", "\"\\h\"", 4, base::nullopt}, - {"0x69 in string", "\"\\i\"", 4, base::nullopt}, - {"0x6a in string", "\"\\j\"", 4, base::nullopt}, - {"0x6b in string", "\"\\k\"", 4, base::nullopt}, - {"0x6c in string", "\"\\l\"", 4, base::nullopt}, - {"0x6d in string", "\"\\m\"", 4, base::nullopt}, - {"0x6e in string", "\"\\n\"", 4, base::nullopt}, - {"0x6f in string", "\"\\o\"", 4, base::nullopt}, - {"0x70 in string", "\"\\p\"", 4, base::nullopt}, - {"0x71 in string", "\"\\q\"", 4, base::nullopt}, - {"0x72 in string", "\"\\r\"", 4, base::nullopt}, - {"0x73 in string", "\"\\s\"", 4, base::nullopt}, - {"0x74 in string", "\"\\t\"", 4, base::nullopt}, - {"0x75 in string", "\"\\u\"", 4, base::nullopt}, - {"0x76 in string", "\"\\v\"", 4, base::nullopt}, - {"0x77 in string", "\"\\w\"", 4, base::nullopt}, - {"0x78 in string", "\"\\x\"", 4, base::nullopt}, - {"0x79 in string", "\"\\y\"", 4, base::nullopt}, - {"0x7a in string", "\"\\z\"", 4, base::nullopt}, - {"0x7b in string", "\"\\{\"", 4, base::nullopt}, - {"0x7c in string", "\"\\|\"", 4, base::nullopt}, - {"0x7d in string", "\"\\}\"", 4, base::nullopt}, - {"0x7e in string", "\"\\~\"", 4, base::nullopt}, - {"0x7f in string", "\"\\\177\"", 4, base::nullopt}, + {"0x5d in string", "\"\\]\"", 4, absl::nullopt}, + {"0x5e in string", "\"\\^\"", 4, absl::nullopt}, + {"0x5f in string", "\"\\_\"", 4, absl::nullopt}, + {"0x60 in string", "\"\\`\"", 4, absl::nullopt}, + {"0x61 in string", "\"\\a\"", 4, absl::nullopt}, + {"0x62 in string", "\"\\b\"", 4, absl::nullopt}, + {"0x63 in string", "\"\\c\"", 4, absl::nullopt}, + {"0x64 in string", "\"\\d\"", 4, absl::nullopt}, + {"0x65 in string", "\"\\e\"", 4, absl::nullopt}, + {"0x66 in string", "\"\\f\"", 4, absl::nullopt}, + {"0x67 in string", "\"\\g\"", 4, absl::nullopt}, + {"0x68 in string", "\"\\h\"", 4, absl::nullopt}, + {"0x69 in string", "\"\\i\"", 4, absl::nullopt}, + {"0x6a in string", "\"\\j\"", 4, absl::nullopt}, + {"0x6b in string", "\"\\k\"", 4, absl::nullopt}, + {"0x6c in string", "\"\\l\"", 4, absl::nullopt}, + {"0x6d in string", "\"\\m\"", 4, absl::nullopt}, + {"0x6e in string", "\"\\n\"", 4, absl::nullopt}, + {"0x6f in string", "\"\\o\"", 4, absl::nullopt}, + {"0x70 in string", "\"\\p\"", 4, absl::nullopt}, + {"0x71 in string", "\"\\q\"", 4, absl::nullopt}, + {"0x72 in string", "\"\\r\"", 4, absl::nullopt}, + {"0x73 in string", "\"\\s\"", 4, absl::nullopt}, + {"0x74 in string", "\"\\t\"", 4, absl::nullopt}, + {"0x75 in string", "\"\\u\"", 4, absl::nullopt}, + {"0x76 in string", "\"\\v\"", 4, absl::nullopt}, + {"0x77 in string", "\"\\w\"", 4, absl::nullopt}, + {"0x78 in string", "\"\\x\"", 4, absl::nullopt}, + {"0x79 in string", "\"\\y\"", 4, absl::nullopt}, + {"0x7a in string", "\"\\z\"", 4, absl::nullopt}, + {"0x7b in string", "\"\\{\"", 4, absl::nullopt}, + {"0x7c in string", "\"\\|\"", 4, absl::nullopt}, + {"0x7d in string", "\"\\}\"", 4, absl::nullopt}, + {"0x7e in string", "\"\\~\"", 4, absl::nullopt}, + {"0x7f in string", "\"\\\177\"", 4, absl::nullopt}, // string.json {"basic string", "\"foo bar\"", 9, {{Item("foo bar"), {}}}}, {"empty string", "\"\"", 2, {{Item(""), {}}}}, @@ -1153,64 +1153,64 @@ const struct ParameterizedItemTestCase { "foo "), {}}}}, {"whitespace string", "\" \"", 5, {{Item(" "), {}}}}, - {"non-ascii string", "\"f\374\374\"", 5, base::nullopt}, - {"tab in string", "\"\\t\"", 4, base::nullopt}, - {"newline in string", "\" \\n \"", 6, base::nullopt}, - {"single quoted string", "'foo'", 5, base::nullopt}, - {"unbalanced string", "\"foo", 4, base::nullopt}, + {"non-ascii string", "\"f\374\374\"", 5, absl::nullopt}, + {"tab in string", "\"\\t\"", 4, absl::nullopt}, + {"newline in string", "\" \\n \"", 6, absl::nullopt}, + {"single quoted string", "'foo'", 5, absl::nullopt}, + {"unbalanced string", "\"foo", 4, absl::nullopt}, {"string quoting", "\"foo \\\"bar\\\" \\\\ baz\"", 20, {{Item("foo \"bar\" \\ baz"), {}}}}, - {"bad string quoting", "\"foo \\,\"", 8, base::nullopt}, - {"ending string quote", "\"foo \\\"", 7, base::nullopt}, - {"abruptly ending string quote", "\"foo \\", 6, base::nullopt}, + {"bad string quoting", "\"foo \\,\"", 8, absl::nullopt}, + {"ending string quote", "\"foo \\\"", 7, absl::nullopt}, + {"abruptly ending string quote", "\"foo \\", 6, absl::nullopt}, // token-generated.json - {"0x00 in token", "a\000a", 3, base::nullopt}, - {"0x01 in token", "a\001a", 3, base::nullopt}, - {"0x02 in token", "a\002a", 3, base::nullopt}, - {"0x03 in token", "a\003a", 3, base::nullopt}, - {"0x04 in token", "a\004a", 3, base::nullopt}, - {"0x05 in token", "a\005a", 3, base::nullopt}, - {"0x06 in token", "a\006a", 3, base::nullopt}, - {"0x07 in token", "a\aa", 3, base::nullopt}, - {"0x08 in token", "a\ba", 3, base::nullopt}, - {"0x09 in token", "a\ta", 3, base::nullopt}, - {"0x0a in token", "a\na", 3, base::nullopt}, - {"0x0b in token", "a\va", 3, base::nullopt}, - {"0x0c in token", "a\fa", 3, base::nullopt}, - {"0x0d in token", "a\ra", 3, base::nullopt}, - {"0x0e in token", "a\016a", 3, base::nullopt}, - {"0x0f in token", "a\017a", 3, base::nullopt}, - {"0x10 in token", "a\020a", 3, base::nullopt}, - {"0x11 in token", "a\021a", 3, base::nullopt}, - {"0x12 in token", "a\022a", 3, base::nullopt}, - {"0x13 in token", "a\023a", 3, base::nullopt}, - {"0x14 in token", "a\024a", 3, base::nullopt}, - {"0x15 in token", "a\025a", 3, base::nullopt}, - {"0x16 in token", "a\026a", 3, base::nullopt}, - {"0x17 in token", "a\027a", 3, base::nullopt}, - {"0x18 in token", "a\030a", 3, base::nullopt}, - {"0x19 in token", "a\031a", 3, base::nullopt}, - {"0x1a in token", "a\032a", 3, base::nullopt}, - {"0x1b in token", "a\033a", 3, base::nullopt}, - {"0x1c in token", "a\034a", 3, base::nullopt}, - {"0x1d in token", "a\035a", 3, base::nullopt}, - {"0x1e in token", "a\036a", 3, base::nullopt}, - {"0x1f in token", "a\037a", 3, base::nullopt}, - {"0x20 in token", "a a", 3, base::nullopt}, + {"0x00 in token", "a\000a", 3, absl::nullopt}, + {"0x01 in token", "a\001a", 3, absl::nullopt}, + {"0x02 in token", "a\002a", 3, absl::nullopt}, + {"0x03 in token", "a\003a", 3, absl::nullopt}, + {"0x04 in token", "a\004a", 3, absl::nullopt}, + {"0x05 in token", "a\005a", 3, absl::nullopt}, + {"0x06 in token", "a\006a", 3, absl::nullopt}, + {"0x07 in token", "a\aa", 3, absl::nullopt}, + {"0x08 in token", "a\ba", 3, absl::nullopt}, + {"0x09 in token", "a\ta", 3, absl::nullopt}, + {"0x0a in token", "a\na", 3, absl::nullopt}, + {"0x0b in token", "a\va", 3, absl::nullopt}, + {"0x0c in token", "a\fa", 3, absl::nullopt}, + {"0x0d in token", "a\ra", 3, absl::nullopt}, + {"0x0e in token", "a\016a", 3, absl::nullopt}, + {"0x0f in token", "a\017a", 3, absl::nullopt}, + {"0x10 in token", "a\020a", 3, absl::nullopt}, + {"0x11 in token", "a\021a", 3, absl::nullopt}, + {"0x12 in token", "a\022a", 3, absl::nullopt}, + {"0x13 in token", "a\023a", 3, absl::nullopt}, + {"0x14 in token", "a\024a", 3, absl::nullopt}, + {"0x15 in token", "a\025a", 3, absl::nullopt}, + {"0x16 in token", "a\026a", 3, absl::nullopt}, + {"0x17 in token", "a\027a", 3, absl::nullopt}, + {"0x18 in token", "a\030a", 3, absl::nullopt}, + {"0x19 in token", "a\031a", 3, absl::nullopt}, + {"0x1a in token", "a\032a", 3, absl::nullopt}, + {"0x1b in token", "a\033a", 3, absl::nullopt}, + {"0x1c in token", "a\034a", 3, absl::nullopt}, + {"0x1d in token", "a\035a", 3, absl::nullopt}, + {"0x1e in token", "a\036a", 3, absl::nullopt}, + {"0x1f in token", "a\037a", 3, absl::nullopt}, + {"0x20 in token", "a a", 3, absl::nullopt}, {"0x21 in token", "a!a", 3, {{Item("a!a", Item::kTokenType), {}}}}, - {"0x22 in token", "a\"a", 3, base::nullopt}, + {"0x22 in token", "a\"a", 3, absl::nullopt}, {"0x23 in token", "a#a", 3, {{Item("a#a", Item::kTokenType), {}}}}, {"0x24 in token", "a$a", 3, {{Item("a$a", Item::kTokenType), {}}}}, {"0x25 in token", "a%a", 3, {{Item("a%a", Item::kTokenType), {}}}}, {"0x26 in token", "a&a", 3, {{Item("a&a", Item::kTokenType), {}}}}, {"0x27 in token", "a'a", 3, {{Item("a'a", Item::kTokenType), {}}}}, - {"0x28 in token", "a(a", 3, base::nullopt}, - {"0x29 in token", "a)a", 3, base::nullopt}, + {"0x28 in token", "a(a", 3, absl::nullopt}, + {"0x29 in token", "a)a", 3, absl::nullopt}, {"0x2a in token", "a*a", 3, {{Item("a*a", Item::kTokenType), {}}}}, {"0x2b in token", "a+a", 3, {{Item("a+a", Item::kTokenType), {}}}}, - {"0x2c in token", "a,a", 3, base::nullopt}, + {"0x2c in token", "a,a", 3, absl::nullopt}, {"0x2d in token", "a-a", 3, {{Item("a-a", Item::kTokenType), {}}}}, {"0x2e in token", "a.a", 3, {{Item("a.a", Item::kTokenType), {}}}}, {"0x2f in token", "a/a", 3, {{Item("a/a", Item::kTokenType), {}}}}, @@ -1229,11 +1229,11 @@ const struct ParameterizedItemTestCase { "a;a", 3, {{Item("a", Item::kTokenType), {BooleanParam("a", true)}}}}, - {"0x3c in token", "aa", 3, base::nullopt}, - {"0x3f in token", "a?a", 3, base::nullopt}, - {"0x40 in token", "a@a", 3, base::nullopt}, + {"0x3c in token", "aa", 3, absl::nullopt}, + {"0x3f in token", "a?a", 3, absl::nullopt}, + {"0x40 in token", "a@a", 3, absl::nullopt}, {"0x41 in token", "aAa", 3, {{Item("aAa", Item::kTokenType), {}}}}, {"0x42 in token", "aBa", 3, {{Item("aBa", Item::kTokenType), {}}}}, {"0x43 in token", "aCa", 3, {{Item("aCa", Item::kTokenType), {}}}}, @@ -1260,9 +1260,9 @@ const struct ParameterizedItemTestCase { {"0x58 in token", "aXa", 3, {{Item("aXa", Item::kTokenType), {}}}}, {"0x59 in token", "aYa", 3, {{Item("aYa", Item::kTokenType), {}}}}, {"0x5a in token", "aZa", 3, {{Item("aZa", Item::kTokenType), {}}}}, - {"0x5b in token", "a[a", 3, base::nullopt}, - {"0x5c in token", "a\\a", 3, base::nullopt}, - {"0x5d in token", "a]a", 3, base::nullopt}, + {"0x5b in token", "a[a", 3, absl::nullopt}, + {"0x5c in token", "a\\a", 3, absl::nullopt}, + {"0x5d in token", "a]a", 3, absl::nullopt}, {"0x5e in token", "a^a", 3, {{Item("a^a", Item::kTokenType), {}}}}, {"0x5f in token", "a_a", 3, {{Item("a_a", Item::kTokenType), {}}}}, {"0x60 in token", "a`a", 3, {{Item("a`a", Item::kTokenType), {}}}}, @@ -1292,80 +1292,80 @@ const struct ParameterizedItemTestCase { {"0x78 in token", "axa", 3, {{Item("axa", Item::kTokenType), {}}}}, {"0x79 in token", "aya", 3, {{Item("aya", Item::kTokenType), {}}}}, {"0x7a in token", "aza", 3, {{Item("aza", Item::kTokenType), {}}}}, - {"0x7b in token", "a{a", 3, base::nullopt}, + {"0x7b in token", "a{a", 3, absl::nullopt}, {"0x7c in token", "a|a", 3, {{Item("a|a", Item::kTokenType), {}}}}, - {"0x7d in token", "a}a", 3, base::nullopt}, + {"0x7d in token", "a}a", 3, absl::nullopt}, {"0x7e in token", "a~a", 3, {{Item("a~a", Item::kTokenType), {}}}}, - {"0x7f in token", "a\177a", 3, base::nullopt}, - {"0x00 starting an token", "\000a", 2, base::nullopt}, - {"0x01 starting an token", "\001a", 2, base::nullopt}, - {"0x02 starting an token", "\002a", 2, base::nullopt}, - {"0x03 starting an token", "\003a", 2, base::nullopt}, - {"0x04 starting an token", "\004a", 2, base::nullopt}, - {"0x05 starting an token", "\005a", 2, base::nullopt}, - {"0x06 starting an token", "\006a", 2, base::nullopt}, - {"0x07 starting an token", "\aa", 2, base::nullopt}, - {"0x08 starting an token", "\ba", 2, base::nullopt}, - {"0x09 starting an token", "\ta", 2, base::nullopt}, - {"0x0a starting an token", "\na", 2, base::nullopt}, - {"0x0b starting an token", "\va", 2, base::nullopt}, - {"0x0c starting an token", "\fa", 2, base::nullopt}, - {"0x0d starting an token", "\ra", 2, base::nullopt}, - {"0x0e starting an token", "\016a", 2, base::nullopt}, - {"0x0f starting an token", "\017a", 2, base::nullopt}, - {"0x10 starting an token", "\020a", 2, base::nullopt}, - {"0x11 starting an token", "\021a", 2, base::nullopt}, - {"0x12 starting an token", "\022a", 2, base::nullopt}, - {"0x13 starting an token", "\023a", 2, base::nullopt}, - {"0x14 starting an token", "\024a", 2, base::nullopt}, - {"0x15 starting an token", "\025a", 2, base::nullopt}, - {"0x16 starting an token", "\026a", 2, base::nullopt}, - {"0x17 starting an token", "\027a", 2, base::nullopt}, - {"0x18 starting an token", "\030a", 2, base::nullopt}, - {"0x19 starting an token", "\031a", 2, base::nullopt}, - {"0x1a starting an token", "\032a", 2, base::nullopt}, - {"0x1b starting an token", "\033a", 2, base::nullopt}, - {"0x1c starting an token", "\034a", 2, base::nullopt}, - {"0x1d starting an token", "\035a", 2, base::nullopt}, - {"0x1e starting an token", "\036a", 2, base::nullopt}, - {"0x1f starting an token", "\037a", 2, base::nullopt}, + {"0x7f in token", "a\177a", 3, absl::nullopt}, + {"0x00 starting an token", "\000a", 2, absl::nullopt}, + {"0x01 starting an token", "\001a", 2, absl::nullopt}, + {"0x02 starting an token", "\002a", 2, absl::nullopt}, + {"0x03 starting an token", "\003a", 2, absl::nullopt}, + {"0x04 starting an token", "\004a", 2, absl::nullopt}, + {"0x05 starting an token", "\005a", 2, absl::nullopt}, + {"0x06 starting an token", "\006a", 2, absl::nullopt}, + {"0x07 starting an token", "\aa", 2, absl::nullopt}, + {"0x08 starting an token", "\ba", 2, absl::nullopt}, + {"0x09 starting an token", "\ta", 2, absl::nullopt}, + {"0x0a starting an token", "\na", 2, absl::nullopt}, + {"0x0b starting an token", "\va", 2, absl::nullopt}, + {"0x0c starting an token", "\fa", 2, absl::nullopt}, + {"0x0d starting an token", "\ra", 2, absl::nullopt}, + {"0x0e starting an token", "\016a", 2, absl::nullopt}, + {"0x0f starting an token", "\017a", 2, absl::nullopt}, + {"0x10 starting an token", "\020a", 2, absl::nullopt}, + {"0x11 starting an token", "\021a", 2, absl::nullopt}, + {"0x12 starting an token", "\022a", 2, absl::nullopt}, + {"0x13 starting an token", "\023a", 2, absl::nullopt}, + {"0x14 starting an token", "\024a", 2, absl::nullopt}, + {"0x15 starting an token", "\025a", 2, absl::nullopt}, + {"0x16 starting an token", "\026a", 2, absl::nullopt}, + {"0x17 starting an token", "\027a", 2, absl::nullopt}, + {"0x18 starting an token", "\030a", 2, absl::nullopt}, + {"0x19 starting an token", "\031a", 2, absl::nullopt}, + {"0x1a starting an token", "\032a", 2, absl::nullopt}, + {"0x1b starting an token", "\033a", 2, absl::nullopt}, + {"0x1c starting an token", "\034a", 2, absl::nullopt}, + {"0x1d starting an token", "\035a", 2, absl::nullopt}, + {"0x1e starting an token", "\036a", 2, absl::nullopt}, + {"0x1f starting an token", "\037a", 2, absl::nullopt}, {"0x20 starting an token", " a", 2, {{Item("a", Item::kTokenType), {}}}, "a"}, - {"0x21 starting an token", "!a", 2, base::nullopt}, - {"0x22 starting an token", "\"a", 2, base::nullopt}, - {"0x23 starting an token", "#a", 2, base::nullopt}, - {"0x24 starting an token", "$a", 2, base::nullopt}, - {"0x25 starting an token", "%a", 2, base::nullopt}, - {"0x26 starting an token", "&a", 2, base::nullopt}, - {"0x27 starting an token", "'a", 2, base::nullopt}, - {"0x28 starting an token", "(a", 2, base::nullopt}, - {"0x29 starting an token", ")a", 2, base::nullopt}, + {"0x21 starting an token", "!a", 2, absl::nullopt}, + {"0x22 starting an token", "\"a", 2, absl::nullopt}, + {"0x23 starting an token", "#a", 2, absl::nullopt}, + {"0x24 starting an token", "$a", 2, absl::nullopt}, + {"0x25 starting an token", "%a", 2, absl::nullopt}, + {"0x26 starting an token", "&a", 2, absl::nullopt}, + {"0x27 starting an token", "'a", 2, absl::nullopt}, + {"0x28 starting an token", "(a", 2, absl::nullopt}, + {"0x29 starting an token", ")a", 2, absl::nullopt}, {"0x2a starting an token", "*a", 2, {{Item("*a", Item::kTokenType), {}}}}, - {"0x2b starting an token", "+a", 2, base::nullopt}, - {"0x2c starting an token", ",a", 2, base::nullopt}, - {"0x2d starting an token", "-a", 2, base::nullopt}, - {"0x2e starting an token", ".a", 2, base::nullopt}, - {"0x2f starting an token", "/a", 2, base::nullopt}, - {"0x30 starting an token", "0a", 2, base::nullopt}, - {"0x31 starting an token", "1a", 2, base::nullopt}, - {"0x32 starting an token", "2a", 2, base::nullopt}, - {"0x33 starting an token", "3a", 2, base::nullopt}, - {"0x34 starting an token", "4a", 2, base::nullopt}, - {"0x35 starting an token", "5a", 2, base::nullopt}, - {"0x36 starting an token", "6a", 2, base::nullopt}, - {"0x37 starting an token", "7a", 2, base::nullopt}, - {"0x38 starting an token", "8a", 2, base::nullopt}, - {"0x39 starting an token", "9a", 2, base::nullopt}, - {"0x3a starting an token", ":a", 2, base::nullopt}, - {"0x3b starting an token", ";a", 2, base::nullopt}, - {"0x3c starting an token", "a", 2, base::nullopt}, - {"0x3f starting an token", "?a", 2, base::nullopt}, - {"0x40 starting an token", "@a", 2, base::nullopt}, + {"0x2b starting an token", "+a", 2, absl::nullopt}, + {"0x2c starting an token", ",a", 2, absl::nullopt}, + {"0x2d starting an token", "-a", 2, absl::nullopt}, + {"0x2e starting an token", ".a", 2, absl::nullopt}, + {"0x2f starting an token", "/a", 2, absl::nullopt}, + {"0x30 starting an token", "0a", 2, absl::nullopt}, + {"0x31 starting an token", "1a", 2, absl::nullopt}, + {"0x32 starting an token", "2a", 2, absl::nullopt}, + {"0x33 starting an token", "3a", 2, absl::nullopt}, + {"0x34 starting an token", "4a", 2, absl::nullopt}, + {"0x35 starting an token", "5a", 2, absl::nullopt}, + {"0x36 starting an token", "6a", 2, absl::nullopt}, + {"0x37 starting an token", "7a", 2, absl::nullopt}, + {"0x38 starting an token", "8a", 2, absl::nullopt}, + {"0x39 starting an token", "9a", 2, absl::nullopt}, + {"0x3a starting an token", ":a", 2, absl::nullopt}, + {"0x3b starting an token", ";a", 2, absl::nullopt}, + {"0x3c starting an token", "a", 2, absl::nullopt}, + {"0x3f starting an token", "?a", 2, absl::nullopt}, + {"0x40 starting an token", "@a", 2, absl::nullopt}, {"0x41 starting an token", "Aa", 2, {{Item("Aa", Item::kTokenType), {}}}}, {"0x42 starting an token", "Ba", 2, {{Item("Ba", Item::kTokenType), {}}}}, {"0x43 starting an token", "Ca", 2, {{Item("Ca", Item::kTokenType), {}}}}, @@ -1392,12 +1392,12 @@ const struct ParameterizedItemTestCase { {"0x58 starting an token", "Xa", 2, {{Item("Xa", Item::kTokenType), {}}}}, {"0x59 starting an token", "Ya", 2, {{Item("Ya", Item::kTokenType), {}}}}, {"0x5a starting an token", "Za", 2, {{Item("Za", Item::kTokenType), {}}}}, - {"0x5b starting an token", "[a", 2, base::nullopt}, - {"0x5c starting an token", "\\a", 2, base::nullopt}, - {"0x5d starting an token", "]a", 2, base::nullopt}, - {"0x5e starting an token", "^a", 2, base::nullopt}, - {"0x5f starting an token", "_a", 2, base::nullopt}, - {"0x60 starting an token", "`a", 2, base::nullopt}, + {"0x5b starting an token", "[a", 2, absl::nullopt}, + {"0x5c starting an token", "\\a", 2, absl::nullopt}, + {"0x5d starting an token", "]a", 2, absl::nullopt}, + {"0x5e starting an token", "^a", 2, absl::nullopt}, + {"0x5f starting an token", "_a", 2, absl::nullopt}, + {"0x60 starting an token", "`a", 2, absl::nullopt}, {"0x61 starting an token", "aa", 2, {{Item("aa", Item::kTokenType), {}}}}, {"0x62 starting an token", "ba", 2, {{Item("ba", Item::kTokenType), {}}}}, {"0x63 starting an token", "ca", 2, {{Item("ca", Item::kTokenType), {}}}}, @@ -1424,11 +1424,11 @@ const struct ParameterizedItemTestCase { {"0x78 starting an token", "xa", 2, {{Item("xa", Item::kTokenType), {}}}}, {"0x79 starting an token", "ya", 2, {{Item("ya", Item::kTokenType), {}}}}, {"0x7a starting an token", "za", 2, {{Item("za", Item::kTokenType), {}}}}, - {"0x7b starting an token", "{a", 2, base::nullopt}, - {"0x7c starting an token", "|a", 2, base::nullopt}, - {"0x7d starting an token", "}a", 2, base::nullopt}, - {"0x7e starting an token", "~a", 2, base::nullopt}, - {"0x7f starting an token", "\177a", 2, base::nullopt}, + {"0x7b starting an token", "{a", 2, absl::nullopt}, + {"0x7c starting an token", "|a", 2, absl::nullopt}, + {"0x7d starting an token", "}a", 2, absl::nullopt}, + {"0x7e starting an token", "~a", 2, absl::nullopt}, + {"0x7f starting an token", "\177a", 2, absl::nullopt}, // token.json {"basic token - item", "a_b-c.d3:f%00/*", @@ -1448,13 +1448,13 @@ const struct ListTestCase { const char* name; const char* raw; size_t raw_len; - const base::Optional expected; // nullopt if parse error is expected. + const absl::optional expected; // nullopt if parse error is expected. const char* canonical; // nullptr if parse error is expected, or if canonical // format is identical to raw. } list_test_cases[] = { // dictionary.json - {"tab separated dictionary", "a=1\t,\tb=2", 9, base::nullopt}, + {"tab separated dictionary", "a=1\t,\tb=2", 9, absl::nullopt}, // examples.json {"Example-StrListHeader", "\"foo\", \"bar\", \"It was the best of times.\"", @@ -1496,55 +1496,55 @@ const struct ListTestCase { {Param("q", "9"), TokenParam("r", "w")}}}}, "abc;a=1;b=2;cde_456, (ghi;jk=4 l);q=\"9\";r=w"}, // key-generated.json - {"0x00 in parameterised list key", "foo; a\000a=1", 10, base::nullopt}, - {"0x01 in parameterised list key", "foo; a\001a=1", 10, base::nullopt}, - {"0x02 in parameterised list key", "foo; a\002a=1", 10, base::nullopt}, - {"0x03 in parameterised list key", "foo; a\003a=1", 10, base::nullopt}, - {"0x04 in parameterised list key", "foo; a\004a=1", 10, base::nullopt}, - {"0x05 in parameterised list key", "foo; a\005a=1", 10, base::nullopt}, - {"0x06 in parameterised list key", "foo; a\006a=1", 10, base::nullopt}, - {"0x07 in parameterised list key", "foo; a\aa=1", 10, base::nullopt}, - {"0x08 in parameterised list key", "foo; a\ba=1", 10, base::nullopt}, - {"0x09 in parameterised list key", "foo; a\ta=1", 10, base::nullopt}, - {"0x0a in parameterised list key", "foo; a\na=1", 10, base::nullopt}, - {"0x0b in parameterised list key", "foo; a\va=1", 10, base::nullopt}, - {"0x0c in parameterised list key", "foo; a\fa=1", 10, base::nullopt}, - {"0x0d in parameterised list key", "foo; a\ra=1", 10, base::nullopt}, - {"0x0e in parameterised list key", "foo; a\016a=1", 10, base::nullopt}, - {"0x0f in parameterised list key", "foo; a\017a=1", 10, base::nullopt}, - {"0x10 in parameterised list key", "foo; a\020a=1", 10, base::nullopt}, - {"0x11 in parameterised list key", "foo; a\021a=1", 10, base::nullopt}, - {"0x12 in parameterised list key", "foo; a\022a=1", 10, base::nullopt}, - {"0x13 in parameterised list key", "foo; a\023a=1", 10, base::nullopt}, - {"0x14 in parameterised list key", "foo; a\024a=1", 10, base::nullopt}, - {"0x15 in parameterised list key", "foo; a\025a=1", 10, base::nullopt}, - {"0x16 in parameterised list key", "foo; a\026a=1", 10, base::nullopt}, - {"0x17 in parameterised list key", "foo; a\027a=1", 10, base::nullopt}, - {"0x18 in parameterised list key", "foo; a\030a=1", 10, base::nullopt}, - {"0x19 in parameterised list key", "foo; a\031a=1", 10, base::nullopt}, - {"0x1a in parameterised list key", "foo; a\032a=1", 10, base::nullopt}, - {"0x1b in parameterised list key", "foo; a\033a=1", 10, base::nullopt}, - {"0x1c in parameterised list key", "foo; a\034a=1", 10, base::nullopt}, - {"0x1d in parameterised list key", "foo; a\035a=1", 10, base::nullopt}, - {"0x1e in parameterised list key", "foo; a\036a=1", 10, base::nullopt}, - {"0x1f in parameterised list key", "foo; a\037a=1", 10, base::nullopt}, - {"0x20 in parameterised list key", "foo; a a=1", 10, base::nullopt}, - {"0x21 in parameterised list key", "foo; a!a=1", 10, base::nullopt}, - {"0x22 in parameterised list key", "foo; a\"a=1", 10, base::nullopt}, - {"0x23 in parameterised list key", "foo; a#a=1", 10, base::nullopt}, - {"0x24 in parameterised list key", "foo; a$a=1", 10, base::nullopt}, - {"0x25 in parameterised list key", "foo; a%a=1", 10, base::nullopt}, - {"0x26 in parameterised list key", "foo; a&a=1", 10, base::nullopt}, - {"0x27 in parameterised list key", "foo; a'a=1", 10, base::nullopt}, - {"0x28 in parameterised list key", "foo; a(a=1", 10, base::nullopt}, - {"0x29 in parameterised list key", "foo; a)a=1", 10, base::nullopt}, + {"0x00 in parameterised list key", "foo; a\000a=1", 10, absl::nullopt}, + {"0x01 in parameterised list key", "foo; a\001a=1", 10, absl::nullopt}, + {"0x02 in parameterised list key", "foo; a\002a=1", 10, absl::nullopt}, + {"0x03 in parameterised list key", "foo; a\003a=1", 10, absl::nullopt}, + {"0x04 in parameterised list key", "foo; a\004a=1", 10, absl::nullopt}, + {"0x05 in parameterised list key", "foo; a\005a=1", 10, absl::nullopt}, + {"0x06 in parameterised list key", "foo; a\006a=1", 10, absl::nullopt}, + {"0x07 in parameterised list key", "foo; a\aa=1", 10, absl::nullopt}, + {"0x08 in parameterised list key", "foo; a\ba=1", 10, absl::nullopt}, + {"0x09 in parameterised list key", "foo; a\ta=1", 10, absl::nullopt}, + {"0x0a in parameterised list key", "foo; a\na=1", 10, absl::nullopt}, + {"0x0b in parameterised list key", "foo; a\va=1", 10, absl::nullopt}, + {"0x0c in parameterised list key", "foo; a\fa=1", 10, absl::nullopt}, + {"0x0d in parameterised list key", "foo; a\ra=1", 10, absl::nullopt}, + {"0x0e in parameterised list key", "foo; a\016a=1", 10, absl::nullopt}, + {"0x0f in parameterised list key", "foo; a\017a=1", 10, absl::nullopt}, + {"0x10 in parameterised list key", "foo; a\020a=1", 10, absl::nullopt}, + {"0x11 in parameterised list key", "foo; a\021a=1", 10, absl::nullopt}, + {"0x12 in parameterised list key", "foo; a\022a=1", 10, absl::nullopt}, + {"0x13 in parameterised list key", "foo; a\023a=1", 10, absl::nullopt}, + {"0x14 in parameterised list key", "foo; a\024a=1", 10, absl::nullopt}, + {"0x15 in parameterised list key", "foo; a\025a=1", 10, absl::nullopt}, + {"0x16 in parameterised list key", "foo; a\026a=1", 10, absl::nullopt}, + {"0x17 in parameterised list key", "foo; a\027a=1", 10, absl::nullopt}, + {"0x18 in parameterised list key", "foo; a\030a=1", 10, absl::nullopt}, + {"0x19 in parameterised list key", "foo; a\031a=1", 10, absl::nullopt}, + {"0x1a in parameterised list key", "foo; a\032a=1", 10, absl::nullopt}, + {"0x1b in parameterised list key", "foo; a\033a=1", 10, absl::nullopt}, + {"0x1c in parameterised list key", "foo; a\034a=1", 10, absl::nullopt}, + {"0x1d in parameterised list key", "foo; a\035a=1", 10, absl::nullopt}, + {"0x1e in parameterised list key", "foo; a\036a=1", 10, absl::nullopt}, + {"0x1f in parameterised list key", "foo; a\037a=1", 10, absl::nullopt}, + {"0x20 in parameterised list key", "foo; a a=1", 10, absl::nullopt}, + {"0x21 in parameterised list key", "foo; a!a=1", 10, absl::nullopt}, + {"0x22 in parameterised list key", "foo; a\"a=1", 10, absl::nullopt}, + {"0x23 in parameterised list key", "foo; a#a=1", 10, absl::nullopt}, + {"0x24 in parameterised list key", "foo; a$a=1", 10, absl::nullopt}, + {"0x25 in parameterised list key", "foo; a%a=1", 10, absl::nullopt}, + {"0x26 in parameterised list key", "foo; a&a=1", 10, absl::nullopt}, + {"0x27 in parameterised list key", "foo; a'a=1", 10, absl::nullopt}, + {"0x28 in parameterised list key", "foo; a(a=1", 10, absl::nullopt}, + {"0x29 in parameterised list key", "foo; a)a=1", 10, absl::nullopt}, {"0x2a in parameterised list key", "foo; a*a=1", 10, {{{Item("foo", Item::kTokenType), {Param("a*a", 1)}}}}, "foo;a*a=1"}, - {"0x2b in parameterised list key", "foo; a+a=1", 10, base::nullopt}, - {"0x2c in parameterised list key", "foo; a,a=1", 10, base::nullopt}, + {"0x2b in parameterised list key", "foo; a+a=1", 10, absl::nullopt}, + {"0x2c in parameterised list key", "foo; a,a=1", 10, absl::nullopt}, {"0x2d in parameterised list key", "foo; a-a=1", 10, @@ -1555,7 +1555,7 @@ const struct ListTestCase { 10, {{{Item("foo", Item::kTokenType), {Param("a.a", 1)}}}}, "foo;a.a=1"}, - {"0x2f in parameterised list key", "foo; a/a=1", 10, base::nullopt}, + {"0x2f in parameterised list key", "foo; a/a=1", 10, absl::nullopt}, {"0x30 in parameterised list key", "foo; a0a=1", 10, @@ -1606,53 +1606,53 @@ const struct ListTestCase { 10, {{{Item("foo", Item::kTokenType), {Param("a9a", 1)}}}}, "foo;a9a=1"}, - {"0x3a in parameterised list key", "foo; a:a=1", 10, base::nullopt}, + {"0x3a in parameterised list key", "foo; a:a=1", 10, absl::nullopt}, {"0x3b in parameterised list key", "foo; a;a=1", 10, {{{Item("foo", Item::kTokenType), {Param("a", 1)}}}}, "foo;a=1"}, - {"0x3c in parameterised list key", "foo; aa=1", 10, base::nullopt}, - {"0x3f in parameterised list key", "foo; a?a=1", 10, base::nullopt}, - {"0x40 in parameterised list key", "foo; a@a=1", 10, base::nullopt}, - {"0x41 in parameterised list key", "foo; aAa=1", 10, base::nullopt}, - {"0x42 in parameterised list key", "foo; aBa=1", 10, base::nullopt}, - {"0x43 in parameterised list key", "foo; aCa=1", 10, base::nullopt}, - {"0x44 in parameterised list key", "foo; aDa=1", 10, base::nullopt}, - {"0x45 in parameterised list key", "foo; aEa=1", 10, base::nullopt}, - {"0x46 in parameterised list key", "foo; aFa=1", 10, base::nullopt}, - {"0x47 in parameterised list key", "foo; aGa=1", 10, base::nullopt}, - {"0x48 in parameterised list key", "foo; aHa=1", 10, base::nullopt}, - {"0x49 in parameterised list key", "foo; aIa=1", 10, base::nullopt}, - {"0x4a in parameterised list key", "foo; aJa=1", 10, base::nullopt}, - {"0x4b in parameterised list key", "foo; aKa=1", 10, base::nullopt}, - {"0x4c in parameterised list key", "foo; aLa=1", 10, base::nullopt}, - {"0x4d in parameterised list key", "foo; aMa=1", 10, base::nullopt}, - {"0x4e in parameterised list key", "foo; aNa=1", 10, base::nullopt}, - {"0x4f in parameterised list key", "foo; aOa=1", 10, base::nullopt}, - {"0x50 in parameterised list key", "foo; aPa=1", 10, base::nullopt}, - {"0x51 in parameterised list key", "foo; aQa=1", 10, base::nullopt}, - {"0x52 in parameterised list key", "foo; aRa=1", 10, base::nullopt}, - {"0x53 in parameterised list key", "foo; aSa=1", 10, base::nullopt}, - {"0x54 in parameterised list key", "foo; aTa=1", 10, base::nullopt}, - {"0x55 in parameterised list key", "foo; aUa=1", 10, base::nullopt}, - {"0x56 in parameterised list key", "foo; aVa=1", 10, base::nullopt}, - {"0x57 in parameterised list key", "foo; aWa=1", 10, base::nullopt}, - {"0x58 in parameterised list key", "foo; aXa=1", 10, base::nullopt}, - {"0x59 in parameterised list key", "foo; aYa=1", 10, base::nullopt}, - {"0x5a in parameterised list key", "foo; aZa=1", 10, base::nullopt}, - {"0x5b in parameterised list key", "foo; a[a=1", 10, base::nullopt}, - {"0x5c in parameterised list key", "foo; a\\a=1", 10, base::nullopt}, - {"0x5d in parameterised list key", "foo; a]a=1", 10, base::nullopt}, - {"0x5e in parameterised list key", "foo; a^a=1", 10, base::nullopt}, + {"0x3c in parameterised list key", "foo; aa=1", 10, absl::nullopt}, + {"0x3f in parameterised list key", "foo; a?a=1", 10, absl::nullopt}, + {"0x40 in parameterised list key", "foo; a@a=1", 10, absl::nullopt}, + {"0x41 in parameterised list key", "foo; aAa=1", 10, absl::nullopt}, + {"0x42 in parameterised list key", "foo; aBa=1", 10, absl::nullopt}, + {"0x43 in parameterised list key", "foo; aCa=1", 10, absl::nullopt}, + {"0x44 in parameterised list key", "foo; aDa=1", 10, absl::nullopt}, + {"0x45 in parameterised list key", "foo; aEa=1", 10, absl::nullopt}, + {"0x46 in parameterised list key", "foo; aFa=1", 10, absl::nullopt}, + {"0x47 in parameterised list key", "foo; aGa=1", 10, absl::nullopt}, + {"0x48 in parameterised list key", "foo; aHa=1", 10, absl::nullopt}, + {"0x49 in parameterised list key", "foo; aIa=1", 10, absl::nullopt}, + {"0x4a in parameterised list key", "foo; aJa=1", 10, absl::nullopt}, + {"0x4b in parameterised list key", "foo; aKa=1", 10, absl::nullopt}, + {"0x4c in parameterised list key", "foo; aLa=1", 10, absl::nullopt}, + {"0x4d in parameterised list key", "foo; aMa=1", 10, absl::nullopt}, + {"0x4e in parameterised list key", "foo; aNa=1", 10, absl::nullopt}, + {"0x4f in parameterised list key", "foo; aOa=1", 10, absl::nullopt}, + {"0x50 in parameterised list key", "foo; aPa=1", 10, absl::nullopt}, + {"0x51 in parameterised list key", "foo; aQa=1", 10, absl::nullopt}, + {"0x52 in parameterised list key", "foo; aRa=1", 10, absl::nullopt}, + {"0x53 in parameterised list key", "foo; aSa=1", 10, absl::nullopt}, + {"0x54 in parameterised list key", "foo; aTa=1", 10, absl::nullopt}, + {"0x55 in parameterised list key", "foo; aUa=1", 10, absl::nullopt}, + {"0x56 in parameterised list key", "foo; aVa=1", 10, absl::nullopt}, + {"0x57 in parameterised list key", "foo; aWa=1", 10, absl::nullopt}, + {"0x58 in parameterised list key", "foo; aXa=1", 10, absl::nullopt}, + {"0x59 in parameterised list key", "foo; aYa=1", 10, absl::nullopt}, + {"0x5a in parameterised list key", "foo; aZa=1", 10, absl::nullopt}, + {"0x5b in parameterised list key", "foo; a[a=1", 10, absl::nullopt}, + {"0x5c in parameterised list key", "foo; a\\a=1", 10, absl::nullopt}, + {"0x5d in parameterised list key", "foo; a]a=1", 10, absl::nullopt}, + {"0x5e in parameterised list key", "foo; a^a=1", 10, absl::nullopt}, {"0x5f in parameterised list key", "foo; a_a=1", 10, {{{Item("foo", Item::kTokenType), {Param("a_a", 1)}}}}, "foo;a_a=1"}, - {"0x60 in parameterised list key", "foo; a`a=1", 10, base::nullopt}, + {"0x60 in parameterised list key", "foo; a`a=1", 10, absl::nullopt}, {"0x61 in parameterised list key", "foo; aaa=1", 10, @@ -1783,141 +1783,141 @@ const struct ListTestCase { 10, {{{Item("foo", Item::kTokenType), {Param("aza", 1)}}}}, "foo;aza=1"}, - {"0x7b in parameterised list key", "foo; a{a=1", 10, base::nullopt}, - {"0x7c in parameterised list key", "foo; a|a=1", 10, base::nullopt}, - {"0x7d in parameterised list key", "foo; a}a=1", 10, base::nullopt}, - {"0x7e in parameterised list key", "foo; a~a=1", 10, base::nullopt}, - {"0x7f in parameterised list key", "foo; a\177a=1", 10, base::nullopt}, + {"0x7b in parameterised list key", "foo; a{a=1", 10, absl::nullopt}, + {"0x7c in parameterised list key", "foo; a|a=1", 10, absl::nullopt}, + {"0x7d in parameterised list key", "foo; a}a=1", 10, absl::nullopt}, + {"0x7e in parameterised list key", "foo; a~a=1", 10, absl::nullopt}, + {"0x7f in parameterised list key", "foo; a\177a=1", 10, absl::nullopt}, {"0x00 starting a parameterised list key", "foo; \000a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x01 starting a parameterised list key", "foo; \001a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x02 starting a parameterised list key", "foo; \002a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x03 starting a parameterised list key", "foo; \003a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x04 starting a parameterised list key", "foo; \004a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x05 starting a parameterised list key", "foo; \005a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x06 starting a parameterised list key", "foo; \006a=1", 9, - base::nullopt}, - {"0x07 starting a parameterised list key", "foo; \aa=1", 9, base::nullopt}, - {"0x08 starting a parameterised list key", "foo; \ba=1", 9, base::nullopt}, - {"0x09 starting a parameterised list key", "foo; \ta=1", 9, base::nullopt}, - {"0x0a starting a parameterised list key", "foo; \na=1", 9, base::nullopt}, - {"0x0b starting a parameterised list key", "foo; \va=1", 9, base::nullopt}, - {"0x0c starting a parameterised list key", "foo; \fa=1", 9, base::nullopt}, - {"0x0d starting a parameterised list key", "foo; \ra=1", 9, base::nullopt}, + absl::nullopt}, + {"0x07 starting a parameterised list key", "foo; \aa=1", 9, absl::nullopt}, + {"0x08 starting a parameterised list key", "foo; \ba=1", 9, absl::nullopt}, + {"0x09 starting a parameterised list key", "foo; \ta=1", 9, absl::nullopt}, + {"0x0a starting a parameterised list key", "foo; \na=1", 9, absl::nullopt}, + {"0x0b starting a parameterised list key", "foo; \va=1", 9, absl::nullopt}, + {"0x0c starting a parameterised list key", "foo; \fa=1", 9, absl::nullopt}, + {"0x0d starting a parameterised list key", "foo; \ra=1", 9, absl::nullopt}, {"0x0e starting a parameterised list key", "foo; \016a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x0f starting a parameterised list key", "foo; \017a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x10 starting a parameterised list key", "foo; \020a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x11 starting a parameterised list key", "foo; \021a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x12 starting a parameterised list key", "foo; \022a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x13 starting a parameterised list key", "foo; \023a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x14 starting a parameterised list key", "foo; \024a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x15 starting a parameterised list key", "foo; \025a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x16 starting a parameterised list key", "foo; \026a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x17 starting a parameterised list key", "foo; \027a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x18 starting a parameterised list key", "foo; \030a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x19 starting a parameterised list key", "foo; \031a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x1a starting a parameterised list key", "foo; \032a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x1b starting a parameterised list key", "foo; \033a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x1c starting a parameterised list key", "foo; \034a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x1d starting a parameterised list key", "foo; \035a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x1e starting a parameterised list key", "foo; \036a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x1f starting a parameterised list key", "foo; \037a=1", 9, - base::nullopt}, + absl::nullopt}, {"0x20 starting a parameterised list key", "foo; a=1", 9, {{{Item("foo", Item::kTokenType), {Param("a", 1)}}}}, "foo;a=1"}, - {"0x21 starting a parameterised list key", "foo; !a=1", 9, base::nullopt}, - {"0x22 starting a parameterised list key", "foo; \"a=1", 9, base::nullopt}, - {"0x23 starting a parameterised list key", "foo; #a=1", 9, base::nullopt}, - {"0x24 starting a parameterised list key", "foo; $a=1", 9, base::nullopt}, - {"0x25 starting a parameterised list key", "foo; %a=1", 9, base::nullopt}, - {"0x26 starting a parameterised list key", "foo; &a=1", 9, base::nullopt}, - {"0x27 starting a parameterised list key", "foo; 'a=1", 9, base::nullopt}, - {"0x28 starting a parameterised list key", "foo; (a=1", 9, base::nullopt}, - {"0x29 starting a parameterised list key", "foo; )a=1", 9, base::nullopt}, + {"0x21 starting a parameterised list key", "foo; !a=1", 9, absl::nullopt}, + {"0x22 starting a parameterised list key", "foo; \"a=1", 9, absl::nullopt}, + {"0x23 starting a parameterised list key", "foo; #a=1", 9, absl::nullopt}, + {"0x24 starting a parameterised list key", "foo; $a=1", 9, absl::nullopt}, + {"0x25 starting a parameterised list key", "foo; %a=1", 9, absl::nullopt}, + {"0x26 starting a parameterised list key", "foo; &a=1", 9, absl::nullopt}, + {"0x27 starting a parameterised list key", "foo; 'a=1", 9, absl::nullopt}, + {"0x28 starting a parameterised list key", "foo; (a=1", 9, absl::nullopt}, + {"0x29 starting a parameterised list key", "foo; )a=1", 9, absl::nullopt}, {"0x2a starting a parameterised list key", "foo; *a=1", 9, {{{Item("foo", Item::kTokenType), {Param("*a", 1)}}}}, "foo;*a=1"}, - {"0x2b starting a parameterised list key", "foo; +a=1", 9, base::nullopt}, - {"0x2c starting a parameterised list key", "foo; ,a=1", 9, base::nullopt}, - {"0x2d starting a parameterised list key", "foo; -a=1", 9, base::nullopt}, - {"0x2e starting a parameterised list key", "foo; .a=1", 9, base::nullopt}, - {"0x2f starting a parameterised list key", "foo; /a=1", 9, base::nullopt}, - {"0x30 starting a parameterised list key", "foo; 0a=1", 9, base::nullopt}, - {"0x31 starting a parameterised list key", "foo; 1a=1", 9, base::nullopt}, - {"0x32 starting a parameterised list key", "foo; 2a=1", 9, base::nullopt}, - {"0x33 starting a parameterised list key", "foo; 3a=1", 9, base::nullopt}, - {"0x34 starting a parameterised list key", "foo; 4a=1", 9, base::nullopt}, - {"0x35 starting a parameterised list key", "foo; 5a=1", 9, base::nullopt}, - {"0x36 starting a parameterised list key", "foo; 6a=1", 9, base::nullopt}, - {"0x37 starting a parameterised list key", "foo; 7a=1", 9, base::nullopt}, - {"0x38 starting a parameterised list key", "foo; 8a=1", 9, base::nullopt}, - {"0x39 starting a parameterised list key", "foo; 9a=1", 9, base::nullopt}, - {"0x3a starting a parameterised list key", "foo; :a=1", 9, base::nullopt}, - {"0x3b starting a parameterised list key", "foo; ;a=1", 9, base::nullopt}, - {"0x3c starting a parameterised list key", "foo; a=1", 9, base::nullopt}, - {"0x3f starting a parameterised list key", "foo; ?a=1", 9, base::nullopt}, - {"0x40 starting a parameterised list key", "foo; @a=1", 9, base::nullopt}, - {"0x41 starting a parameterised list key", "foo; Aa=1", 9, base::nullopt}, - {"0x42 starting a parameterised list key", "foo; Ba=1", 9, base::nullopt}, - {"0x43 starting a parameterised list key", "foo; Ca=1", 9, base::nullopt}, - {"0x44 starting a parameterised list key", "foo; Da=1", 9, base::nullopt}, - {"0x45 starting a parameterised list key", "foo; Ea=1", 9, base::nullopt}, - {"0x46 starting a parameterised list key", "foo; Fa=1", 9, base::nullopt}, - {"0x47 starting a parameterised list key", "foo; Ga=1", 9, base::nullopt}, - {"0x48 starting a parameterised list key", "foo; Ha=1", 9, base::nullopt}, - {"0x49 starting a parameterised list key", "foo; Ia=1", 9, base::nullopt}, - {"0x4a starting a parameterised list key", "foo; Ja=1", 9, base::nullopt}, - {"0x4b starting a parameterised list key", "foo; Ka=1", 9, base::nullopt}, - {"0x4c starting a parameterised list key", "foo; La=1", 9, base::nullopt}, - {"0x4d starting a parameterised list key", "foo; Ma=1", 9, base::nullopt}, - {"0x4e starting a parameterised list key", "foo; Na=1", 9, base::nullopt}, - {"0x4f starting a parameterised list key", "foo; Oa=1", 9, base::nullopt}, - {"0x50 starting a parameterised list key", "foo; Pa=1", 9, base::nullopt}, - {"0x51 starting a parameterised list key", "foo; Qa=1", 9, base::nullopt}, - {"0x52 starting a parameterised list key", "foo; Ra=1", 9, base::nullopt}, - {"0x53 starting a parameterised list key", "foo; Sa=1", 9, base::nullopt}, - {"0x54 starting a parameterised list key", "foo; Ta=1", 9, base::nullopt}, - {"0x55 starting a parameterised list key", "foo; Ua=1", 9, base::nullopt}, - {"0x56 starting a parameterised list key", "foo; Va=1", 9, base::nullopt}, - {"0x57 starting a parameterised list key", "foo; Wa=1", 9, base::nullopt}, - {"0x58 starting a parameterised list key", "foo; Xa=1", 9, base::nullopt}, - {"0x59 starting a parameterised list key", "foo; Ya=1", 9, base::nullopt}, - {"0x5a starting a parameterised list key", "foo; Za=1", 9, base::nullopt}, - {"0x5b starting a parameterised list key", "foo; [a=1", 9, base::nullopt}, - {"0x5c starting a parameterised list key", "foo; \\a=1", 9, base::nullopt}, - {"0x5d starting a parameterised list key", "foo; ]a=1", 9, base::nullopt}, - {"0x5e starting a parameterised list key", "foo; ^a=1", 9, base::nullopt}, - {"0x5f starting a parameterised list key", "foo; _a=1", 9, base::nullopt}, - {"0x60 starting a parameterised list key", "foo; `a=1", 9, base::nullopt}, + {"0x2b starting a parameterised list key", "foo; +a=1", 9, absl::nullopt}, + {"0x2c starting a parameterised list key", "foo; ,a=1", 9, absl::nullopt}, + {"0x2d starting a parameterised list key", "foo; -a=1", 9, absl::nullopt}, + {"0x2e starting a parameterised list key", "foo; .a=1", 9, absl::nullopt}, + {"0x2f starting a parameterised list key", "foo; /a=1", 9, absl::nullopt}, + {"0x30 starting a parameterised list key", "foo; 0a=1", 9, absl::nullopt}, + {"0x31 starting a parameterised list key", "foo; 1a=1", 9, absl::nullopt}, + {"0x32 starting a parameterised list key", "foo; 2a=1", 9, absl::nullopt}, + {"0x33 starting a parameterised list key", "foo; 3a=1", 9, absl::nullopt}, + {"0x34 starting a parameterised list key", "foo; 4a=1", 9, absl::nullopt}, + {"0x35 starting a parameterised list key", "foo; 5a=1", 9, absl::nullopt}, + {"0x36 starting a parameterised list key", "foo; 6a=1", 9, absl::nullopt}, + {"0x37 starting a parameterised list key", "foo; 7a=1", 9, absl::nullopt}, + {"0x38 starting a parameterised list key", "foo; 8a=1", 9, absl::nullopt}, + {"0x39 starting a parameterised list key", "foo; 9a=1", 9, absl::nullopt}, + {"0x3a starting a parameterised list key", "foo; :a=1", 9, absl::nullopt}, + {"0x3b starting a parameterised list key", "foo; ;a=1", 9, absl::nullopt}, + {"0x3c starting a parameterised list key", "foo; a=1", 9, absl::nullopt}, + {"0x3f starting a parameterised list key", "foo; ?a=1", 9, absl::nullopt}, + {"0x40 starting a parameterised list key", "foo; @a=1", 9, absl::nullopt}, + {"0x41 starting a parameterised list key", "foo; Aa=1", 9, absl::nullopt}, + {"0x42 starting a parameterised list key", "foo; Ba=1", 9, absl::nullopt}, + {"0x43 starting a parameterised list key", "foo; Ca=1", 9, absl::nullopt}, + {"0x44 starting a parameterised list key", "foo; Da=1", 9, absl::nullopt}, + {"0x45 starting a parameterised list key", "foo; Ea=1", 9, absl::nullopt}, + {"0x46 starting a parameterised list key", "foo; Fa=1", 9, absl::nullopt}, + {"0x47 starting a parameterised list key", "foo; Ga=1", 9, absl::nullopt}, + {"0x48 starting a parameterised list key", "foo; Ha=1", 9, absl::nullopt}, + {"0x49 starting a parameterised list key", "foo; Ia=1", 9, absl::nullopt}, + {"0x4a starting a parameterised list key", "foo; Ja=1", 9, absl::nullopt}, + {"0x4b starting a parameterised list key", "foo; Ka=1", 9, absl::nullopt}, + {"0x4c starting a parameterised list key", "foo; La=1", 9, absl::nullopt}, + {"0x4d starting a parameterised list key", "foo; Ma=1", 9, absl::nullopt}, + {"0x4e starting a parameterised list key", "foo; Na=1", 9, absl::nullopt}, + {"0x4f starting a parameterised list key", "foo; Oa=1", 9, absl::nullopt}, + {"0x50 starting a parameterised list key", "foo; Pa=1", 9, absl::nullopt}, + {"0x51 starting a parameterised list key", "foo; Qa=1", 9, absl::nullopt}, + {"0x52 starting a parameterised list key", "foo; Ra=1", 9, absl::nullopt}, + {"0x53 starting a parameterised list key", "foo; Sa=1", 9, absl::nullopt}, + {"0x54 starting a parameterised list key", "foo; Ta=1", 9, absl::nullopt}, + {"0x55 starting a parameterised list key", "foo; Ua=1", 9, absl::nullopt}, + {"0x56 starting a parameterised list key", "foo; Va=1", 9, absl::nullopt}, + {"0x57 starting a parameterised list key", "foo; Wa=1", 9, absl::nullopt}, + {"0x58 starting a parameterised list key", "foo; Xa=1", 9, absl::nullopt}, + {"0x59 starting a parameterised list key", "foo; Ya=1", 9, absl::nullopt}, + {"0x5a starting a parameterised list key", "foo; Za=1", 9, absl::nullopt}, + {"0x5b starting a parameterised list key", "foo; [a=1", 9, absl::nullopt}, + {"0x5c starting a parameterised list key", "foo; \\a=1", 9, absl::nullopt}, + {"0x5d starting a parameterised list key", "foo; ]a=1", 9, absl::nullopt}, + {"0x5e starting a parameterised list key", "foo; ^a=1", 9, absl::nullopt}, + {"0x5f starting a parameterised list key", "foo; _a=1", 9, absl::nullopt}, + {"0x60 starting a parameterised list key", "foo; `a=1", 9, absl::nullopt}, {"0x61 starting a parameterised list key", "foo; aa=1", 9, @@ -2048,12 +2048,12 @@ const struct ListTestCase { 9, {{{Item("foo", Item::kTokenType), {Param("za", 1)}}}}, "foo;za=1"}, - {"0x7b starting a parameterised list key", "foo; {a=1", 9, base::nullopt}, - {"0x7c starting a parameterised list key", "foo; |a=1", 9, base::nullopt}, - {"0x7d starting a parameterised list key", "foo; }a=1", 9, base::nullopt}, - {"0x7e starting a parameterised list key", "foo; ~a=1", 9, base::nullopt}, + {"0x7b starting a parameterised list key", "foo; {a=1", 9, absl::nullopt}, + {"0x7c starting a parameterised list key", "foo; |a=1", 9, absl::nullopt}, + {"0x7d starting a parameterised list key", "foo; }a=1", 9, absl::nullopt}, + {"0x7e starting a parameterised list key", "foo; ~a=1", 9, absl::nullopt}, {"0x7f starting a parameterised list key", "foo; \177a=1", 9, - base::nullopt}, + absl::nullopt}, // list.json {"basic list", "1, 42", 5, {{{Integer(1), {}}, {Integer(42), {}}}}}, {"empty list", "", 0, {List()}}, @@ -2073,14 +2073,14 @@ const struct ListTestCase { 6, {{{Integer(1), {}}, {Integer(42), {}}}}, "1, 42"}, - {"tab separated list", "1\t,\t42", 6, base::nullopt}, + {"tab separated list", "1\t,\t42", 6, absl::nullopt}, {"two line list", "1, 42", 5, {{{Integer(1), {}}, {Integer(42), {}}}}, "1, 42"}, - {"trailing comma list", "1, 42,", 6, base::nullopt}, - {"empty item list", "1,,42", 5, base::nullopt}, + {"trailing comma list", "1, 42,", 6, absl::nullopt}, + {"empty item list", "1,,42", 5, absl::nullopt}, // listlist.json {"basic list of lists", "(1 2), (42 43)", @@ -2104,12 +2104,12 @@ const struct ListTestCase { 11, {{{{{Integer(1), {}}, {Integer(42), {}}}, {}}}}, "(1 42)"}, - {"wrong whitespace list of lists", "(1\t 42)", 7, base::nullopt}, - {"no trailing parenthesis list of lists", "(1 42", 5, base::nullopt}, + {"wrong whitespace list of lists", "(1\t 42)", 7, absl::nullopt}, + {"no trailing parenthesis list of lists", "(1 42", 5, absl::nullopt}, {"no trailing parenthesis middle list of lists", "(1 2, (42 43)", 13, - base::nullopt}, + absl::nullopt}, {"no spaces in inner-list", "(abc\"def\"?0123*dXZ3*xyz)", 24, - base::nullopt}, + absl::nullopt}, // param-list.json {"basic parameterised list", "abc_123;a=1;b=2; cdef_456, ghi;q=9;r=\"+w\"", @@ -2139,11 +2139,11 @@ const struct ListTestCase { {Item("text/plain", Item::kTokenType), {DoubleParam("q", 0.500000)}}}}, "text/html, text/plain;q=0.5"}, {"whitespace before = parameterised list", "text/html, text/plain;q =0.5", - 28, base::nullopt}, + 28, absl::nullopt}, {"whitespace after = parameterised list", "text/html, text/plain;q= 0.5", - 28, base::nullopt}, + 28, absl::nullopt}, {"whitespace before ; parameterised list", "text/html, text/plain ;q=0.5", - 28, base::nullopt}, + 28, absl::nullopt}, {"whitespace after ; parameterised list", "text/html, text/plain; q=0.5", 28, @@ -2164,9 +2164,9 @@ const struct ListTestCase { {Item("text/plain", Item::kTokenType), {DoubleParam("q", 0.500000)}}}}, "text/html, text/plain;q=0.5"}, {"trailing comma parameterised list", "text/html,text/plain;q=0.5,", 27, - base::nullopt}, + absl::nullopt}, {"empty item parameterised list", "text/html,,text/plain;q=0.5,", 28, - base::nullopt}, + absl::nullopt}, // token.json {"basic token - list", "a_b-c3/*", @@ -2186,7 +2186,7 @@ const struct DictionaryTestCase { const char* name; const char* raw; size_t raw_len; - const base::Optional + const absl::optional expected; // nullopt if parse error is expected. const char* canonical; // nullptr if parse error is expected, or if canonical // format is identical to raw. @@ -2232,8 +2232,8 @@ const struct DictionaryTestCase { 15, {Dictionary{{{"a", {Integer(1), {}}}, {"b", {Integer(2), {}}}}}}, "a=1, b=2"}, - {"whitespace before = dictionary", "a =1, b=2", 9, base::nullopt}, - {"whitespace after = dictionary", "a=1, b= 2", 9, base::nullopt}, + {"whitespace before = dictionary", "a =1, b=2", 9, absl::nullopt}, + {"whitespace after = dictionary", "a=1, b= 2", 9, absl::nullopt}, {"two lines dictionary", "a=1, b=2", 8, @@ -2272,16 +2272,16 @@ const struct DictionaryTestCase { {"b", {Item(true), {Param("foo", 9)}}}, {"c", {Integer(3), {}}}}}}, "a=1, b;foo=9, c=3"}, - {"trailing comma dictionary", "a=1, b=2,", 9, base::nullopt}, - {"empty item dictionary", "a=1,,b=2,", 9, base::nullopt}, + {"trailing comma dictionary", "a=1, b=2,", 9, absl::nullopt}, + {"empty item dictionary", "a=1,,b=2,", 9, absl::nullopt}, {"duplicate key dictionary", "a=1,b=2,a=3", 11, {Dictionary{{{"a", {Integer(3), {}}}, {"b", {Integer(2), {}}}}}}, "a=3, b=2"}, - {"numeric key dictionary", "a=1,1b=2,a=1", 12, base::nullopt}, - {"uppercase key dictionary", "a=1,B=2,a=1", 11, base::nullopt}, - {"bad key dictionary", "a=1,b!=2,a=1", 12, base::nullopt}, + {"numeric key dictionary", "a=1,1b=2,a=1", 12, absl::nullopt}, + {"uppercase key dictionary", "a=1,B=2,a=1", 11, absl::nullopt}, + {"bad key dictionary", "a=1,b!=2,a=1", 12, absl::nullopt}, // examples.json {"Example-DictHeader", "en=\"Applepie\", da=:w4ZibGV0w6ZydGU=:", @@ -2325,53 +2325,53 @@ const struct DictionaryTestCase { {Dictionary{{{"foo", {Integer(1), {}}}, {"bar", {Integer(2), {}}}}}}, "foo=1, bar=2"}, // key-generated.json - {"0x00 in dictionary key", "a\000a=1", 5, base::nullopt}, - {"0x01 in dictionary key", "a\001a=1", 5, base::nullopt}, - {"0x02 in dictionary key", "a\002a=1", 5, base::nullopt}, - {"0x03 in dictionary key", "a\003a=1", 5, base::nullopt}, - {"0x04 in dictionary key", "a\004a=1", 5, base::nullopt}, - {"0x05 in dictionary key", "a\005a=1", 5, base::nullopt}, - {"0x06 in dictionary key", "a\006a=1", 5, base::nullopt}, - {"0x07 in dictionary key", "a\aa=1", 5, base::nullopt}, - {"0x08 in dictionary key", "a\ba=1", 5, base::nullopt}, - {"0x09 in dictionary key", "a\ta=1", 5, base::nullopt}, - {"0x0a in dictionary key", "a\na=1", 5, base::nullopt}, - {"0x0b in dictionary key", "a\va=1", 5, base::nullopt}, - {"0x0c in dictionary key", "a\fa=1", 5, base::nullopt}, - {"0x0d in dictionary key", "a\ra=1", 5, base::nullopt}, - {"0x0e in dictionary key", "a\016a=1", 5, base::nullopt}, - {"0x0f in dictionary key", "a\017a=1", 5, base::nullopt}, - {"0x10 in dictionary key", "a\020a=1", 5, base::nullopt}, - {"0x11 in dictionary key", "a\021a=1", 5, base::nullopt}, - {"0x12 in dictionary key", "a\022a=1", 5, base::nullopt}, - {"0x13 in dictionary key", "a\023a=1", 5, base::nullopt}, - {"0x14 in dictionary key", "a\024a=1", 5, base::nullopt}, - {"0x15 in dictionary key", "a\025a=1", 5, base::nullopt}, - {"0x16 in dictionary key", "a\026a=1", 5, base::nullopt}, - {"0x17 in dictionary key", "a\027a=1", 5, base::nullopt}, - {"0x18 in dictionary key", "a\030a=1", 5, base::nullopt}, - {"0x19 in dictionary key", "a\031a=1", 5, base::nullopt}, - {"0x1a in dictionary key", "a\032a=1", 5, base::nullopt}, - {"0x1b in dictionary key", "a\033a=1", 5, base::nullopt}, - {"0x1c in dictionary key", "a\034a=1", 5, base::nullopt}, - {"0x1d in dictionary key", "a\035a=1", 5, base::nullopt}, - {"0x1e in dictionary key", "a\036a=1", 5, base::nullopt}, - {"0x1f in dictionary key", "a\037a=1", 5, base::nullopt}, - {"0x20 in dictionary key", "a a=1", 5, base::nullopt}, - {"0x21 in dictionary key", "a!a=1", 5, base::nullopt}, - {"0x22 in dictionary key", "a\"a=1", 5, base::nullopt}, - {"0x23 in dictionary key", "a#a=1", 5, base::nullopt}, - {"0x24 in dictionary key", "a$a=1", 5, base::nullopt}, - {"0x25 in dictionary key", "a%a=1", 5, base::nullopt}, - {"0x26 in dictionary key", "a&a=1", 5, base::nullopt}, - {"0x27 in dictionary key", "a'a=1", 5, base::nullopt}, - {"0x28 in dictionary key", "a(a=1", 5, base::nullopt}, - {"0x29 in dictionary key", "a)a=1", 5, base::nullopt}, + {"0x00 in dictionary key", "a\000a=1", 5, absl::nullopt}, + {"0x01 in dictionary key", "a\001a=1", 5, absl::nullopt}, + {"0x02 in dictionary key", "a\002a=1", 5, absl::nullopt}, + {"0x03 in dictionary key", "a\003a=1", 5, absl::nullopt}, + {"0x04 in dictionary key", "a\004a=1", 5, absl::nullopt}, + {"0x05 in dictionary key", "a\005a=1", 5, absl::nullopt}, + {"0x06 in dictionary key", "a\006a=1", 5, absl::nullopt}, + {"0x07 in dictionary key", "a\aa=1", 5, absl::nullopt}, + {"0x08 in dictionary key", "a\ba=1", 5, absl::nullopt}, + {"0x09 in dictionary key", "a\ta=1", 5, absl::nullopt}, + {"0x0a in dictionary key", "a\na=1", 5, absl::nullopt}, + {"0x0b in dictionary key", "a\va=1", 5, absl::nullopt}, + {"0x0c in dictionary key", "a\fa=1", 5, absl::nullopt}, + {"0x0d in dictionary key", "a\ra=1", 5, absl::nullopt}, + {"0x0e in dictionary key", "a\016a=1", 5, absl::nullopt}, + {"0x0f in dictionary key", "a\017a=1", 5, absl::nullopt}, + {"0x10 in dictionary key", "a\020a=1", 5, absl::nullopt}, + {"0x11 in dictionary key", "a\021a=1", 5, absl::nullopt}, + {"0x12 in dictionary key", "a\022a=1", 5, absl::nullopt}, + {"0x13 in dictionary key", "a\023a=1", 5, absl::nullopt}, + {"0x14 in dictionary key", "a\024a=1", 5, absl::nullopt}, + {"0x15 in dictionary key", "a\025a=1", 5, absl::nullopt}, + {"0x16 in dictionary key", "a\026a=1", 5, absl::nullopt}, + {"0x17 in dictionary key", "a\027a=1", 5, absl::nullopt}, + {"0x18 in dictionary key", "a\030a=1", 5, absl::nullopt}, + {"0x19 in dictionary key", "a\031a=1", 5, absl::nullopt}, + {"0x1a in dictionary key", "a\032a=1", 5, absl::nullopt}, + {"0x1b in dictionary key", "a\033a=1", 5, absl::nullopt}, + {"0x1c in dictionary key", "a\034a=1", 5, absl::nullopt}, + {"0x1d in dictionary key", "a\035a=1", 5, absl::nullopt}, + {"0x1e in dictionary key", "a\036a=1", 5, absl::nullopt}, + {"0x1f in dictionary key", "a\037a=1", 5, absl::nullopt}, + {"0x20 in dictionary key", "a a=1", 5, absl::nullopt}, + {"0x21 in dictionary key", "a!a=1", 5, absl::nullopt}, + {"0x22 in dictionary key", "a\"a=1", 5, absl::nullopt}, + {"0x23 in dictionary key", "a#a=1", 5, absl::nullopt}, + {"0x24 in dictionary key", "a$a=1", 5, absl::nullopt}, + {"0x25 in dictionary key", "a%a=1", 5, absl::nullopt}, + {"0x26 in dictionary key", "a&a=1", 5, absl::nullopt}, + {"0x27 in dictionary key", "a'a=1", 5, absl::nullopt}, + {"0x28 in dictionary key", "a(a=1", 5, absl::nullopt}, + {"0x29 in dictionary key", "a)a=1", 5, absl::nullopt}, {"0x2a in dictionary key", "a*a=1", 5, {Dictionary{{{"a*a", {Integer(1), {}}}}}}}, - {"0x2b in dictionary key", "a+a=1", 5, base::nullopt}, + {"0x2b in dictionary key", "a+a=1", 5, absl::nullopt}, {"0x2c in dictionary key", "a,a=1", 5, @@ -2385,7 +2385,7 @@ const struct DictionaryTestCase { "a.a=1", 5, {Dictionary{{{"a.a", {Integer(1), {}}}}}}}, - {"0x2f in dictionary key", "a/a=1", 5, base::nullopt}, + {"0x2f in dictionary key", "a/a=1", 5, absl::nullopt}, {"0x30 in dictionary key", "a0a=1", 5, @@ -2426,51 +2426,51 @@ const struct DictionaryTestCase { "a9a=1", 5, {Dictionary{{{"a9a", {Integer(1), {}}}}}}}, - {"0x3a in dictionary key", "a:a=1", 5, base::nullopt}, + {"0x3a in dictionary key", "a:a=1", 5, absl::nullopt}, {"0x3b in dictionary key", "a;a=1", 5, {Dictionary{{{"a", {Item(true), {Param("a", 1)}}}}}}}, - {"0x3c in dictionary key", "aa=1", 5, base::nullopt}, - {"0x3f in dictionary key", "a?a=1", 5, base::nullopt}, - {"0x40 in dictionary key", "a@a=1", 5, base::nullopt}, - {"0x41 in dictionary key", "aAa=1", 5, base::nullopt}, - {"0x42 in dictionary key", "aBa=1", 5, base::nullopt}, - {"0x43 in dictionary key", "aCa=1", 5, base::nullopt}, - {"0x44 in dictionary key", "aDa=1", 5, base::nullopt}, - {"0x45 in dictionary key", "aEa=1", 5, base::nullopt}, - {"0x46 in dictionary key", "aFa=1", 5, base::nullopt}, - {"0x47 in dictionary key", "aGa=1", 5, base::nullopt}, - {"0x48 in dictionary key", "aHa=1", 5, base::nullopt}, - {"0x49 in dictionary key", "aIa=1", 5, base::nullopt}, - {"0x4a in dictionary key", "aJa=1", 5, base::nullopt}, - {"0x4b in dictionary key", "aKa=1", 5, base::nullopt}, - {"0x4c in dictionary key", "aLa=1", 5, base::nullopt}, - {"0x4d in dictionary key", "aMa=1", 5, base::nullopt}, - {"0x4e in dictionary key", "aNa=1", 5, base::nullopt}, - {"0x4f in dictionary key", "aOa=1", 5, base::nullopt}, - {"0x50 in dictionary key", "aPa=1", 5, base::nullopt}, - {"0x51 in dictionary key", "aQa=1", 5, base::nullopt}, - {"0x52 in dictionary key", "aRa=1", 5, base::nullopt}, - {"0x53 in dictionary key", "aSa=1", 5, base::nullopt}, - {"0x54 in dictionary key", "aTa=1", 5, base::nullopt}, - {"0x55 in dictionary key", "aUa=1", 5, base::nullopt}, - {"0x56 in dictionary key", "aVa=1", 5, base::nullopt}, - {"0x57 in dictionary key", "aWa=1", 5, base::nullopt}, - {"0x58 in dictionary key", "aXa=1", 5, base::nullopt}, - {"0x59 in dictionary key", "aYa=1", 5, base::nullopt}, - {"0x5a in dictionary key", "aZa=1", 5, base::nullopt}, - {"0x5b in dictionary key", "a[a=1", 5, base::nullopt}, - {"0x5c in dictionary key", "a\\a=1", 5, base::nullopt}, - {"0x5d in dictionary key", "a]a=1", 5, base::nullopt}, - {"0x5e in dictionary key", "a^a=1", 5, base::nullopt}, + {"0x3c in dictionary key", "aa=1", 5, absl::nullopt}, + {"0x3f in dictionary key", "a?a=1", 5, absl::nullopt}, + {"0x40 in dictionary key", "a@a=1", 5, absl::nullopt}, + {"0x41 in dictionary key", "aAa=1", 5, absl::nullopt}, + {"0x42 in dictionary key", "aBa=1", 5, absl::nullopt}, + {"0x43 in dictionary key", "aCa=1", 5, absl::nullopt}, + {"0x44 in dictionary key", "aDa=1", 5, absl::nullopt}, + {"0x45 in dictionary key", "aEa=1", 5, absl::nullopt}, + {"0x46 in dictionary key", "aFa=1", 5, absl::nullopt}, + {"0x47 in dictionary key", "aGa=1", 5, absl::nullopt}, + {"0x48 in dictionary key", "aHa=1", 5, absl::nullopt}, + {"0x49 in dictionary key", "aIa=1", 5, absl::nullopt}, + {"0x4a in dictionary key", "aJa=1", 5, absl::nullopt}, + {"0x4b in dictionary key", "aKa=1", 5, absl::nullopt}, + {"0x4c in dictionary key", "aLa=1", 5, absl::nullopt}, + {"0x4d in dictionary key", "aMa=1", 5, absl::nullopt}, + {"0x4e in dictionary key", "aNa=1", 5, absl::nullopt}, + {"0x4f in dictionary key", "aOa=1", 5, absl::nullopt}, + {"0x50 in dictionary key", "aPa=1", 5, absl::nullopt}, + {"0x51 in dictionary key", "aQa=1", 5, absl::nullopt}, + {"0x52 in dictionary key", "aRa=1", 5, absl::nullopt}, + {"0x53 in dictionary key", "aSa=1", 5, absl::nullopt}, + {"0x54 in dictionary key", "aTa=1", 5, absl::nullopt}, + {"0x55 in dictionary key", "aUa=1", 5, absl::nullopt}, + {"0x56 in dictionary key", "aVa=1", 5, absl::nullopt}, + {"0x57 in dictionary key", "aWa=1", 5, absl::nullopt}, + {"0x58 in dictionary key", "aXa=1", 5, absl::nullopt}, + {"0x59 in dictionary key", "aYa=1", 5, absl::nullopt}, + {"0x5a in dictionary key", "aZa=1", 5, absl::nullopt}, + {"0x5b in dictionary key", "a[a=1", 5, absl::nullopt}, + {"0x5c in dictionary key", "a\\a=1", 5, absl::nullopt}, + {"0x5d in dictionary key", "a]a=1", 5, absl::nullopt}, + {"0x5e in dictionary key", "a^a=1", 5, absl::nullopt}, {"0x5f in dictionary key", "a_a=1", 5, {Dictionary{{{"a_a", {Integer(1), {}}}}}}}, - {"0x60 in dictionary key", "a`a=1", 5, base::nullopt}, + {"0x60 in dictionary key", "a`a=1", 5, absl::nullopt}, {"0x61 in dictionary key", "aaa=1", 5, @@ -2575,115 +2575,115 @@ const struct DictionaryTestCase { "aza=1", 5, {Dictionary{{{"aza", {Integer(1), {}}}}}}}, - {"0x7b in dictionary key", "a{a=1", 5, base::nullopt}, - {"0x7c in dictionary key", "a|a=1", 5, base::nullopt}, - {"0x7d in dictionary key", "a}a=1", 5, base::nullopt}, - {"0x7e in dictionary key", "a~a=1", 5, base::nullopt}, - {"0x7f in dictionary key", "a\177a=1", 5, base::nullopt}, - {"0x00 starting an dictionary key", "\000a=1", 4, base::nullopt}, - {"0x01 starting an dictionary key", "\001a=1", 4, base::nullopt}, - {"0x02 starting an dictionary key", "\002a=1", 4, base::nullopt}, - {"0x03 starting an dictionary key", "\003a=1", 4, base::nullopt}, - {"0x04 starting an dictionary key", "\004a=1", 4, base::nullopt}, - {"0x05 starting an dictionary key", "\005a=1", 4, base::nullopt}, - {"0x06 starting an dictionary key", "\006a=1", 4, base::nullopt}, - {"0x07 starting an dictionary key", "\aa=1", 4, base::nullopt}, - {"0x08 starting an dictionary key", "\ba=1", 4, base::nullopt}, - {"0x09 starting an dictionary key", "\ta=1", 4, base::nullopt}, - {"0x0a starting an dictionary key", "\na=1", 4, base::nullopt}, - {"0x0b starting an dictionary key", "\va=1", 4, base::nullopt}, - {"0x0c starting an dictionary key", "\fa=1", 4, base::nullopt}, - {"0x0d starting an dictionary key", "\ra=1", 4, base::nullopt}, - {"0x0e starting an dictionary key", "\016a=1", 4, base::nullopt}, - {"0x0f starting an dictionary key", "\017a=1", 4, base::nullopt}, - {"0x10 starting an dictionary key", "\020a=1", 4, base::nullopt}, - {"0x11 starting an dictionary key", "\021a=1", 4, base::nullopt}, - {"0x12 starting an dictionary key", "\022a=1", 4, base::nullopt}, - {"0x13 starting an dictionary key", "\023a=1", 4, base::nullopt}, - {"0x14 starting an dictionary key", "\024a=1", 4, base::nullopt}, - {"0x15 starting an dictionary key", "\025a=1", 4, base::nullopt}, - {"0x16 starting an dictionary key", "\026a=1", 4, base::nullopt}, - {"0x17 starting an dictionary key", "\027a=1", 4, base::nullopt}, - {"0x18 starting an dictionary key", "\030a=1", 4, base::nullopt}, - {"0x19 starting an dictionary key", "\031a=1", 4, base::nullopt}, - {"0x1a starting an dictionary key", "\032a=1", 4, base::nullopt}, - {"0x1b starting an dictionary key", "\033a=1", 4, base::nullopt}, - {"0x1c starting an dictionary key", "\034a=1", 4, base::nullopt}, - {"0x1d starting an dictionary key", "\035a=1", 4, base::nullopt}, - {"0x1e starting an dictionary key", "\036a=1", 4, base::nullopt}, - {"0x1f starting an dictionary key", "\037a=1", 4, base::nullopt}, + {"0x7b in dictionary key", "a{a=1", 5, absl::nullopt}, + {"0x7c in dictionary key", "a|a=1", 5, absl::nullopt}, + {"0x7d in dictionary key", "a}a=1", 5, absl::nullopt}, + {"0x7e in dictionary key", "a~a=1", 5, absl::nullopt}, + {"0x7f in dictionary key", "a\177a=1", 5, absl::nullopt}, + {"0x00 starting an dictionary key", "\000a=1", 4, absl::nullopt}, + {"0x01 starting an dictionary key", "\001a=1", 4, absl::nullopt}, + {"0x02 starting an dictionary key", "\002a=1", 4, absl::nullopt}, + {"0x03 starting an dictionary key", "\003a=1", 4, absl::nullopt}, + {"0x04 starting an dictionary key", "\004a=1", 4, absl::nullopt}, + {"0x05 starting an dictionary key", "\005a=1", 4, absl::nullopt}, + {"0x06 starting an dictionary key", "\006a=1", 4, absl::nullopt}, + {"0x07 starting an dictionary key", "\aa=1", 4, absl::nullopt}, + {"0x08 starting an dictionary key", "\ba=1", 4, absl::nullopt}, + {"0x09 starting an dictionary key", "\ta=1", 4, absl::nullopt}, + {"0x0a starting an dictionary key", "\na=1", 4, absl::nullopt}, + {"0x0b starting an dictionary key", "\va=1", 4, absl::nullopt}, + {"0x0c starting an dictionary key", "\fa=1", 4, absl::nullopt}, + {"0x0d starting an dictionary key", "\ra=1", 4, absl::nullopt}, + {"0x0e starting an dictionary key", "\016a=1", 4, absl::nullopt}, + {"0x0f starting an dictionary key", "\017a=1", 4, absl::nullopt}, + {"0x10 starting an dictionary key", "\020a=1", 4, absl::nullopt}, + {"0x11 starting an dictionary key", "\021a=1", 4, absl::nullopt}, + {"0x12 starting an dictionary key", "\022a=1", 4, absl::nullopt}, + {"0x13 starting an dictionary key", "\023a=1", 4, absl::nullopt}, + {"0x14 starting an dictionary key", "\024a=1", 4, absl::nullopt}, + {"0x15 starting an dictionary key", "\025a=1", 4, absl::nullopt}, + {"0x16 starting an dictionary key", "\026a=1", 4, absl::nullopt}, + {"0x17 starting an dictionary key", "\027a=1", 4, absl::nullopt}, + {"0x18 starting an dictionary key", "\030a=1", 4, absl::nullopt}, + {"0x19 starting an dictionary key", "\031a=1", 4, absl::nullopt}, + {"0x1a starting an dictionary key", "\032a=1", 4, absl::nullopt}, + {"0x1b starting an dictionary key", "\033a=1", 4, absl::nullopt}, + {"0x1c starting an dictionary key", "\034a=1", 4, absl::nullopt}, + {"0x1d starting an dictionary key", "\035a=1", 4, absl::nullopt}, + {"0x1e starting an dictionary key", "\036a=1", 4, absl::nullopt}, + {"0x1f starting an dictionary key", "\037a=1", 4, absl::nullopt}, {"0x20 starting an dictionary key", " a=1", 4, {Dictionary{{{"a", {Integer(1), {}}}}}}, "a=1"}, - {"0x21 starting an dictionary key", "!a=1", 4, base::nullopt}, - {"0x22 starting an dictionary key", "\"a=1", 4, base::nullopt}, - {"0x23 starting an dictionary key", "#a=1", 4, base::nullopt}, - {"0x24 starting an dictionary key", "$a=1", 4, base::nullopt}, - {"0x25 starting an dictionary key", "%a=1", 4, base::nullopt}, - {"0x26 starting an dictionary key", "&a=1", 4, base::nullopt}, - {"0x27 starting an dictionary key", "'a=1", 4, base::nullopt}, - {"0x28 starting an dictionary key", "(a=1", 4, base::nullopt}, - {"0x29 starting an dictionary key", ")a=1", 4, base::nullopt}, + {"0x21 starting an dictionary key", "!a=1", 4, absl::nullopt}, + {"0x22 starting an dictionary key", "\"a=1", 4, absl::nullopt}, + {"0x23 starting an dictionary key", "#a=1", 4, absl::nullopt}, + {"0x24 starting an dictionary key", "$a=1", 4, absl::nullopt}, + {"0x25 starting an dictionary key", "%a=1", 4, absl::nullopt}, + {"0x26 starting an dictionary key", "&a=1", 4, absl::nullopt}, + {"0x27 starting an dictionary key", "'a=1", 4, absl::nullopt}, + {"0x28 starting an dictionary key", "(a=1", 4, absl::nullopt}, + {"0x29 starting an dictionary key", ")a=1", 4, absl::nullopt}, {"0x2a starting an dictionary key", "*a=1", 4, {Dictionary{{{"*a", {Integer(1), {}}}}}}}, - {"0x2b starting an dictionary key", "+a=1", 4, base::nullopt}, - {"0x2c starting an dictionary key", ",a=1", 4, base::nullopt}, - {"0x2d starting an dictionary key", "-a=1", 4, base::nullopt}, - {"0x2e starting an dictionary key", ".a=1", 4, base::nullopt}, - {"0x2f starting an dictionary key", "/a=1", 4, base::nullopt}, - {"0x30 starting an dictionary key", "0a=1", 4, base::nullopt}, - {"0x31 starting an dictionary key", "1a=1", 4, base::nullopt}, - {"0x32 starting an dictionary key", "2a=1", 4, base::nullopt}, - {"0x33 starting an dictionary key", "3a=1", 4, base::nullopt}, - {"0x34 starting an dictionary key", "4a=1", 4, base::nullopt}, - {"0x35 starting an dictionary key", "5a=1", 4, base::nullopt}, - {"0x36 starting an dictionary key", "6a=1", 4, base::nullopt}, - {"0x37 starting an dictionary key", "7a=1", 4, base::nullopt}, - {"0x38 starting an dictionary key", "8a=1", 4, base::nullopt}, - {"0x39 starting an dictionary key", "9a=1", 4, base::nullopt}, - {"0x3a starting an dictionary key", ":a=1", 4, base::nullopt}, - {"0x3b starting an dictionary key", ";a=1", 4, base::nullopt}, - {"0x3c starting an dictionary key", "a=1", 4, base::nullopt}, - {"0x3f starting an dictionary key", "?a=1", 4, base::nullopt}, - {"0x40 starting an dictionary key", "@a=1", 4, base::nullopt}, - {"0x41 starting an dictionary key", "Aa=1", 4, base::nullopt}, - {"0x42 starting an dictionary key", "Ba=1", 4, base::nullopt}, - {"0x43 starting an dictionary key", "Ca=1", 4, base::nullopt}, - {"0x44 starting an dictionary key", "Da=1", 4, base::nullopt}, - {"0x45 starting an dictionary key", "Ea=1", 4, base::nullopt}, - {"0x46 starting an dictionary key", "Fa=1", 4, base::nullopt}, - {"0x47 starting an dictionary key", "Ga=1", 4, base::nullopt}, - {"0x48 starting an dictionary key", "Ha=1", 4, base::nullopt}, - {"0x49 starting an dictionary key", "Ia=1", 4, base::nullopt}, - {"0x4a starting an dictionary key", "Ja=1", 4, base::nullopt}, - {"0x4b starting an dictionary key", "Ka=1", 4, base::nullopt}, - {"0x4c starting an dictionary key", "La=1", 4, base::nullopt}, - {"0x4d starting an dictionary key", "Ma=1", 4, base::nullopt}, - {"0x4e starting an dictionary key", "Na=1", 4, base::nullopt}, - {"0x4f starting an dictionary key", "Oa=1", 4, base::nullopt}, - {"0x50 starting an dictionary key", "Pa=1", 4, base::nullopt}, - {"0x51 starting an dictionary key", "Qa=1", 4, base::nullopt}, - {"0x52 starting an dictionary key", "Ra=1", 4, base::nullopt}, - {"0x53 starting an dictionary key", "Sa=1", 4, base::nullopt}, - {"0x54 starting an dictionary key", "Ta=1", 4, base::nullopt}, - {"0x55 starting an dictionary key", "Ua=1", 4, base::nullopt}, - {"0x56 starting an dictionary key", "Va=1", 4, base::nullopt}, - {"0x57 starting an dictionary key", "Wa=1", 4, base::nullopt}, - {"0x58 starting an dictionary key", "Xa=1", 4, base::nullopt}, - {"0x59 starting an dictionary key", "Ya=1", 4, base::nullopt}, - {"0x5a starting an dictionary key", "Za=1", 4, base::nullopt}, - {"0x5b starting an dictionary key", "[a=1", 4, base::nullopt}, - {"0x5c starting an dictionary key", "\\a=1", 4, base::nullopt}, - {"0x5d starting an dictionary key", "]a=1", 4, base::nullopt}, - {"0x5e starting an dictionary key", "^a=1", 4, base::nullopt}, - {"0x5f starting an dictionary key", "_a=1", 4, base::nullopt}, - {"0x60 starting an dictionary key", "`a=1", 4, base::nullopt}, + {"0x2b starting an dictionary key", "+a=1", 4, absl::nullopt}, + {"0x2c starting an dictionary key", ",a=1", 4, absl::nullopt}, + {"0x2d starting an dictionary key", "-a=1", 4, absl::nullopt}, + {"0x2e starting an dictionary key", ".a=1", 4, absl::nullopt}, + {"0x2f starting an dictionary key", "/a=1", 4, absl::nullopt}, + {"0x30 starting an dictionary key", "0a=1", 4, absl::nullopt}, + {"0x31 starting an dictionary key", "1a=1", 4, absl::nullopt}, + {"0x32 starting an dictionary key", "2a=1", 4, absl::nullopt}, + {"0x33 starting an dictionary key", "3a=1", 4, absl::nullopt}, + {"0x34 starting an dictionary key", "4a=1", 4, absl::nullopt}, + {"0x35 starting an dictionary key", "5a=1", 4, absl::nullopt}, + {"0x36 starting an dictionary key", "6a=1", 4, absl::nullopt}, + {"0x37 starting an dictionary key", "7a=1", 4, absl::nullopt}, + {"0x38 starting an dictionary key", "8a=1", 4, absl::nullopt}, + {"0x39 starting an dictionary key", "9a=1", 4, absl::nullopt}, + {"0x3a starting an dictionary key", ":a=1", 4, absl::nullopt}, + {"0x3b starting an dictionary key", ";a=1", 4, absl::nullopt}, + {"0x3c starting an dictionary key", "a=1", 4, absl::nullopt}, + {"0x3f starting an dictionary key", "?a=1", 4, absl::nullopt}, + {"0x40 starting an dictionary key", "@a=1", 4, absl::nullopt}, + {"0x41 starting an dictionary key", "Aa=1", 4, absl::nullopt}, + {"0x42 starting an dictionary key", "Ba=1", 4, absl::nullopt}, + {"0x43 starting an dictionary key", "Ca=1", 4, absl::nullopt}, + {"0x44 starting an dictionary key", "Da=1", 4, absl::nullopt}, + {"0x45 starting an dictionary key", "Ea=1", 4, absl::nullopt}, + {"0x46 starting an dictionary key", "Fa=1", 4, absl::nullopt}, + {"0x47 starting an dictionary key", "Ga=1", 4, absl::nullopt}, + {"0x48 starting an dictionary key", "Ha=1", 4, absl::nullopt}, + {"0x49 starting an dictionary key", "Ia=1", 4, absl::nullopt}, + {"0x4a starting an dictionary key", "Ja=1", 4, absl::nullopt}, + {"0x4b starting an dictionary key", "Ka=1", 4, absl::nullopt}, + {"0x4c starting an dictionary key", "La=1", 4, absl::nullopt}, + {"0x4d starting an dictionary key", "Ma=1", 4, absl::nullopt}, + {"0x4e starting an dictionary key", "Na=1", 4, absl::nullopt}, + {"0x4f starting an dictionary key", "Oa=1", 4, absl::nullopt}, + {"0x50 starting an dictionary key", "Pa=1", 4, absl::nullopt}, + {"0x51 starting an dictionary key", "Qa=1", 4, absl::nullopt}, + {"0x52 starting an dictionary key", "Ra=1", 4, absl::nullopt}, + {"0x53 starting an dictionary key", "Sa=1", 4, absl::nullopt}, + {"0x54 starting an dictionary key", "Ta=1", 4, absl::nullopt}, + {"0x55 starting an dictionary key", "Ua=1", 4, absl::nullopt}, + {"0x56 starting an dictionary key", "Va=1", 4, absl::nullopt}, + {"0x57 starting an dictionary key", "Wa=1", 4, absl::nullopt}, + {"0x58 starting an dictionary key", "Xa=1", 4, absl::nullopt}, + {"0x59 starting an dictionary key", "Ya=1", 4, absl::nullopt}, + {"0x5a starting an dictionary key", "Za=1", 4, absl::nullopt}, + {"0x5b starting an dictionary key", "[a=1", 4, absl::nullopt}, + {"0x5c starting an dictionary key", "\\a=1", 4, absl::nullopt}, + {"0x5d starting an dictionary key", "]a=1", 4, absl::nullopt}, + {"0x5e starting an dictionary key", "^a=1", 4, absl::nullopt}, + {"0x5f starting an dictionary key", "_a=1", 4, absl::nullopt}, + {"0x60 starting an dictionary key", "`a=1", 4, absl::nullopt}, {"0x61 starting an dictionary key", "aa=1", 4, @@ -2788,11 +2788,11 @@ const struct DictionaryTestCase { "za=1", 4, {Dictionary{{{"za", {Integer(1), {}}}}}}}, - {"0x7b starting an dictionary key", "{a=1", 4, base::nullopt}, - {"0x7c starting an dictionary key", "|a=1", 4, base::nullopt}, - {"0x7d starting an dictionary key", "}a=1", 4, base::nullopt}, - {"0x7e starting an dictionary key", "~a=1", 4, base::nullopt}, - {"0x7f starting an dictionary key", "\177a=1", 4, base::nullopt}, + {"0x7b starting an dictionary key", "{a=1", 4, absl::nullopt}, + {"0x7c starting an dictionary key", "|a=1", 4, absl::nullopt}, + {"0x7d starting an dictionary key", "}a=1", 4, absl::nullopt}, + {"0x7e starting an dictionary key", "~a=1", 4, absl::nullopt}, + {"0x7f starting an dictionary key", "\177a=1", 4, absl::nullopt}, // param-dict.json {"basic parameterised dict", "abc=123;a=1;b=2, def=456, ghi=789;q=9;r=\"+w\"", @@ -2830,9 +2830,9 @@ const struct DictionaryTestCase { {Dictionary{{{"a", {Item("b", Item::kTokenType), {Param("c", 1)}}}, {"d", {Item("e", Item::kTokenType), {Param("f", 2)}}}}}}, "a=b;c=1, d=e;f=2"}, - {"whitespace before = parameterised dict", "a=b;q =0.5", 10, base::nullopt}, - {"whitespace after = parameterised dict", "a=b;q= 0.5", 10, base::nullopt}, - {"whitespace before ; parameterised dict", "a=b ;q=0.5", 10, base::nullopt}, + {"whitespace before = parameterised dict", "a=b;q =0.5", 10, absl::nullopt}, + {"whitespace after = parameterised dict", "a=b;q= 0.5", 10, absl::nullopt}, + {"whitespace before ; parameterised dict", "a=b ;q=0.5", 10, absl::nullopt}, {"whitespace after ; parameterised dict", "a=b; q=0.5", 10, @@ -2853,8 +2853,8 @@ const struct DictionaryTestCase { {Dictionary{{{"a", {Item("b", Item::kTokenType), {Param("c", 1)}}}, {"d", {Item("e", Item::kTokenType), {Param("f", 2)}}}}}}, "a=b;c=1, d=e;f=2"}, - {"trailing comma parameterised list", "a=b; q=1.0,", 11, base::nullopt}, - {"empty item parameterised list", "a=b; q=1.0,,c=d", 15, base::nullopt}, + {"trailing comma parameterised list", "a=b; q=1.0,", 11, absl::nullopt}, + {"empty item parameterised list", "a=b; q=1.0,,c=d", 15, absl::nullopt}, }; } // namespace @@ -2863,7 +2863,7 @@ TEST(StructuredHeaderGeneratedTest, ParseItem) { if (c.raw) { SCOPED_TRACE(c.name); std::string raw{c.raw, c.raw_len}; - base::Optional result = ParseItem(raw); + absl::optional result = ParseItem(raw); EXPECT_EQ(result, c.expected); } } @@ -2874,7 +2874,7 @@ TEST(StructuredHeaderGeneratedTest, ParseList) { if (c.raw) { SCOPED_TRACE(c.name); std::string raw{c.raw, c.raw_len}; - base::Optional result = ParseList(raw); + absl::optional result = ParseList(raw); EXPECT_EQ(result, c.expected); } } @@ -2885,7 +2885,7 @@ TEST(StructuredHeaderGeneratedTest, ParseDictionary) { if (c.raw) { SCOPED_TRACE(c.name); std::string raw{c.raw, c.raw_len}; - base::Optional result = ParseDictionary(raw); + absl::optional result = ParseDictionary(raw); EXPECT_EQ(result, c.expected); } } @@ -2895,7 +2895,7 @@ TEST(StructuredHeaderGeneratedTest, SerializeItem) { for (const auto& c : parameterized_item_test_cases) { SCOPED_TRACE(c.name); if (c.expected) { - base::Optional result = SerializeItem(*c.expected); + absl::optional result = SerializeItem(*c.expected); if (c.raw || c.canonical) { EXPECT_TRUE(result.has_value()); EXPECT_EQ(result.value(), @@ -2911,7 +2911,7 @@ TEST(StructuredHeaderGeneratedTest, SerializeList) { for (const auto& c : list_test_cases) { SCOPED_TRACE(c.name); if (c.expected) { - base::Optional result = SerializeList(*c.expected); + absl::optional result = SerializeList(*c.expected); if (c.raw || c.canonical) { EXPECT_TRUE(result.has_value()); EXPECT_EQ(result.value(), @@ -2927,7 +2927,7 @@ TEST(StructuredHeaderGeneratedTest, SerializeDictionary) { for (const auto& c : dictionary_test_cases) { SCOPED_TRACE(c.name); if (c.expected) { - base::Optional result = SerializeDictionary(*c.expected); + absl::optional result = SerializeDictionary(*c.expected); if (c.raw || c.canonical) { EXPECT_TRUE(result.has_value()); EXPECT_EQ(result.value(), diff --git a/net/http/structured_headers_unittest.cc b/net/http/structured_headers_unittest.cc index ea97a577fad5d0..62b53b0c67e295 100644 --- a/net/http/structured_headers_unittest.cc +++ b/net/http/structured_headers_unittest.cc @@ -61,31 +61,31 @@ std::pair TokenParam(std::string key, std::string value) { const struct ItemTestCase { const char* name; const char* raw; - const base::Optional expected; // nullopt if parse error is expected. + const absl::optional expected; // nullopt if parse error is expected. const char* canonical; // nullptr if parse error is expected, or if canonical // format is identical to raw. } item_test_cases[] = { // Token - {"bad token - item", "abc$@%!", base::nullopt}, + {"bad token - item", "abc$@%!", absl::nullopt}, {"leading whitespace", " foo", Token("foo"), "foo"}, {"trailing whitespace", "foo ", Token("foo"), "foo"}, {"leading asterisk", "*foo", Token("*foo")}, // Number {"long integer", "999999999999999", Integer(999999999999999L)}, {"long negative integer", "-999999999999999", Integer(-999999999999999L)}, - {"too long integer", "1000000000000000", base::nullopt}, - {"negative too long integer", "-1000000000000000", base::nullopt}, + {"too long integer", "1000000000000000", absl::nullopt}, + {"negative too long integer", "-1000000000000000", absl::nullopt}, {"integral decimal", "1.0", Item(1.0)}, // String {"basic string", "\"foo\"", Item("foo")}, - {"non-ascii string", "\"f\xC3\xBC\xC3\xBC\"", base::nullopt}, + {"non-ascii string", "\"f\xC3\xBC\xC3\xBC\"", absl::nullopt}, // Additional tests {"valid quoting containing \\n", "\"\\\\n\"", Item("\\n")}, {"valid quoting containing \\t", "\"\\\\t\"", Item("\\t")}, {"valid quoting containing \\x", "\"\\\\x61\"", Item("\\x61")}, - {"c-style hex escape in string", "\"\\x61\"", base::nullopt}, + {"c-style hex escape in string", "\"\\x61\"", absl::nullopt}, {"valid quoting containing \\u", "\"\\\\u0061\"", Item("\\u0061")}, - {"c-style unicode escape in string", "\"\\u0061\"", base::nullopt}, + {"c-style unicode escape in string", "\"\\u0061\"", absl::nullopt}, }; const ItemTestCase sh09_item_test_cases[] = { @@ -93,29 +93,29 @@ const ItemTestCase sh09_item_test_cases[] = { {"large integer", "9223372036854775807", Integer(9223372036854775807L)}, {"large negative integer", "-9223372036854775807", Integer(-9223372036854775807L)}, - {"too large integer", "9223372036854775808", base::nullopt}, - {"too large negative integer", "-9223372036854775808", base::nullopt}, + {"too large integer", "9223372036854775808", absl::nullopt}, + {"too large negative integer", "-9223372036854775808", absl::nullopt}, // Byte Sequence {"basic binary", "*aGVsbG8=*", Item("hello", Item::kByteSequenceType)}, {"empty binary", "**", Item("", Item::kByteSequenceType)}, {"bad paddding", "*aGVsbG8*", Item("hello", Item::kByteSequenceType), "*aGVsbG8=*"}, - {"bad end delimiter", "*aGVsbG8=", base::nullopt}, - {"extra whitespace", "*aGVsb G8=*", base::nullopt}, - {"extra chars", "*aGVsbG!8=*", base::nullopt}, - {"suffix chars", "*aGVsbG8=!*", base::nullopt}, + {"bad end delimiter", "*aGVsbG8=", absl::nullopt}, + {"extra whitespace", "*aGVsb G8=*", absl::nullopt}, + {"extra chars", "*aGVsbG!8=*", absl::nullopt}, + {"suffix chars", "*aGVsbG8=!*", absl::nullopt}, {"non-zero pad bits", "*iZ==*", Item("\x89", Item::kByteSequenceType), "*iQ==*"}, {"non-ASCII binary", "*/+Ah*", Item("\xFF\xE0!", Item::kByteSequenceType)}, - {"base64url binary", "*_-Ah*", base::nullopt}, - {"token with leading asterisk", "*foo", base::nullopt}, + {"base64url binary", "*_-Ah*", absl::nullopt}, + {"token with leading asterisk", "*foo", absl::nullopt}, }; // For Structured Headers Draft 15 const struct ParameterizedItemTestCase { const char* name; const char* raw; - const base::Optional + const absl::optional expected; // nullopt if parse error is expected. const char* canonical; // nullptr if parse error is expected, or if canonical // format is identical to raw. @@ -143,11 +143,11 @@ const struct ParameterizedItemTestCase { {{Token("text/html"), {Param("a", 1L)}}}, "text/html;a=1"}, {"whitespace before = parameterised item", "text/html, text/plain;q =0.5", - base::nullopt}, + absl::nullopt}, {"whitespace after = parameterised item", "text/html, text/plain;q= 0.5", - base::nullopt}, + absl::nullopt}, {"whitespace before ; parameterised item", "text/html, text/plain ;q=0.5", - base::nullopt}, + absl::nullopt}, {"whitespace after ; parameterised item", "text/plain; q=0.5", {{Token("text/plain"), {DoubleParam("q", 0.5)}}}, @@ -163,7 +163,7 @@ const struct ParameterizedItemTestCase { const struct ListTestCase { const char* name; const char* raw; - const base::Optional expected; // nullopt if parse error is expected. + const absl::optional expected; // nullopt if parse error is expected. const char* canonical; // nullptr if parse error is expected, or if canonical // format is identical to raw. } list_test_cases[] = { @@ -206,7 +206,7 @@ const struct ListTestCase { {{{{{Integer(1L), {}}, {Integer(2L), {}}}, {BooleanParam("a", true)}}, {{{Integer(42L), {}}, {Integer(43L), {}}}, {BooleanParam("b", true)}}}}}, {"extra whitespace before semicolon in parameters on inner list member", - "(a;b ;c b)", base::nullopt}, + "(a;b ;c b)", absl::nullopt}, {"extra whitespace between parameters on inner list member", "(a;b; c b)", {{{{{Token("a"), {BooleanParam("b", true), BooleanParam("c", true)}}, @@ -214,7 +214,7 @@ const struct ListTestCase { {}}}}, "(a;b;c b)"}, {"extra whitespace before semicolon in parameters on inner list", - "(a b);c ;d, (e)", base::nullopt}, + "(a b);c ;d, (e)", absl::nullopt}, {"extra whitespace between parameters on inner list", "(a b);c; d, (e)", {{{{{Token("a"), {}}, {Token("b"), {}}}, @@ -227,7 +227,7 @@ const struct ListTestCase { const struct DictionaryTestCase { const char* name; const char* raw; - const base::Optional + const absl::optional expected; // nullopt if parse error is expected. const char* canonical; // nullptr if parse error is expected, or if canonical // format is identical to raw. @@ -236,7 +236,7 @@ const struct DictionaryTestCase { "en=\"Applepie\", da=:aGVsbG8=:", {Dictionary{{{"en", {Item("Applepie"), {}}}, {"da", {Item("hello", Item::kByteSequenceType), {}}}}}}}, - {"tab separated dictionary", "a=1\t,\tb=2", base::nullopt}, + {"tab separated dictionary", "a=1\t,\tb=2", absl::nullopt}, {"missing value with params dictionary", "a=1, b;foo=9, c=3", {Dictionary{{{"a", {Integer(1L), {}}}, @@ -265,7 +265,7 @@ const struct DictionaryTestCase { TEST(StructuredHeaderTest, ParseBareItem) { for (const auto& c : item_test_cases) { SCOPED_TRACE(c.name); - base::Optional result = ParseBareItem(c.raw); + absl::optional result = ParseBareItem(c.raw); EXPECT_EQ(result, c.expected); } } @@ -274,7 +274,7 @@ TEST(StructuredHeaderTest, ParseBareItem) { TEST(StructuredHeaderTest, ParseItem) { for (const auto& c : parameterized_item_test_cases) { SCOPED_TRACE(c.name); - base::Optional result = ParseItem(c.raw); + absl::optional result = ParseItem(c.raw); EXPECT_EQ(result, c.expected); } } @@ -286,7 +286,7 @@ TEST(StructuredHeaderTest, ParseItem) { TEST(StructuredHeaderTest, ParseSH09Item) { for (const auto& c : sh09_item_test_cases) { SCOPED_TRACE(c.name); - base::Optional result = ParseListOfLists(c.raw); + absl::optional result = ParseListOfLists(c.raw); if (c.expected.has_value()) { EXPECT_TRUE(result.has_value()); EXPECT_EQ(result->size(), 1UL); @@ -304,7 +304,7 @@ TEST(StructuredHeaderTest, ParseSH09Item) { TEST(StructuredHeaderTest, SH09HighPrecisionFloats) { // These values are exactly representable in binary floating point, so no // accuracy issues are expected in this test. - base::Optional result = + absl::optional result = ParseListOfLists("1.03125;-1.03125;12345678901234.5;-12345678901234.5"); ASSERT_TRUE(result.has_value()); EXPECT_EQ(*result, @@ -349,7 +349,7 @@ TEST(StructuredHeaderTest, ParseListOfLists) { }; for (const auto& c : cases) { SCOPED_TRACE(c.name); - base::Optional result = ParseListOfLists(c.raw); + absl::optional result = ParseListOfLists(c.raw); if (!c.expected.empty()) { EXPECT_TRUE(result.has_value()); EXPECT_EQ(*result, c.expected); @@ -401,7 +401,7 @@ TEST(StructuredHeaderTest, ParseParameterisedList) { }; for (const auto& c : cases) { SCOPED_TRACE(c.name); - base::Optional result = ParseParameterisedList(c.raw); + absl::optional result = ParseParameterisedList(c.raw); if (c.expected.empty()) { EXPECT_FALSE(result.has_value()); continue; @@ -419,7 +419,7 @@ TEST(StructuredHeaderTest, ParseParameterisedList) { TEST(StructuredHeaderTest, ParseList) { for (const auto& c : list_test_cases) { SCOPED_TRACE(c.name); - base::Optional result = ParseList(c.raw); + absl::optional result = ParseList(c.raw); EXPECT_EQ(result, c.expected); } } @@ -428,7 +428,7 @@ TEST(StructuredHeaderTest, ParseList) { TEST(StructuredHeaderTest, ParseDictionary) { for (const auto& c : dictionary_test_cases) { SCOPED_TRACE(c.name); - base::Optional result = ParseDictionary(c.raw); + absl::optional result = ParseDictionary(c.raw); EXPECT_EQ(result, c.expected); } } @@ -439,7 +439,7 @@ TEST(StructuredHeaderTest, SerializeItem) { for (const auto& c : item_test_cases) { SCOPED_TRACE(c.name); if (c.expected) { - base::Optional result = SerializeItem(*c.expected); + absl::optional result = SerializeItem(*c.expected); EXPECT_TRUE(result.has_value()); EXPECT_EQ(result.value(), std::string(c.canonical ? c.canonical : c.raw)); } @@ -450,7 +450,7 @@ TEST(StructuredHeaderTest, SerializeParameterizedItem) { for (const auto& c : parameterized_item_test_cases) { SCOPED_TRACE(c.name); if (c.expected) { - base::Optional result = SerializeItem(*c.expected); + absl::optional result = SerializeItem(*c.expected); EXPECT_TRUE(result.has_value()); EXPECT_EQ(result.value(), std::string(c.canonical ? c.canonical : c.raw)); } @@ -487,7 +487,7 @@ TEST(StructuredHeaderTest, UnserializableTokens) { }; for (const auto& bad_token : bad_tokens) { SCOPED_TRACE(bad_token.name); - base::Optional serialization = + absl::optional serialization = SerializeItem(Token(bad_token.value)); EXPECT_FALSE(serialization.has_value()) << *serialization; } @@ -519,7 +519,7 @@ TEST(StructuredHeaderTest, UnserializableKeys) { }; for (const auto& bad_key : bad_keys) { SCOPED_TRACE(bad_key.name); - base::Optional serialization = + absl::optional serialization = SerializeItem(ParameterizedItem("a", {{bad_key.value, "a"}})); EXPECT_FALSE(serialization.has_value()) << *serialization; } @@ -540,7 +540,7 @@ TEST(StructuredHeaderTest, UnserializableStrings) { }; for (const auto& bad_string : bad_strings) { SCOPED_TRACE(bad_string.name); - base::Optional serialization = + absl::optional serialization = SerializeItem(Item(bad_string.value)); EXPECT_FALSE(serialization.has_value()) << *serialization; } @@ -599,7 +599,7 @@ TEST(StructuredHeaderTest, SerializeUnparseableDecimals) { }; for (const auto& test_case : float_test_cases) { SCOPED_TRACE(test_case.name); - base::Optional serialization = + absl::optional serialization = SerializeItem(Item(test_case.value)); EXPECT_TRUE(serialization.has_value()); EXPECT_EQ(*serialization, test_case.canonical); @@ -610,7 +610,7 @@ TEST(StructuredHeaderTest, SerializeList) { for (const auto& c : list_test_cases) { SCOPED_TRACE(c.name); if (c.expected) { - base::Optional result = SerializeList(*c.expected); + absl::optional result = SerializeList(*c.expected); EXPECT_TRUE(result.has_value()); EXPECT_EQ(result.value(), std::string(c.canonical ? c.canonical : c.raw)); } @@ -637,7 +637,7 @@ TEST(StructuredHeaderTest, UnserializableLists) { }; for (const auto& bad_list : bad_lists) { SCOPED_TRACE(bad_list.name); - base::Optional serialization = SerializeList(bad_list.value); + absl::optional serialization = SerializeList(bad_list.value); EXPECT_FALSE(serialization.has_value()) << *serialization; } } @@ -646,7 +646,7 @@ TEST(StructuredHeaderTest, SerializeDictionary) { for (const auto& c : dictionary_test_cases) { SCOPED_TRACE(c.name); if (c.expected) { - base::Optional result = SerializeDictionary(*c.expected); + absl::optional result = SerializeDictionary(*c.expected); EXPECT_TRUE(result.has_value()); EXPECT_EQ(result.value(), std::string(c.canonical ? c.canonical : c.raw)); } @@ -735,7 +735,7 @@ TEST(StructuredHeaderTest, UnserializableDictionary) { }; for (const auto& bad_dictionary : bad_dictionaries) { SCOPED_TRACE(bad_dictionary.name); - base::Optional serialization = + absl::optional serialization = SerializeDictionary(bad_dictionary.value); EXPECT_FALSE(serialization.has_value()) << *serialization; } diff --git a/net/http/transport_security_persister.cc b/net/http/transport_security_persister.cc index 8fa281256c0a3e..7523178f721b1f 100644 --- a/net/http/transport_security_persister.cc +++ b/net/http/transport_security_persister.cc @@ -16,7 +16,6 @@ #include "base/json/json_writer.h" #include "base/location.h" #include "base/metrics/histogram_macros.h" -#include "base/optional.h" #include "base/sequenced_task_runner.h" #include "base/task_runner_util.h" #include "base/threading/thread_task_runner_handle.h" @@ -26,6 +25,7 @@ #include "net/base/network_isolation_key.h" #include "net/cert/x509_certificate.h" #include "net/http/transport_security_state.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -144,10 +144,10 @@ void DeserializeSTSData(const base::Value& sts_list, continue; const std::string* hostname = sts_entry.FindStringKey(kHostname); - base::Optional sts_include_subdomains = + absl::optional sts_include_subdomains = sts_entry.FindBoolKey(kStsIncludeSubdomains); - base::Optional sts_observed = sts_entry.FindDoubleKey(kStsObserved); - base::Optional expiry = sts_entry.FindDoubleKey(kExpiry); + absl::optional sts_observed = sts_entry.FindDoubleKey(kStsObserved); + absl::optional expiry = sts_entry.FindDoubleKey(kExpiry); const std::string* mode = sts_entry.FindStringKey(kMode); if (!hostname || !sts_include_subdomains.has_value() || @@ -235,11 +235,11 @@ void DeserializeExpectCTData(const base::Value& ct_list, const std::string* hostname = ct_entry.FindStringKey(kHostname); const base::Value* network_isolation_key_value = ct_entry.FindKey(kNetworkIsolationKey); - base::Optional expect_ct_last_observed = + absl::optional expect_ct_last_observed = ct_entry.FindDoubleKey(kExpectCTObserved); - base::Optional expect_ct_expiry = + absl::optional expect_ct_expiry = ct_entry.FindDoubleKey(kExpectCTExpiry); - base::Optional expect_ct_enforce = + absl::optional expect_ct_enforce = ct_entry.FindBoolKey(kExpectCTEnforce); const std::string* expect_ct_report_uri = ct_entry.FindStringKey(kExpectCTReportUri); @@ -370,11 +370,11 @@ bool TransportSecurityPersister::LoadEntries(const std::string& serialized) { bool TransportSecurityPersister::Deserialize(const std::string& serialized, TransportSecurityState* state) { - base::Optional value = base::JSONReader::Read(serialized); + absl::optional value = base::JSONReader::Read(serialized); if (!value || !value->is_dict()) return false; - base::Optional version = value->FindIntKey(kVersionKey); + absl::optional version = value->FindIntKey(kVersionKey); // Stop if the data is out of date (or in the previous format that didn't have // a version number). diff --git a/net/http/transport_security_state.cc b/net/http/transport_security_state.cc index 3faeff14d45799..c736aef8be8837 100644 --- a/net/http/transport_security_state.cc +++ b/net/http/transport_security_state.cc @@ -22,7 +22,6 @@ #include "base/metrics/field_trial_params.h" #include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_macros.h" -#include "base/optional.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" @@ -45,6 +44,7 @@ #include "net/http/http_security_headers.h" #include "net/net_buildflags.h" #include "net/ssl/ssl_info.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -1194,7 +1194,7 @@ bool TransportSecurityState::GetDynamicSTSState(const std::string& host, // An entry matches if it is either an exact match, or if it is a prefix // match and the includeSubDomains directive was included. if (i == 0 || j->second.include_subdomains) { - base::Optional dotted_name = + absl::optional dotted_name = DnsDomainToString(host_sub_chunk); if (!dotted_name) return false; @@ -1240,7 +1240,7 @@ bool TransportSecurityState::GetDynamicPKPState(const std::string& host, // implement HPKP, so this logic is only used via AddHPKP(), reachable from // Cronet. if (i == 0 || j->second.include_subdomains) { - base::Optional dotted_name = + absl::optional dotted_name = DnsDomainToString(host_sub_chunk); if (!dotted_name) return false; diff --git a/net/http/transport_security_state_unittest.cc b/net/http/transport_security_state_unittest.cc index f35c486e4126f8..6d6cff5ee827dc 100644 --- a/net/http/transport_security_state_unittest.cc +++ b/net/http/transport_security_state_unittest.cc @@ -264,7 +264,7 @@ void CheckHPKPReport( const scoped_refptr& served_certificate_chain, const scoped_refptr& validated_certificate_chain, const HashValueVector& known_pins) { - base::Optional value = base::JSONReader::Read(report); + absl::optional value = base::JSONReader::Read(report); ASSERT_TRUE(value.has_value()); const base::Value& report_dict = value.value(); ASSERT_TRUE(report_dict.is_dict()); @@ -273,11 +273,11 @@ void CheckHPKPReport( ASSERT_TRUE(report_hostname); EXPECT_EQ(host_port_pair.host(), *report_hostname); - base::Optional report_port = report_dict.FindIntKey("port"); + absl::optional report_port = report_dict.FindIntKey("port"); ASSERT_TRUE(report_port.has_value()); EXPECT_EQ(host_port_pair.port(), report_port.value()); - base::Optional report_include_subdomains = + absl::optional report_include_subdomains = report_dict.FindBoolKey("include-subdomains"); ASSERT_TRUE(report_include_subdomains.has_value()); EXPECT_EQ(include_subdomains, report_include_subdomains.value()); diff --git a/net/log/file_net_log_observer.cc b/net/log/file_net_log_observer.cc index 337ff2a1892992..72b540a6651ec4 100644 --- a/net/log/file_net_log_observer.cc +++ b/net/log/file_net_log_observer.cc @@ -201,7 +201,7 @@ class FileNetLogObserver::FileWriter { // If max_event_file_size == kNoLimit, then no limit is enforced. FileWriter(const base::FilePath& log_path, const base::FilePath& inprogress_dir_path, - base::Optional pre_existing_log_file, + absl::optional pre_existing_log_file, uint64_t max_event_file_size, size_t total_num_event_files, scoped_refptr task_runner); @@ -336,7 +336,7 @@ std::unique_ptr FileNetLogObserver::CreateBounded( NetLogCaptureMode capture_mode, std::unique_ptr constants) { return CreateInternal(log_path, SiblingInprogressDirectory(log_path), - base::nullopt, max_total_size, kDefaultNumFiles, + absl::nullopt, max_total_size, kDefaultNumFiles, capture_mode, std::move(constants)); } @@ -344,7 +344,7 @@ std::unique_ptr FileNetLogObserver::CreateUnbounded( const base::FilePath& log_path, NetLogCaptureMode capture_mode, std::unique_ptr constants) { - return CreateInternal(log_path, base::FilePath(), base::nullopt, kNoLimit, + return CreateInternal(log_path, base::FilePath(), absl::nullopt, kNoLimit, kDefaultNumFiles, capture_mode, std::move(constants)); } @@ -356,7 +356,7 @@ FileNetLogObserver::CreateBoundedPreExisting( NetLogCaptureMode capture_mode, std::unique_ptr constants) { return CreateInternal(base::FilePath(), inprogress_dir_path, - base::make_optional(std::move(output_file)), + absl::make_optional(std::move(output_file)), max_total_size, kDefaultNumFiles, capture_mode, std::move(constants)); } @@ -367,7 +367,7 @@ FileNetLogObserver::CreateUnboundedPreExisting( NetLogCaptureMode capture_mode, std::unique_ptr constants) { return CreateInternal(base::FilePath(), base::FilePath(), - base::make_optional(std::move(output_file)), + absl::make_optional(std::move(output_file)), kNoLimit, kDefaultNumFiles, capture_mode, std::move(constants)); } @@ -433,14 +433,14 @@ std::unique_ptr FileNetLogObserver::CreateBoundedForTests( NetLogCaptureMode capture_mode, std::unique_ptr constants) { return CreateInternal(log_path, SiblingInprogressDirectory(log_path), - base::nullopt, max_total_size, total_num_event_files, + absl::nullopt, max_total_size, total_num_event_files, capture_mode, std::move(constants)); } std::unique_ptr FileNetLogObserver::CreateInternal( const base::FilePath& log_path, const base::FilePath& inprogress_dir_path, - base::Optional pre_existing_log_file, + absl::optional pre_existing_log_file, uint64_t max_total_size, size_t total_num_event_files, NetLogCaptureMode capture_mode, @@ -545,7 +545,7 @@ FileNetLogObserver::WriteQueue::~WriteQueue() = default; FileNetLogObserver::FileWriter::FileWriter( const base::FilePath& log_path, const base::FilePath& inprogress_dir_path, - base::Optional pre_existing_log_file, + absl::optional pre_existing_log_file, uint64_t max_event_file_size, size_t total_num_event_files, scoped_refptr task_runner) diff --git a/net/log/file_net_log_observer.h b/net/log/file_net_log_observer.h index 2ed9862b2d8941..a7a641f632a0e0 100644 --- a/net/log/file_net_log_observer.h +++ b/net/log/file_net_log_observer.h @@ -12,9 +12,9 @@ #include "base/files/file.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "net/base/net_export.h" #include "net/log/net_log.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { class Value; @@ -126,7 +126,7 @@ class NET_EXPORT FileNetLogObserver : public NetLog::ThreadSafeObserver { static std::unique_ptr CreateInternal( const base::FilePath& log_path, const base::FilePath& inprogress_dir_path, - base::Optional pre_existing_out_file, + absl::optional pre_existing_out_file, uint64_t max_total_size, size_t total_num_event_files, NetLogCaptureMode capture_mode, diff --git a/net/log/net_log_unittest.cc b/net/log/net_log_unittest.cc index 4bd1cf1d38366b..f83b334c298342 100644 --- a/net/log/net_log_unittest.cc +++ b/net/log/net_log_unittest.cc @@ -414,7 +414,7 @@ TEST(NetLogTest, NetLogTwoObservers) { // Add event and make sure both observers receive it at their respective log // levels. - base::Optional param; + absl::optional param; AddEvent(&net_log); ASSERT_EQ(1U, observer[0].GetNumValues()); param = observer[0].GetValue(0)->FindIntKey("params"); diff --git a/net/log/test_net_log_util.cc b/net/log/test_net_log_util.cc index 25551cc1543cdf..5d50b275ad0eed 100644 --- a/net/log/test_net_log_util.cc +++ b/net/log/test_net_log_util.cc @@ -123,34 +123,34 @@ size_t ExpectLogContainsSomewhereAfter(const std::vector& entries, return i; } -base::Optional GetOptionalStringValueFromParams( +absl::optional GetOptionalStringValueFromParams( const NetLogEntry& entry, base::StringPiece path) { if (!entry.params.is_dict()) - return base::nullopt; + return absl::nullopt; const std::string* result = entry.params.FindStringPath(path); if (!result) - return base::nullopt; + return absl::nullopt; return *result; } -base::Optional GetOptionalBooleanValueFromParams(const NetLogEntry& entry, +absl::optional GetOptionalBooleanValueFromParams(const NetLogEntry& entry, base::StringPiece path) { if (!entry.params.is_dict()) - return base::nullopt; + return absl::nullopt; return entry.params.FindBoolPath(path); } -base::Optional GetOptionalIntegerValueFromParams(const NetLogEntry& entry, +absl::optional GetOptionalIntegerValueFromParams(const NetLogEntry& entry, base::StringPiece path) { if (!entry.params.is_dict()) - return base::nullopt; + return absl::nullopt; return entry.params.FindIntPath(path); } -base::Optional GetOptionalNetErrorCodeFromParams( +absl::optional GetOptionalNetErrorCodeFromParams( const NetLogEntry& entry) { return GetOptionalIntegerValueFromParams(entry, "net_error"); } diff --git a/net/log/test_net_log_util.h b/net/log/test_net_log_util.h index 96cb1ca2c3da33..fb9593141142db 100644 --- a/net/log/test_net_log_util.h +++ b/net/log/test_net_log_util.h @@ -7,10 +7,10 @@ #include -#include "base/optional.h" #include "base/strings/string_piece.h" #include "net/log/net_log_event_type.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { class ListValue; @@ -75,14 +75,14 @@ size_t ExpectLogContainsSomewhereAfter(const std::vector& entries, // The following methods return a parameter of the given type at the given path, // or nullopt if there is none. -base::Optional GetOptionalStringValueFromParams( +absl::optional GetOptionalStringValueFromParams( const NetLogEntry& entry, base::StringPiece path); -base::Optional GetOptionalBooleanValueFromParams(const NetLogEntry& entry, +absl::optional GetOptionalBooleanValueFromParams(const NetLogEntry& entry, base::StringPiece path); -base::Optional GetOptionalIntegerValueFromParams(const NetLogEntry& entry, +absl::optional GetOptionalIntegerValueFromParams(const NetLogEntry& entry, base::StringPiece path); -base::Optional GetOptionalNetErrorCodeFromParams(const NetLogEntry& entry); +absl::optional GetOptionalNetErrorCodeFromParams(const NetLogEntry& entry); // Same as the *Optional* versions above, except will add a Gtest failure if the // value was not present, and then return some default. diff --git a/net/network_error_logging/network_error_logging_service.cc b/net/network_error_logging/network_error_logging_service.cc index 7408915a1d9ac0..b2faaaa72b14a5 100644 --- a/net/network_error_logging/network_error_logging_service.cc +++ b/net/network_error_logging/network_error_logging_service.cc @@ -14,7 +14,6 @@ #include "base/json/json_reader.h" #include "base/logging.h" #include "base/metrics/histogram_macros.h" -#include "base/optional.h" #include "base/rand_util.h" #include "base/stl_util.h" #include "base/time/clock.h" @@ -28,6 +27,7 @@ #include "net/base/url_util.h" #include "net/log/net_log.h" #include "net/reporting/reporting_service.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/origin.h" @@ -479,7 +479,7 @@ class NetworkErrorLoggingServiceImpl : public NetworkErrorLoggingService { } bool success = (type == OK) && !IsHttpError(details); - const base::Optional sampling_fraction = + const absl::optional sampling_fraction = SampleAndReturnFraction(*policy, success); if (!sampling_fraction.has_value()) return; @@ -528,7 +528,7 @@ class NetworkErrorLoggingServiceImpl : public NetworkErrorLoggingService { RequestOutcome::kDiscardedIPAddressMismatch); return; } - const base::Optional sampling_fraction = + const absl::optional sampling_fraction = SampleAndReturnFraction(*policy, details.success); if (!sampling_fraction.has_value()) { RecordSignedExchangeRequestOutcome( @@ -823,7 +823,7 @@ class NetworkErrorLoggingServiceImpl : public NetworkErrorLoggingService { } // Returns a valid value of matching fraction iff the event should be sampled. - base::Optional SampleAndReturnFraction(const NelPolicy& policy, + absl::optional SampleAndReturnFraction(const NelPolicy& policy, bool success) const { const double sampling_fraction = success ? policy.success_fraction : policy.failure_fraction; @@ -831,12 +831,12 @@ class NetworkErrorLoggingServiceImpl : public NetworkErrorLoggingService { // Sampling fractions are often either 0.0 or 1.0, so in those cases we // can avoid having to call RandDouble(). if (sampling_fraction <= 0.0) - return base::nullopt; + return absl::nullopt; if (sampling_fraction >= 1.0) return sampling_fraction; if (base::RandDouble() >= sampling_fraction) - return base::nullopt; + return absl::nullopt; return sampling_fraction; } diff --git a/net/nqe/connectivity_monitor.cc b/net/nqe/connectivity_monitor.cc index 09ea0334fb78d8..db330c7cbeffec 100644 --- a/net/nqe/connectivity_monitor.cc +++ b/net/nqe/connectivity_monitor.cc @@ -190,10 +190,10 @@ void ConnectivityMonitor::SetReportCallbackForTesting( report_callback_for_testing_ = std::move(callback); } -base::Optional +absl::optional ConnectivityMonitor::GetTimeSinceLastFailureForTesting() { if (!time_last_failure_observed_) - return base::nullopt; + return absl::nullopt; return base::TimeTicks::Now() - *time_last_failure_observed_; } @@ -212,7 +212,7 @@ void ConnectivityMonitor::OnNetworkMadeDefault( #if defined(OS_ANDROID) NetworkChangeType change_type = NetworkChangeType::kNoEarlyActivation; if (mobile_network_request_) { - const base::Optional& + const absl::optional& activated_network = mobile_network_request_->activated_network(); if (!activated_network) { change_type = NetworkChangeType::kEarlyActivationOfUnknownNetwork; diff --git a/net/nqe/connectivity_monitor.h b/net/nqe/connectivity_monitor.h index a49445b20bb39d..39ef1b5210f534 100644 --- a/net/nqe/connectivity_monitor.h +++ b/net/nqe/connectivity_monitor.h @@ -13,12 +13,12 @@ #include "base/callback.h" #include "base/cancelable_callback.h" -#include "base/optional.h" #include "base/time/time.h" #include "build/build_config.h" #include "net/base/net_export.h" #include "net/base/network_change_notifier.h" #include "net/url_request/url_request.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -76,7 +76,7 @@ class NET_EXPORT_PRIVATE ConnectivityMonitor // Returns the amount of time since the ConnectivityMonitor first observed the // current lapse in connectivity, if any. - base::Optional GetTimeSinceLastFailureForTesting(); + absl::optional GetTimeSinceLastFailureForTesting(); // Registers a callback to hook into any time an activity deadline is reached. void SetNextDeadlineCallbackForTesting(base::OnceClosure callback); @@ -109,7 +109,7 @@ class NET_EXPORT_PRIVATE ConnectivityMonitor std::set active_requests_; base::CancelableOnceClosure next_activity_deadline_; - base::Optional time_last_failure_observed_; + absl::optional time_last_failure_observed_; NetworkChangeNotifier::ConnectionType current_connection_type_; diff --git a/net/nqe/connectivity_monitor_unittest.cc b/net/nqe/connectivity_monitor_unittest.cc index 8b504711d25b80..d603be7b87f7b7 100644 --- a/net/nqe/connectivity_monitor_unittest.cc +++ b/net/nqe/connectivity_monitor_unittest.cc @@ -6,7 +6,6 @@ #include -#include "base/optional.h" #include "base/run_loop.h" #include "base/test/bind.h" #include "base/test/metrics/histogram_tester.h" @@ -22,6 +21,7 @@ #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_test_util.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { namespace { @@ -108,7 +108,7 @@ class ConnectivityMonitorTest ConnectivityMonitor connectivity_monitor_{kInactivityThreshold, kMinFailureLoggingInterval}; TestDelegate test_url_request_delegate_; - base::Optional network_change_wait_loop_; + absl::optional network_change_wait_loop_; }; INSTANTIATE_TEST_SUITE_P(, ConnectivityMonitorTest, testing::Bool()); @@ -142,7 +142,7 @@ TEST_P(ConnectivityMonitorTest, NetworkChangeResetsState) { FastForwardTimeBy(base::TimeDelta::FromDays(42)); SimulateSwitchToMobileNetwork(); EXPECT_EQ(0u, monitor().num_active_requests_for_testing()); - EXPECT_EQ(base::nullopt, monitor().GetTimeSinceLastFailureForTesting()); + EXPECT_EQ(absl::nullopt, monitor().GetTimeSinceLastFailureForTesting()); } TEST_P(ConnectivityMonitorTest, BasicStalledRequest) { @@ -158,7 +158,7 @@ TEST_P(ConnectivityMonitorTest, BasicStalledRequest) { // Pass some time, but not enough to suspect connectivity issues. FastForwardTimeBy(kUpdateInterval); EXPECT_FALSE(deadline_reached); - EXPECT_EQ(base::nullopt, monitor().GetTimeSinceLastFailureForTesting()); + EXPECT_EQ(absl::nullopt, monitor().GetTimeSinceLastFailureForTesting()); // Simulate additional passage of time to trigger connectivity failure // observation. @@ -191,13 +191,13 @@ TEST_P(ConnectivityMonitorTest, MultipleRequests) { // Pass some time, but not enough to suspect connectivity issues. FastForwardTimeBy(kUpdateInterval); - EXPECT_EQ(base::nullopt, monitor().GetTimeSinceLastFailureForTesting()); + EXPECT_EQ(absl::nullopt, monitor().GetTimeSinceLastFailureForTesting()); // Simulate progress on one but not both requests. Connectivity failure should // still not be detected due to the first request's progress. monitor().NotifyRequestProgress(*request1); FastForwardTimeBy(kInactivityThreshold - kUpdateInterval); - EXPECT_EQ(base::nullopt, monitor().GetTimeSinceLastFailureForTesting()); + EXPECT_EQ(absl::nullopt, monitor().GetTimeSinceLastFailureForTesting()); // Pass enough time to trigger a failure. FastForwardTimeBy(kUpdateInterval); @@ -241,7 +241,7 @@ TEST_P(ConnectivityMonitorTest, OnlyReportToOSWithFeatureEnabled) { // Pass some time, but not enough to suspect connectivity issues. FastForwardTimeBy(kUpdateInterval); EXPECT_FALSE(reported_to_os); - EXPECT_EQ(base::nullopt, monitor().GetTimeSinceLastFailureForTesting()); + EXPECT_EQ(absl::nullopt, monitor().GetTimeSinceLastFailureForTesting()); // Simulate additional passage of time to trigger connectivity failure // observation. If the ReportPoorConnectivity feature is enabled, this should diff --git a/net/nqe/effective_connection_type.cc b/net/nqe/effective_connection_type.cc index e9d9aa710e2ca8..f227a865ff4dcb 100644 --- a/net/nqe/effective_connection_type.cc +++ b/net/nqe/effective_connection_type.cc @@ -43,7 +43,7 @@ const char* GetNameForEffectiveConnectionType(EffectiveConnectionType type) { return ""; } -base::Optional GetEffectiveConnectionTypeForName( +absl::optional GetEffectiveConnectionTypeForName( base::StringPiece connection_type_name) { if (connection_type_name == kEffectiveConnectionTypeUnknown) return EFFECTIVE_CONNECTION_TYPE_UNKNOWN; @@ -61,7 +61,7 @@ base::Optional GetEffectiveConnectionTypeForName( return EFFECTIVE_CONNECTION_TYPE_3G; if (connection_type_name == kEffectiveConnectionType4G) return EFFECTIVE_CONNECTION_TYPE_4G; - return base::nullopt; + return absl::nullopt; } const char* DeprecatedGetNameForEffectiveConnectionType( diff --git a/net/nqe/effective_connection_type.h b/net/nqe/effective_connection_type.h index 518cc9083cdb13..445801dce5f143 100644 --- a/net/nqe/effective_connection_type.h +++ b/net/nqe/effective_connection_type.h @@ -5,9 +5,9 @@ #ifndef NET_NQE_EFFECTIVE_CONNECTION_TYPE_H_ #define NET_NQE_EFFECTIVE_CONNECTION_TYPE_H_ -#include "base/optional.h" #include "base/strings/string_piece.h" #include "net/base/net_export.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -69,7 +69,7 @@ NET_EXPORT const char* GetNameForEffectiveConnectionType( // |connection_type_name|. If the effective connection type is unavailable or if // |connection_type_name| does not match to a known effective connection type, // an unset value is returned. -NET_EXPORT base::Optional +NET_EXPORT absl::optional GetEffectiveConnectionTypeForName(base::StringPiece connection_type_name); // Returns the string equivalent of |type|. Deprecated, and replaced by diff --git a/net/nqe/effective_connection_type_unittest.cc b/net/nqe/effective_connection_type_unittest.cc index 1aa0f0450e34d1..0c32da17c78475 100644 --- a/net/nqe/effective_connection_type_unittest.cc +++ b/net/nqe/effective_connection_type_unittest.cc @@ -6,8 +6,8 @@ #include -#include "base/optional.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -48,7 +48,7 @@ TEST(EffectiveConnectionTypeTest, Slow2GTypeConversion) { // GetEffectiveConnectionTypeForName should return Slow2G as effective // connection type for both the deprecated and the current string // representation. - base::Optional type = + absl::optional type = GetEffectiveConnectionTypeForName("Slow2G"); EXPECT_EQ(EFFECTIVE_CONNECTION_TYPE_SLOW_2G, type.value()); diff --git a/net/nqe/network_qualities_prefs_manager.cc b/net/nqe/network_qualities_prefs_manager.cc index f0fe9c350038bf..f960ad9a96e46b 100644 --- a/net/nqe/network_qualities_prefs_manager.cc +++ b/net/nqe/network_qualities_prefs_manager.cc @@ -9,11 +9,11 @@ #include "base/bind.h" #include "base/metrics/histogram_macros_local.h" -#include "base/optional.h" #include "base/rand_util.h" #include "base/sequenced_task_runner.h" #include "base/threading/thread_task_runner_handle.h" #include "net/nqe/network_quality_estimator.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -44,7 +44,7 @@ ParsedPrefs ConvertDictionaryValueToMap(const base::DictionaryValue* value) { it.second.GetAsString(&effective_connection_type_string); DCHECK(effective_connection_type_available); - base::Optional effective_connection_type = + absl::optional effective_connection_type = GetEffectiveConnectionTypeForName(effective_connection_type_string); DCHECK(effective_connection_type.has_value()); diff --git a/net/nqe/network_quality_estimator.cc b/net/nqe/network_quality_estimator.cc index c61b62e997fbae..1ebb0b78061860 100644 --- a/net/nqe/network_quality_estimator.cc +++ b/net/nqe/network_quality_estimator.cc @@ -564,7 +564,7 @@ void NetworkQualityEstimator::OnConnectionTypeChanged( min_signal_strength_since_connection_change_.reset(); max_signal_strength_since_connection_change_.reset(); network_quality_ = nqe::internal::NetworkQuality(); - end_to_end_rtt_ = base::nullopt; + end_to_end_rtt_ = absl::nullopt; effective_connection_type_ = EFFECTIVE_CONNECTION_TYPE_UNKNOWN; effective_connection_type_at_last_main_frame_ = EFFECTIVE_CONNECTION_TYPE_UNKNOWN; @@ -627,19 +627,19 @@ void NetworkQualityEstimator::ContinueGatherEstimatesForNextConnectionType( ComputeEffectiveConnectionType(); } -base::Optional +absl::optional NetworkQualityEstimator::GetCurrentSignalStrengthWithThrottling() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (!params_->get_signal_strength_and_detailed_network_id()) - return base::nullopt; + return absl::nullopt; if (params_->weight_multiplier_per_signal_strength_level() >= 1.0) - return base::nullopt; + return absl::nullopt; if ((current_network_id_.type != NetworkChangeNotifier::CONNECTION_WIFI) && !NetworkChangeNotifier::IsConnectionCellular(current_network_id_.type)) { - return base::nullopt; + return absl::nullopt; } // Do not call more than once per |wifi_signal_strength_query_interval| @@ -649,7 +649,7 @@ NetworkQualityEstimator::GetCurrentSignalStrengthWithThrottling() { params_->wifi_signal_strength_query_interval()) && (last_signal_strength_check_timestamp_.value() > last_connection_change_)) { - return base::nullopt; + return absl::nullopt; } last_signal_strength_check_timestamp_ = tick_clock_->NowTicks(); @@ -669,14 +669,14 @@ NetworkQualityEstimator::GetCurrentSignalStrengthWithThrottling() { #endif // OS_ANDROID } - return base::nullopt; + return absl::nullopt; } void NetworkQualityEstimator::UpdateSignalStrength() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); int32_t past_signal_strength = current_network_id_.signal_strength; - base::Optional new_signal_strength = + absl::optional new_signal_strength = GetCurrentSignalStrengthWithThrottling(); // A fresh value is unavailable. So, return early. @@ -814,7 +814,7 @@ void NetworkQualityEstimator::ComputeEffectiveConnectionType() { if (end_to_end_rtt != nqe::internal::InvalidRTT()) { UMA_HISTOGRAM_TIMES("NQE.EndToEndRTT.OnECTComputation", end_to_end_rtt); } - end_to_end_rtt_ = base::nullopt; + end_to_end_rtt_ = absl::nullopt; if (end_to_end_rtt != nqe::internal::InvalidRTT()) end_to_end_rtt_ = end_to_end_rtt; @@ -842,9 +842,9 @@ void NetworkQualityEstimator::ComputeEffectiveConnectionType() { new_throughput_observations_since_last_ect_computation_ = 0; } -base::Optional +absl::optional NetworkQualityEstimator::GetOverrideECT() const { - return base::nullopt; + return absl::nullopt; } void NetworkQualityEstimator::ClampKbpsBasedOnEct() { @@ -1013,7 +1013,7 @@ EffectiveConnectionType NetworkQualityEstimator::GetEffectiveConnectionType() const { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - base::Optional override_ect = GetOverrideECT(); + absl::optional override_ect = GetOverrideECT(); if (override_ect) { return override_ect.value(); } @@ -1388,7 +1388,7 @@ void NetworkQualityEstimator::SetTickClockForTesting( void NetworkQualityEstimator::OnUpdatedTransportRTTAvailable( SocketPerformanceWatcherFactory::Protocol protocol, const base::TimeDelta& rtt, - const base::Optional& host) { + const absl::optional& host) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_LT(nqe::internal::INVALID_RTT_THROUGHPUT, rtt.InMilliseconds()); Observation observation(rtt.InMilliseconds(), tick_clock_->NowTicks(), @@ -1557,7 +1557,7 @@ void NetworkQualityEstimator:: DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_NE(EFFECTIVE_CONNECTION_TYPE_LAST, effective_connection_type_); - base::Optional override_ect = GetOverrideECT(); + absl::optional override_ect = GetOverrideECT(); // TODO(tbansal): Add hysteresis in the notification. for (auto& observer : effective_connection_type_observer_list_) @@ -1588,7 +1588,7 @@ void NetworkQualityEstimator::NotifyEffectiveConnectionTypeObserverIfPresent( if (!effective_connection_type_observer_list_.HasObserver(observer)) return; - base::Optional override_ect = GetOverrideECT(); + absl::optional override_ect = GetOverrideECT(); if (override_ect) { observer->OnEffectiveConnectionTypeChanged(override_ect.value()); return; @@ -1670,30 +1670,30 @@ void NetworkQualityEstimator::EnableGetNetworkIdAsynchronously() { } #endif // BUILDFLAG(IS_CHROMEOS_ASH) -base::Optional NetworkQualityEstimator::GetHttpRTT() const { +absl::optional NetworkQualityEstimator::GetHttpRTT() const { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (network_quality_.http_rtt() == nqe::internal::InvalidRTT()) - return base::Optional(); + return absl::optional(); return network_quality_.http_rtt(); } -base::Optional NetworkQualityEstimator::GetTransportRTT() +absl::optional NetworkQualityEstimator::GetTransportRTT() const { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (network_quality_.transport_rtt() == nqe::internal::InvalidRTT()) - return base::Optional(); + return absl::optional(); return network_quality_.transport_rtt(); } -base::Optional NetworkQualityEstimator::GetDownstreamThroughputKbps() +absl::optional NetworkQualityEstimator::GetDownstreamThroughputKbps() const { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (network_quality_.downstream_throughput_kbps() == nqe::internal::INVALID_RTT_THROUGHPUT) { - return base::Optional(); + return absl::optional(); } return network_quality_.downstream_throughput_kbps(); } @@ -1780,7 +1780,7 @@ void NetworkQualityEstimator::OnPeerToPeerConnectionsCountChange( LOCAL_HISTOGRAM_CUSTOM_TIMES("NQE.PeerToPeerConnectionsDuration", duration, base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromHours(1), 50); - p2p_connections_count_active_timestamp_ = base::nullopt; + p2p_connections_count_active_timestamp_ = absl::nullopt; } p2p_connections_count_ = count; diff --git a/net/nqe/network_quality_estimator.h b/net/nqe/network_quality_estimator.h index 6ef1eacb1eb29c..4c8d636b75d735 100644 --- a/net/nqe/network_quality_estimator.h +++ b/net/nqe/network_quality_estimator.h @@ -18,7 +18,6 @@ #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" -#include "base/optional.h" #include "base/sequence_checker.h" #include "base/time/time.h" #include "build/build_config.h" @@ -40,6 +39,7 @@ #include "net/nqe/peer_to_peer_connections_count_observer.h" #include "net/nqe/rtt_throughput_estimates_observer.h" #include "net/nqe/socket_watcher_factory.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { class TickClock; @@ -147,18 +147,18 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator // time from when the request was sent (this happens after the connection is // established) to the time when the response headers were received. // Virtualized for testing. - virtual base::Optional GetHttpRTT() const; + virtual absl::optional GetHttpRTT() const; // Returns the current transport RTT estimate. If the estimate is // unavailable, the returned optional value is null. The RTT at the transport // layer provides an aggregate estimate of the transport RTT as computed by // various underlying TCP and QUIC connections. Virtualized for testing. - virtual base::Optional GetTransportRTT() const; + virtual absl::optional GetTransportRTT() const; // Returns the current downstream throughput estimate (in kilobits per // second). If the estimate is unavailable, the returned optional value is // null. - base::Optional GetDownstreamThroughputKbps() const; + absl::optional GetDownstreamThroughputKbps() const; // Adds |observer| to the list of RTT and throughput estimate observers. // The observer must register and unregister itself on the same thread. @@ -338,7 +338,7 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator void OnUpdatedTransportRTTAvailable( SocketPerformanceWatcherFactory::Protocol protocol, const base::TimeDelta& rtt, - const base::Optional& host); + const absl::optional& host); // Returns an estimate of network quality at the specified |percentile|. // Only the observations later than |start_time| are taken into account. @@ -392,7 +392,7 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator // 4 to ensure that a change in the value indicates a non-negligible change in // the signal quality. To reduce the number of Android API calls, it returns // a null value if the signal strength was recently obtained. - virtual base::Optional GetCurrentSignalStrengthWithThrottling(); + virtual absl::optional GetCurrentSignalStrengthWithThrottling(); // Forces computation of effective connection type, and notifies observers // if there is a change in its value. @@ -400,7 +400,7 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator // Returns a non-null value if the value of the effective connection type has // been overridden for testing. - virtual base::Optional GetOverrideECT() const; + virtual absl::optional GetOverrideECT() const; // Observer list for RTT or throughput estimates. Protected for testing. base::ObserverList::Unchecked @@ -552,7 +552,7 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator // Earliest timestamp since when there is at least one active peer to peer // connection count. Set to current timestamp when |p2p_connections_count_| // changes from 0 to 1. Reset to null when |p2p_connections_count_| becomes 0. - base::Optional p2p_connections_count_active_timestamp_; + absl::optional p2p_connections_count_active_timestamp_; // Determines if the requests to local host can be used in estimating the // network quality. Set to true only for tests. @@ -629,7 +629,7 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator // Current estimate of the network quality. nqe::internal::NetworkQuality network_quality_; - base::Optional end_to_end_rtt_; + absl::optional end_to_end_rtt_; // Current effective connection type. It is updated on connection change // events. It is also updated every time there is network traffic (provided @@ -639,8 +639,8 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator // Minimum and maximum signal strength level observed since last connection // change. Updated on connection change and main frame requests. - base::Optional min_signal_strength_since_connection_change_; - base::Optional max_signal_strength_since_connection_change_; + absl::optional min_signal_strength_since_connection_change_; + absl::optional max_signal_strength_since_connection_change_; // Stores the qualities of different networks. std::unique_ptr network_quality_store_; @@ -659,7 +659,7 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator // Time when the last RTT observation from a socket watcher was received. base::TimeTicks last_socket_watcher_rtt_notification_; - base::Optional last_signal_strength_check_timestamp_; + absl::optional last_signal_strength_check_timestamp_; #if BUILDFLAG(IS_CHROMEOS_ASH) // Whether the network id should be obtained on a worker thread. diff --git a/net/nqe/network_quality_estimator_params.cc b/net/nqe/network_quality_estimator_params.cc index c3e4e5c46f3d7b..0940489c366d63 100644 --- a/net/nqe/network_quality_estimator_params.cc +++ b/net/nqe/network_quality_estimator_params.cc @@ -405,13 +405,13 @@ bool GetForcedEffectiveConnectionTypeOnCellularOnly( kEffectiveConnectionTypeSlow2GOnCellular; } -base::Optional GetInitForcedEffectiveConnectionType( +absl::optional GetInitForcedEffectiveConnectionType( const std::map& params) { if (GetForcedEffectiveConnectionTypeOnCellularOnly(params)) { - return base::nullopt; + return absl::nullopt; } std::string forced_value = GetForcedEffectiveConnectionTypeString(params); - base::Optional ect = + absl::optional ect = GetEffectiveConnectionTypeForName(forced_value); DCHECK(forced_value.empty() || ect); return ect; @@ -581,7 +581,7 @@ void NetworkQualityEstimatorParams::SetForcedEffectiveConnectionTypeForTesting( forced_effective_connection_type_ = type; } -base::Optional +absl::optional NetworkQualityEstimatorParams::GetForcedEffectiveConnectionType( NetworkChangeNotifier::ConnectionType connection_type) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); @@ -593,7 +593,7 @@ NetworkQualityEstimatorParams::GetForcedEffectiveConnectionType( net::NetworkChangeNotifier::IsConnectionCellular(connection_type)) { return EFFECTIVE_CONNECTION_TYPE_SLOW_2G; } - return base::nullopt; + return absl::nullopt; } size_t NetworkQualityEstimatorParams::throughput_min_requests_in_flight() diff --git a/net/nqe/network_quality_estimator_params.h b/net/nqe/network_quality_estimator_params.h index 773c44e5be3cd3..185d21741376cf 100644 --- a/net/nqe/network_quality_estimator_params.h +++ b/net/nqe/network_quality_estimator_params.h @@ -9,12 +9,12 @@ #include #include "base/macros.h" -#include "base/optional.h" #include "base/sequence_checker.h" #include "net/base/net_export.h" #include "net/base/network_change_notifier.h" #include "net/nqe/effective_connection_type.h" #include "net/nqe/network_quality.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -80,7 +80,7 @@ class NET_EXPORT NetworkQualityEstimatorParams { // the effective connection type that has been forced. Forced ECT can be // forced based on |connection_type| (e.g. Slow-2G on cellular, and default on // other connection type). - base::Optional GetForcedEffectiveConnectionType( + absl::optional GetForcedEffectiveConnectionType( NetworkChangeNotifier::ConnectionType connection_type); void SetForcedEffectiveConnectionType( @@ -290,7 +290,7 @@ class NET_EXPORT NetworkQualityEstimatorParams { const double throughput_hanging_requests_cwnd_size_multiplier_; const double weight_multiplier_per_second_; const double weight_multiplier_per_signal_strength_level_; - base::Optional forced_effective_connection_type_; + absl::optional forced_effective_connection_type_; const bool forced_effective_connection_type_on_cellular_only_; bool persistent_cache_reading_enabled_; const base::TimeDelta min_socket_watcher_notification_interval_; diff --git a/net/nqe/network_quality_estimator_params_unittest.cc b/net/nqe/network_quality_estimator_params_unittest.cc index aa6c98bb087a32..59139be1178fde 100644 --- a/net/nqe/network_quality_estimator_params_unittest.cc +++ b/net/nqe/network_quality_estimator_params_unittest.cc @@ -126,7 +126,7 @@ TEST(NetworkQualityEstimatorParamsTest, GetForcedECTCellularOnly) { ++i) { NetworkChangeNotifier::ConnectionType connection_type = static_cast(i); - base::Optional ect = + absl::optional ect = params.GetForcedEffectiveConnectionType(connection_type); if (net::NetworkChangeNotifier::IsConnectionCellular(connection_type)) { @@ -135,7 +135,7 @@ TEST(NetworkQualityEstimatorParamsTest, GetForcedECTCellularOnly) { } else { // Test for non-cellular connection types. Make sure that there is no // forced ect. - EXPECT_EQ(base::nullopt, ect); + EXPECT_EQ(absl::nullopt, ect); } } } diff --git a/net/nqe/network_quality_estimator_test_util.cc b/net/nqe/network_quality_estimator_test_util.cc index c9c133d684a1c8..11f4f5fadc97b9 100644 --- a/net/nqe/network_quality_estimator_test_util.cc +++ b/net/nqe/network_quality_estimator_test_util.cc @@ -206,7 +206,7 @@ bool TestNetworkQualityEstimator::GetRecentRTT( rtt, observations_count); } -base::Optional TestNetworkQualityEstimator::GetTransportRTT() +absl::optional TestNetworkQualityEstimator::GetTransportRTT() const { if (start_time_null_transport_rtt_) return start_time_null_transport_rtt_; @@ -297,7 +297,7 @@ void TestNetworkQualityEstimator:: observer.OnEffectiveConnectionTypeChanged(type); } -base::Optional +absl::optional TestNetworkQualityEstimator::GetOverrideECT() const { return effective_connection_type_; } @@ -327,7 +327,7 @@ nqe::internal::NetworkID TestNetworkQualityEstimator::GetCurrentNetworkID() INT32_MIN); } -base::Optional +absl::optional TestNetworkQualityEstimator::GetCurrentSignalStrengthWithThrottling() { if (current_cellular_signal_strength_) { return current_cellular_signal_strength_; diff --git a/net/nqe/network_quality_estimator_test_util.h b/net/nqe/network_quality_estimator_test_util.h index 35eb978819995f..1b2cc87c06cd8c 100644 --- a/net/nqe/network_quality_estimator_test_util.h +++ b/net/nqe/network_quality_estimator_test_util.h @@ -15,7 +15,6 @@ #include "base/files/file_path.h" #include "base/macros.h" -#include "base/optional.h" #include "base/time/time.h" #include "net/base/network_change_notifier.h" #include "net/log/net_log.h" @@ -24,6 +23,7 @@ #include "net/nqe/network_quality_estimator.h" #include "net/test/embedded_test_server/embedded_test_server.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace net { @@ -136,7 +136,7 @@ class TestNetworkQualityEstimator : public NetworkQualityEstimator { recent_transport_rtt_ = recent_transport_rtt; } - base::Optional GetTransportRTT() const override; + absl::optional GetTransportRTT() const override; void set_start_time_null_downlink_throughput_kbps( int32_t downlink_throughput_kbps) { @@ -230,7 +230,7 @@ class TestNetworkQualityEstimator : public NetworkQualityEstimator { // NetworkQualityEstimator implementation that returns the overridden // network id and signal strength (instead of invoking platform APIs). - base::Optional GetCurrentSignalStrengthWithThrottling() override; + absl::optional GetCurrentSignalStrengthWithThrottling() override; private: class LocalHttpTestServer : public EmbeddedTestServer { @@ -246,15 +246,15 @@ class TestNetworkQualityEstimator : public NetworkQualityEstimator { // network id and signal strength (instead of invoking platform APIs). nqe::internal::NetworkID GetCurrentNetworkID() const override; - base::Optional GetOverrideECT() const override; + absl::optional GetOverrideECT() const override; // Net log provided to network quality estimator. std::unique_ptr net_log_; // If set, GetEffectiveConnectionType() and GetRecentEffectiveConnectionType() // would return the set values, respectively. - base::Optional effective_connection_type_; - base::Optional recent_effective_connection_type_; + absl::optional effective_connection_type_; + absl::optional recent_effective_connection_type_; NetworkChangeNotifier::ConnectionType current_network_type_; std::string current_network_id_; @@ -262,29 +262,29 @@ class TestNetworkQualityEstimator : public NetworkQualityEstimator { // If set, GetRecentHttpRTT() would return one of the set values. // |start_time_null_http_rtt_| is returned if the |start_time| is null. // Otherwise, |recent_http_rtt_| is returned. - base::Optional start_time_null_http_rtt_; - base::Optional recent_http_rtt_; + absl::optional start_time_null_http_rtt_; + absl::optional recent_http_rtt_; // If set, GetRecentTransportRTT() would return one of the set values. // |start_time_null_transport_rtt_| is returned if the |start_time| is null. // Otherwise, |recent_transport_rtt_| is returned. - base::Optional start_time_null_transport_rtt_; - base::Optional recent_transport_rtt_; + absl::optional start_time_null_transport_rtt_; + absl::optional recent_transport_rtt_; // If set, GetRecentDownlinkThroughputKbps() would return one of the set // values. |start_time_null_downlink_throughput_kbps_| is returned if the // |start_time| is null. Otherwise, |recent_downlink_throughput_kbps_| is // returned. - base::Optional start_time_null_downlink_throughput_kbps_; - base::Optional recent_downlink_throughput_kbps_; + absl::optional start_time_null_downlink_throughput_kbps_; + absl::optional recent_downlink_throughput_kbps_; // If set, GetRTTEstimateInternal() would return the set value. - base::Optional rtt_estimate_internal_; + absl::optional rtt_estimate_internal_; // If set, GetRTTEstimateInternal() would return the set value. - base::Optional start_time_null_end_to_end_rtt_; + absl::optional start_time_null_end_to_end_rtt_; - base::Optional current_cellular_signal_strength_; + absl::optional current_cellular_signal_strength_; LocalHttpTestServer embedded_test_server_; @@ -293,7 +293,7 @@ class TestNetworkQualityEstimator : public NetworkQualityEstimator { size_t ping_rtt_received_count_ = 0; - base::Optional transport_rtt_observation_count_last_ect_computation_; + absl::optional transport_rtt_observation_count_last_ect_computation_; DISALLOW_COPY_AND_ASSIGN(TestNetworkQualityEstimator); }; diff --git a/net/nqe/network_quality_estimator_unittest.cc b/net/nqe/network_quality_estimator_unittest.cc index e958d910f02eb6..52a598124cd366 100644 --- a/net/nqe/network_quality_estimator_unittest.cc +++ b/net/nqe/network_quality_estimator_unittest.cc @@ -17,7 +17,6 @@ #include "base/check_op.h" #include "base/macros.h" #include "base/metrics/histogram_samples.h" -#include "base/optional.h" #include "base/run_loop.h" #include "base/strings/string_number_conversions.h" #include "base/task/thread_pool/thread_pool_instance.h" @@ -47,6 +46,7 @@ #include "net/url_request/url_request.h" #include "net/url_request/url_request_test_util.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace { @@ -563,10 +563,10 @@ TEST_F(NetworkQualityEstimatorTest, QuicObservations) { TestNetworkQualityEstimator estimator(variation_params); estimator.OnUpdatedTransportRTTAvailable( SocketPerformanceWatcherFactory::PROTOCOL_TCP, - base::TimeDelta::FromMilliseconds(10), base::nullopt); + base::TimeDelta::FromMilliseconds(10), absl::nullopt); estimator.OnUpdatedTransportRTTAvailable( SocketPerformanceWatcherFactory::PROTOCOL_QUIC, - base::TimeDelta::FromMilliseconds(10), base::nullopt); + base::TimeDelta::FromMilliseconds(10), absl::nullopt); histogram_tester.ExpectBucketCount("NQE.RTT.ObservationSource", NETWORK_QUALITY_OBSERVATION_SOURCE_TCP, 1); histogram_tester.ExpectBucketCount( @@ -590,7 +590,7 @@ TEST_F(NetworkQualityEstimatorTest, TestNetworkQualityEstimator estimator(variation_params); estimator.OnUpdatedTransportRTTAvailable( SocketPerformanceWatcherFactory::PROTOCOL_QUIC, - base::TimeDelta::FromMilliseconds(10), base::nullopt); + base::TimeDelta::FromMilliseconds(10), absl::nullopt); histogram_tester.ExpectBucketCount( "NQE.RTT.ObservationSource", NETWORK_QUALITY_OBSERVATION_SOURCE_QUIC, 1); histogram_tester.ExpectTotalCount("NQE.EndToEndRTT.OnECTComputation", 1); @@ -3078,7 +3078,7 @@ TEST_F(NetworkQualityEstimatorTest, MAYBE_CheckSignalStrength) { estimator.SetTickClockForTesting(&tick_clock); base::HistogramTester histogram_tester; - base::Optional signal_strength = + absl::optional signal_strength = estimator.GetCurrentSignalStrengthWithThrottling(); signal_strength = estimator.GetCurrentSignalStrengthWithThrottling(); @@ -3135,7 +3135,7 @@ TEST_F(NetworkQualityEstimatorTest, CheckSignalStrengthDisabledByDefault) { estimator.SetTickClockForTesting(&tick_clock); - base::Optional signal_strength = + absl::optional signal_strength = estimator.GetCurrentSignalStrengthWithThrottling(); EXPECT_FALSE(signal_strength); diff --git a/net/nqe/network_quality_estimator_util_unittest.cc b/net/nqe/network_quality_estimator_util_unittest.cc index ebb2a28fa07f00..418cef67427fe7 100644 --- a/net/nqe/network_quality_estimator_util_unittest.cc +++ b/net/nqe/network_quality_estimator_util_unittest.cc @@ -6,7 +6,6 @@ #include -#include "base/optional.h" #include "base/test/scoped_feature_list.h" #include "base/test/task_environment.h" #include "build/build_config.h" @@ -21,6 +20,7 @@ #include "net/dns/mock_host_resolver.h" #include "net/log/test_net_log.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace net { @@ -59,10 +59,10 @@ TEST(NetworkQualityEstimatorUtilTest, MAYBE_ReservedHost) { // Load hostnames into HostResolver cache. int rv = mock_host_resolver.LoadIntoCache( - HostPortPair("example1.com", 443), NetworkIsolationKey(), base::nullopt); + HostPortPair("example1.com", 443), NetworkIsolationKey(), absl::nullopt); EXPECT_EQ(OK, rv); rv = mock_host_resolver.LoadIntoCache(HostPortPair("example2.com", 443), - NetworkIsolationKey(), base::nullopt); + NetworkIsolationKey(), absl::nullopt); EXPECT_EQ(OK, rv); EXPECT_EQ(2u, mock_host_resolver.num_non_local_resolves()); @@ -119,7 +119,7 @@ TEST(NetworkQualityEstimatorUtilTest, MAYBE_ReservedHostUncached) { EXPECT_EQ(0u, mock_host_resolver.num_non_local_resolves()); int rv = mock_host_resolver.LoadIntoCache( - HostPortPair("example3.com", 443), NetworkIsolationKey(), base::nullopt); + HostPortPair("example3.com", 443), NetworkIsolationKey(), absl::nullopt); EXPECT_EQ(OK, rv); EXPECT_EQ(1u, mock_host_resolver.num_non_local_resolves()); @@ -168,7 +168,7 @@ TEST(NetworkQualityEstimatorUtilTest, EXPECT_EQ(0u, mock_host_resolver.num_non_local_resolves()); int rv = mock_host_resolver.LoadIntoCache( - HostPortPair("example3.com", 443), kNetworkIsolationKey, base::nullopt); + HostPortPair("example3.com", 443), kNetworkIsolationKey, absl::nullopt); EXPECT_EQ(OK, rv); EXPECT_EQ(1u, mock_host_resolver.num_non_local_resolves()); diff --git a/net/nqe/network_quality_observation.cc b/net/nqe/network_quality_observation.cc index 8f5bf3377b4ccf..12ec3fe8359b0e 100644 --- a/net/nqe/network_quality_observation.cc +++ b/net/nqe/network_quality_observation.cc @@ -18,13 +18,13 @@ Observation::Observation(int32_t value, base::TimeTicks timestamp, int32_t signal_strength, NetworkQualityObservationSource source) - : Observation(value, timestamp, signal_strength, source, base::nullopt) {} + : Observation(value, timestamp, signal_strength, source, absl::nullopt) {} Observation::Observation(int32_t value, base::TimeTicks timestamp, int32_t signal_strength, NetworkQualityObservationSource source, - const base::Optional& host) + const absl::optional& host) : value_(value), timestamp_(timestamp), signal_strength_(signal_strength), diff --git a/net/nqe/network_quality_observation.h b/net/nqe/network_quality_observation.h index 9c5f954127996e..86007e123cc9a9 100644 --- a/net/nqe/network_quality_observation.h +++ b/net/nqe/network_quality_observation.h @@ -9,11 +9,11 @@ #include -#include "base/optional.h" #include "base/time/time.h" #include "net/base/net_export.h" #include "net/nqe/network_quality_estimator_util.h" #include "net/nqe/network_quality_observation_source.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -36,7 +36,7 @@ class NET_EXPORT_PRIVATE Observation { base::TimeTicks timestamp, int32_t signal_strength, NetworkQualityObservationSource source, - const base::Optional& host); + const absl::optional& host); Observation(const Observation& other); Observation& operator=(const Observation& other); @@ -57,7 +57,7 @@ class NET_EXPORT_PRIVATE Observation { NetworkQualityObservationSource source() const { return source_; } // A unique identifier for the remote host which was used for the measurement. - base::Optional host() const { return host_; } + absl::optional host() const { return host_; } // Returns the observation categories to which this observation belongs to. std::vector GetObservationCategories() const; @@ -74,7 +74,7 @@ class NET_EXPORT_PRIVATE Observation { NetworkQualityObservationSource source_; - base::Optional host_; + absl::optional host_; }; } // namespace internal diff --git a/net/nqe/observation_buffer.cc b/net/nqe/observation_buffer.cc index c6ac960721b5bd..0b99d81dbc376b 100644 --- a/net/nqe/observation_buffer.cc +++ b/net/nqe/observation_buffer.cc @@ -71,7 +71,7 @@ void ObservationBuffer::AddObservation(const Observation& observation) { DCHECK_LE(observations_.size(), params_->observation_buffer_size()); } -base::Optional ObservationBuffer::GetPercentile( +absl::optional ObservationBuffer::GetPercentile( base::TimeTicks begin_timestamp, int32_t current_signal_strength, int percentile, @@ -94,7 +94,7 @@ base::Optional ObservationBuffer::GetPercentile( } if (weighted_observations.empty()) - return base::nullopt; + return absl::nullopt; double desired_weight = percentile / 100.0 * total_weight; diff --git a/net/nqe/observation_buffer.h b/net/nqe/observation_buffer.h index d352658131fb63..20acc516b1be76 100644 --- a/net/nqe/observation_buffer.h +++ b/net/nqe/observation_buffer.h @@ -13,12 +13,12 @@ #include #include "base/containers/circular_deque.h" -#include "base/optional.h" #include "base/time/tick_clock.h" #include "net/base/net_export.h" #include "net/nqe/network_quality_estimator_util.h" #include "net/nqe/network_quality_observation.h" #include "net/nqe/network_quality_observation_source.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { @@ -74,7 +74,7 @@ class NET_EXPORT_PRIVATE ObservationBuffer { // signal strength. |result| must not be null. If |observations_count| is not // null, then it is set to the number of observations that were available // in the observation buffer for computing the percentile. - base::Optional GetPercentile(base::TimeTicks begin_timestamp, + absl::optional GetPercentile(base::TimeTicks begin_timestamp, int32_t current_signal_strength, int percentile, size_t* observations_count) const; diff --git a/net/nqe/observation_buffer_unittest.cc b/net/nqe/observation_buffer_unittest.cc index ac9f279c638a03..c0c3afc561e809 100644 --- a/net/nqe/observation_buffer_unittest.cc +++ b/net/nqe/observation_buffer_unittest.cc @@ -68,7 +68,7 @@ TEST(NetworkQualityObservationBufferTest, GetPercentileWithWeights) { for (int i = 1; i <= 100; ++i) { size_t observations_count = 0; // Verify that i'th percentile is more than i-1'th percentile. - base::Optional result_i = observation_buffer.GetPercentile( + absl::optional result_i = observation_buffer.GetPercentile( now, INT32_MIN, i, &observations_count); EXPECT_EQ(100u, observations_count); ASSERT_TRUE(result_i.has_value()); @@ -76,7 +76,7 @@ TEST(NetworkQualityObservationBufferTest, GetPercentileWithWeights) { result_highest = std::max(result_highest, result_i.value()); - base::Optional result_i_1 = observation_buffer.GetPercentile( + absl::optional result_i_1 = observation_buffer.GetPercentile( now, INT32_MIN, i - 1, &observations_count); EXPECT_EQ(100u, observations_count); ASSERT_TRUE(result_i_1.has_value()); @@ -133,7 +133,7 @@ TEST(NetworkQualityObservationBufferTest, PercentileSameTimestamps) { // less than 1. This is required because computed percentiles may be // slightly different from what is expected due to floating point // computation errors and integer rounding off errors. - base::Optional result = buffer.GetPercentile( + absl::optional result = buffer.GetPercentile( base::TimeTicks(), INT32_MIN, i, &observations_count); EXPECT_EQ(100u, observations_count); EXPECT_TRUE(result.has_value()); @@ -199,7 +199,7 @@ TEST(NetworkQualityObservationBufferTest, PercentileDifferentTimestamps) { // required because computed percentiles may be slightly different from // what is expected due to floating point computation errors and integer // rounding off errors. - base::Optional result = + absl::optional result = buffer.GetPercentile(very_old, INT32_MIN, i, &observations_count); EXPECT_TRUE(result.has_value()); EXPECT_NEAR(result.value(), 51 + 0.49 * i, 1); @@ -244,7 +244,7 @@ TEST(NetworkQualityObservationBufferTest, PercentileDifferentRSSI) { // When the current RSSI is |high_rssi|, higher weight should be assigned // to observations that were taken at |high_rssi|. for (int i = 1; i < 100; ++i) { - base::Optional result = + absl::optional result = buffer.GetPercentile(now, high_rssi, i, nullptr); EXPECT_TRUE(result.has_value()); EXPECT_NEAR(result.value(), 51 + 0.49 * i, 2); @@ -253,7 +253,7 @@ TEST(NetworkQualityObservationBufferTest, PercentileDifferentRSSI) { // When the current RSSI is |low_rssi|, higher weight should be assigned // to observations that were taken at |low_rssi|. for (int i = 1; i < 100; ++i) { - base::Optional result = + absl::optional result = buffer.GetPercentile(now, low_rssi, i, nullptr); EXPECT_TRUE(result.has_value()); EXPECT_NEAR(result.value(), i / 2, 2); @@ -314,9 +314,8 @@ TEST(NetworkQualityObservationBufferTest, RemoveObservations) { // required because computed percentiles may be slightly different from // what is expected due to floating point computation errors and integer // rounding off errors. - base::Optional result = - buffer.GetPercentile(base::TimeTicks(), INT32_MIN, i, - nullptr); + absl::optional result = + buffer.GetPercentile(base::TimeTicks(), INT32_MIN, i, nullptr); EXPECT_TRUE(result.has_value()); EXPECT_NEAR(result.value(), i, 1); } @@ -357,7 +356,7 @@ TEST(NetworkQualityObservationBufferTest, TestGetMedianRTTSince) { }; for (const auto& test : tests) { - base::Optional url_request_rtt = + absl::optional url_request_rtt = buffer.GetPercentile(test.start_timestamp, INT32_MIN, 50, nullptr); EXPECT_EQ(test.expect_network_quality_available, url_request_rtt.has_value()); diff --git a/net/nqe/socket_watcher.cc b/net/nqe/socket_watcher.cc index b0daf8eded1efc..129f1d340ed43f 100644 --- a/net/nqe/socket_watcher.cc +++ b/net/nqe/socket_watcher.cc @@ -23,9 +23,9 @@ namespace { // Generate a compact representation for the first IP in |address_list|. For // IPv4, all 32 bits are used and for IPv6, the first 64 bits are used as the // remote host identifier. -base::Optional CalculateIPHash(const AddressList& address_list) { +absl::optional CalculateIPHash(const AddressList& address_list) { if (address_list.empty()) - return base::nullopt; + return absl::nullopt; const IPAddress& ip_addr = address_list.front().address(); diff --git a/net/nqe/socket_watcher.h b/net/nqe/socket_watcher.h index f2b0ea2ecb4f74..07abb55973e042 100644 --- a/net/nqe/socket_watcher.h +++ b/net/nqe/socket_watcher.h @@ -8,13 +8,13 @@ #include "base/callback.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "base/sequence_checker.h" #include "base/time/time.h" #include "net/base/net_export.h" #include "net/nqe/network_quality_estimator_util.h" #include "net/socket/socket_performance_watcher.h" #include "net/socket/socket_performance_watcher_factory.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { class SingleThreadTaskRunner; @@ -31,7 +31,7 @@ namespace { typedef base::RepeatingCallback& host)> + const absl::optional& host)> OnUpdatedRTTAvailableCallback; typedef base::RepeatingCallback ShouldNotifyRTTCallback; @@ -105,7 +105,7 @@ class NET_EXPORT_PRIVATE SocketWatcher : public SocketPerformanceWatcher { bool first_quic_rtt_notification_received_; // A unique identifier for the remote host that this socket connects to. - const base::Optional host_; + const absl::optional host_; DISALLOW_COPY_AND_ASSIGN(SocketWatcher); }; diff --git a/net/nqe/socket_watcher_factory.h b/net/nqe/socket_watcher_factory.h index 769a7b12ed6d40..88c5bbaf06f147 100644 --- a/net/nqe/socket_watcher_factory.h +++ b/net/nqe/socket_watcher_factory.h @@ -10,13 +10,13 @@ #include "base/callback.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "base/sequence_checker.h" #include "base/single_thread_task_runner.h" #include "base/time/time.h" #include "net/nqe/network_quality_estimator_util.h" #include "net/socket/socket_performance_watcher.h" #include "net/socket/socket_performance_watcher_factory.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { class TickClock; @@ -30,7 +30,7 @@ namespace { typedef base::RepeatingCallback& host)> + const absl::optional& host)> OnUpdatedRTTAvailableCallback; typedef base::RepeatingCallback ShouldNotifyRTTCallback; diff --git a/net/nqe/socket_watcher_unittest.cc b/net/nqe/socket_watcher_unittest.cc index cada676153b9f8..ce39ef3ce8565e 100644 --- a/net/nqe/socket_watcher_unittest.cc +++ b/net/nqe/socket_watcher_unittest.cc @@ -33,7 +33,7 @@ class NetworkQualitySocketWatcherTest : public TestWithTaskEnvironment { static void OnUpdatedRTTAvailableStoreParams( SocketPerformanceWatcherFactory::Protocol protocol, const base::TimeDelta& rtt, - const base::Optional& host) { + const absl::optional& host) { // Need to verify before another callback is executed, or explicitly call // |ResetCallbackParams()|. ASSERT_FALSE(callback_executed_); @@ -45,7 +45,7 @@ class NetworkQualitySocketWatcherTest : public TestWithTaskEnvironment { static void OnUpdatedRTTAvailable( SocketPerformanceWatcherFactory::Protocol protocol, const base::TimeDelta& rtt, - const base::Optional& host) { + const absl::optional& host) { // Need to verify before another callback is executed, or explicitly call // |ResetCallbackParams()|. ASSERT_FALSE(callback_executed_); @@ -61,7 +61,7 @@ class NetworkQualitySocketWatcherTest : public TestWithTaskEnvironment { } static void VerifyCallbackParams(const base::TimeDelta& rtt, - const base::Optional& host) { + const absl::optional& host) { ASSERT_TRUE(callback_executed_); EXPECT_EQ(rtt, callback_rtt_); if (host) @@ -73,7 +73,7 @@ class NetworkQualitySocketWatcherTest : public TestWithTaskEnvironment { static void ResetExpectedCallbackParams() { callback_rtt_ = base::TimeDelta::FromMilliseconds(0); - callback_host_ = base::nullopt; + callback_host_ = absl::nullopt; callback_executed_ = false; should_notify_rtt_callback_ = false; } @@ -82,7 +82,7 @@ class NetworkQualitySocketWatcherTest : public TestWithTaskEnvironment { private: static base::TimeDelta callback_rtt_; - static base::Optional callback_host_; + static absl::optional callback_host_; static bool callback_executed_; static bool should_notify_rtt_callback_; @@ -92,8 +92,8 @@ class NetworkQualitySocketWatcherTest : public TestWithTaskEnvironment { base::TimeDelta NetworkQualitySocketWatcherTest::callback_rtt_ = base::TimeDelta::FromMilliseconds(0); -base::Optional NetworkQualitySocketWatcherTest::callback_host_ = - base::nullopt; +absl::optional NetworkQualitySocketWatcherTest::callback_host_ = + absl::nullopt; bool NetworkQualitySocketWatcherTest::callback_executed_ = false; diff --git a/net/nqe/throughput_analyzer.h b/net/nqe/throughput_analyzer.h index a5378cf8c3df41..a243b370da97fe 100644 --- a/net/nqe/throughput_analyzer.h +++ b/net/nqe/throughput_analyzer.h @@ -13,11 +13,11 @@ #include "base/callback.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "base/sequence_checker.h" #include "base/time/time.h" #include "net/base/net_export.h" #include "net/log/net_log_with_source.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace { typedef base::RepeatingCallback ThroughputObservationCallback; diff --git a/net/nqe/throughput_analyzer_unittest.cc b/net/nqe/throughput_analyzer_unittest.cc index 2df3d1d0e88f94..2b65a2f9d7af0e 100644 --- a/net/nqe/throughput_analyzer_unittest.cc +++ b/net/nqe/throughput_analyzer_unittest.cc @@ -94,9 +94,9 @@ class TestThroughputAnalyzer : public internal::ThroughputAnalyzer { rules->AddRule("local.com", "127.0.0.1"); mock_host_resolver_.set_rules(rules.get()); mock_host_resolver_.LoadIntoCache(HostPortPair("example.com", 80), - NetworkIsolationKey(), base::nullopt); + NetworkIsolationKey(), absl::nullopt); mock_host_resolver_.LoadIntoCache(HostPortPair("local.com", 80), - NetworkIsolationKey(), base::nullopt); + NetworkIsolationKey(), absl::nullopt); context->set_host_resolver(&mock_host_resolver_); } @@ -209,7 +209,7 @@ TEST_F(ThroughputAnalyzerTest, MAYBE_MaximumRequestsWithNetworkIsolationKey) { rules->AddRule(kUrl.host(), "1.2.3.4"); mock_host_resolver.set_rules(rules.get()); mock_host_resolver.LoadIntoCache(HostPortPair::FromURL(kUrl), - NetworkIsolationKey(), base::nullopt); + NetworkIsolationKey(), absl::nullopt); // Add an entry to the host cache mapping kUrl to local IP when using // kNetworkIsolationKey. @@ -217,7 +217,7 @@ TEST_F(ThroughputAnalyzerTest, MAYBE_MaximumRequestsWithNetworkIsolationKey) { rules->AddRule(kUrl.host(), "127.0.0.1"); mock_host_resolver.set_rules(rules.get()); mock_host_resolver.LoadIntoCache(HostPortPair::FromURL(kUrl), - kNetworkIsolationKey, base::nullopt); + kNetworkIsolationKey, absl::nullopt); ASSERT_FALSE( throughput_analyzer.disable_throughput_measurements_for_testing()); diff --git a/net/proxy_resolution/configured_proxy_resolution_service.cc b/net/proxy_resolution/configured_proxy_resolution_service.cc index a987dc1cfe8bdf..c2f76e5f2dd7d0 100644 --- a/net/proxy_resolution/configured_proxy_resolution_service.cc +++ b/net/proxy_resolution/configured_proxy_resolution_service.cc @@ -322,7 +322,7 @@ class ProxyResolverFactoryForPacResult : public ProxyResolverFactory { // Returns NetLog parameters describing a proxy configuration change. base::Value NetLogProxyConfigChangedParams( - const base::Optional* old_config, + const absl::optional* old_config, const ProxyConfigWithAnnotation* new_config) { base::Value dict(base::Value::Type::DICTIONARY); // The "old_config" is optional -- the first notification will not have @@ -1341,9 +1341,9 @@ ConfiguredProxyResolutionService::ResetProxyConfig(bool reset_fetched_config) { init_proxy_resolver_.reset(); SuspendAllPendingRequests(); resolver_.reset(); - config_ = base::nullopt; + config_ = absl::nullopt; if (reset_fetched_config) - fetched_config_ = base::nullopt; + fetched_config_ = absl::nullopt; current_state_ = STATE_NONE; return previous_state; diff --git a/net/proxy_resolution/configured_proxy_resolution_service.h b/net/proxy_resolution/configured_proxy_resolution_service.h index b5ee7944bb6ce7..1174be73665f3e 100644 --- a/net/proxy_resolution/configured_proxy_resolution_service.h +++ b/net/proxy_resolution/configured_proxy_resolution_service.h @@ -15,7 +15,6 @@ #include "base/gtest_prod_util.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "base/synchronization/waitable_event.h" #include "base/threading/thread_checker.h" #include "net/base/completion_once_callback.h" @@ -30,6 +29,7 @@ #include "net/proxy_resolution/proxy_resolution_service.h" #include "net/proxy_resolution/proxy_resolver.h" #include "net/traffic_annotation/network_traffic_annotation.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace base { @@ -150,12 +150,12 @@ class NET_EXPORT ConfiguredProxyResolutionService void OnShutdown() override; // Returns the last configuration fetched from ProxyConfigService. - const base::Optional& fetched_config() const { + const absl::optional& fetched_config() const { return fetched_config_; } // Returns the current configuration being used by ProxyConfigService. - const base::Optional& config() const { + const absl::optional& config() const { return config_; } @@ -359,8 +359,8 @@ class NET_EXPORT ConfiguredProxyResolutionService // and custom PAC url). // // These are "optional" as their value remains unset while being calculated. - base::Optional fetched_config_; - base::Optional config_; + absl::optional fetched_config_; + absl::optional config_; // Map of the known bad proxies and the information about the retry time. ProxyRetryInfoMap proxy_retry_info_; diff --git a/net/proxy_resolution/network_delegate_error_observer_unittest.cc b/net/proxy_resolution/network_delegate_error_observer_unittest.cc index bd3ce6bbbea98f..57439a3d4091b4 100644 --- a/net/proxy_resolution/network_delegate_error_observer_unittest.cc +++ b/net/proxy_resolution/network_delegate_error_observer_unittest.cc @@ -7,7 +7,6 @@ #include "base/bind.h" #include "base/callback_helpers.h" #include "base/location.h" -#include "base/optional.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/test/task_environment.h" @@ -16,6 +15,7 @@ #include "net/base/net_errors.h" #include "net/base/network_delegate_impl.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -46,7 +46,7 @@ class TestNetworkDelegate : public NetworkDelegateImpl { const HttpResponseHeaders* original_response_headers, scoped_refptr* override_response_headers, const net::IPEndPoint& endpoint, - base::Optional* preserve_fragment_on_redirect_url) override { + absl::optional* preserve_fragment_on_redirect_url) override { return OK; } void OnBeforeRedirect(URLRequest* request, diff --git a/net/proxy_resolution/pac_file_fetcher_impl_unittest.cc b/net/proxy_resolution/pac_file_fetcher_impl_unittest.cc index 6ea2bb3f0bd34a..41b4d0cffb7cb1 100644 --- a/net/proxy_resolution/pac_file_fetcher_impl_unittest.cc +++ b/net/proxy_resolution/pac_file_fetcher_impl_unittest.cc @@ -11,7 +11,6 @@ #include "base/compiler_specific.h" #include "base/files/file_path.h" #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "base/path_service.h" #include "base/run_loop.h" #include "base/sequenced_task_runner.h" @@ -53,6 +52,7 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" +#include "third_party/abseil-cpp/absl/types/optional.h" using net::test::IsError; using net::test::IsOk; @@ -158,7 +158,7 @@ class BasicNetworkDelegate : public NetworkDelegateImpl { const HttpResponseHeaders* original_response_headers, scoped_refptr* override_response_headers, const net::IPEndPoint& endpoint, - base::Optional* preserve_fragment_on_redirect_url) override { + absl::optional* preserve_fragment_on_redirect_url) override { return OK; } diff --git a/net/proxy_resolution/proxy_config_service_linux.cc b/net/proxy_resolution/proxy_config_service_linux.cc index c697b3b981fa73..baf86b8196051f 100644 --- a/net/proxy_resolution/proxy_config_service_linux.cc +++ b/net/proxy_resolution/proxy_config_service_linux.cc @@ -102,7 +102,7 @@ std::string FixupProxyHostScheme(ProxyServer::Scheme scheme, } ProxyConfigWithAnnotation GetConfigOrDirect( - const base::Optional& optional_config) { + const absl::optional& optional_config) { if (optional_config) return optional_config.value(); @@ -143,7 +143,7 @@ bool ProxyConfigServiceLinux::Delegate::GetProxyFromEnvVar( result_server); } -base::Optional +absl::optional ProxyConfigServiceLinux::Delegate::GetConfigFromEnv() { ProxyConfig config; @@ -214,7 +214,7 @@ ProxyConfigServiceLinux::Delegate::GetConfigFromEnv() { return !no_proxy.empty() ? ProxyConfigWithAnnotation( config, NetworkTrafficAnnotationTag(traffic_annotation_)) - : base::Optional(); + : absl::optional(); } // Note that this uses "suffix" matching. So a bypass of "google.com" // is understood to mean a bypass of "*google.com". @@ -1039,7 +1039,7 @@ bool ProxyConfigServiceLinux::Delegate::GetProxyFromSettings( return false; } -base::Optional +absl::optional ProxyConfigServiceLinux::Delegate::GetConfigFromSettings() { ProxyConfig config; @@ -1047,7 +1047,7 @@ ProxyConfigServiceLinux::Delegate::GetConfigFromSettings() { if (!setting_getter_->GetString(SettingGetter::PROXY_MODE, &mode)) { // We expect this to always be set, so if we don't see it then we probably // have a gsettings problem, and so we don't have a valid proxy config. - return base::nullopt; + return absl::nullopt; } if (mode == "none") { // Specifically specifies no proxy. @@ -1066,7 +1066,7 @@ ProxyConfigServiceLinux::Delegate::GetConfigFromSettings() { pac_url_str = "file://" + pac_url_str; GURL pac_url(pac_url_str); if (!pac_url.is_valid()) - return base::nullopt; + return absl::nullopt; config.set_pac_url(pac_url); return ProxyConfigWithAnnotation( config, NetworkTrafficAnnotationTag(traffic_annotation_)); @@ -1079,7 +1079,7 @@ ProxyConfigServiceLinux::Delegate::GetConfigFromSettings() { if (mode != "manual") { // Mode is unrecognized. - return base::nullopt; + return absl::nullopt; } bool use_http_proxy; if (setting_getter_->GetBool(SettingGetter::PROXY_USE_HTTP_PROXY, @@ -1143,7 +1143,7 @@ ProxyConfigServiceLinux::Delegate::GetConfigFromSettings() { if (config.proxy_rules().empty()) { // Manual mode but we couldn't parse any rules. - return base::nullopt; + return absl::nullopt; } // Check for authentication, just so we can warn. @@ -1184,8 +1184,8 @@ ProxyConfigServiceLinux::Delegate::GetConfigFromSettings() { ProxyConfigServiceLinux::Delegate::Delegate( std::unique_ptr env_var_getter, - base::Optional> setting_getter, - base::Optional traffic_annotation) + absl::optional> setting_getter, + absl::optional traffic_annotation) : env_var_getter_(std::move(env_var_getter)) { if (traffic_annotation) { traffic_annotation_ = @@ -1256,7 +1256,7 @@ void ProxyConfigServiceLinux::Delegate::SetUpAndFetchInitialConfig( // does so even if the proxy mode is set to auto, which would // mislead us. - cached_config_ = base::nullopt; + cached_config_ = absl::nullopt; if (setting_getter_ && setting_getter_->Init(glib_task_runner)) { cached_config_ = GetConfigFromSettings(); } @@ -1352,7 +1352,7 @@ void ProxyConfigServiceLinux::Delegate::OnCheckProxyConfigSettings() { scoped_refptr required_loop = setting_getter_->GetNotificationTaskRunner(); DCHECK(!required_loop.get() || required_loop->RunsTasksInCurrentSequence()); - base::Optional new_config = + absl::optional new_config = GetConfigFromSettings(); // See if it is different from what we had before. @@ -1373,7 +1373,7 @@ void ProxyConfigServiceLinux::Delegate::OnCheckProxyConfigSettings() { } void ProxyConfigServiceLinux::Delegate::SetNewProxyConfig( - const base::Optional& new_config) { + const absl::optional& new_config) { DCHECK(main_task_runner_->RunsTasksInCurrentSequence()); VLOG(1) << "Proxy configuration changed"; cached_config_ = new_config; @@ -1410,8 +1410,8 @@ void ProxyConfigServiceLinux::Delegate::OnDestroy() { ProxyConfigServiceLinux::ProxyConfigServiceLinux() : delegate_(new Delegate(base::Environment::Create(), - base::nullopt, - base::nullopt)) {} + absl::nullopt, + absl::nullopt)) {} ProxyConfigServiceLinux::~ProxyConfigServiceLinux() { delegate_->PostDestroyTask(); @@ -1421,7 +1421,7 @@ ProxyConfigServiceLinux::ProxyConfigServiceLinux( std::unique_ptr env_var_getter, const NetworkTrafficAnnotationTag& traffic_annotation) : delegate_(new Delegate(std::move(env_var_getter), - base::nullopt, + absl::nullopt, traffic_annotation)) {} ProxyConfigServiceLinux::ProxyConfigServiceLinux( diff --git a/net/proxy_resolution/proxy_config_service_linux.h b/net/proxy_resolution/proxy_config_service_linux.h index 2ded6e3bc01c69..fbaa70be584582 100644 --- a/net/proxy_resolution/proxy_config_service_linux.h +++ b/net/proxy_resolution/proxy_config_service_linux.h @@ -16,11 +16,11 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/observer_list.h" -#include "base/optional.h" #include "net/base/net_export.h" #include "net/base/proxy_server.h" #include "net/proxy_resolution/proxy_config_service.h" #include "net/proxy_resolution/proxy_config_with_annotation.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { class SingleThreadTaskRunner; @@ -172,8 +172,8 @@ class NET_EXPORT_PRIVATE ProxyConfigServiceLinux : public ProxyConfigService { // Test code can set |setting_getter| and |traffic_annotation|. If left // unspecified, reasonable defaults will be used. Delegate(std::unique_ptr env_var_getter, - base::Optional> setting_getter, - base::Optional traffic_annotation); + absl::optional> setting_getter, + absl::optional traffic_annotation); // Synchronously obtains the proxy configuration. If gconf, // gsettings, or kioslaverc are used, also enables notifications for @@ -224,7 +224,7 @@ class NET_EXPORT_PRIVATE ProxyConfigServiceLinux : public ProxyConfigService { ProxyServer* result_server); // Returns a proxy config based on the environment variables, or empty value // on failure. - base::Optional GetConfigFromEnv(); + absl::optional GetConfigFromEnv(); // Obtains host and port config settings and parses a proxy server // specification from it and puts it in result. Returns true if the @@ -233,12 +233,12 @@ class NET_EXPORT_PRIVATE ProxyConfigServiceLinux : public ProxyConfigService { ProxyServer* result_server); // Returns a proxy config based on the settings, or empty value // on failure. - base::Optional GetConfigFromSettings(); + absl::optional GetConfigFromSettings(); // This method is posted from the glib thread to the main TaskRunner to // carry the new config information. void SetNewProxyConfig( - const base::Optional& new_config); + const absl::optional& new_config); // This method is run on the getter's notification thread. void SetUpNotifications(); @@ -249,12 +249,12 @@ class NET_EXPORT_PRIVATE ProxyConfigServiceLinux : public ProxyConfigService { // Cached proxy configuration, to be returned by // GetLatestProxyConfig. Initially populated from the glib thread, but // afterwards only accessed from the main TaskRunner. - base::Optional cached_config_; + absl::optional cached_config_; // A copy kept on the glib thread of the last seen proxy config, so as // to avoid posting a call to SetNewProxyConfig when we get a // notification but the config has not actually changed. - base::Optional reference_config_; + absl::optional reference_config_; // The task runner for the glib thread, aka main browser thread. This thread // is where we run the glib main loop (see diff --git a/net/quic/dedicated_web_transport_http3_client.cc b/net/quic/dedicated_web_transport_http3_client.cc index 43259ffe414524..d934a0eb64d115 100644 --- a/net/quic/dedicated_web_transport_http3_client.cc +++ b/net/quic/dedicated_web_transport_http3_client.cc @@ -140,8 +140,8 @@ class DedicatedWebTransportHttp3ClientSession void OnDatagramProcessed( absl::optional status) override { client_->OnDatagramProcessed( - status.has_value() ? base::Optional(*status) - : base::Optional()); + status.has_value() ? absl::optional(*status) + : absl::optional()); } private: @@ -335,7 +335,7 @@ int DedicatedWebTransportHttp3Client::DoResolveHost() { next_connect_state_ = CONNECT_STATE_RESOLVE_HOST_COMPLETE; HostResolver::ResolveHostParameters parameters; resolve_host_request_ = context_->host_resolver()->CreateRequest( - HostPortPair::FromURL(url_), isolation_key_, net_log_, base::nullopt); + HostPortPair::FromURL(url_), isolation_key_, net_log_, absl::nullopt); return resolve_host_request_->Start(base::BindOnce( &DedicatedWebTransportHttp3Client::DoLoop, base::Unretained(this))); } @@ -647,7 +647,7 @@ void DedicatedWebTransportHttp3Client::OnConnectionClosed( } void DedicatedWebTransportHttp3Client::OnDatagramProcessed( - base::Optional status) { + absl::optional status) { visitor_->OnDatagramProcessed(status); } diff --git a/net/quic/dedicated_web_transport_http3_client.h b/net/quic/dedicated_web_transport_http3_client.h index d40989ce5876da..c598b934e302c9 100644 --- a/net/quic/dedicated_web_transport_http3_client.h +++ b/net/quic/dedicated_web_transport_http3_client.h @@ -69,7 +69,7 @@ class NET_EXPORT DedicatedWebTransportHttp3Client void OnSettingsReceived(); void OnHeadersComplete(); void OnConnectStreamClosed(); - void OnDatagramProcessed(base::Optional status); + void OnDatagramProcessed(absl::optional status); // QuicTransportClientSession::ClientVisitor methods. void OnSessionReady() override; diff --git a/net/quic/platform/impl/quic_flags_impl.h b/net/quic/platform/impl/quic_flags_impl.h index fa13f9015daec0..dab7dd052753fe 100644 --- a/net/quic/platform/impl/quic_flags_impl.h +++ b/net/quic/platform/impl/quic_flags_impl.h @@ -12,9 +12,9 @@ #include #include "base/export_template.h" -#include "base/optional.h" #include "net/third_party/quiche/src/common/platform/api/quiche_flags.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #define QUIC_PROTOCOL_FLAG(type, flag, ...) \ QUIC_EXPORT_PRIVATE extern type FLAGS_##flag; @@ -155,7 +155,7 @@ struct QUIC_EXPORT_PRIVATE QuicParseCommandLineFlagsResult { ~QuicParseCommandLineFlagsResult(); std::vector non_flag_args; - base::Optional exit_status; + absl::optional exit_status; }; QUIC_EXPORT_PRIVATE QuicParseCommandLineFlagsResult diff --git a/net/quic/platform/impl/quic_flags_test.cc b/net/quic/platform/impl/quic_flags_test.cc index f850c9a27947c6..f8fa493ac1da1e 100644 --- a/net/quic/platform/impl/quic_flags_test.cc +++ b/net/quic/platform/impl/quic_flags_test.cc @@ -7,7 +7,6 @@ #include #include "base/command_line.h" -#include "base/optional.h" #include "base/stl_util.h" #include "base/strings/strcat.h" #include "base/strings/stringprintf.h" @@ -15,6 +14,7 @@ #include "net/quic/platform/impl/quic_flags_impl.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "third_party/abseil-cpp/absl/types/optional.h" DEFINE_QUIC_COMMAND_LINE_FLAG(bool, foo, false, "An old silent pond..."); DEFINE_QUIC_COMMAND_LINE_FLAG(int32_t, bar, 123, "A frog jumps into the pond,"); diff --git a/net/quic/quic_connectivity_monitor.cc b/net/quic/quic_connectivity_monitor.cc index 6aa56e08dc029f..c23c61a3a6a672 100644 --- a/net/quic/quic_connectivity_monitor.cc +++ b/net/quic/quic_connectivity_monitor.cc @@ -148,7 +148,7 @@ void QuicConnectivityMonitor::OnSessionResumedPostPathDegrading( num_all_degraded_sessions_ = 0u; num_sessions_active_during_current_speculative_connectivity_failure_ = - base::nullopt; + absl::nullopt; } void QuicConnectivityMonitor::OnSessionEncounteringWriteError( @@ -228,7 +228,7 @@ void QuicConnectivityMonitor::OnDefaultNetworkUpdated( active_sessions_.clear(); degrading_sessions_.clear(); num_sessions_active_during_current_speculative_connectivity_failure_ = - base::nullopt; + absl::nullopt; write_error_map_.clear(); quic_error_map_.clear(); } diff --git a/net/quic/quic_connectivity_monitor.h b/net/quic/quic_connectivity_monitor.h index 6e36b2a021c261..bc458bfd8b0e55 100644 --- a/net/quic/quic_connectivity_monitor.h +++ b/net/quic/quic_connectivity_monitor.h @@ -108,7 +108,7 @@ class NET_EXPORT_PRIVATE QuicConnectivityMonitor // related packet write error, // - ends immediately by the detection of path recovery or a network change. // Use clamped math to cap number of sessions at INT_MAX. - base::Optional> + absl::optional> num_sessions_active_during_current_speculative_connectivity_failure_; // Total number of sessions that has been degraded before any recovery, // including no longer active sessions. diff --git a/net/quic/quic_network_transaction_unittest.cc b/net/quic/quic_network_transaction_unittest.cc index 27d6f90ebf6936..5dd509d7e772bd 100644 --- a/net/quic/quic_network_transaction_unittest.cc +++ b/net/quic/quic_network_transaction_unittest.cc @@ -8564,7 +8564,7 @@ TEST_P(QuicNetworkTransactionTest, QuicProxyAuth) { EXPECT_EQ(407, response->headers->response_code()); EXPECT_EQ(10, response->headers->GetContentLength()); EXPECT_EQ(HttpVersion(1, 1), response->headers->GetHttpVersion()); - base::Optional auth_challenge = + absl::optional auth_challenge = response->auth_challenge; ASSERT_TRUE(auth_challenge.has_value()); EXPECT_TRUE(auth_challenge->is_proxy); diff --git a/net/quic/quic_transport_client.cc b/net/quic/quic_transport_client.cc index a80a9c45bb9afc..320047fd98f912 100644 --- a/net/quic/quic_transport_client.cc +++ b/net/quic/quic_transport_client.cc @@ -212,7 +212,7 @@ int QuicTransportClient::DoResolveHost() { next_connect_state_ = CONNECT_STATE_RESOLVE_HOST_COMPLETE; HostResolver::ResolveHostParameters parameters; resolve_host_request_ = context_->host_resolver()->CreateRequest( - HostPortPair::FromURL(url_), isolation_key_, net_log_, base::nullopt); + HostPortPair::FromURL(url_), isolation_key_, net_log_, absl::nullopt); return resolve_host_request_->Start( base::BindOnce(&QuicTransportClient::DoLoop, base::Unretained(this))); } @@ -485,8 +485,8 @@ void QuicTransportClient::OnConnectionClosed( void QuicTransportClient::DatagramObserverProxy::OnDatagramProcessed( absl::optional status) { client_->visitor_->OnDatagramProcessed( - status.has_value() ? base::Optional(*status) - : base::Optional()); + status.has_value() ? absl::optional(*status) + : absl::optional()); } } // namespace net diff --git a/net/quic/quic_transport_end_to_end_test.cc b/net/quic/quic_transport_end_to_end_test.cc index 4cdfd0bbc4b1b4..6bf3a2e6a0b30d 100644 --- a/net/quic/quic_transport_end_to_end_test.cc +++ b/net/quic/quic_transport_end_to_end_test.cc @@ -45,7 +45,7 @@ class MockVisitor : public WebTransportClientVisitor { MOCK_METHOD1(OnDatagramReceived, void(base::StringPiece)); MOCK_METHOD0(OnCanCreateNewOutgoingBidirectionalStream, void()); MOCK_METHOD0(OnCanCreateNewOutgoingUnidirectionalStream, void()); - MOCK_METHOD1(OnDatagramProcessed, void(base::Optional)); + MOCK_METHOD1(OnDatagramProcessed, void(absl::optional)); }; // A clock that only mocks out WallNow(), but uses real Now() and diff --git a/net/quic/web_transport_client.h b/net/quic/web_transport_client.h index 916f180cdc0b4a..db7e73d8ad21cd 100644 --- a/net/quic/web_transport_client.h +++ b/net/quic/web_transport_client.h @@ -7,13 +7,13 @@ #include -#include "base/optional.h" #include "base/strings/string_piece.h" #include "net/base/network_isolation_key.h" #include "net/quic/web_transport_error.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/core/web_transport_interface.h" #include "net/third_party/quiche/src/quic/quic_transport/web_transport_fingerprint_proof_verifier.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/origin.h" @@ -67,7 +67,7 @@ class NET_EXPORT WebTransportClientVisitor { virtual void OnCanCreateNewOutgoingBidirectionalStream() = 0; virtual void OnCanCreateNewOutgoingUnidirectionalStream() = 0; virtual void OnDatagramProcessed( - base::Optional status) = 0; + absl::optional status) = 0; }; // Parameters that determine the way WebTransport session is established. diff --git a/net/reporting/reporting_cache_impl.cc b/net/reporting/reporting_cache_impl.cc index 27c142a05c13d6..b2db5774d07190 100644 --- a/net/reporting/reporting_cache_impl.cc +++ b/net/reporting/reporting_cache_impl.cc @@ -410,7 +410,7 @@ void ReportingCacheImpl::AddClientsLoadedFromStore( auto endpoints_it = loaded_endpoints.begin(); auto endpoint_groups_it = loaded_endpoint_groups.begin(); - base::Optional client; + absl::optional client; while (endpoint_groups_it != loaded_endpoint_groups.end() && endpoints_it != loaded_endpoints.end()) { @@ -455,7 +455,7 @@ void ReportingCacheImpl::AddClientsLoadedFromStore( EnforcePerClientAndGlobalEndpointLimits(client_it); } DCHECK(FindClientIt(group_key) == clients_.end()); - client = base::make_optional( + client = absl::make_optional( Client(group_key.network_isolation_key, group_key.origin)); } DCHECK(client.has_value()); @@ -969,7 +969,7 @@ void ReportingCacheImpl::RemoveEndpointsInGroupOtherThan( // This may invalidate |group_it| (and also possibly |client_it|), but only // if we are processing the last remaining endpoint in the group. - base::Optional next_it = + absl::optional next_it = RemoveEndpointInternal(client_it, group_it, it); if (!next_it.has_value()) return; @@ -1023,7 +1023,7 @@ void ReportingCacheImpl::MarkEndpointGroupAndClientUsed( store()->UpdateReportingEndpointGroupAccessTime(group_it->second); } -base::Optional +absl::optional ReportingCacheImpl::RemoveEndpointInternal(ClientMap::iterator client_it, EndpointGroupMap::iterator group_it, EndpointMap::iterator endpoint_it) { @@ -1037,7 +1037,7 @@ ReportingCacheImpl::RemoveEndpointInternal(ClientMap::iterator client_it, // be removed if it becomes empty. if (endpoints_.count(group_key) == 1) { RemoveEndpointGroupInternal(client_it, group_it); - return base::nullopt; + return absl::nullopt; } // Otherwise, there are other endpoints in the group, so there is no chance // of needing to remove the group/client. Just remove this endpoint and @@ -1050,7 +1050,7 @@ ReportingCacheImpl::RemoveEndpointInternal(ClientMap::iterator client_it, return endpoints_.erase(endpoint_it); } -base::Optional +absl::optional ReportingCacheImpl::RemoveEndpointGroupInternal( ClientMap::iterator client_it, EndpointGroupMap::iterator group_it, @@ -1086,14 +1086,14 @@ ReportingCacheImpl::RemoveEndpointGroupInternal( if (context_->IsClientDataPersisted()) store()->DeleteReportingEndpointGroup(group_it->second); - base::Optional rv = + absl::optional rv = endpoint_groups_.erase(group_it); // Delete client if empty. if (client.endpoint_count == 0) { DCHECK(client.endpoint_group_names.empty()); clients_.erase(client_it); - rv = base::nullopt; + rv = absl::nullopt; } return rv; } diff --git a/net/reporting/reporting_cache_impl.h b/net/reporting/reporting_cache_impl.h index a0b008f58d2d4e..59b1ed8c3837ca 100644 --- a/net/reporting/reporting_cache_impl.h +++ b/net/reporting/reporting_cache_impl.h @@ -16,7 +16,6 @@ #include "base/containers/flat_set.h" #include "base/containers/unique_ptr_adapters.h" #include "base/macros.h" -#include "base/optional.h" #include "base/sequence_checker.h" #include "base/time/time.h" #include "base/values.h" @@ -25,6 +24,7 @@ #include "net/reporting/reporting_endpoint.h" #include "net/reporting/reporting_header_parser.h" #include "net/reporting/reporting_report.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/origin.h" @@ -231,10 +231,10 @@ class ReportingCacheImpl : public ReportingCache { // Also takes iterators to the client and endpoint group to avoid repeated // lookups. May cause the client and/or group to be removed if they become // empty, which would invalidate those iterators. - // Returns the iterator following the endpoint removed, or base::nullopt if + // Returns the iterator following the endpoint removed, or absl::nullopt if // either of |group_it| or |client_it| were invalidated. (If |client_it| is // invalidated, then so must |group_it|). - base::Optional RemoveEndpointInternal( + absl::optional RemoveEndpointInternal( ClientMap::iterator client_it, EndpointGroupMap::iterator group_it, EndpointMap::iterator endpoint_it); @@ -245,9 +245,9 @@ class ReportingCacheImpl : public ReportingCache { // invalidate |client_it|. If |num_endpoints_removed| is not null, then // |*num_endpoints_removed| is incremented by the number of endpoints // removed. - // Returns the iterator following the endpoint group removed, or base::nullopt + // Returns the iterator following the endpoint group removed, or absl::nullopt // if |client_it| was invalidated. - base::Optional RemoveEndpointGroupInternal( + absl::optional RemoveEndpointGroupInternal( ClientMap::iterator client_it, EndpointGroupMap::iterator group_it, size_t* num_endpoints_removed = nullptr); diff --git a/net/reporting/reporting_header_parser_unittest.cc b/net/reporting/reporting_header_parser_unittest.cc index e3c00d2df352c5..64453033c6ef91 100644 --- a/net/reporting/reporting_header_parser_unittest.cc +++ b/net/reporting/reporting_header_parser_unittest.cc @@ -1754,7 +1754,7 @@ class ReportingHeaderParserStructuredHeaderTest void ParseHeader(const NetworkIsolationKey& network_isolation_key, const url::Origin& origin, const std::string& header_string) { - base::Optional header_dict = + absl::optional header_dict = structured_headers::ParseDictionary(header_string); if (header_dict) { diff --git a/net/reporting/reporting_report.h b/net/reporting/reporting_report.h index dee358878cc1ee..5da1dc27693b90 100644 --- a/net/reporting/reporting_report.h +++ b/net/reporting/reporting_report.h @@ -8,11 +8,11 @@ #include #include -#include "base/optional.h" #include "base/time/time.h" #include "net/base/net_export.h" #include "net/base/network_isolation_key.h" #include "net/reporting/reporting_endpoint.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace base { diff --git a/net/reporting/reporting_service.cc b/net/reporting/reporting_service.cc index 9381c4e093150b..3e237a8f2454ec 100644 --- a/net/reporting/reporting_service.cc +++ b/net/reporting/reporting_service.cc @@ -12,7 +12,6 @@ #include "base/logging.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "base/time/tick_clock.h" #include "base/time/time.h" #include "base/values.h" @@ -24,6 +23,7 @@ #include "net/reporting/reporting_delegate.h" #include "net/reporting/reporting_header_parser.h" #include "net/reporting/reporting_uploader.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace net { @@ -111,7 +111,7 @@ class ReportingServiceImpl : public ReportingService { if (header_string.size() == 0 || header_string.size() > kMaxSHSize) return; - base::Optional header_dict = + absl::optional header_dict = structured_headers::ParseDictionary(header_string); if (!header_dict) { DVLOG(1) << "Error processing Reporting-Endpoints header string: " diff --git a/net/reporting/reporting_uploader_unittest.cc b/net/reporting/reporting_uploader_unittest.cc index a64d0d96498541..484184b2576bee 100644 --- a/net/reporting/reporting_uploader_unittest.cc +++ b/net/reporting/reporting_uploader_unittest.cc @@ -453,7 +453,7 @@ TEST_F(ReportingUploaderTest, DontSendCookies) { ResultSavingCookieCallback cookie_callback; GURL url = server_.GetURL("/"); auto cookie = CanonicalCookie::Create(url, "foo=bar", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); context_.cookie_store()->SetCanonicalCookieAsync( std::move(cookie), url, CookieOptions::MakeAllInclusive(), cookie_callback.MakeCallback()); diff --git a/net/socket/client_socket_handle.cc b/net/socket/client_socket_handle.cc index 525a22f0441454..8a265355524f64 100644 --- a/net/socket/client_socket_handle.cc +++ b/net/socket/client_socket_handle.cc @@ -36,7 +36,7 @@ ClientSocketHandle::~ClientSocketHandle() { int ClientSocketHandle::Init( const ClientSocketPool::GroupId& group_id, scoped_refptr socket_params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, RequestPriority priority, const SocketTag& socket_tag, ClientSocketPool::RespectLimits respect_limits, diff --git a/net/socket/client_socket_handle.h b/net/socket/client_socket_handle.h index 9282dae7dd849f..1a8f4c5499a8e4 100644 --- a/net/socket/client_socket_handle.h +++ b/net/socket/client_socket_handle.h @@ -13,7 +13,6 @@ #include "base/check.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "base/time/time.h" #include "net/base/ip_endpoint.h" #include "net/base/load_states.h" @@ -28,6 +27,7 @@ #include "net/socket/connection_attempts.h" #include "net/socket/stream_socket.h" #include "net/ssl/ssl_cert_request_info.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -85,7 +85,7 @@ class NET_EXPORT ClientSocketHandle { int Init( const ClientSocketPool::GroupId& group_id, scoped_refptr socket_params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, RequestPriority priority, const SocketTag& socket_tag, ClientSocketPool::RespectLimits respect_limits, diff --git a/net/socket/client_socket_pool.cc b/net/socket/client_socket_pool.cc index 537867b2c820fc..60d011d3fb5f0a 100644 --- a/net/socket/client_socket_pool.cc +++ b/net/socket/client_socket_pool.cc @@ -160,7 +160,7 @@ std::unique_ptr ClientSocketPool::CreateConnectJob( GroupId group_id, scoped_refptr socket_params, const ProxyServer& proxy_server, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, bool is_for_websockets, const CommonConnectJobParams* common_connect_job_params, RequestPriority request_priority, diff --git a/net/socket/client_socket_pool.h b/net/socket/client_socket_pool.h index 4d213ba15073d0..5bd1661451c2de 100644 --- a/net/socket/client_socket_pool.h +++ b/net/socket/client_socket_pool.h @@ -10,7 +10,6 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "base/time/time.h" #include "net/base/completion_once_callback.h" #include "net/base/load_states.h" @@ -24,6 +23,7 @@ #include "net/log/net_log_capture_mode.h" #include "net/socket/connect_job.h" #include "net/socket/socket_tag.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { class Value; @@ -250,7 +250,7 @@ class NET_EXPORT ClientSocketPool : public LowerLayeredPool { virtual int RequestSocket( const GroupId& group_id, scoped_refptr params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, RequestPriority priority, const SocketTag& socket_tag, RespectLimits respect_limits, @@ -272,7 +272,7 @@ class NET_EXPORT ClientSocketPool : public LowerLayeredPool { virtual void RequestSockets( const GroupId& group_id, scoped_refptr params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, int num_sockets, const NetLogWithSource& net_log) = 0; @@ -367,7 +367,7 @@ class NET_EXPORT ClientSocketPool : public LowerLayeredPool { GroupId group_id, scoped_refptr socket_params, const ProxyServer& proxy_server, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, bool is_for_websockets, const CommonConnectJobParams* common_connect_job_params, RequestPriority request_priority, diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc index 1fb16fb8b7d9e5..80d4868698b36d 100644 --- a/net/socket/client_socket_pool_base_unittest.cc +++ b/net/socket/client_socket_pool_base_unittest.cc @@ -16,7 +16,6 @@ #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/notreached.h" -#include "base/optional.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/stl_util.h" @@ -62,6 +61,7 @@ #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" using net::test::IsError; using net::test::IsOk; @@ -470,7 +470,7 @@ class TestConnectJob : public ConnectJob { return ERR_IO_PENDING; default: NOTREACHED(); - SetSocket(std::unique_ptr(), base::nullopt); + SetSocket(std::unique_ptr(), absl::nullopt); return ERR_FAILED; } } @@ -482,15 +482,15 @@ class TestConnectJob : public ConnectJob { has_established_connection_ = true; if (succeed) { SetSocket(std::make_unique(net_log().net_log()), - base::nullopt); + absl::nullopt); socket()->Connect(CompletionOnceCallback()); } else if (cert_error) { SetSocket(std::make_unique(net_log().net_log()), - base::nullopt); + absl::nullopt); result = ERR_CERT_COMMON_NAME_INVALID; } else { result = ERR_CONNECTION_FAILED; - SetSocket(std::unique_ptr(), base::nullopt); + SetSocket(std::unique_ptr(), absl::nullopt); } if (was_async) @@ -580,7 +580,7 @@ class TestConnectJobFactory std::unique_ptr NewConnectJob( ClientSocketPool::GroupId group_id, scoped_refptr socket_params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, RequestPriority request_priority, SocketTag socket_tag, ConnectJob::Delegate* delegate) const override { @@ -745,7 +745,7 @@ TEST_F(ClientSocketPoolBaseTest, BasicSynchronous) { TestLoadTimingInfoNotConnected(handle); EXPECT_EQ(OK, handle.Init( - TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), log.bound())); @@ -785,7 +785,7 @@ TEST_F(ClientSocketPoolBaseTest, InitConnectionFailure) { handle.set_ssl_cert_request_info(base::MakeRefCounted()); EXPECT_EQ( ERR_CONNECTION_FAILED, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), log.bound())); @@ -902,7 +902,7 @@ TEST_F(ClientSocketPoolBaseTest, GroupSeparation) { // Since the group is empty, requesting a socket should not complete // synchronously. - EXPECT_THAT(handle.Init(group_id, params_, base::nullopt, + EXPECT_THAT(handle.Init(group_id, params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), @@ -923,7 +923,7 @@ TEST_F(ClientSocketPoolBaseTest, GroupSeparation) { // Requesting a socket again should return the same socket as // before, so should complete synchronously. - EXPECT_THAT(handle.Init(group_id, params_, base::nullopt, + EXPECT_THAT(handle.Init(group_id, params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), @@ -1270,7 +1270,7 @@ TEST_F(ClientSocketPoolBaseTest, StallAndThenCancelAndTriggerAvailableSocket) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -1280,7 +1280,7 @@ TEST_F(ClientSocketPoolBaseTest, StallAndThenCancelAndTriggerAvailableSocket) { TestCompletionCallback callback; EXPECT_EQ(ERR_IO_PENDING, handles[i].Init( - TestGroupId("b"), params_, base::nullopt, DEFAULT_PRIORITY, + TestGroupId("b"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -1303,7 +1303,7 @@ TEST_F(ClientSocketPoolBaseTest, CancelStalledSocketAtSocketLimit) { for (int i = 0; i < kDefaultMaxSockets; ++i) { EXPECT_EQ(OK, handles[i].Init(TestGroupId(base::NumberToString(i)), params_, - base::nullopt, DEFAULT_PRIORITY, SocketTag(), + absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callbacks[i].callback(), ClientSocketPool::ProxyAuthCallback(), @@ -1315,7 +1315,7 @@ TEST_F(ClientSocketPoolBaseTest, CancelStalledSocketAtSocketLimit) { TestCompletionCallback callback; EXPECT_EQ(ERR_IO_PENDING, stalled_handle.Init( - TestGroupId("foo"), params_, base::nullopt, DEFAULT_PRIORITY, + TestGroupId("foo"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -1343,7 +1343,7 @@ TEST_F(ClientSocketPoolBaseTest, CancelPendingSocketAtSocketLimit) { TestCompletionCallback callback; EXPECT_EQ(ERR_IO_PENDING, handles[i].Init(TestGroupId(base::NumberToString(i)), params_, - base::nullopt, DEFAULT_PRIORITY, SocketTag(), + absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), @@ -1356,7 +1356,7 @@ TEST_F(ClientSocketPoolBaseTest, CancelPendingSocketAtSocketLimit) { TestCompletionCallback callback; EXPECT_EQ(ERR_IO_PENDING, stalled_handle.Init( - TestGroupId("foo"), params_, base::nullopt, DEFAULT_PRIORITY, + TestGroupId("foo"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -1410,7 +1410,7 @@ TEST_F(ClientSocketPoolBaseTest, WaitForStalledSocketAtSocketLimit) { EXPECT_EQ( OK, handles[i].Init( TestGroupId(base::StringPrintf("Take 2: %d", i)), params_, - base::nullopt, DEFAULT_PRIORITY, SocketTag(), + absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -1423,7 +1423,7 @@ TEST_F(ClientSocketPoolBaseTest, WaitForStalledSocketAtSocketLimit) { // Now we will hit the socket limit. EXPECT_EQ(ERR_IO_PENDING, stalled_handle.Init( - TestGroupId("foo"), params_, base::nullopt, DEFAULT_PRIORITY, + TestGroupId("foo"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -1450,7 +1450,7 @@ TEST_F(ClientSocketPoolBaseTest, CloseIdleSocketAtSocketLimitDeleteGroup) { ClientSocketHandle handle; TestCompletionCallback callback; EXPECT_EQ(OK, handle.Init(TestGroupId(base::NumberToString(i)), params_, - base::nullopt, DEFAULT_PRIORITY, SocketTag(), + absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), @@ -1470,7 +1470,7 @@ TEST_F(ClientSocketPoolBaseTest, CloseIdleSocketAtSocketLimitDeleteGroup) { // which is the one which we would close an idle socket for. We shouldn't // close an idle socket though, since we should reuse the idle socket. EXPECT_EQ(OK, handle.Init( - TestGroupId("0"), params_, base::nullopt, DEFAULT_PRIORITY, + TestGroupId("0"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -1540,7 +1540,7 @@ TEST_F(ClientSocketPoolBaseTest, ResetAndCloseSocket) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -1565,7 +1565,7 @@ TEST_F(ClientSocketPoolBaseTest, CancelRequestKeepsConnectJob) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -1591,7 +1591,7 @@ TEST_F(ClientSocketPoolBaseTest, CancelRequestAndCloseSocket) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -1629,7 +1629,7 @@ TEST_F(ClientSocketPoolBaseTest, std::make_unique(); EXPECT_EQ(ERR_IO_PENDING, handle->Init( - TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -1689,7 +1689,7 @@ TEST_F(ClientSocketPoolBaseTest, ConnectCancelConnect) { EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -1703,7 +1703,7 @@ TEST_F(ClientSocketPoolBaseTest, ConnectCancelConnect) { TestCompletionCallback callback2; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -1786,7 +1786,7 @@ void RequestSocketOnComplete(ClientSocketHandle* handle, TestCompletionCallback callback; int rv = handle->Init( TestGroupId("a"), - ClientSocketPool::SocketParams::CreateForHttpForTesting(), base::nullopt, + ClientSocketPool::SocketParams::CreateForHttpForTesting(), absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, nested_callback->callback(), ClientSocketPool::ProxyAuthCallback(), pool, NetLogWithSource()); @@ -1808,7 +1808,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestPendingJobTwice) { ClientSocketHandle handle; TestCompletionCallback second_result_callback; int rv = handle.Init( - TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, base::BindOnce(&RequestSocketOnComplete, &handle, pool_.get(), connect_job_factory_, TestConnectJob::kMockPendingJob, @@ -1829,7 +1829,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestPendingJobThenSynchronous) { ClientSocketHandle handle; TestCompletionCallback second_result_callback; int rv = handle.Init( - TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, base::BindOnce(&RequestSocketOnComplete, &handle, pool_.get(), connect_job_factory_, TestConnectJob::kMockPendingJob, @@ -1930,7 +1930,7 @@ TEST_F(ClientSocketPoolBaseTest, CancelActiveRequestThenRequestSocket) { ClientSocketHandle handle; TestCompletionCallback callback; int rv = handle.Init( - TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); @@ -1938,7 +1938,7 @@ TEST_F(ClientSocketPoolBaseTest, CancelActiveRequestThenRequestSocket) { // Cancel the active request. handle.Reset(); - rv = handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + rv = handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -1958,7 +1958,7 @@ TEST_F(ClientSocketPoolBaseTest, CloseIdleSocketsForced) { TestCompletionCallback callback; RecordingBoundTestNetLog log; int rv = handle.Init( - TestGroupId("a"), params_, base::nullopt, LOWEST, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), log.bound()); EXPECT_THAT(rv, IsOk()); @@ -1976,17 +1976,17 @@ TEST_F(ClientSocketPoolBaseTest, CloseIdleSocketsInGroupForced) { RecordingBoundTestNetLog log; ClientSocketHandle handle1; int rv = handle1.Init( - TestGroupId("a"), params_, base::nullopt, LOWEST, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), log.bound()); EXPECT_THAT(rv, IsOk()); ClientSocketHandle handle2; - rv = handle2.Init(TestGroupId("a"), params_, base::nullopt, LOWEST, + rv = handle2.Init(TestGroupId("a"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), log.bound()); ClientSocketHandle handle3; - rv = handle3.Init(TestGroupId("b"), params_, base::nullopt, LOWEST, + rv = handle3.Init(TestGroupId("b"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), log.bound()); @@ -2005,7 +2005,7 @@ TEST_F(ClientSocketPoolBaseTest, CleanUpUnusableIdleSockets) { TestCompletionCallback callback; RecordingBoundTestNetLog log; int rv = handle.Init( - TestGroupId("a"), params_, base::nullopt, LOWEST, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), log.bound()); EXPECT_THAT(rv, IsOk()); @@ -2018,7 +2018,7 @@ TEST_F(ClientSocketPoolBaseTest, CleanUpUnusableIdleSockets) { NetLogSource source = socket->NetLog().source(); socket->Disconnect(); ClientSocketHandle handle2; - rv = handle2.Init(TestGroupId("a"), params_, base::nullopt, LOWEST, + rv = handle2.Init(TestGroupId("a"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), log.bound()); @@ -2081,7 +2081,7 @@ TEST_F(ClientSocketPoolBaseTest, BasicAsynchronous) { TestCompletionCallback callback; RecordingBoundTestNetLog log; int rv = handle.Init( - TestGroupId("a"), params_, base::nullopt, LOWEST, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), log.bound()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); @@ -2126,7 +2126,7 @@ TEST_F(ClientSocketPoolBaseTest, handle.set_ssl_cert_request_info(base::MakeRefCounted()); EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), log.bound())); @@ -2180,14 +2180,14 @@ TEST_F(ClientSocketPoolBaseTest, TwoRequestsCancelOne) { EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); RecordingBoundTestNetLog log2; EXPECT_EQ( ERR_IO_PENDING, - handle2.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle2.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -2246,7 +2246,7 @@ TEST_F(ClientSocketPoolBaseTest, ReleaseSockets) { size_t completion_count; // unused TestSocketRequest req1(&request_order, &completion_count); int rv = req1.handle()->Init( - TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, req1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); @@ -2258,13 +2258,13 @@ TEST_F(ClientSocketPoolBaseTest, ReleaseSockets) { TestSocketRequest req2(&request_order, &completion_count); rv = req2.handle()->Init( - TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, req2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); TestSocketRequest req3(&request_order, &completion_count); rv = req3.handle()->Init( - TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, req3.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); @@ -2301,14 +2301,14 @@ TEST_F(ClientSocketPoolBaseTest, PendingJobCompletionOrder) { size_t completion_count; // unused TestSocketRequest req1(&request_order, &completion_count); int rv = req1.handle()->Init( - TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, req1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); TestSocketRequest req2(&request_order, &completion_count); rv = req2.handle()->Init( - TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, req2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); @@ -2318,7 +2318,7 @@ TEST_F(ClientSocketPoolBaseTest, PendingJobCompletionOrder) { TestSocketRequest req3(&request_order, &completion_count); rv = req3.handle()->Init( - TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, req3.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); @@ -2341,7 +2341,7 @@ TEST_F(ClientSocketPoolBaseTest, LoadStateOneRequest) { ClientSocketHandle handle; TestCompletionCallback callback; int rv = handle.Init( - TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); @@ -2362,7 +2362,7 @@ TEST_F(ClientSocketPoolBaseTest, LoadStateTwoRequests) { ClientSocketHandle handle; TestCompletionCallback callback; int rv = handle.Init( - TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); @@ -2370,7 +2370,7 @@ TEST_F(ClientSocketPoolBaseTest, LoadStateTwoRequests) { ClientSocketHandle handle2; TestCompletionCallback callback2; - rv = handle2.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + rv = handle2.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -2410,7 +2410,7 @@ TEST_F(ClientSocketPoolBaseTest, LoadStateGroupLimit) { ClientSocketHandle handle; TestCompletionCallback callback; int rv = handle.Init( - TestGroupId("a"), params_, base::nullopt, MEDIUM, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, MEDIUM, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); @@ -2420,7 +2420,7 @@ TEST_F(ClientSocketPoolBaseTest, LoadStateGroupLimit) { // The first request should now be stalled at the socket group limit. ClientSocketHandle handle2; TestCompletionCallback callback2; - rv = handle2.Init(TestGroupId("a"), params_, base::nullopt, HIGHEST, + rv = handle2.Init(TestGroupId("a"), params_, absl::nullopt, HIGHEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -2454,7 +2454,7 @@ TEST_F(ClientSocketPoolBaseTest, LoadStatePoolLimit) { ClientSocketHandle handle; TestCompletionCallback callback; int rv = handle.Init( - TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); @@ -2462,7 +2462,7 @@ TEST_F(ClientSocketPoolBaseTest, LoadStatePoolLimit) { // Request for socket from another pool. ClientSocketHandle handle2; TestCompletionCallback callback2; - rv = handle2.Init(TestGroupId("b"), params_, base::nullopt, DEFAULT_PRIORITY, + rv = handle2.Init(TestGroupId("b"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -2472,7 +2472,7 @@ TEST_F(ClientSocketPoolBaseTest, LoadStatePoolLimit) { // socket pool limit. ClientSocketHandle handle3; TestCompletionCallback callback3; - rv = handle3.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + rv = handle3.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -2507,7 +2507,7 @@ TEST_F(ClientSocketPoolBaseTest, CertError) { TestCompletionCallback callback; EXPECT_EQ( ERR_CERT_COMMON_NAME_INVALID, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -2523,7 +2523,7 @@ TEST_F(ClientSocketPoolBaseTest, AsyncCertError) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -2543,7 +2543,7 @@ TEST_F(ClientSocketPoolBaseTest, AdditionalErrorStateSynchronous) { TestCompletionCallback callback; EXPECT_EQ( ERR_CONNECTION_FAILED, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -2562,7 +2562,7 @@ TEST_F(ClientSocketPoolBaseTest, AdditionalErrorStateAsynchronous) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -2587,7 +2587,7 @@ TEST_F(ClientSocketPoolBaseTest, CleanupTimedOutIdleSocketsReuse) { ClientSocketHandle handle; TestCompletionCallback callback; int rv = handle.Init( - TestGroupId("a"), params_, base::nullopt, LOWEST, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); ASSERT_THAT(rv, IsError(ERR_IO_PENDING)); @@ -2608,7 +2608,7 @@ TEST_F(ClientSocketPoolBaseTest, CleanupTimedOutIdleSocketsReuse) { // synchronously. RecordingBoundTestNetLog log; rv = handle.Init( - TestGroupId("a"), params_, base::nullopt, LOWEST, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, CompletionOnceCallback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), log.bound()); ASSERT_THAT(rv, IsOk()); @@ -2642,7 +2642,7 @@ TEST_F(ClientSocketPoolBaseTest, CleanupTimedOutIdleSocketsNoReuse) { ClientSocketHandle handle; TestCompletionCallback callback; int rv = handle.Init( - TestGroupId("a"), params_, base::nullopt, LOWEST, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); ASSERT_THAT(rv, IsError(ERR_IO_PENDING)); @@ -2651,7 +2651,7 @@ TEST_F(ClientSocketPoolBaseTest, CleanupTimedOutIdleSocketsNoReuse) { ClientSocketHandle handle2; TestCompletionCallback callback2; - rv = handle2.Init(TestGroupId("a"), params_, base::nullopt, LOWEST, + rv = handle2.Init(TestGroupId("a"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -2687,7 +2687,7 @@ TEST_F(ClientSocketPoolBaseTest, CleanupTimedOutIdleSocketsNoReuse) { // A new socket will be created rather than reusing the idle one. RecordingBoundTestNetLog log; TestCompletionCallback callback3; - rv = handle.Init(TestGroupId("a"), params_, base::nullopt, LOWEST, + rv = handle.Init(TestGroupId("a"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback3.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), log.bound()); @@ -2722,14 +2722,14 @@ TEST_F(ClientSocketPoolBaseTest, MultipleReleasingDisconnectedSockets) { ClientSocketHandle handle; TestCompletionCallback callback; int rv = handle.Init( - TestGroupId("a"), params_, base::nullopt, LOWEST, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); EXPECT_THAT(rv, IsOk()); ClientSocketHandle handle2; TestCompletionCallback callback2; - rv = handle2.Init(TestGroupId("a"), params_, base::nullopt, LOWEST, + rv = handle2.Init(TestGroupId("a"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -2737,7 +2737,7 @@ TEST_F(ClientSocketPoolBaseTest, MultipleReleasingDisconnectedSockets) { ClientSocketHandle handle3; TestCompletionCallback callback3; - rv = handle3.Init(TestGroupId("a"), params_, base::nullopt, LOWEST, + rv = handle3.Init(TestGroupId("a"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback3.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -2745,7 +2745,7 @@ TEST_F(ClientSocketPoolBaseTest, MultipleReleasingDisconnectedSockets) { ClientSocketHandle handle4; TestCompletionCallback callback4; - rv = handle4.Init(TestGroupId("a"), params_, base::nullopt, LOWEST, + rv = handle4.Init(TestGroupId("a"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback4.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -2783,13 +2783,13 @@ TEST_F(ClientSocketPoolBaseTest, SocketLimitReleasingSockets) { TestCompletionCallback callback_b[4]; for (int i = 0; i < 2; ++i) { - EXPECT_EQ(OK, handle_a[i].Init(TestGroupId("a"), params_, base::nullopt, + EXPECT_EQ(OK, handle_a[i].Init(TestGroupId("a"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback_a[i].callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); - EXPECT_EQ(OK, handle_b[i].Init(TestGroupId("b"), params_, base::nullopt, + EXPECT_EQ(OK, handle_b[i].Init(TestGroupId("b"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback_b[i].callback(), @@ -2802,14 +2802,14 @@ TEST_F(ClientSocketPoolBaseTest, SocketLimitReleasingSockets) { for (int i = 2; i < 4; ++i) { EXPECT_EQ( ERR_IO_PENDING, - handle_a[i].Init(TestGroupId("a"), params_, base::nullopt, LOWEST, + handle_a[i].Init(TestGroupId("a"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback_a[i].callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); EXPECT_EQ( ERR_IO_PENDING, - handle_b[i].Init(TestGroupId("b"), params_, base::nullopt, LOWEST, + handle_b[i].Init(TestGroupId("b"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback_b[i].callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), @@ -2905,7 +2905,7 @@ class TestReleasingSocketRequest : public TestCompletionCallbackBase { handle2_.Init( TestGroupId("a"), ClientSocketPool::SocketParams::CreateForHttpForTesting(), - base::nullopt, DEFAULT_PRIORITY, SocketTag(), + absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, CompletionOnceCallback(), ClientSocketPool::ProxyAuthCallback(), pool_, NetLogWithSource())); } @@ -2933,7 +2933,7 @@ TEST_F(ClientSocketPoolBaseTest, AdditionalErrorSocketsDontUseSlot) { TestReleasingSocketRequest req(pool_.get(), OK, false); EXPECT_EQ(ERR_IO_PENDING, req.handle()->Init( - TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, req.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -2963,7 +2963,7 @@ TEST_F(ClientSocketPoolBaseTest, CallbackThatReleasesPool) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -2982,7 +2982,7 @@ TEST_F(ClientSocketPoolBaseTest, DoNotReuseSocketAfterFlush) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -2997,7 +2997,7 @@ TEST_F(ClientSocketPoolBaseTest, DoNotReuseSocketAfterFlush) { EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3032,7 +3032,7 @@ class ConnectWithinCallback : public TestCompletionCallbackBase { SetResult(result); EXPECT_EQ( ERR_IO_PENDING, - handle_.Init(group_id_, params_, base::nullopt, DEFAULT_PRIORITY, + handle_.Init(group_id_, params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, nested_callback_.callback(), ClientSocketPool::ProxyAuthCallback(), pool_, @@ -3058,7 +3058,7 @@ TEST_F(ClientSocketPoolBaseTest, AbortAllRequestsOnFlush) { ConnectWithinCallback callback(TestGroupId("a"), params_, pool_.get()); EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3080,7 +3080,7 @@ TEST_F(ClientSocketPoolBaseTest, BackupSocketWaitsForHostResolution) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("bar"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("bar"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3110,7 +3110,7 @@ TEST_F(ClientSocketPoolBaseTest, NoBackupSocketWhenConnected) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("bar"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("bar"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3142,7 +3142,7 @@ TEST_F(ClientSocketPoolBaseTest, BackupSocketCancelAtMaxSockets) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("bar"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("bar"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3152,7 +3152,7 @@ TEST_F(ClientSocketPoolBaseTest, BackupSocketCancelAtMaxSockets) { ClientSocketHandle handles[kDefaultMaxSockets]; for (int i = 1; i < kDefaultMaxSockets; ++i) { TestCompletionCallback callback; - EXPECT_EQ(OK, handles[i].Init(TestGroupId("bar"), params_, base::nullopt, + EXPECT_EQ(OK, handles[i].Init(TestGroupId("bar"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), @@ -3183,7 +3183,7 @@ TEST_F(ClientSocketPoolBaseTest, CancelBackupSocketAfterCancelingAllRequests) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("bar"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("bar"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3215,7 +3215,7 @@ TEST_F(ClientSocketPoolBaseTest, CancelBackupSocketAfterFinishingAllRequests) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("bar"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("bar"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3224,7 +3224,7 @@ TEST_F(ClientSocketPoolBaseTest, CancelBackupSocketAfterFinishingAllRequests) { TestCompletionCallback callback2; EXPECT_EQ( ERR_IO_PENDING, - handle2.Init(TestGroupId("bar"), params_, base::nullopt, DEFAULT_PRIORITY, + handle2.Init(TestGroupId("bar"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3252,7 +3252,7 @@ TEST_F(ClientSocketPoolBaseTest, DelayedSocketBindingWaitingForConnect) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3267,7 +3267,7 @@ TEST_F(ClientSocketPoolBaseTest, DelayedSocketBindingWaitingForConnect) { ClientSocketHandle handle2; EXPECT_EQ( ERR_IO_PENDING, - handle2.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle2.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3308,7 +3308,7 @@ TEST_F(ClientSocketPoolBaseTest, DelayedSocketBindingAtGroupCapacity) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3323,7 +3323,7 @@ TEST_F(ClientSocketPoolBaseTest, DelayedSocketBindingAtGroupCapacity) { ClientSocketHandle handle2; EXPECT_EQ( ERR_IO_PENDING, - handle2.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle2.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3366,7 +3366,7 @@ TEST_F(ClientSocketPoolBaseTest, DelayedSocketBindingAtStall) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3381,7 +3381,7 @@ TEST_F(ClientSocketPoolBaseTest, DelayedSocketBindingAtStall) { ClientSocketHandle handle2; EXPECT_EQ( ERR_IO_PENDING, - handle2.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle2.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3427,7 +3427,7 @@ TEST_F(ClientSocketPoolBaseTest, SynchronouslyProcessOnePendingRequest) { TestCompletionCallback callback1; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3442,7 +3442,7 @@ TEST_F(ClientSocketPoolBaseTest, SynchronouslyProcessOnePendingRequest) { // when created. EXPECT_EQ( ERR_IO_PENDING, - handle2.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle2.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3463,7 +3463,7 @@ TEST_F(ClientSocketPoolBaseTest, PreferUsedSocketToUnusedSocket) { TestCompletionCallback callback1; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3472,7 +3472,7 @@ TEST_F(ClientSocketPoolBaseTest, PreferUsedSocketToUnusedSocket) { TestCompletionCallback callback2; EXPECT_EQ( ERR_IO_PENDING, - handle2.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle2.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3480,7 +3480,7 @@ TEST_F(ClientSocketPoolBaseTest, PreferUsedSocketToUnusedSocket) { TestCompletionCallback callback3; EXPECT_EQ( ERR_IO_PENDING, - handle3.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle3.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback3.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3500,17 +3500,17 @@ TEST_F(ClientSocketPoolBaseTest, PreferUsedSocketToUnusedSocket) { handle3.Reset(); EXPECT_EQ(OK, handle1.Init( - TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); EXPECT_EQ(OK, handle2.Init( - TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); EXPECT_EQ(OK, handle3.Init( - TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback3.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3524,7 +3524,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSockets) { CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); connect_job_factory_->set_job_type(TestConnectJob::kMockPendingJob); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, 2, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, 2, NetLogWithSource()); ASSERT_TRUE(pool_->HasGroupForTesting(TestGroupId("a"))); @@ -3539,7 +3539,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSockets) { TestCompletionCallback callback1; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3548,7 +3548,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSockets) { TestCompletionCallback callback2; EXPECT_EQ( ERR_IO_PENDING, - handle2.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle2.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3581,7 +3581,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsWhenAlreadyHaveAConnectJob) { TestCompletionCallback callback1; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3594,7 +3594,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsWhenAlreadyHaveAConnectJob) { pool_->NumUnassignedConnectJobsInGroupForTesting(TestGroupId("a"))); EXPECT_EQ(0u, pool_->IdleSocketCountInGroup(TestGroupId("a"))); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, 2, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, 2, NetLogWithSource()); EXPECT_EQ(2u, pool_->NumConnectJobsInGroupForTesting(TestGroupId("a"))); @@ -3608,7 +3608,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsWhenAlreadyHaveAConnectJob) { TestCompletionCallback callback2; EXPECT_EQ( ERR_IO_PENDING, - handle2.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle2.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3642,7 +3642,7 @@ TEST_F(ClientSocketPoolBaseTest, TestCompletionCallback callback1; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3651,7 +3651,7 @@ TEST_F(ClientSocketPoolBaseTest, TestCompletionCallback callback2; EXPECT_EQ( ERR_IO_PENDING, - handle2.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle2.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3660,7 +3660,7 @@ TEST_F(ClientSocketPoolBaseTest, TestCompletionCallback callback3; EXPECT_EQ( ERR_IO_PENDING, - handle3.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle3.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback3.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3673,7 +3673,7 @@ TEST_F(ClientSocketPoolBaseTest, pool_->NumUnassignedConnectJobsInGroupForTesting(TestGroupId("a"))); EXPECT_EQ(0u, pool_->IdleSocketCountInGroup(TestGroupId("a"))); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, 2, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, 2, NetLogWithSource()); EXPECT_EQ(3u, pool_->NumConnectJobsInGroupForTesting(TestGroupId("a"))); @@ -3704,7 +3704,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsAtMaxSocketLimit) { ASSERT_FALSE(pool_->HasGroupForTesting(TestGroupId("a"))); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, kDefaultMaxSockets, NetLogWithSource()); ASSERT_TRUE(pool_->HasGroupForTesting(TestGroupId("a"))); @@ -3721,7 +3721,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsAtMaxSocketLimit) { ASSERT_FALSE(pool_->HasGroupForTesting(TestGroupId("b"))); - pool_->RequestSockets(TestGroupId("b"), params_, base::nullopt, + pool_->RequestSockets(TestGroupId("b"), params_, absl::nullopt, kDefaultMaxSockets, NetLogWithSource()); ASSERT_FALSE(pool_->HasGroupForTesting(TestGroupId("b"))); @@ -3733,7 +3733,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsHitMaxSocketLimit) { ASSERT_FALSE(pool_->HasGroupForTesting(TestGroupId("a"))); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, kDefaultMaxSockets - 1, NetLogWithSource()); ASSERT_TRUE(pool_->HasGroupForTesting(TestGroupId("a"))); @@ -3751,7 +3751,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsHitMaxSocketLimit) { ASSERT_FALSE(pool_->HasGroupForTesting(TestGroupId("b"))); - pool_->RequestSockets(TestGroupId("b"), params_, base::nullopt, + pool_->RequestSockets(TestGroupId("b"), params_, absl::nullopt, kDefaultMaxSockets, NetLogWithSource()); ASSERT_TRUE(pool_->HasGroupForTesting(TestGroupId("b"))); @@ -3767,7 +3767,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsCountIdleSockets) { TestCompletionCallback callback1; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3782,7 +3782,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsCountIdleSockets) { pool_->NumUnassignedConnectJobsInGroupForTesting(TestGroupId("a"))); EXPECT_EQ(1u, pool_->IdleSocketCountInGroup(TestGroupId("a"))); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, 2, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, 2, NetLogWithSource()); EXPECT_EQ(1u, pool_->NumConnectJobsInGroupForTesting(TestGroupId("a"))); @@ -3801,7 +3801,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsCountActiveSockets) { TestCompletionCallback callback1; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3816,7 +3816,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsCountActiveSockets) { EXPECT_EQ(0u, pool_->IdleSocketCountInGroup(TestGroupId("a"))); EXPECT_EQ(1, pool_->NumActiveSocketsInGroupForTesting(TestGroupId("a"))); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, 2, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, 2, NetLogWithSource()); EXPECT_EQ(1u, pool_->NumConnectJobsInGroupForTesting(TestGroupId("a"))); @@ -3832,7 +3832,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsSynchronous) { CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); connect_job_factory_->set_job_type(TestConnectJob::kMockJob); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, kDefaultMaxSocketsPerGroup, NetLogWithSource()); ASSERT_TRUE(pool_->HasGroupForTesting(TestGroupId("a"))); @@ -3844,7 +3844,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsSynchronous) { EXPECT_EQ(kDefaultMaxSocketsPerGroup, static_cast(pool_->IdleSocketCountInGroup(TestGroupId("a")))); - pool_->RequestSockets(TestGroupId("b"), params_, base::nullopt, + pool_->RequestSockets(TestGroupId("b"), params_, absl::nullopt, kDefaultMaxSocketsPerGroup, NetLogWithSource()); EXPECT_EQ(0u, pool_->NumConnectJobsInGroupForTesting(TestGroupId("b"))); @@ -3860,14 +3860,14 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsSynchronousError) { CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); connect_job_factory_->set_job_type(TestConnectJob::kMockFailingJob); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, kDefaultMaxSocketsPerGroup, NetLogWithSource()); ASSERT_FALSE(pool_->HasGroupForTesting(TestGroupId("a"))); connect_job_factory_->set_job_type( TestConnectJob::kMockAdditionalErrorStateJob); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, kDefaultMaxSocketsPerGroup, NetLogWithSource()); ASSERT_FALSE(pool_->HasGroupForTesting(TestGroupId("a"))); @@ -3877,7 +3877,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsMultipleTimesDoesNothing) { CreatePool(4, 4); connect_job_factory_->set_job_type(TestConnectJob::kMockWaitingJob); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, 2, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, 2, NetLogWithSource()); ASSERT_TRUE(pool_->HasGroupForTesting(TestGroupId("a"))); @@ -3889,7 +3889,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsMultipleTimesDoesNothing) { EXPECT_EQ(0, pool_->NumActiveSocketsInGroupForTesting(TestGroupId("a"))); EXPECT_EQ(0u, pool_->IdleSocketCountInGroup(TestGroupId("a"))); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, 2, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, 2, NetLogWithSource()); EXPECT_EQ(2u, pool_->NumConnectJobsInGroupForTesting(TestGroupId("a"))); EXPECT_EQ(2u, pool_->NumNeverAssignedConnectJobsInGroupForTesting( @@ -3903,7 +3903,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsMultipleTimesDoesNothing) { TestCompletionCallback callback1; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3923,7 +3923,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsMultipleTimesDoesNothing) { TestCompletionCallback callback2; EXPECT_EQ( ERR_IO_PENDING, - handle2.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle2.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -3949,7 +3949,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsMultipleTimesDoesNothing) { EXPECT_EQ(0, pool_->NumActiveSocketsInGroupForTesting(TestGroupId("a"))); EXPECT_EQ(2u, pool_->IdleSocketCountInGroup(TestGroupId("a"))); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, 2, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, 2, NetLogWithSource()); EXPECT_EQ(0u, pool_->NumConnectJobsInGroupForTesting(TestGroupId("a"))); EXPECT_EQ(0u, pool_->NumNeverAssignedConnectJobsInGroupForTesting( @@ -3964,7 +3964,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsDifferentNumSockets) { CreatePool(4, 4); connect_job_factory_->set_job_type(TestConnectJob::kMockPendingJob); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, 1, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, 1, NetLogWithSource()); ASSERT_TRUE(pool_->HasGroupForTesting(TestGroupId("a"))); @@ -3975,7 +3975,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsDifferentNumSockets) { pool_->NumUnassignedConnectJobsInGroupForTesting(TestGroupId("a"))); EXPECT_EQ(0u, pool_->IdleSocketCountInGroup(TestGroupId("a"))); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, 2, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, 2, NetLogWithSource()); EXPECT_EQ(2u, pool_->NumConnectJobsInGroupForTesting(TestGroupId("a"))); EXPECT_EQ(2u, pool_->NumNeverAssignedConnectJobsInGroupForTesting( @@ -3984,7 +3984,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsDifferentNumSockets) { pool_->NumUnassignedConnectJobsInGroupForTesting(TestGroupId("a"))); EXPECT_EQ(0u, pool_->IdleSocketCountInGroup(TestGroupId("a"))); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, 3, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, 3, NetLogWithSource()); EXPECT_EQ(3u, pool_->NumConnectJobsInGroupForTesting(TestGroupId("a"))); EXPECT_EQ(3u, pool_->NumNeverAssignedConnectJobsInGroupForTesting( @@ -3993,7 +3993,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestSocketsDifferentNumSockets) { pool_->NumUnassignedConnectJobsInGroupForTesting(TestGroupId("a"))); EXPECT_EQ(0u, pool_->IdleSocketCountInGroup(TestGroupId("a"))); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, 1, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, 1, NetLogWithSource()); EXPECT_EQ(3u, pool_->NumConnectJobsInGroupForTesting(TestGroupId("a"))); EXPECT_EQ(3u, pool_->NumNeverAssignedConnectJobsInGroupForTesting( @@ -4007,7 +4007,7 @@ TEST_F(ClientSocketPoolBaseTest, PreconnectJobsTakenByNormalRequests) { CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); connect_job_factory_->set_job_type(TestConnectJob::kMockWaitingJob); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, 1, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, 1, NetLogWithSource()); ASSERT_TRUE(pool_->HasGroupForTesting(TestGroupId("a"))); @@ -4022,7 +4022,7 @@ TEST_F(ClientSocketPoolBaseTest, PreconnectJobsTakenByNormalRequests) { TestCompletionCallback callback1; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4058,7 +4058,7 @@ TEST_F(ClientSocketPoolBaseTest, PreconnectJobsTakenByNormalRequests) { TEST_F(ClientSocketPoolBaseTest, ConnectedPreconnectJobsHaveNoConnectTimes) { CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); connect_job_factory_->set_job_type(TestConnectJob::kMockJob); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, 1, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, 1, NetLogWithSource()); ASSERT_TRUE(pool_->HasGroupForTesting(TestGroupId("a"))); @@ -4072,7 +4072,7 @@ TEST_F(ClientSocketPoolBaseTest, ConnectedPreconnectJobsHaveNoConnectTimes) { ClientSocketHandle handle; TestCompletionCallback callback; EXPECT_EQ(OK, handle.Init( - TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4100,7 +4100,7 @@ TEST_F(ClientSocketPoolBaseTest, PreconnectClosesIdleSocketRemovesGroup) { TestCompletionCallback callback1; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4129,13 +4129,13 @@ TEST_F(ClientSocketPoolBaseTest, PreconnectClosesIdleSocketRemovesGroup) { TestCompletionCallback callback2; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("b"), params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(TestGroupId("b"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); EXPECT_EQ( ERR_IO_PENDING, - handle2.Init(TestGroupId("b"), params_, base::nullopt, DEFAULT_PRIORITY, + handle2.Init(TestGroupId("b"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4163,7 +4163,7 @@ TEST_F(ClientSocketPoolBaseTest, PreconnectClosesIdleSocketRemovesGroup) { // Requesting 2 preconnected sockets for "a" should fail to allocate any more // sockets for "a", and "b" should still have 2 active sockets. - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, 2, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, 2, NetLogWithSource()); EXPECT_EQ(0u, pool_->NumConnectJobsInGroupForTesting(TestGroupId("a"))); EXPECT_EQ(0u, pool_->NumNeverAssignedConnectJobsInGroupForTesting( @@ -4188,7 +4188,7 @@ TEST_F(ClientSocketPoolBaseTest, PreconnectClosesIdleSocketRemovesGroup) { EXPECT_EQ(2u, pool_->IdleSocketCountInGroup(TestGroupId("b"))); EXPECT_EQ(0, pool_->NumActiveSocketsInGroupForTesting(TestGroupId("b"))); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, 2, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, 2, NetLogWithSource()); EXPECT_EQ(1u, pool_->NumConnectJobsInGroupForTesting(TestGroupId("a"))); EXPECT_EQ(1u, pool_->NumNeverAssignedConnectJobsInGroupForTesting( @@ -4214,7 +4214,7 @@ TEST_F(ClientSocketPoolBaseTest, PreconnectWithoutBackupJob) { connect_job_factory_->set_job_type(TestConnectJob::kMockWaitingJob); connect_job_factory_->set_timeout_duration( base::TimeDelta::FromMilliseconds(500)); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, 1, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, 1, NetLogWithSource()); EXPECT_EQ(1u, pool_->NumConnectJobsInGroupForTesting(TestGroupId("a"))); EXPECT_EQ(1u, pool_->NumNeverAssignedConnectJobsInGroupForTesting( @@ -4240,7 +4240,7 @@ TEST_F(ClientSocketPoolBaseTest, PreconnectWithBackupJob) { // Make the ConnectJob hang forever. connect_job_factory_->set_job_type(TestConnectJob::kMockWaitingJob); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, 1, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, 1, NetLogWithSource()); EXPECT_EQ(1u, pool_->NumConnectJobsInGroupForTesting(TestGroupId("a"))); EXPECT_EQ(1u, pool_->NumNeverAssignedConnectJobsInGroupForTesting( @@ -4256,7 +4256,7 @@ TEST_F(ClientSocketPoolBaseTest, PreconnectWithBackupJob) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4287,7 +4287,7 @@ TEST_F(ClientSocketPoolBaseTest, PreconnectWithUnreadData) { CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); connect_job_factory_->set_job_type(TestConnectJob::kMockUnreadDataJob); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, 1, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, 1, NetLogWithSource()); ASSERT_TRUE(pool_->HasGroupForTesting(TestGroupId("a"))); @@ -4304,7 +4304,7 @@ TEST_F(ClientSocketPoolBaseTest, PreconnectWithUnreadData) { ClientSocketHandle handle; TestCompletionCallback callback; EXPECT_EQ(OK, handle.Init( - TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4336,7 +4336,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestGetsAssignedJob) { TestCompletionCallback callback1; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4360,7 +4360,7 @@ TEST_F(ClientSocketPoolBaseTest, MultipleRequestsGetAssignedJobs) { TestCompletionCallback callback1; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4376,7 +4376,7 @@ TEST_F(ClientSocketPoolBaseTest, MultipleRequestsGetAssignedJobs) { TestCompletionCallback callback2; EXPECT_EQ( ERR_IO_PENDING, - handle2.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle2.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4413,7 +4413,7 @@ TEST_F(ClientSocketPoolBaseTest, PreconnectJobGetsAssignedToRequest) { CreatePool(kDefaultMaxSockets, kDefaultMaxSocketsPerGroup); connect_job_factory_->set_job_type(TestConnectJob::kMockWaitingJob); - pool_->RequestSockets(TestGroupId("a"), params_, base::nullopt, 1, + pool_->RequestSockets(TestGroupId("a"), params_, absl::nullopt, 1, NetLogWithSource()); ASSERT_TRUE(pool_->HasGroupForTesting(TestGroupId("a"))); @@ -4428,7 +4428,7 @@ TEST_F(ClientSocketPoolBaseTest, PreconnectJobGetsAssignedToRequest) { TestCompletionCallback callback1; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4452,7 +4452,7 @@ TEST_F(ClientSocketPoolBaseTest, HigherPriorityRequestStealsJob) { TestCompletionCallback callback1; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4472,7 +4472,7 @@ TEST_F(ClientSocketPoolBaseTest, HigherPriorityRequestStealsJob) { TestCompletionCallback callback2; EXPECT_EQ( ERR_IO_PENDING, - handle2.Init(TestGroupId("a"), params_, base::nullopt, HIGHEST, + handle2.Init(TestGroupId("a"), params_, absl::nullopt, HIGHEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4500,7 +4500,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestStealsJobFromLowestRequestWithJob) { TestCompletionCallback callback_lowest; EXPECT_EQ( ERR_IO_PENDING, - handle_lowest.Init(TestGroupId("a"), params_, base::nullopt, LOWEST, + handle_lowest.Init(TestGroupId("a"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback_lowest.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), @@ -4517,7 +4517,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestStealsJobFromLowestRequestWithJob) { TestCompletionCallback callback_highest; EXPECT_EQ( ERR_IO_PENDING, - handle_highest.Init(TestGroupId("a"), params_, base::nullopt, HIGHEST, + handle_highest.Init(TestGroupId("a"), params_, absl::nullopt, HIGHEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback_highest.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), @@ -4534,7 +4534,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestStealsJobFromLowestRequestWithJob) { TestCompletionCallback callback_low; EXPECT_EQ(ERR_IO_PENDING, handle_low.Init( - TestGroupId("a"), params_, base::nullopt, LOW, SocketTag(), + TestGroupId("a"), params_, absl::nullopt, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback_low.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4550,7 +4550,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestStealsJobFromLowestRequestWithJob) { TestCompletionCallback callback_lowest2; EXPECT_EQ( ERR_IO_PENDING, - handle_lowest2.Init(TestGroupId("a"), params_, base::nullopt, LOWEST, + handle_lowest2.Init(TestGroupId("a"), params_, absl::nullopt, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback_lowest2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), @@ -4579,7 +4579,7 @@ TEST_F(ClientSocketPoolBaseTest, RequestStealsJobFromLowestRequestWithJob) { TestCompletionCallback callback_medium; EXPECT_EQ( ERR_IO_PENDING, - handle_medium.Init(TestGroupId("a"), params_, base::nullopt, MEDIUM, + handle_medium.Init(TestGroupId("a"), params_, absl::nullopt, MEDIUM, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback_medium.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), @@ -4611,7 +4611,7 @@ TEST_F(ClientSocketPoolBaseTest, ReprioritizeRequestStealsJob) { TestCompletionCallback callback1; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4627,7 +4627,7 @@ TEST_F(ClientSocketPoolBaseTest, ReprioritizeRequestStealsJob) { TestCompletionCallback callback2; EXPECT_EQ( ERR_IO_PENDING, - handle2.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle2.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4662,7 +4662,7 @@ TEST_F(ClientSocketPoolBaseTest, CancelRequestReassignsJob) { TestCompletionCallback callback1; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4681,7 +4681,7 @@ TEST_F(ClientSocketPoolBaseTest, CancelRequestReassignsJob) { TestCompletionCallback callback2; EXPECT_EQ( ERR_IO_PENDING, - handle2.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle2.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4720,7 +4720,7 @@ TEST_F(ClientSocketPoolBaseTest, JobCompletionReassignsJob) { TestCompletionCallback callback1; EXPECT_EQ( ERR_IO_PENDING, - handle1.Init(TestGroupId("a"), params_, base::nullopt, HIGHEST, + handle1.Init(TestGroupId("a"), params_, absl::nullopt, HIGHEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4736,7 +4736,7 @@ TEST_F(ClientSocketPoolBaseTest, JobCompletionReassignsJob) { TestCompletionCallback callback2; EXPECT_EQ( ERR_IO_PENDING, - handle2.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle2.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4783,7 +4783,7 @@ class MockLayeredPool : public HigherLayeredPool { int RequestSocket(TransportClientSocketPool* pool) { return handle_.Init( group_id_, ClientSocketPool::SocketParams::CreateForHttpForTesting(), - base::nullopt, DEFAULT_PRIORITY, SocketTag(), + absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback_.callback(), ClientSocketPool::ProxyAuthCallback(), pool, NetLogWithSource()); } @@ -4791,7 +4791,7 @@ class MockLayeredPool : public HigherLayeredPool { int RequestSocketWithoutLimits(TransportClientSocketPool* pool) { return handle_.Init( group_id_, ClientSocketPool::SocketParams::CreateForHttpForTesting(), - base::nullopt, MAXIMUM_PRIORITY, SocketTag(), + absl::nullopt, MAXIMUM_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::DISABLED, callback_.callback(), ClientSocketPool::ProxyAuthCallback(), pool, NetLogWithSource()); } @@ -4834,7 +4834,7 @@ TEST_F(ClientSocketPoolBaseTest, CloseIdleSocketsHeldByLayeredPoolWhenNeeded) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4858,7 +4858,7 @@ TEST_F(ClientSocketPoolBaseTest, TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4880,7 +4880,7 @@ TEST_F(ClientSocketPoolBaseTest, // has the maximum number of connections already, it's not stalled). ClientSocketHandle handle1; TestCompletionCallback callback1; - EXPECT_EQ(OK, handle1.Init(TestGroupId("group1"), params_, base::nullopt, + EXPECT_EQ(OK, handle1.Init(TestGroupId("group1"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), @@ -4896,7 +4896,7 @@ TEST_F(ClientSocketPoolBaseTest, TestCompletionCallback callback2; EXPECT_EQ(ERR_IO_PENDING, handle.Init( - TestGroupId("group2"), params_, base::nullopt, DEFAULT_PRIORITY, + TestGroupId("group2"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4917,7 +4917,7 @@ TEST_F(ClientSocketPoolBaseTest, ClientSocketHandle handle1; TestCompletionCallback callback1; - EXPECT_EQ(OK, handle1.Init(TestGroupId("group1"), params_, base::nullopt, + EXPECT_EQ(OK, handle1.Init(TestGroupId("group1"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), @@ -4936,7 +4936,7 @@ TEST_F(ClientSocketPoolBaseTest, TestCompletionCallback callback3; EXPECT_EQ(ERR_IO_PENDING, handle3.Init( - TestGroupId("group3"), params_, base::nullopt, DEFAULT_PRIORITY, + TestGroupId("group3"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback3.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4952,7 +4952,7 @@ TEST_F(ClientSocketPoolBaseTest, TestCompletionCallback callback4; EXPECT_EQ(ERR_IO_PENDING, handle4.Init( - TestGroupId("group3"), params_, base::nullopt, DEFAULT_PRIORITY, + TestGroupId("group3"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback4.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -4982,7 +4982,7 @@ TEST_F(ClientSocketPoolBaseTest, ClientSocketHandle handle1; TestCompletionCallback callback1; - EXPECT_EQ(OK, handle1.Init(TestGroupId("group1"), params_, base::nullopt, + EXPECT_EQ(OK, handle1.Init(TestGroupId("group1"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), @@ -5001,7 +5001,7 @@ TEST_F(ClientSocketPoolBaseTest, TestCompletionCallback callback3; EXPECT_EQ( ERR_IO_PENDING, - handle3.Init(TestGroupId("group3"), params_, base::nullopt, MEDIUM, + handle3.Init(TestGroupId("group3"), params_, absl::nullopt, MEDIUM, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback3.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -5016,7 +5016,7 @@ TEST_F(ClientSocketPoolBaseTest, TestCompletionCallback callback4; EXPECT_EQ( ERR_IO_PENDING, - handle4.Init(TestGroupId("group3"), params_, base::nullopt, HIGHEST, + handle4.Init(TestGroupId("group3"), params_, absl::nullopt, HIGHEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback4.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -5048,7 +5048,7 @@ TEST_F(ClientSocketPoolBaseTest, TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -5130,7 +5130,7 @@ TEST_F(ClientSocketPoolBaseTest, ProxyAuthNoAuthCallback) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(TestGroupId("a"), params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(TestGroupId("a"), params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -5158,7 +5158,7 @@ class TestAuthHelper { ClientSocketPool::RespectLimits::ENABLED, const ClientSocketPool::GroupId& group_id_in = TestGroupId("a")) { EXPECT_EQ(ERR_IO_PENDING, - handle_.Init(group_id_in, params, base::nullopt, priority, + handle_.Init(group_id_in, params, absl::nullopt, priority, SocketTag(), respect_limits, callback_.callback(), base::BindRepeating(&TestAuthHelper::AuthCallback, base::Unretained(this)), @@ -5691,7 +5691,7 @@ TEST_P(ClientSocketPoolBaseRefreshTest, RefreshGroupCreatesNewConnectJobs) { ClientSocketHandle handle; TestCompletionCallback callback; EXPECT_THAT( - handle.Init(kGroupId, params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(kGroupId, params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()), @@ -5720,9 +5720,9 @@ TEST_P(ClientSocketPoolBaseRefreshTest, RefreshGroupClosesIdleConnectJobs) { const ClientSocketPool::GroupId kGroupId = GetGroupId(); const ClientSocketPool::GroupId kGroupIdInPartition = GetGroupIdInPartition(); - pool_->RequestSockets(kGroupId, params_, base::nullopt, 2, + pool_->RequestSockets(kGroupId, params_, absl::nullopt, 2, NetLogWithSource()); - pool_->RequestSockets(kGroupIdInPartition, params_, base::nullopt, 2, + pool_->RequestSockets(kGroupIdInPartition, params_, absl::nullopt, 2, NetLogWithSource()); ASSERT_TRUE(pool_->HasGroupForTesting(kGroupId)); ASSERT_TRUE(pool_->HasGroupForTesting(kGroupIdInPartition)); @@ -5744,7 +5744,7 @@ TEST_F(ClientSocketPoolBaseTest, const ClientSocketPool::GroupId kOtherGroupId = TestGroupId("b", 443, ClientSocketPool::SocketType::kSsl); - pool_->RequestSockets(kOtherGroupId, params_, base::nullopt, 2, + pool_->RequestSockets(kOtherGroupId, params_, absl::nullopt, 2, NetLogWithSource()); ASSERT_TRUE(pool_->HasGroupForTesting(kOtherGroupId)); EXPECT_EQ(2, pool_->IdleSocketCount()); @@ -5763,7 +5763,7 @@ TEST_P(ClientSocketPoolBaseRefreshTest, RefreshGroupPreventsSocketReuse) { ClientSocketHandle handle; TestCompletionCallback callback; EXPECT_THAT( - handle.Init(kGroupId, params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(kGroupId, params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()), @@ -5789,7 +5789,7 @@ TEST_F(ClientSocketPoolBaseTest, ClientSocketHandle handle; TestCompletionCallback callback; EXPECT_THAT( - handle.Init(kOtherGroupId, params_, base::nullopt, DEFAULT_PRIORITY, + handle.Init(kOtherGroupId, params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()), @@ -5863,19 +5863,19 @@ TEST_F(ClientSocketPoolBaseTest, RefreshProxyRefreshesAllGroups) { ClientSocketHandle handle1, handle2, handle3; TestCompletionCallback callback; EXPECT_THAT( - handle1.Init(kGroupId1, params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(kGroupId1, params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()), IsOk()); EXPECT_THAT( - handle2.Init(kGroupId2, params_, base::nullopt, DEFAULT_PRIORITY, + handle2.Init(kGroupId2, params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()), IsOk()); EXPECT_THAT( - handle3.Init(kGroupId3, params_, base::nullopt, DEFAULT_PRIORITY, + handle3.Init(kGroupId3, params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()), @@ -5937,19 +5937,19 @@ TEST_F(ClientSocketPoolBaseTest, RefreshBothPrivacyAndNormalSockets) { ClientSocketHandle handle1, handle2, handle3; TestCompletionCallback callback; EXPECT_THAT( - handle1.Init(kGroupId, params_, base::nullopt, DEFAULT_PRIORITY, + handle1.Init(kGroupId, params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()), IsOk()); EXPECT_THAT( - handle2.Init(kGroupIdPrivacy, params_, base::nullopt, DEFAULT_PRIORITY, + handle2.Init(kGroupIdPrivacy, params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()), IsOk()); EXPECT_THAT( - handle3.Init(kOtherGroupId, params_, base::nullopt, DEFAULT_PRIORITY, + handle3.Init(kOtherGroupId, params_, absl::nullopt, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()), diff --git a/net/socket/client_socket_pool_manager.cc b/net/socket/client_socket_pool_manager.cc index e6682d31f69250..0a8e29845fd74e 100644 --- a/net/socket/client_socket_pool_manager.cc +++ b/net/socket/client_socket_pool_manager.cc @@ -8,7 +8,6 @@ #include "base/check_op.h" #include "base/metrics/field_trial_params.h" -#include "base/optional.h" #include "base/stl_util.h" #include "build/build_config.h" #include "net/base/features.h" @@ -20,6 +19,7 @@ #include "net/socket/client_socket_pool.h" #include "net/socket/connect_job.h" #include "net/ssl/ssl_config.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -143,9 +143,9 @@ int InitSocketPoolHelper( if ((request_load_flags & LOAD_IGNORE_LIMITS) != 0) respect_limits = ClientSocketPool::RespectLimits::DISABLED; - base::Optional proxy_annotation = - proxy_info.is_direct() ? base::nullopt - : base::Optional( + absl::optional proxy_annotation = + proxy_info.is_direct() ? absl::nullopt + : absl::optional( proxy_info.traffic_annotation()); if (num_preconnect_streams) { pool->RequestSockets(connection_group, std::move(socket_params), diff --git a/net/socket/connect_job.cc b/net/socket/connect_job.cc index 89773f2b3b95c8..8335b5faf94b68 100644 --- a/net/socket/connect_job.cc +++ b/net/socket/connect_job.cc @@ -100,7 +100,7 @@ std::unique_ptr ConnectJob::CreateConnectJob( bool using_ssl, const HostPortPair& endpoint, const ProxyServer& proxy_server, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, const SSLConfig* ssl_config_for_origin, const SSLConfig* ssl_config_for_proxy, bool force_tunnel, @@ -228,7 +228,7 @@ scoped_refptr ConnectJob::GetCertRequestInfo() { void ConnectJob::SetSocket( std::unique_ptr socket, - base::Optional> dns_aliases) { + absl::optional> dns_aliases) { if (socket) { net_log().AddEvent(NetLogEventType::CONNECT_JOB_SET_SOCKET); if (dns_aliases) @@ -277,7 +277,7 @@ void ConnectJob::LogConnectCompletion(int net_error) { void ConnectJob::OnTimeout() { // Make sure the socket is NULL before calling into |delegate|. - SetSocket(nullptr, base::nullopt /* dns_aliases */); + SetSocket(nullptr, absl::nullopt /* dns_aliases */); OnTimedOutInternal(); diff --git a/net/socket/connect_job.h b/net/socket/connect_job.h index 4ab86946d856bb..ace3b8b7939671 100644 --- a/net/socket/connect_job.h +++ b/net/socket/connect_job.h @@ -12,7 +12,6 @@ #include "base/callback_forward.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "base/time/time.h" #include "base/timer/timer.h" #include "net/base/address_list.h" @@ -28,6 +27,7 @@ #include "net/socket/socket_tag.h" #include "net/socket/ssl_client_socket.h" #include "net/third_party/quiche/src/quic/core/quic_versions.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -182,7 +182,7 @@ class NET_EXPORT_PRIVATE ConnectJob { bool using_ssl, const HostPortPair& endpoint, const ProxyServer& proxy_server, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, const SSLConfig* ssl_config_for_origin, const SSLConfig* ssl_config_for_proxy, bool force_tunnel, @@ -287,7 +287,7 @@ class NET_EXPORT_PRIVATE ConnectJob { } void SetSocket(std::unique_ptr socket, - base::Optional> dns_aliases); + absl::optional> dns_aliases); void NotifyDelegateOfCompletion(int rv); void NotifyDelegateOfProxyAuth(const HttpResponseInfo& response, HttpAuthController* auth_controller, diff --git a/net/socket/connect_job_unittest.cc b/net/socket/connect_job_unittest.cc index 5ec9c067304420..230396e638e51a 100644 --- a/net/socket/connect_job_unittest.cc +++ b/net/socket/connect_job_unittest.cc @@ -69,7 +69,7 @@ class TestConnectJob : public ConnectJob { int ConnectInternal() override { SetSocket(std::unique_ptr(new MockTCPClientSocket( AddressList(), net_log().net_log(), &socket_data_provider_)), - base::nullopt /* dns_aliases */); + absl::nullopt /* dns_aliases */); return socket()->Connect(base::BindOnce( &TestConnectJob::NotifyDelegateOfCompletion, base::Unretained(this))); } diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc index 1be7f8fbeea790..8d6dac1c2523df 100644 --- a/net/socket/socket_test_util.cc +++ b/net/socket/socket_test_util.cc @@ -1606,7 +1606,7 @@ NextProto MockSSLClientSocket::GetNegotiatedProtocol() const { return data_->next_proto; } -base::Optional +absl::optional MockSSLClientSocket::GetPeerApplicationSettings() const { return data_->peer_application_settings; } @@ -2179,7 +2179,7 @@ MockTransportClientSocketPool::~MockTransportClientSocketPool() = default; int MockTransportClientSocketPool::RequestSocket( const ClientSocketPool::GroupId& group_id, scoped_refptr socket_params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, RequestPriority priority, const SocketTag& socket_tag, RespectLimits respect_limits, diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h index 4c390f3d39ecf4..4764ab202968c9 100644 --- a/net/socket/socket_test_util.h +++ b/net/socket/socket_test_util.h @@ -22,7 +22,6 @@ #include "base/memory/ptr_util.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "build/build_config.h" #include "net/base/address_list.h" #include "net/base/completion_once_callback.h" @@ -45,6 +44,7 @@ #include "net/ssl/ssl_config_service.h" #include "net/ssl/ssl_info.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { class RunLoop; @@ -489,7 +489,7 @@ struct SSLSocketDataProvider { NextProto next_proto; // Result for GetPeerApplicationSettings(). - base::Optional peer_application_settings; + absl::optional peer_application_settings; // Result for GetSSLInfo(). SSLInfo ssl_info; @@ -497,15 +497,15 @@ struct SSLSocketDataProvider { // Result for GetSSLCertRequestInfo(). SSLCertRequestInfo* cert_request_info; - base::Optional next_protos_expected_in_ssl_config; + absl::optional next_protos_expected_in_ssl_config; uint16_t expected_ssl_version_min; uint16_t expected_ssl_version_max; - base::Optional expected_send_client_cert; + absl::optional expected_send_client_cert; scoped_refptr expected_client_cert; - base::Optional expected_host_and_port; - base::Optional expected_network_isolation_key; - base::Optional expected_disable_legacy_crypto; + absl::optional expected_host_and_port; + absl::optional expected_network_isolation_key; + absl::optional expected_disable_legacy_crypto; bool is_connect_data_consumed = false; bool is_confirm_data_consumed = false; @@ -980,7 +980,7 @@ class MockSSLClientSocket : public AsyncSocket, public SSLClientSocket { int GetLocalAddress(IPEndPoint* address) const override; bool WasAlpnNegotiated() const override; NextProto GetNegotiatedProtocol() const override; - base::Optional GetPeerApplicationSettings() const override; + absl::optional GetPeerApplicationSettings() const override; bool GetSSLInfo(SSLInfo* ssl_info) override; void GetSSLCertRequestInfo( SSLCertRequestInfo* cert_request_info) const override; @@ -1192,7 +1192,7 @@ class ClientSocketPoolTest { new TestSocketRequest(&request_order_, &completion_count_)); requests_.push_back(base::WrapUnique(request)); int rv = request->handle()->Init( - group_id, socket_params, base::nullopt /* proxy_annotation_tag */, + group_id, socket_params, absl::nullopt /* proxy_annotation_tag */, priority, SocketTag(), respect_limits, request->callback(), ClientSocketPool::ProxyAuthCallback(), socket_pool, NetLogWithSource()); if (rv != ERR_IO_PENDING) @@ -1293,7 +1293,7 @@ class MockTransportClientSocketPool : public TransportClientSocketPool { int RequestSocket( const GroupId& group_id, scoped_refptr socket_params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, RequestPriority priority, const SocketTag& socket_tag, RespectLimits respect_limits, diff --git a/net/socket/socks_connect_job.cc b/net/socket/socks_connect_job.cc index 586dd24e91ce14..97ee6f2f5cf196 100644 --- a/net/socket/socks_connect_job.cc +++ b/net/socket/socks_connect_job.cc @@ -191,7 +191,7 @@ int SOCKSConnectJob::DoSOCKSConnectComplete(int result) { return result; } - SetSocket(std::move(socket_), base::nullopt /* dns_aliases */); + SetSocket(std::move(socket_), absl::nullopt /* dns_aliases */); return result; } diff --git a/net/socket/ssl_client_socket_impl.cc b/net/socket/ssl_client_socket_impl.cc index 79c5d9a30987e3..d049893b0b5525 100644 --- a/net/socket/ssl_client_socket_impl.cc +++ b/net/socket/ssl_client_socket_impl.cc @@ -559,10 +559,10 @@ NextProto SSLClientSocketImpl::GetNegotiatedProtocol() const { return negotiated_protocol_; } -base::Optional +absl::optional SSLClientSocketImpl::GetPeerApplicationSettings() const { if (!SSL_has_application_settings(ssl_.get())) { - return base::nullopt; + return absl::nullopt; } const uint8_t* out_data; @@ -788,7 +788,7 @@ int SSLClientSocketImpl::Init() { if (IsCachingEnabled()) { bssl::UniquePtr session = context_->ssl_client_session_cache()->Lookup( - GetSessionCacheKey(/*dest_ip_addr=*/base::nullopt)); + GetSessionCacheKey(/*dest_ip_addr=*/absl::nullopt)); if (!session) { // If a previous session negotiated an RSA cipher suite then it may have // been inserted into the cache keyed by both hostname and resolved IP @@ -1562,7 +1562,7 @@ void SSLClientSocketImpl::DoPeek() { if (err == ERR_EARLY_DATA_REJECTED || err == ERR_WRONG_VERSION_ON_EARLY_DATA) { context_->ssl_client_session_cache()->ClearEarlyData( - GetSessionCacheKey(base::nullopt)); + GetSessionCacheKey(absl::nullopt)); } handled_early_data_result_ = true; @@ -1686,7 +1686,7 @@ int SSLClientSocketImpl::NewSessionCallback(SSL_SESSION* session) { if (!IsCachingEnabled()) return 0; - base::Optional ip_addr; + absl::optional ip_addr; if (SSL_CIPHER_get_kx_nid(SSL_SESSION_get0_cipher(session)) == NID_kx_rsa) { // If RSA key exchange was used, additionally key the cache with the // destination IP address. Of course, if a proxy is being used, the @@ -1707,7 +1707,7 @@ int SSLClientSocketImpl::NewSessionCallback(SSL_SESSION* session) { } SSLClientSessionCache::Key SSLClientSocketImpl::GetSessionCacheKey( - base::Optional dest_ip_addr) const { + absl::optional dest_ip_addr) const { SSLClientSessionCache::Key key; key.server = host_and_port_; key.dest_ip_addr = dest_ip_addr; diff --git a/net/socket/ssl_client_socket_impl.h b/net/socket/ssl_client_socket_impl.h index 1f8e63a60b6013..83e5129092998d 100644 --- a/net/socket/ssl_client_socket_impl.h +++ b/net/socket/ssl_client_socket_impl.h @@ -17,7 +17,6 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "net/base/completion_once_callback.h" #include "net/base/host_port_pair.h" #include "net/base/io_buffer.h" @@ -33,6 +32,7 @@ #include "net/ssl/ssl_client_session_cache.h" #include "net/ssl/ssl_config.h" #include "net/traffic_annotation/network_traffic_annotation.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/boringssl/src/include/openssl/base.h" #include "third_party/boringssl/src/include/openssl/ssl.h" @@ -86,7 +86,7 @@ class SSLClientSocketImpl : public SSLClientSocket, bool WasEverUsed() const override; bool WasAlpnNegotiated() const override; NextProto GetNegotiatedProtocol() const override; - base::Optional GetPeerApplicationSettings() const override; + absl::optional GetPeerApplicationSettings() const override; bool GetSSLInfo(SSLInfo* ssl_info) override; void GetConnectionAttempts(ConnectionAttempts* out) const override; void ClearConnectionAttempts() override {} @@ -161,7 +161,7 @@ class SSLClientSocketImpl : public SSLClientSocket, // Returns a session cache key for this socket. SSLClientSessionCache::Key GetSessionCacheKey( - base::Optional dest_ip_addr) const; + absl::optional dest_ip_addr) const; // Returns true if renegotiations are allowed. bool IsRenegotiationAllowed() const; diff --git a/net/socket/ssl_client_socket_unittest.cc b/net/socket/ssl_client_socket_unittest.cc index 557a641c3ab456..099b67af7fd283 100644 --- a/net/socket/ssl_client_socket_unittest.cc +++ b/net/socket/ssl_client_socket_unittest.cc @@ -18,7 +18,6 @@ #include "base/location.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/stl_util.h" @@ -94,6 +93,7 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/boringssl/src/include/openssl/bio.h" #include "third_party/boringssl/src/include/openssl/evp.h" #include "third_party/boringssl/src/include/openssl/pem.h" @@ -1003,7 +1003,7 @@ std::vector GetTLSVersions() { SSL_PROTOCOL_VERSION_TLS1_2, SSL_PROTOCOL_VERSION_TLS1_3}; } -base::Optional +absl::optional ProtocolVersionToSpawnedTestServer(uint16_t version) { switch (version) { case SSL_PROTOCOL_VERSION_TLS1: @@ -1014,10 +1014,10 @@ ProtocolVersionToSpawnedTestServer(uint16_t version) { return SpawnedTestServer::SSLOptions::TLS_MAX_VERSION_TLS1_2; case SSL_PROTOCOL_VERSION_TLS1_3: // SpawnedTestServer does not support TLS 1.3. - return base::nullopt; + return absl::nullopt; default: ADD_FAILURE() << "Unknown version " << version; - return base::nullopt; + return absl::nullopt; } } diff --git a/net/socket/ssl_server_socket_impl.cc b/net/socket/ssl_server_socket_impl.cc index c2eedb838cc104..2b63812e48d8d6 100644 --- a/net/socket/ssl_server_socket_impl.cc +++ b/net/socket/ssl_server_socket_impl.cc @@ -12,7 +12,6 @@ #include "base/lazy_instance.h" #include "base/logging.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "base/strings/string_util.h" #include "crypto/openssl_util.h" #include "crypto/rsa_private_key.h" @@ -28,6 +27,7 @@ #include "net/ssl/ssl_connection_status_flags.h" #include "net/ssl/ssl_info.h" #include "net/traffic_annotation/network_traffic_annotation.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/boringssl/src/include/openssl/bytestring.h" #include "third_party/boringssl/src/include/openssl/err.h" #include "third_party/boringssl/src/include/openssl/pool.h" @@ -109,7 +109,7 @@ class SSLServerContextImpl::SocketImpl : public SSLServerSocket, bool WasEverUsed() const override; bool WasAlpnNegotiated() const override; NextProto GetNegotiatedProtocol() const override; - base::Optional GetPeerApplicationSettings() const override; + absl::optional GetPeerApplicationSettings() const override; bool GetSSLInfo(SSLInfo* ssl_info) override; void GetConnectionAttempts(ConnectionAttempts* out) const override; void ClearConnectionAttempts() override {} @@ -576,10 +576,10 @@ NextProto SSLServerContextImpl::SocketImpl::GetNegotiatedProtocol() const { return negotiated_protocol_; } -base::Optional +absl::optional SSLServerContextImpl::SocketImpl::GetPeerApplicationSettings() const { if (!SSL_has_application_settings(ssl_.get())) { - return base::nullopt; + return absl::nullopt; } const uint8_t* out_data; diff --git a/net/socket/stream_socket.cc b/net/socket/stream_socket.cc index e1e7d0d14318c8..f85ac8cc4c0220 100644 --- a/net/socket/stream_socket.cc +++ b/net/socket/stream_socket.cc @@ -13,9 +13,9 @@ void StreamSocket::SetBeforeConnectCallback( NOTREACHED(); } -base::Optional StreamSocket::GetPeerApplicationSettings() +absl::optional StreamSocket::GetPeerApplicationSettings() const { - return base::nullopt; + return absl::nullopt; } void StreamSocket::GetSSLCertRequestInfo( diff --git a/net/socket/stream_socket.h b/net/socket/stream_socket.h index d15f2829e86f6b..fd765764bd28ef 100644 --- a/net/socket/stream_socket.h +++ b/net/socket/stream_socket.h @@ -9,13 +9,13 @@ #include "base/bind.h" #include "base/macros.h" -#include "base/optional.h" #include "net/base/net_errors.h" #include "net/base/net_export.h" #include "net/dns/public/resolve_error_info.h" #include "net/socket/connection_attempts.h" #include "net/socket/next_proto.h" #include "net/socket/socket.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -140,7 +140,7 @@ class NET_EXPORT StreamSocket : public Socket { // Get data received from peer in ALPS TLS extension. // Returns a (possibly empty) value if a TLS version supporting ALPS was used // and ALPS was negotiated, nullopt otherwise. - virtual base::Optional GetPeerApplicationSettings() const; + virtual absl::optional GetPeerApplicationSettings() const; // Gets the SSL connection information of the socket. Returns false if // SSL was not used by this socket. diff --git a/net/socket/tcp_client_socket.cc b/net/socket/tcp_client_socket.cc index a049f46937622d..6a28311f175760 100644 --- a/net/socket/tcp_client_socket.cc +++ b/net/socket/tcp_client_socket.cc @@ -278,7 +278,7 @@ int TCPClientSocket::DoConnect() { int TCPClientSocket::DoConnectComplete(int result) { if (start_connect_attempt_) { EmitConnectAttemptHistograms(result); - start_connect_attempt_ = base::nullopt; + start_connect_attempt_ = absl::nullopt; connect_attempt_timer_.Stop(); } @@ -335,7 +335,7 @@ void TCPClientSocket::Disconnect() { void TCPClientSocket::DoDisconnect() { if (start_connect_attempt_) { EmitConnectAttemptHistograms(ERR_ABORTED); - start_connect_attempt_ = base::nullopt; + start_connect_attempt_ = absl::nullopt; connect_attempt_timer_.Stop(); } @@ -589,7 +589,7 @@ void TCPClientSocket::EmitConnectAttemptHistograms(int result) { UMA_HISTOGRAM_MEDIUM_TIMES("Net.TcpConnectAttempt.Latency.Error", duration); } - base::Optional transport_rtt = base::nullopt; + absl::optional transport_rtt = absl::nullopt; if (network_quality_estimator_) transport_rtt = network_quality_estimator_->GetTransportRTT(); @@ -625,7 +625,7 @@ base::TimeDelta TCPClientSocket::GetConnectAttemptTimeout() { if (!base::FeatureList::IsEnabled(features::kTimeoutTcpConnectAttempt)) return base::TimeDelta::Max(); - base::Optional transport_rtt = base::nullopt; + absl::optional transport_rtt = absl::nullopt; if (network_quality_estimator_) transport_rtt = network_quality_estimator_->GetTransportRTT(); diff --git a/net/socket/tcp_client_socket.h b/net/socket/tcp_client_socket.h index 6512770594ffcb..c3888a9fbed751 100644 --- a/net/socket/tcp_client_socket.h +++ b/net/socket/tcp_client_socket.h @@ -224,7 +224,7 @@ class NET_EXPORT TCPClientSocket : public TransportClientSocket, bool was_disconnected_on_suspend_; // The time when the latest connect attempt was started. - base::Optional start_connect_attempt_; + absl::optional start_connect_attempt_; // The NetworkQualityEstimator for the context this socket is associated with. // Can be nullptr. diff --git a/net/socket/transport_client_socket_pool.cc b/net/socket/transport_client_socket_pool.cc index e060c917de758d..c200f29958daee 100644 --- a/net/socket/transport_client_socket_pool.cc +++ b/net/socket/transport_client_socket_pool.cc @@ -92,7 +92,7 @@ class TransportClientSocketPool::ConnectJobFactoryImpl std::unique_ptr NewConnectJob( ClientSocketPool::GroupId group_id, scoped_refptr socket_params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, RequestPriority request_priority, SocketTag socket_tag, ConnectJob::Delegate* delegate) const override { @@ -119,7 +119,7 @@ TransportClientSocketPool::Request::Request( RespectLimits respect_limits, Flags flags, scoped_refptr socket_params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, const NetLogWithSource& net_log) : handle_(handle), callback_(std::move(callback)), @@ -260,7 +260,7 @@ void TransportClientSocketPool::RemoveHigherLayeredPool( int TransportClientSocketPool::RequestSocket( const GroupId& group_id, scoped_refptr params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, RequestPriority priority, const SocketTag& socket_tag, RespectLimits respect_limits, @@ -312,7 +312,7 @@ int TransportClientSocketPool::RequestSocket( void TransportClientSocketPool::RequestSockets( const GroupId& group_id, scoped_refptr params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, int num_sockets, const NetLogWithSource& net_log) { if (net_log.IsCapturing()) { @@ -1331,7 +1331,7 @@ void TransportClientSocketPool::OnConnectJobComplete(Group* group, // Check if the ConnectJob is already bound to a Request. If so, result is // returned to that specific request. - base::Optional bound_request = + absl::optional bound_request = group->FindAndRemoveBoundRequestForConnectJob(job); Request* request = nullptr; std::unique_ptr owned_request; @@ -1854,7 +1854,7 @@ TransportClientSocketPool::Group::BindRequestToConnectJob( return request; } -base::Optional +absl::optional TransportClientSocketPool::Group::FindAndRemoveBoundRequestForConnectJob( ConnectJob* connect_job) { for (auto bound_pair = bound_requests_.begin(); @@ -1865,7 +1865,7 @@ TransportClientSocketPool::Group::FindAndRemoveBoundRequestForConnectJob( bound_requests_.erase(bound_pair); return std::move(ret); } - return base::nullopt; + return absl::nullopt; } std::unique_ptr diff --git a/net/socket/transport_client_socket_pool.h b/net/socket/transport_client_socket_pool.h index ed6fe00ebe51a1..b711242e380fd4 100644 --- a/net/socket/transport_client_socket_pool.h +++ b/net/socket/transport_client_socket_pool.h @@ -19,7 +19,6 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "base/time/time.h" #include "base/timer/timer.h" #include "net/base/address_list.h" @@ -40,6 +39,7 @@ #include "net/socket/socket_tag.h" #include "net/socket/ssl_client_socket.h" #include "net/socket/stream_socket.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { namespace trace_event { @@ -103,7 +103,7 @@ class NET_EXPORT_PRIVATE TransportClientSocketPool RespectLimits respect_limits, Flags flags, scoped_refptr socket_params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, const NetLogWithSource& net_log); ~Request(); @@ -118,7 +118,7 @@ class NET_EXPORT_PRIVATE TransportClientSocketPool RespectLimits respect_limits() const { return respect_limits_; } Flags flags() const { return flags_; } SocketParams* socket_params() const { return socket_params_.get(); } - const base::Optional& proxy_annotation_tag() + const absl::optional& proxy_annotation_tag() const { return proxy_annotation_tag_; } @@ -142,7 +142,7 @@ class NET_EXPORT_PRIVATE TransportClientSocketPool const RespectLimits respect_limits_; const Flags flags_; const scoped_refptr socket_params_; - const base::Optional proxy_annotation_tag_; + const absl::optional proxy_annotation_tag_; const NetLogWithSource net_log_; const SocketTag socket_tag_; ConnectJob* job_; @@ -158,7 +158,7 @@ class NET_EXPORT_PRIVATE TransportClientSocketPool virtual std::unique_ptr NewConnectJob( ClientSocketPool::GroupId group_id, scoped_refptr socket_params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, RequestPriority request_priority, SocketTag socket_tag, ConnectJob::Delegate* delegate) const = 0; @@ -204,7 +204,7 @@ class NET_EXPORT_PRIVATE TransportClientSocketPool int RequestSocket( const GroupId& group_id, scoped_refptr params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, RequestPriority priority, const SocketTag& socket_tag, RespectLimits respect_limits, @@ -215,7 +215,7 @@ class NET_EXPORT_PRIVATE TransportClientSocketPool void RequestSockets( const GroupId& group_id, scoped_refptr params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, int num_sockets, const NetLogWithSource& net_log) override; void SetPriority(const GroupId& group_id, @@ -461,8 +461,8 @@ class NET_EXPORT_PRIVATE TransportClientSocketPool const Request* BindRequestToConnectJob(ConnectJob* connect_job); // Finds the request, if any, bound to |connect_job|, and returns the - // BoundRequest or base::nullopt if there was none. - base::Optional FindAndRemoveBoundRequestForConnectJob( + // BoundRequest or absl::nullopt if there was none. + absl::optional FindAndRemoveBoundRequestForConnectJob( ConnectJob* connect_job); // Finds the bound request, if any, corresponding to |client_socket_handle| diff --git a/net/socket/transport_client_socket_pool_unittest.cc b/net/socket/transport_client_socket_pool_unittest.cc index 68dbf42afd1f25..b016786f8bc01d 100644 --- a/net/socket/transport_client_socket_pool_unittest.cc +++ b/net/socket/transport_client_socket_pool_unittest.cc @@ -11,7 +11,6 @@ #include "base/callback.h" #include "base/callback_helpers.h" #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "base/run_loop.h" #include "base/stl_util.h" #include "base/test/bind.h" @@ -56,6 +55,7 @@ #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" using net::test::IsError; @@ -225,7 +225,7 @@ TEST_F(TransportClientSocketPoolTest, Basic) { TestCompletionCallback callback; ClientSocketHandle handle; int rv = - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -250,7 +250,7 @@ TEST_F(TransportClientSocketPoolTest, SetResolvePriorityOnInit) { EXPECT_EQ( ERR_IO_PENDING, handle.Init(group_id_, params_, - base::nullopt /* proxy_annotation_tag */, priority, + absl::nullopt /* proxy_annotation_tag */, priority, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -269,7 +269,7 @@ TEST_F(TransportClientSocketPoolTest, SetSecureDnsPolicy) { secure_dns_policy); EXPECT_EQ( ERR_IO_PENDING, - handle.Init(group_id, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); @@ -284,7 +284,7 @@ TEST_F(TransportClientSocketPoolTest, ReprioritizeRequests) { TestCompletionCallback callback1; ClientSocketHandle handle1; int rv1 = - handle1.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle1.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -293,7 +293,7 @@ TEST_F(TransportClientSocketPoolTest, ReprioritizeRequests) { TestCompletionCallback callback2; ClientSocketHandle handle2; int rv2 = handle2.Init( - group_id_, params_, base::nullopt /* proxy_annotation_tag */, HIGHEST, + group_id_, params_, absl::nullopt /* proxy_annotation_tag */, HIGHEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -302,7 +302,7 @@ TEST_F(TransportClientSocketPoolTest, ReprioritizeRequests) { TestCompletionCallback callback3; ClientSocketHandle handle3; int rv3 = handle3.Init( - group_id_, params_, base::nullopt /* proxy_annotation_tag */, LOWEST, + group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback3.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -311,7 +311,7 @@ TEST_F(TransportClientSocketPoolTest, ReprioritizeRequests) { TestCompletionCallback callback4; ClientSocketHandle handle4; int rv4 = handle4.Init( - group_id_, params_, base::nullopt /* proxy_annotation_tag */, MEDIUM, + group_id_, params_, absl::nullopt /* proxy_annotation_tag */, MEDIUM, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback4.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -320,7 +320,7 @@ TEST_F(TransportClientSocketPoolTest, ReprioritizeRequests) { TestCompletionCallback callback5; ClientSocketHandle handle5; int rv5 = handle5.Init( - group_id_, params_, base::nullopt /* proxy_annotation_tag */, HIGHEST, + group_id_, params_, absl::nullopt /* proxy_annotation_tag */, HIGHEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback5.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -329,7 +329,7 @@ TEST_F(TransportClientSocketPoolTest, ReprioritizeRequests) { TestCompletionCallback callback6; ClientSocketHandle handle6; int rv6 = - handle6.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle6.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback6.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -359,7 +359,7 @@ TEST_F(TransportClientSocketPoolTest, ReprioritizeRequests) { TestCompletionCallback callback7; ClientSocketHandle handle7; int rv7 = handle7.Init( - group_id_, params_, base::nullopt /* proxy_annotation_tag */, HIGHEST, + group_id_, params_, absl::nullopt /* proxy_annotation_tag */, HIGHEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback7.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -384,7 +384,7 @@ TEST_F(TransportClientSocketPoolTest, ReprioritizeRequests) { TestCompletionCallback callback8; ClientSocketHandle handle8; int rv8 = handle8.Init( - group_id_, params_, base::nullopt /* proxy_annotation_tag */, HIGHEST, + group_id_, params_, absl::nullopt /* proxy_annotation_tag */, HIGHEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback8.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -535,7 +535,7 @@ TEST_F(TransportClientSocketPoolTest, RequestIgnoringLimitsIsReprioritized) { TestCompletionCallback callback1; ClientSocketHandle handle1; int rv1 = handle1.Init( - group_id_, params_, base::nullopt /* proxy_annotation_tag */, + group_id_, params_, absl::nullopt /* proxy_annotation_tag */, MAXIMUM_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::DISABLED, callback1.callback(), ClientSocketPool::ProxyAuthCallback(), &pool, NetLogWithSource()); @@ -546,7 +546,7 @@ TEST_F(TransportClientSocketPoolTest, RequestIgnoringLimitsIsReprioritized) { TestCompletionCallback callback2; ClientSocketHandle handle2; int rv2 = - handle2.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle2.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), &pool, NetLogWithSource()); @@ -564,7 +564,7 @@ TEST_F(TransportClientSocketPoolTest, InitHostResolutionFailure) { ClientSocketHandle handle; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, kDefaultPriority, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), @@ -584,7 +584,7 @@ TEST_F(TransportClientSocketPoolTest, InitConnectionFailure) { ClientSocketHandle handle; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, kDefaultPriority, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), @@ -600,7 +600,7 @@ TEST_F(TransportClientSocketPoolTest, InitConnectionFailure) { session_deps_.host_resolver->set_synchronous_mode(true); EXPECT_EQ( ERR_CONNECTION_FAILED, - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, kDefaultPriority, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), @@ -716,7 +716,7 @@ TEST_F(TransportClientSocketPoolTest, CancelRequestClearGroup) { ClientSocketHandle handle; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, kDefaultPriority, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), @@ -732,14 +732,14 @@ TEST_F(TransportClientSocketPoolTest, TwoRequestsCancelOne) { EXPECT_EQ( ERR_IO_PENDING, - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, kDefaultPriority, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource())); EXPECT_EQ( ERR_IO_PENDING, - handle2.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle2.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, kDefaultPriority, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), @@ -758,7 +758,7 @@ TEST_F(TransportClientSocketPoolTest, ConnectCancelConnect) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, kDefaultPriority, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), @@ -769,7 +769,7 @@ TEST_F(TransportClientSocketPoolTest, ConnectCancelConnect) { TestCompletionCallback callback2; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, kDefaultPriority, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), @@ -883,7 +883,7 @@ class RequestSocketCallback : public TestCompletionCallbackBase { base::RunLoop(base::RunLoop::Type::kNestableTasksAllowed).RunUntilIdle(); within_callback_ = true; int rv = handle_->Init( - group_id_, socket_params_, base::nullopt /* proxy_annotation_tag */, + group_id_, socket_params_, absl::nullopt /* proxy_annotation_tag */, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback(), ClientSocketPool::ProxyAuthCallback(), pool_, NetLogWithSource()); @@ -904,7 +904,7 @@ TEST_F(TransportClientSocketPoolTest, RequestTwice) { ClientSocketHandle handle; RequestSocketCallback callback(group_id_, params_, &handle, pool_.get()); int rv = - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -971,7 +971,7 @@ TEST_F(TransportClientSocketPoolTest, IdleSocketLoadTiming) { TestCompletionCallback callback; ClientSocketHandle handle; int rv = - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -991,7 +991,7 @@ TEST_F(TransportClientSocketPoolTest, IdleSocketLoadTiming) { // Now we should have 1 idle socket. EXPECT_EQ(1, pool_->IdleSocketCount()); - rv = handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + rv = handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -1004,7 +1004,7 @@ TEST_F(TransportClientSocketPoolTest, CloseIdleSocketsOnIPAddressChange) { TestCompletionCallback callback; ClientSocketHandle handle; int rv = - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -1051,7 +1051,7 @@ TEST_F(TransportClientSocketPoolTest, SSLCertError) { kHostPortPair, ClientSocketPool::SocketType::kSsl, PrivacyMode::PRIVACY_MODE_DISABLED, NetworkIsolationKey(), SecureDnsPolicy::kAllow), - socket_params, base::nullopt /* proxy_annotation_tag */, + socket_params, absl::nullopt /* proxy_annotation_tag */, MEDIUM, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), tagging_pool_.get(), NetLogWithSource()); @@ -1068,7 +1068,7 @@ TEST_F(TransportClientSocketPoolTest, CloseIdleSocketsOnSSLConfigChange) { TestCompletionCallback callback; ClientSocketHandle handle; int rv = - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -1127,7 +1127,7 @@ TEST_F(TransportClientSocketPoolTest, BackupSocketConnect) { TestCompletionCallback callback; ClientSocketHandle handle; int rv = handle.Init( - group_id_, params_, base::nullopt /* proxy_annotation_tag */, LOW, + group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -1172,7 +1172,7 @@ TEST_F(TransportClientSocketPoolTest, BackupSocketCancel) { TestCompletionCallback callback; ClientSocketHandle handle; int rv = handle.Init( - group_id_, params_, base::nullopt /* proxy_annotation_tag */, LOW, + group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -1221,7 +1221,7 @@ TEST_F(TransportClientSocketPoolTest, BackupSocketFailAfterStall) { TestCompletionCallback callback; ClientSocketHandle handle; int rv = - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -1272,7 +1272,7 @@ TEST_F(TransportClientSocketPoolTest, BackupSocketFailAfterDelay) { TestCompletionCallback callback; ClientSocketHandle handle; int rv = - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_.get(), NetLogWithSource()); @@ -1919,7 +1919,7 @@ TEST_F(TransportClientSocketPoolTest, Tag) { ClientSocketPool::SocketParams::CreateForHttpForTesting(); TestCompletionCallback callback; int rv = - handle.Init(kGroupId, params, base::nullopt /* proxy_annotation_tag */, + handle.Init(kGroupId, params, absl::nullopt /* proxy_annotation_tag */, LOW, tag1, ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_for_real_sockets_.get(), NetLogWithSource()); @@ -1932,7 +1932,7 @@ TEST_F(TransportClientSocketPoolTest, Tag) { StreamSocket* socket = handle.socket(); handle.Reset(); old_traffic = GetTaggedBytes(tag_val2); - rv = handle.Init(kGroupId, params, base::nullopt /* proxy_annotation_tag */, + rv = handle.Init(kGroupId, params, absl::nullopt /* proxy_annotation_tag */, LOW, tag2, ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_for_real_sockets_.get(), NetLogWithSource()); @@ -1955,14 +1955,14 @@ TEST_F(TransportClientSocketPoolTest, Tag) { // Test connect jobs that are orphaned and then adopted, appropriately apply // new tag. Request socket with |tag1|. TestCompletionCallback callback2; - rv = handle.Init(kGroupId, params, base::nullopt /* proxy_annotation_tag */, + rv = handle.Init(kGroupId, params, absl::nullopt /* proxy_annotation_tag */, LOW, tag1, ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_for_real_sockets_.get(), NetLogWithSource()); EXPECT_TRUE(rv == OK || rv == ERR_IO_PENDING) << "Result: " << rv; // Abort and request socket with |tag2|. handle.Reset(); - rv = handle.Init(kGroupId, params, base::nullopt /* proxy_annotation_tag */, + rv = handle.Init(kGroupId, params, absl::nullopt /* proxy_annotation_tag */, LOW, tag2, ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_for_real_sockets_.get(), NetLogWithSource()); @@ -1981,7 +1981,7 @@ TEST_F(TransportClientSocketPoolTest, Tag) { handle.Reset(); // Eat the left over connect job from the second request. // TODO(pauljensen): remove when crbug.com/800731 fixed. - rv = handle.Init(kGroupId, params, base::nullopt /* proxy_annotation_tag */, + rv = handle.Init(kGroupId, params, absl::nullopt /* proxy_annotation_tag */, LOW, tag1, ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_for_real_sockets_.get(), NetLogWithSource()); @@ -1994,13 +1994,13 @@ TEST_F(TransportClientSocketPoolTest, Tag) { // first but expect its socket to get vended to the higher priority request. ClientSocketHandle handle_high_pri; TestCompletionCallback callback_high_pri; - rv = handle.Init(kGroupId, params, base::nullopt /* proxy_annotation_tag */, + rv = handle.Init(kGroupId, params, absl::nullopt /* proxy_annotation_tag */, LOW, tag1, ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_for_real_sockets_.get(), NetLogWithSource()); EXPECT_TRUE(rv == OK || rv == ERR_IO_PENDING) << "Result: " << rv; int rv_high_pri = handle_high_pri.Init( - kGroupId, params, base::nullopt /* proxy_annotation_tag */, HIGHEST, tag2, + kGroupId, params, absl::nullopt /* proxy_annotation_tag */, HIGHEST, tag2, ClientSocketPool::RespectLimits::ENABLED, callback_high_pri.callback(), ClientSocketPool::ProxyAuthCallback(), pool_for_real_sockets_.get(), NetLogWithSource()); @@ -2145,7 +2145,7 @@ TEST_F(TransportClientSocketPoolTest, TagSSLDirect) { // Test socket is tagged before connected. uint64_t old_traffic = GetTaggedBytes(tag_val1); int rv = handle.Init( - kGroupId, socket_params, base::nullopt /* proxy_annotation_tag */, LOW, + kGroupId, socket_params, absl::nullopt /* proxy_annotation_tag */, LOW, tag1, ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_for_real_sockets_.get(), NetLogWithSource()); @@ -2160,7 +2160,7 @@ TEST_F(TransportClientSocketPoolTest, TagSSLDirect) { old_traffic = GetTaggedBytes(tag_val2); TestCompletionCallback callback2; rv = handle.Init(kGroupId, socket_params, - base::nullopt /* proxy_annotation_tag */, LOW, tag2, + absl::nullopt /* proxy_annotation_tag */, LOW, tag2, ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_for_real_sockets_.get(), NetLogWithSource()); @@ -2216,7 +2216,7 @@ TEST_F(TransportClientSocketPoolTest, TagSSLDirectTwoSockets) { // new tag. Request socket with |tag1|. TestCompletionCallback callback; int rv = handle.Init( - kGroupId, socket_params, base::nullopt /* proxy_annotation_tag */, LOW, + kGroupId, socket_params, absl::nullopt /* proxy_annotation_tag */, LOW, tag1, ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_for_real_sockets_.get(), NetLogWithSource()); @@ -2225,7 +2225,7 @@ TEST_F(TransportClientSocketPoolTest, TagSSLDirectTwoSockets) { handle.Reset(); TestCompletionCallback callback2; rv = handle.Init(kGroupId, socket_params, - base::nullopt /* proxy_annotation_tag */, LOW, tag2, + absl::nullopt /* proxy_annotation_tag */, LOW, tag2, ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool_for_real_sockets_.get(), NetLogWithSource()); @@ -2283,7 +2283,7 @@ TEST_F(TransportClientSocketPoolTest, TagSSLDirectTwoSocketsFullPool) { int rv; for (auto& tcp_handle : tcp_handles) { rv = tcp_handle.Init( - kGroupId, socket_params, base::nullopt /* proxy_annotation_tag */, LOW, + kGroupId, socket_params, absl::nullopt /* proxy_annotation_tag */, LOW, tag1, ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_for_real_sockets_.get(), NetLogWithSource()); @@ -2294,13 +2294,13 @@ TEST_F(TransportClientSocketPoolTest, TagSSLDirectTwoSocketsFullPool) { // Request two SSL sockets. ClientSocketHandle handle_to_be_canceled; rv = handle_to_be_canceled.Init( - kGroupId, socket_params, base::nullopt /* proxy_annotation_tag */, LOW, + kGroupId, socket_params, absl::nullopt /* proxy_annotation_tag */, LOW, tag1, ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_for_real_sockets_.get(), NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); rv = handle.Init(kGroupId, socket_params, - base::nullopt /* proxy_annotation_tag */, LOW, tag2, + absl::nullopt /* proxy_annotation_tag */, LOW, tag2, ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), pool_for_real_sockets_.get(), NetLogWithSource()); @@ -2545,7 +2545,7 @@ TEST_F(TransportClientSocketPoolMockNowSourceTest, IdleUnusedSocketTimeout) { PrivacyMode::PRIVACY_MODE_DISABLED, NetworkIsolationKey(), SecureDnsPolicy::kAllow), ClientSocketPool::SocketParams::CreateForHttpForTesting(), - base::nullopt /* proxy_annotation_tag */, MEDIUM, SocketTag(), + absl::nullopt /* proxy_annotation_tag */, MEDIUM, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), session->GetSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL, @@ -2593,7 +2593,7 @@ TEST_F(TransportClientSocketPoolMockNowSourceTest, IdleUnusedSocketTimeout) { kHostPortPair2, ClientSocketPool::SocketType::kHttp, PrivacyMode::PRIVACY_MODE_DISABLED, NetworkIsolationKey(), SecureDnsPolicy::kAllow), - socket_params, base::nullopt /* proxy_annotation_tag */, MEDIUM, + socket_params, absl::nullopt /* proxy_annotation_tag */, MEDIUM, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), session->GetSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL, diff --git a/net/socket/websocket_transport_client_socket_pool.cc b/net/socket/websocket_transport_client_socket_pool.cc index d153655749e0f3..6f96c9bb14fe91 100644 --- a/net/socket/websocket_transport_client_socket_pool.cc +++ b/net/socket/websocket_transport_client_socket_pool.cc @@ -64,7 +64,7 @@ void WebSocketTransportClientSocketPool::UnlockEndpoint( int WebSocketTransportClientSocketPool::RequestSocket( const GroupId& group_id, scoped_refptr params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, RequestPriority priority, const SocketTag& socket_tag, RespectLimits respect_limits, @@ -130,7 +130,7 @@ int WebSocketTransportClientSocketPool::RequestSocket( void WebSocketTransportClientSocketPool::RequestSockets( const GroupId& group_id, scoped_refptr params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, int num_sockets, const NetLogWithSource& net_log) { NOTIMPLEMENTED(); @@ -498,7 +498,7 @@ WebSocketTransportClientSocketPool::ConnectJobDelegate::connect_job_net_log() { WebSocketTransportClientSocketPool::StalledRequest::StalledRequest( const GroupId& group_id, const scoped_refptr& params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, RequestPriority priority, ClientSocketHandle* handle, CompletionOnceCallback callback, diff --git a/net/socket/websocket_transport_client_socket_pool.h b/net/socket/websocket_transport_client_socket_pool.h index 6bc76ce87a24a1..e6438a3c07133d 100644 --- a/net/socket/websocket_transport_client_socket_pool.h +++ b/net/socket/websocket_transport_client_socket_pool.h @@ -15,7 +15,6 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "base/timer/timer.h" #include "net/base/net_export.h" #include "net/base/proxy_server.h" @@ -23,6 +22,7 @@ #include "net/socket/client_socket_pool.h" #include "net/socket/connect_job.h" #include "net/socket/ssl_client_socket.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { namespace trace_event { @@ -60,7 +60,7 @@ class NET_EXPORT_PRIVATE WebSocketTransportClientSocketPool int RequestSocket( const GroupId& group_id, scoped_refptr params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, RequestPriority priority, const SocketTag& socket_tag, RespectLimits respect_limits, @@ -71,7 +71,7 @@ class NET_EXPORT_PRIVATE WebSocketTransportClientSocketPool void RequestSockets( const GroupId& group_id, scoped_refptr params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, int num_sockets, const NetLogWithSource& net_log) override; void SetPriority(const GroupId& group_id, @@ -146,7 +146,7 @@ class NET_EXPORT_PRIVATE WebSocketTransportClientSocketPool StalledRequest( const GroupId& group_id, const scoped_refptr& params, - const base::Optional& proxy_annotation_tag, + const absl::optional& proxy_annotation_tag, RequestPriority priority, ClientSocketHandle* handle, CompletionOnceCallback callback, @@ -157,7 +157,7 @@ class NET_EXPORT_PRIVATE WebSocketTransportClientSocketPool const GroupId group_id; const scoped_refptr params; - const base::Optional proxy_annotation_tag; + const absl::optional proxy_annotation_tag; const RequestPriority priority; ClientSocketHandle* const handle; CompletionOnceCallback callback; diff --git a/net/socket/websocket_transport_client_socket_pool_unittest.cc b/net/socket/websocket_transport_client_socket_pool_unittest.cc index 6c9d51fadb046f..171e180590d8e9 100644 --- a/net/socket/websocket_transport_client_socket_pool_unittest.cc +++ b/net/socket/websocket_transport_client_socket_pool_unittest.cc @@ -10,7 +10,6 @@ #include "base/callback.h" #include "base/callback_helpers.h" #include "base/location.h" -#include "base/optional.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/stl_util.h" @@ -45,6 +44,7 @@ #include "net/test/test_with_task_environment.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" using net::test::IsError; @@ -155,7 +155,7 @@ TEST_F(WebSocketTransportClientSocketPoolTest, Basic) { TestCompletionCallback callback; ClientSocketHandle handle; int rv = - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), &pool_, NetLogWithSource()); @@ -179,7 +179,7 @@ TEST_F(WebSocketTransportClientSocketPoolTest, SetResolvePriorityOnInit) { EXPECT_EQ( ERR_IO_PENDING, handle.Init(group_id_, params_, - base::nullopt /* proxy_annotation_tag */, priority, + absl::nullopt /* proxy_annotation_tag */, priority, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), &pool_, NetLogWithSource())); @@ -199,7 +199,7 @@ TEST_F(WebSocketTransportClientSocketPoolTest, InitHostResolutionFailure) { PRIVACY_MODE_DISABLED, NetworkIsolationKey(), SecureDnsPolicy::kAllow), ClientSocketPool::SocketParams::CreateForHttpForTesting(), - base::nullopt /* proxy_annotation_tag */, kDefaultPriority, + absl::nullopt /* proxy_annotation_tag */, kDefaultPriority, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), &pool_, NetLogWithSource())); @@ -214,7 +214,7 @@ TEST_F(WebSocketTransportClientSocketPoolTest, InitConnectionFailure) { ClientSocketHandle handle; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, kDefaultPriority, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), &pool_, @@ -225,7 +225,7 @@ TEST_F(WebSocketTransportClientSocketPoolTest, InitConnectionFailure) { host_resolver_->set_synchronous_mode(true); EXPECT_EQ( ERR_CONNECTION_FAILED, - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, kDefaultPriority, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), &pool_, @@ -305,7 +305,7 @@ TEST_F(WebSocketTransportClientSocketPoolTest, CancelRequestClearGroup) { ClientSocketHandle handle; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, kDefaultPriority, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), &pool_, @@ -321,14 +321,14 @@ TEST_F(WebSocketTransportClientSocketPoolTest, TwoRequestsCancelOne) { EXPECT_EQ( ERR_IO_PENDING, - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, kDefaultPriority, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), &pool_, NetLogWithSource())); EXPECT_EQ( ERR_IO_PENDING, - handle2.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle2.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, kDefaultPriority, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), @@ -347,7 +347,7 @@ TEST_F(WebSocketTransportClientSocketPoolTest, ConnectCancelConnect) { TestCompletionCallback callback; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, kDefaultPriority, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), &pool_, @@ -358,7 +358,7 @@ TEST_F(WebSocketTransportClientSocketPoolTest, ConnectCancelConnect) { TestCompletionCallback callback2; EXPECT_EQ( ERR_IO_PENDING, - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, kDefaultPriority, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), @@ -434,7 +434,7 @@ void RequestSocketOnComplete(const ClientSocketPool::GroupId& group_id, int rv = handle->Init( group_id, ClientSocketPool::SocketParams::CreateForHttpForTesting(), - base::nullopt /* proxy_annotation_tag */, LOWEST, SocketTag(), + absl::nullopt /* proxy_annotation_tag */, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, nested_callback->callback(), ClientSocketPool::ProxyAuthCallback(), pool, NetLogWithSource()); EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); @@ -450,7 +450,7 @@ TEST_F(WebSocketTransportClientSocketPoolTest, RequestTwice) { TestCompletionCallback second_result_callback; int rv = handle.Init( group_id_, ClientSocketPool::SocketParams::CreateForHttpForTesting(), - base::nullopt /* proxy_annotation_tag */, LOWEST, SocketTag(), + absl::nullopt /* proxy_annotation_tag */, LOWEST, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, base::BindOnce(&RequestSocketOnComplete, group_id_, &handle, &pool_, &second_result_callback), @@ -526,7 +526,7 @@ TEST_F(WebSocketTransportClientSocketPoolTest, LockReleasedOnHandleDelete) { TestCompletionCallback callback; std::unique_ptr handle(new ClientSocketHandle); int rv = - handle->Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle->Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), &pool_, NetLogWithSource()); @@ -592,7 +592,7 @@ TEST_F(WebSocketTransportClientSocketPoolTest, TestCompletionCallback callback; ClientSocketHandle handle; int rv = - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), &pool_, NetLogWithSource()); @@ -631,7 +631,7 @@ TEST_F(WebSocketTransportClientSocketPoolTest, TestCompletionCallback callback; ClientSocketHandle handle; int rv = - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), &pool_, NetLogWithSource()); @@ -660,7 +660,7 @@ TEST_F(WebSocketTransportClientSocketPoolTest, TestCompletionCallback callback; ClientSocketHandle handle; int rv = - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), &pool_, NetLogWithSource()); @@ -687,7 +687,7 @@ TEST_F(WebSocketTransportClientSocketPoolTest, IPv4HasNoFallback) { TestCompletionCallback callback; ClientSocketHandle handle; int rv = - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), &pool_, NetLogWithSource()); @@ -725,7 +725,7 @@ TEST_F(WebSocketTransportClientSocketPoolTest, IPv6InstantFail) { TestCompletionCallback callback; ClientSocketHandle handle; int rv = - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), &pool_, NetLogWithSource()); @@ -758,7 +758,7 @@ TEST_F(WebSocketTransportClientSocketPoolTest, IPv6RapidFail) { TestCompletionCallback callback; ClientSocketHandle handle; int rv = - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), &pool_, NetLogWithSource()); @@ -791,7 +791,7 @@ TEST_F(WebSocketTransportClientSocketPoolTest, FirstSuccessWins) { TestCompletionCallback callback; ClientSocketHandle handle; int rv = - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), &pool_, NetLogWithSource()); @@ -840,7 +840,7 @@ TEST_F(WebSocketTransportClientSocketPoolTest, LastFailureWins) { ClientSocketHandle handle; base::TimeTicks start(base::TimeTicks::Now()); int rv = - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), &pool_, NetLogWithSource()); @@ -876,7 +876,7 @@ TEST_F(WebSocketTransportClientSocketPoolTest, DISABLED_OverallTimeoutApplies) { ClientSocketHandle handle; int rv = - handle.Init(group_id_, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id_, params_, absl::nullopt /* proxy_annotation_tag */, LOW, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), &pool_, NetLogWithSource()); @@ -1155,7 +1155,7 @@ TEST_F(WebSocketTransportClientSocketPoolTest, NetworkIsolationKey) { PrivacyMode::PRIVACY_MODE_DISABLED, kNetworkIsolationKey, SecureDnsPolicy::kAllow); EXPECT_THAT( - handle.Init(group_id, params_, base::nullopt /* proxy_annotation_tag */, + handle.Init(group_id, params_, absl::nullopt /* proxy_annotation_tag */, kDefaultPriority, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), &pool_, diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc index d0f6746224ba11..53e3067759b192 100644 --- a/net/spdy/spdy_network_transaction_unittest.cc +++ b/net/spdy/spdy_network_transaction_unittest.cc @@ -2503,8 +2503,8 @@ TEST_F(SpdyNetworkTransactionTest, RedirectGetRequest) { EXPECT_EQ(1, delegate.received_redirect_count()); - request->FollowDeferredRedirect(base::nullopt /* removed_headers */, - base::nullopt /* modified_headers */); + request->FollowDeferredRedirect(absl::nullopt /* removed_headers */, + absl::nullopt /* modified_headers */); delegate.RunUntilComplete(); EXPECT_EQ(1, delegate.response_started_count()); @@ -2599,8 +2599,8 @@ TEST_F(SpdyNetworkTransactionTest, RedirectServerPush) { delegate1.RunUntilRedirect(); EXPECT_EQ(1, delegate1.received_redirect_count()); - request1->FollowDeferredRedirect(base::nullopt /* removed_headers */, - base::nullopt /* modified_headers */); + request1->FollowDeferredRedirect(absl::nullopt /* removed_headers */, + absl::nullopt /* modified_headers */); delegate1.RunUntilComplete(); EXPECT_EQ(1, delegate1.response_started_count()); EXPECT_FALSE(delegate1.received_data_before_response()); @@ -6204,7 +6204,7 @@ TEST_F(SpdyNetworkTransactionTest, SpdyBasicAuth) { ASSERT_TRUE(response_start->headers); EXPECT_EQ(401, response_start->headers->response_code()); EXPECT_TRUE(response_start->was_fetched_via_spdy); - const base::Optional& auth_challenge = + const absl::optional& auth_challenge = response_start->auth_challenge; ASSERT_TRUE(auth_challenge); EXPECT_FALSE(auth_challenge->is_proxy); @@ -10462,7 +10462,7 @@ TEST_F(SpdyNetworkTransactionTest, const uint8_t flags = 0xcc; const std::string payload("foo"); session_deps->greased_http2_frame = - base::Optional( + absl::optional( {type, flags, payload}); session_deps->http2_end_stream_with_data_frame = false; @@ -10505,7 +10505,7 @@ TEST_F(SpdyNetworkTransactionTest, GreaseFrameTypeWithGetRequest) { const uint8_t flags = 0xcc; const std::string payload("foo"); session_deps->greased_http2_frame = - base::Optional( + absl::optional( {type, flags, payload}); session_deps->http2_end_stream_with_data_frame = true; @@ -10567,7 +10567,7 @@ TEST_F(SpdyNetworkTransactionTest, const uint8_t flags = 0xcc; const std::string payload("foo"); session_deps->greased_http2_frame = - base::Optional( + absl::optional( {type, flags, payload}); session_deps->http2_end_stream_with_data_frame = true; @@ -10627,7 +10627,7 @@ TEST_F(SpdyNetworkTransactionTest, const uint8_t flags = 0xcc; const std::string payload("foo"); session_deps->greased_http2_frame = - base::Optional( + absl::optional( {type, flags, payload}); session_deps->http2_end_stream_with_data_frame = true; @@ -10688,7 +10688,7 @@ TEST_F(SpdyNetworkTransactionTest, DoNotGreaseFrameTypeWithConnect) { const uint8_t flags = 0xcc; const std::string payload("foo"); session_deps->greased_http2_frame = - base::Optional( + absl::optional( {type, flags, payload}); session_deps->http2_end_stream_with_data_frame = true; @@ -10770,7 +10770,7 @@ TEST_F(SpdyNetworkTransactionTest, OnDataSentDoesNotCrashWithGreasedFrameType) { const uint8_t flags = 0xcc; const std::string payload("foo"); session_deps->greased_http2_frame = - base::Optional( + absl::optional( {type, flags, payload}); session_deps->http2_end_stream_with_data_frame = true; diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc index f549d11a3d8e5a..f39707aa45b880 100644 --- a/net/spdy/spdy_session.cc +++ b/net/spdy/spdy_session.cc @@ -934,7 +934,7 @@ SpdySession::SpdySession( size_t session_max_recv_window_size, int session_max_queued_capped_frames, const spdy::SettingsMap& initial_settings, - const base::Optional& + const absl::optional& greased_http2_frame, bool http2_end_stream_with_data_frame, bool enable_priority_update, diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h index 0e5019bacc90cd..2729994d94686f 100644 --- a/net/spdy/spdy_session.h +++ b/net/spdy/spdy_session.h @@ -20,7 +20,6 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_refptr.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "base/strings/string_piece.h" #include "base/time/time.h" #include "net/base/completion_once_callback.h" @@ -51,6 +50,7 @@ #include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" #include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" #include "net/traffic_annotation/network_traffic_annotation.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/origin.h" #include "url/scheme_host_port.h" @@ -351,7 +351,7 @@ class NET_EXPORT SpdySession : public BufferedSpdyFramerVisitorInterface, size_t session_max_recv_window_size, int session_max_queued_capped_frames, const spdy::SettingsMap& initial_settings, - const base::Optional& + const absl::optional& greased_http2_frame, bool http2_end_stream_with_data_frame, bool enable_priority_update, @@ -1146,7 +1146,7 @@ class NET_EXPORT SpdySession : public BufferedSpdyFramerVisitorInterface, // If set, an HTTP/2 frame with a reserved frame type will be sent after // every HTTP/2 SETTINGS frame and before every HTTP/2 DATA frame. See // https://tools.ietf.org/html/draft-bishop-httpbis-grease-00. - const base::Optional greased_http2_frame_; + const absl::optional greased_http2_frame_; // If set, the HEADERS frame carrying a request without body will not have the // END_STREAM flag set. The stream will be closed by a subsequent empty DATA diff --git a/net/spdy/spdy_session_pool.cc b/net/spdy/spdy_session_pool.cc index 6db3e9e13bdd62..859e5e10860689 100644 --- a/net/spdy/spdy_session_pool.cc +++ b/net/spdy/spdy_session_pool.cc @@ -88,7 +88,7 @@ SpdySessionPool::SpdySessionPool( size_t session_max_recv_window_size, int session_max_queued_capped_frames, const spdy::SettingsMap& initial_settings, - const base::Optional& greased_http2_frame, + const absl::optional& greased_http2_frame, bool http2_end_stream_with_data_frame, bool enable_priority_update, SpdySessionPool::TimeFunc time_func, diff --git a/net/spdy/spdy_session_pool.h b/net/spdy/spdy_session_pool.h index 71a58dc5bcd7cb..fe635b32a8713d 100644 --- a/net/spdy/spdy_session_pool.h +++ b/net/spdy/spdy_session_pool.h @@ -17,7 +17,6 @@ #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "net/base/host_port_pair.h" #include "net/base/ip_endpoint.h" #include "net/base/load_timing_info.h" @@ -35,6 +34,7 @@ #include "net/ssl/ssl_config_service.h" #include "net/third_party/quiche/src/quic/core/quic_versions.h" #include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { namespace trace_event { @@ -143,7 +143,7 @@ class NET_EXPORT SpdySessionPool size_t session_max_recv_window_size, int session_max_queued_capped_frames, const spdy::SettingsMap& initial_settings, - const base::Optional& greased_http2_frame, + const absl::optional& greased_http2_frame, bool http2_end_stream_with_data_frame, bool enable_priority_update, SpdySessionPool::TimeFunc time_func, @@ -462,7 +462,7 @@ class NET_EXPORT SpdySessionPool // If set, an HTTP/2 frame with a reserved frame type will be sent after // every HTTP/2 SETTINGS frame and before every HTTP/2 DATA frame. See // https://tools.ietf.org/html/draft-bishop-httpbis-grease-00. - const base::Optional greased_http2_frame_; + const absl::optional greased_http2_frame_; // If set, the HEADERS frame carrying a request without body will not have the // END_STREAM flag set. The stream will be closed by a subsequent empty DATA diff --git a/net/spdy/spdy_session_unittest.cc b/net/spdy/spdy_session_unittest.cc index b20602aa30db25..774db474909f8b 100644 --- a/net/spdy/spdy_session_unittest.cc +++ b/net/spdy/spdy_session_unittest.cc @@ -11,7 +11,6 @@ #include "base/base64.h" #include "base/bind.h" #include "base/callback.h" -#include "base/optional.h" #include "base/run_loop.h" #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" @@ -59,6 +58,7 @@ #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/platform_test.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" using net::test::IsError; @@ -2161,7 +2161,7 @@ bool NetLogSourceFromEventParameters(const base::Value* event_params, *source = NetLogSource(); return false; } - base::Optional opt_int; + absl::optional opt_int; opt_int = source_dict->FindIntKey("id"); if (!opt_int) { *source = NetLogSource(); @@ -3645,7 +3645,7 @@ TEST_F(SpdySessionTest, CloseOneIdleConnection) { PrivacyMode::PRIVACY_MODE_DISABLED, NetworkIsolationKey(), SecureDnsPolicy::kAllow), ClientSocketPool::SocketParams::CreateForHttpForTesting(), - base::nullopt /* proxy_annotation_tag */, DEFAULT_PRIORITY, + absl::nullopt /* proxy_annotation_tag */, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool, NetLogWithSource())); @@ -3735,7 +3735,7 @@ TEST_F(SpdySessionTest, CloseOneIdleConnectionWithAlias) { PrivacyMode::PRIVACY_MODE_DISABLED, NetworkIsolationKey(), SecureDnsPolicy::kAllow), ClientSocketPool::SocketParams::CreateForHttpForTesting(), - base::nullopt /* proxy_annotation_tag */, DEFAULT_PRIORITY, + absl::nullopt /* proxy_annotation_tag */, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback3.callback(), ClientSocketPool::ProxyAuthCallback(), pool, NetLogWithSource())); @@ -3816,7 +3816,7 @@ TEST_F(SpdySessionTest, CloseSessionOnIdleWhenPoolStalled) { PrivacyMode::PRIVACY_MODE_DISABLED, NetworkIsolationKey(), SecureDnsPolicy::kAllow), ClientSocketPool::SocketParams::CreateForHttpForTesting(), - base::nullopt /* proxy_annotation_tag */, DEFAULT_PRIORITY, + absl::nullopt /* proxy_annotation_tag */, DEFAULT_PRIORITY, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, callback2.callback(), ClientSocketPool::ProxyAuthCallback(), pool, NetLogWithSource())); @@ -6116,7 +6116,7 @@ TEST_F(SpdySessionTest, GreaseFrameTypeAfterSettings) { const uint8_t flags = 0xcc; const std::string payload("foo"); session_deps_.greased_http2_frame = - base::Optional( + absl::optional( {type, flags, payload}); // Connection preface. diff --git a/net/spdy/spdy_test_util_common.cc b/net/spdy/spdy_test_util_common.cc index 8d499f9ba775d7..0c7ae7a3a85922 100644 --- a/net/spdy/spdy_test_util_common.cc +++ b/net/spdy/spdy_test_util_common.cc @@ -12,7 +12,6 @@ #include "base/check_op.h" #include "base/compiler_specific.h" #include "base/notreached.h" -#include "base/optional.h" #include "base/strings/abseil_string_conversions.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_piece.h" @@ -47,6 +46,7 @@ #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "net/url_request/url_request_job_factory.h" #include "testing/gmock/include/gmock/gmock.h" +#include "third_party/abseil-cpp/absl/types/optional.h" using net::test::IsError; using net::test::IsOk; @@ -513,7 +513,7 @@ base::WeakPtr CreateSpdySessionHelper( ClientSocketPool::GroupId( key.host_port_pair(), ClientSocketPool::SocketType::kSsl, key.privacy_mode(), NetworkIsolationKey(), SecureDnsPolicy::kAllow), - socket_params, base::nullopt /* proxy_annotation_tag */, MEDIUM, + socket_params, absl::nullopt /* proxy_annotation_tag */, MEDIUM, key.socket_tag(), ClientSocketPool::RespectLimits::ENABLED, callback.callback(), ClientSocketPool::ProxyAuthCallback(), http_session->GetSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL, diff --git a/net/spdy/spdy_test_util_common.h b/net/spdy/spdy_test_util_common.h index f626e0e4838c97..4f2ffd00058924 100644 --- a/net/spdy/spdy_test_util_common.h +++ b/net/spdy/spdy_test_util_common.h @@ -232,7 +232,7 @@ struct SpdySessionDependencies { SpdySession::TimeFunc time_func; bool enable_http2_alternative_service; bool enable_websocket_over_http2; - base::Optional greased_http2_frame; + absl::optional greased_http2_frame; bool http2_end_stream_with_data_frame; NetLog* net_log; bool disable_idle_sockets_close_on_memory_pressure; diff --git a/net/ssl/ssl_client_session_cache.h b/net/ssl/ssl_client_session_cache.h index 88a4ec5b6dee4b..dd5f0d9bbea04f 100644 --- a/net/ssl/ssl_client_session_cache.h +++ b/net/ssl/ssl_client_session_cache.h @@ -15,13 +15,13 @@ #include "base/containers/mru_cache.h" #include "base/macros.h" #include "base/memory/memory_pressure_monitor.h" -#include "base/optional.h" #include "base/trace_event/memory_dump_provider.h" #include "net/base/host_port_pair.h" #include "net/base/ip_address.h" #include "net/base/net_export.h" #include "net/base/network_isolation_key.h" #include "net/base/privacy_mode.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/boringssl/src/include/openssl/base.h" namespace base { @@ -54,7 +54,7 @@ class NET_EXPORT SSLClientSessionCache { bool operator<(const Key& other) const; HostPortPair server; - base::Optional dest_ip_addr; + absl::optional dest_ip_addr; NetworkIsolationKey network_isolation_key; PrivacyMode privacy_mode = PRIVACY_MODE_DISABLED; bool disable_legacy_crypto = false; diff --git a/net/ssl/ssl_config.h b/net/ssl/ssl_config.h index be1c0c351d2bcb..18c5af92a7703b 100644 --- a/net/ssl/ssl_config.h +++ b/net/ssl/ssl_config.h @@ -8,13 +8,13 @@ #include #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "net/base/net_export.h" #include "net/base/network_isolation_key.h" #include "net/base/privacy_mode.h" #include "net/cert/x509_certificate.h" #include "net/socket/next_proto.h" #include "net/ssl/ssl_private_key.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -63,8 +63,8 @@ struct NET_EXPORT SSLConfig { // If specified, the minimum and maximum protocol versions that are enabled. // (Use the SSL_PROTOCOL_VERSION_xxx enumerators defined above.) If // unspecified, values from the SSLConfigService are used. - base::Optional version_min_override; - base::Optional version_max_override; + absl::optional version_min_override; + absl::optional version_max_override; // Whether early data is enabled on this connection. Note that early data has // weaker security properties than normal data and changes the diff --git a/net/ssl/ssl_platform_key_android.cc b/net/ssl/ssl_platform_key_android.cc index 8a13756e07c61d..21baf77f52854c 100644 --- a/net/ssl/ssl_platform_key_android.cc +++ b/net/ssl/ssl_platform_key_android.cc @@ -14,11 +14,11 @@ #include "base/containers/flat_set.h" #include "base/logging.h" #include "base/macros.h" -#include "base/optional.h" #include "net/android/keystore.h" #include "net/base/net_errors.h" #include "net/ssl/ssl_platform_key_util.h" #include "net/ssl/threaded_ssl_private_key.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/boringssl/src/include/openssl/ecdsa.h" #include "third_party/boringssl/src/include/openssl/evp.h" #include "third_party/boringssl/src/include/openssl/mem.h" @@ -74,7 +74,7 @@ class SSLPlatformKeyAndroid : public ThreadedSSLPrivateKey::Delegate { provider_name_(android::GetPrivateKeyClassName(key)) { key_.Reset(key); - base::Optional supports_rsa_no_padding; + absl::optional supports_rsa_no_padding; for (uint16_t algorithm : SSLPrivateKey::DefaultAlgorithmPreferences( EVP_PKEY_id(pubkey_.get()), true /* include PSS */)) { const char* java_algorithm = GetJavaAlgorithm(algorithm); @@ -159,7 +159,7 @@ class SSLPlatformKeyAndroid : public ThreadedSSLPrivateKey::Delegate { return ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED; } - base::Optional> padded = + absl::optional> padded = AddPSSPadding(pubkey_.get(), md, base::make_span(digest, digest_len)); if (!padded) { return ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED; diff --git a/net/ssl/ssl_platform_key_mac.cc b/net/ssl/ssl_platform_key_mac.cc index 58ad16a9c63cf6..4887c146dbf43a 100644 --- a/net/ssl/ssl_platform_key_mac.cc +++ b/net/ssl/ssl_platform_key_mac.cc @@ -25,7 +25,6 @@ #include "base/macros.h" #include "base/memory/scoped_policy.h" #include "base/numerics/safe_conversions.h" -#include "base/optional.h" #include "base/synchronization/lock.h" #include "crypto/mac_security_services_lock.h" #include "crypto/openssl_util.h" @@ -35,6 +34,7 @@ #include "net/ssl/ssl_platform_key_util.h" #include "net/ssl/ssl_private_key.h" #include "net/ssl/threaded_ssl_private_key.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/boringssl/src/include/openssl/ecdsa.h" #include "third_party/boringssl/src/include/openssl/evp.h" #include "third_party/boringssl/src/include/openssl/mem.h" @@ -134,7 +134,7 @@ class SSLPlatformKeyCSSM : public ThreadedSSLPrivateKey::Delegate { hash_data.Length = digest_len; hash_data.Data = digest; - base::Optional> pss_storage; + absl::optional> pss_storage; bssl::UniquePtr free_digest_info; if (cssm_key_->KeyHeader.AlgorithmId == CSSM_ALGID_RSA) { if (SSL_is_signature_algorithm_rsa_pss(algorithm)) { @@ -286,7 +286,7 @@ class API_AVAILABLE(macosx(10.12)) SSLPlatformKeySecKey } base::span digest = base::make_span(digest_buf, digest_len); - base::Optional> pss_storage; + absl::optional> pss_storage; if (pss_fallback) { // Implement RSA-PSS by adding the padding manually and then using // kSecKeyAlgorithmRSASignatureRaw. diff --git a/net/ssl/ssl_platform_key_util.cc b/net/ssl/ssl_platform_key_util.cc index 9baac3b2db2792..6c433af453ff3d 100644 --- a/net/ssl/ssl_platform_key_util.cc +++ b/net/ssl/ssl_platform_key_util.cc @@ -87,19 +87,19 @@ bool GetClientCertInfo(const X509Certificate* certificate, return true; } -base::Optional> AddPSSPadding( +absl::optional> AddPSSPadding( EVP_PKEY* pubkey, const EVP_MD* md, base::span digest) { RSA* rsa = EVP_PKEY_get0_RSA(pubkey); if (!rsa) { - return base::nullopt; + return absl::nullopt; } std::vector ret(RSA_size(rsa)); if (digest.size() != EVP_MD_size(md) || !RSA_padding_add_PKCS1_PSS_mgf1(rsa, ret.data(), digest.data(), md, md, -1 /* salt length is digest length */)) { - return base::nullopt; + return absl::nullopt; } return ret; } diff --git a/net/ssl/ssl_platform_key_util.h b/net/ssl/ssl_platform_key_util.h index 02729fecba7602..c5bfe61e7761ee 100644 --- a/net/ssl/ssl_platform_key_util.h +++ b/net/ssl/ssl_platform_key_util.h @@ -12,9 +12,9 @@ #include "base/containers/span.h" #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "base/single_thread_task_runner.h" #include "net/base/net_export.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/boringssl/src/include/openssl/base.h" namespace net { @@ -42,7 +42,7 @@ NET_EXPORT_PRIVATE bool GetClientCertInfo(const X509Certificate* certificate, // Returns the encoded form of |digest| for use with RSA-PSS with |pubkey|, // using |md| as the hash function and MGF-1 function, and the digest size of // |md| as the salt length. -base::Optional> AddPSSPadding( +absl::optional> AddPSSPadding( EVP_PKEY* pubkey, const EVP_MD* md, base::span digest); diff --git a/net/ssl/ssl_server_config.h b/net/ssl/ssl_server_config.h index 4384c0cf1e178a..aa50e67374d1c7 100644 --- a/net/ssl/ssl_server_config.h +++ b/net/ssl/ssl_server_config.h @@ -10,10 +10,10 @@ #include #include "base/containers/flat_map.h" -#include "base/optional.h" #include "net/base/net_export.h" #include "net/socket/next_proto.h" #include "net/ssl/ssl_config.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -72,12 +72,12 @@ struct NET_EXPORT SSLServerConfig { // cipher_suite_for_testing, if set, causes the server to only support the // specified cipher suite in TLS 1.2 and below. This should only be used in // unit tests. - base::Optional cipher_suite_for_testing; + absl::optional cipher_suite_for_testing; // signature_algorithm_for_testing, if set, causes the server to only support // the specified signature algorithm in TLS 1.2 and below. This should only be // used in unit tests. - base::Optional signature_algorithm_for_testing; + absl::optional signature_algorithm_for_testing; // curves_for_testing, if not empty, specifies the list of NID values (e.g. // NID_X25519) to configure as supported curves for the TLS connection. diff --git a/net/test/embedded_test_server/http_request.h b/net/test/embedded_test_server/http_request.h index 334a2b96cc95a2..65b37bb26ae1ae 100644 --- a/net/test/embedded_test_server/http_request.h +++ b/net/test/embedded_test_server/http_request.h @@ -12,10 +12,10 @@ #include #include "base/macros.h" -#include "base/optional.h" #include "base/strings/string_piece.h" #include "base/strings/string_util.h" #include "net/ssl/ssl_info.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace net { @@ -65,7 +65,7 @@ struct HttpRequest { HeaderMap headers; std::string content; bool has_content; - base::Optional ssl_info; + absl::optional ssl_info; }; // Parses the input data and produces a valid HttpRequest object. If there is diff --git a/net/test/spawned_test_server/base_test_server.cc b/net/test/spawned_test_server/base_test_server.cc index 9b914a715df810..0f23babcb2a74d 100644 --- a/net/test/spawned_test_server/base_test_server.cc +++ b/net/test/spawned_test_server/base_test_server.cc @@ -372,7 +372,7 @@ bool BaseTestServer::SetAndParseServerData(const std::string& server_data, server_data_ = std::move(parsed_json.value); - base::Optional port_value = server_data_->FindIntKey("port"); + absl::optional port_value = server_data_->FindIntKey("port"); if (!port_value) { LOG(ERROR) << "Could not find port value"; return false; diff --git a/net/test/spawned_test_server/base_test_server.h b/net/test/spawned_test_server/base_test_server.h index 8faa27930f2623..6c209afcdeeed1 100644 --- a/net/test/spawned_test_server/base_test_server.h +++ b/net/test/spawned_test_server/base_test_server.h @@ -19,10 +19,10 @@ #include "base/files/file_path.h" #include "base/macros.h" #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "base/values.h" #include "net/base/host_port_pair.h" #include "net/ssl/ssl_client_cert_type.h" +#include "third_party/abseil-cpp/absl/types/optional.h" class GURL; @@ -378,7 +378,7 @@ class BaseTestServer { HostPortPair host_port_pair_; // Holds the data sent from the server (e.g., port number). - base::Optional server_data_; + absl::optional server_data_; // If |type_| is TYPE_HTTPS or TYPE_WSS, the TLS settings to use for the test // server. diff --git a/net/test/spawned_test_server/local_test_server.cc b/net/test/spawned_test_server/local_test_server.cc index d5784963b141c8..a389fe582d7129 100644 --- a/net/test/spawned_test_server/local_test_server.cc +++ b/net/test/spawned_test_server/local_test_server.cc @@ -99,7 +99,7 @@ bool LocalTestServer::StartInBackground() { return false; } - base::Optional> python_path = GetPythonPath(); + absl::optional> python_path = GetPythonPath(); if (!python_path) { LOG(ERROR) << "Could not get Python path."; return false; @@ -164,12 +164,12 @@ bool LocalTestServer::Init(const base::FilePath& document_root) { return true; } -base::Optional> LocalTestServer::GetPythonPath() +absl::optional> LocalTestServer::GetPythonPath() const { base::FilePath third_party_dir; if (!base::PathService::Get(base::DIR_SOURCE_ROOT, &third_party_dir)) { LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT"; - return base::nullopt; + return absl::nullopt; } third_party_dir = third_party_dir.AppendASCII("third_party"); diff --git a/net/test/spawned_test_server/local_test_server.h b/net/test/spawned_test_server/local_test_server.h index 81489c98cc885c..a9dc1afc476718 100644 --- a/net/test/spawned_test_server/local_test_server.h +++ b/net/test/spawned_test_server/local_test_server.h @@ -11,9 +11,9 @@ #include "base/files/file_util.h" #include "base/files/scoped_file.h" #include "base/macros.h" -#include "base/optional.h" #include "base/process/process.h" #include "net/test/spawned_test_server/base_test_server.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #if defined(OS_WIN) #include "base/win/scoped_handle.h" @@ -49,7 +49,7 @@ class LocalTestServer : public BaseTestServer { bool Stop(); // Returns the directories to use as the PYTHONPATH, or nullopt on error. - virtual base::Optional> GetPythonPath() const; + virtual absl::optional> GetPythonPath() const; // Returns true if the base::FilePath for the testserver python script is // successfully stored in |*testserver_path|. diff --git a/net/test/spawned_test_server/remote_test_server.cc b/net/test/spawned_test_server/remote_test_server.cc index b9b1839dbd5907..61ff349540a086 100644 --- a/net/test/spawned_test_server/remote_test_server.cc +++ b/net/test/spawned_test_server/remote_test_server.cc @@ -75,7 +75,7 @@ std::string ReadSpawnerUrlFromConfig() { if (!ReadFileToString(config_path, &config_json)) LOG(FATAL) << "Failed to read " << config_path.value(); - base::Optional config = base::JSONReader::Read(config_json); + absl::optional config = base::JSONReader::Read(config_json); if (!config) LOG(FATAL) << "Failed to parse " << config_path.value(); diff --git a/net/test/url_request/url_request_mock_data_job.h b/net/test/url_request/url_request_mock_data_job.h index 6011a5816868e0..f2789e1c1a45e8 100644 --- a/net/test/url_request/url_request_mock_data_job.h +++ b/net/test/url_request/url_request_mock_data_job.h @@ -10,8 +10,8 @@ #include #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "net/url_request/url_request_job.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -66,7 +66,7 @@ class URLRequestMockDataJob : public URLRequestJob { void StartAsync(); - base::Optional headers_; + absl::optional headers_; std::string data_; size_t data_offset_; bool request_client_certificate_; diff --git a/net/tools/quic/synchronous_host_resolver.cc b/net/tools/quic/synchronous_host_resolver.cc index a3c64ea5986e0f..26e9845ad251e5 100644 --- a/net/tools/quic/synchronous_host_resolver.cc +++ b/net/tools/quic/synchronous_host_resolver.cc @@ -13,7 +13,6 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "base/message_loop/message_pump_type.h" -#include "base/optional.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/task/single_thread_task_executor.h" @@ -25,6 +24,7 @@ #include "net/dns/host_resolver.h" #include "net/log/net_log.h" #include "net/log/net_log_with_source.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -72,7 +72,7 @@ void ResolverThread::Run() { // not used by net/ consumers. std::unique_ptr request = resolver->CreateRequest(host_port_pair, NetworkIsolationKey(), - NetLogWithSource(), base::nullopt); + NetLogWithSource(), absl::nullopt); base::RunLoop run_loop; rv_ = request->Start(base::BindOnce(&ResolverThread::OnResolutionComplete, diff --git a/net/tools/testserver/run_testserver.cc b/net/tools/testserver/run_testserver.cc index 04a7c4aab20652..f3a8bce01b4054 100644 --- a/net/tools/testserver/run_testserver.cc +++ b/net/tools/testserver/run_testserver.cc @@ -51,7 +51,7 @@ int main(int argc, const char* argv[]) { } // If populated, EmbeddedTestServer is used instead of the SpawnedTestServer. - base::Optional + absl::optional embedded_test_server_type; net::SpawnedTestServer::Type server_type; diff --git a/net/url_request/redirect_info.cc b/net/url_request/redirect_info.cc index ef2de4f7628cd9..6cf318a096fb13 100644 --- a/net/url_request/redirect_info.cc +++ b/net/url_request/redirect_info.cc @@ -37,7 +37,7 @@ std::string ComputeMethodForRedirect(const std::string& method, // policy that should be used for the request. ReferrerPolicy ProcessReferrerPolicyHeaderOnRedirect( ReferrerPolicy original_referrer_policy, - const base::Optional& referrer_policy_header) { + const absl::optional& referrer_policy_header) { ReferrerPolicy new_policy = original_referrer_policy; std::vector policy_tokens; if (referrer_policy_header) { @@ -122,7 +122,7 @@ RedirectInfo RedirectInfo::ComputeRedirectInfo( const std::string& original_referrer, int http_status_code, const GURL& new_location, - const base::Optional& referrer_policy_header, + const absl::optional& referrer_policy_header, bool insecure_scheme_was_upgraded, bool copy_fragment, bool is_signed_exchange_fallback_redirect) { diff --git a/net/url_request/redirect_info.h b/net/url_request/redirect_info.h index 9c54cdaa3f79b6..3459a9843554b7 100644 --- a/net/url_request/redirect_info.h +++ b/net/url_request/redirect_info.h @@ -45,7 +45,7 @@ struct NET_EXPORT RedirectInfo { // The new location URL of the redirect response. const GURL& new_location, // Referrer-Policy header of the redirect response. - const base::Optional& referrer_policy_header, + const absl::optional& referrer_policy_header, // Whether the URL was upgraded to HTTPS due to upgrade-insecure-requests. bool insecure_scheme_was_upgraded, // This method copies the URL fragment of the original URL to the new URL diff --git a/net/url_request/redirect_info_unittest.cc b/net/url_request/redirect_info_unittest.cc index a15e442635bcb0..f5851fdc597b12 100644 --- a/net/url_request/redirect_info_unittest.cc +++ b/net/url_request/redirect_info_unittest.cc @@ -53,7 +53,7 @@ TEST(RedirectInfoTest, MethodForRedirect) { test.original_method, kOriginalUrl, kOriginalSiteForCookies, kOriginalFirstPartyUrlPolicy, kOriginalReferrerPolicy, kOriginalReferrer, test.http_status_code, kNewLocation, - base::nullopt /* referrer_policy_header */, kInsecureSchemeWasUpgraded, + absl::nullopt /* referrer_policy_header */, kInsecureSchemeWasUpgraded, kCopyFragment); EXPECT_EQ(test.expected_new_method, redirect_info.new_method); @@ -104,7 +104,7 @@ TEST(RedirectInfoTest, CopyFragment) { kOriginalMethod, GURL(test.original_url), kOriginalSiteForCookies, kOriginalFirstPartyUrlPolicy, kOriginalReferrerPolicy, kOriginalReferrer, kHttpStatusCode, GURL(test.new_location), - base::nullopt /* referrer_policy_header */, kInsecureSchemeWasUpgraded, + absl::nullopt /* referrer_policy_header */, kInsecureSchemeWasUpgraded, test.copy_fragment); EXPECT_EQ(GURL(test.expected_new_url), redirect_info.new_url); @@ -143,7 +143,7 @@ TEST(RedirectInfoTest, FirstPartyURLPolicy) { kOriginalMethod, kOriginalUrl, kOriginalSiteForCookies, test.original_first_party_url_policy, kOriginalReferrerPolicy, kOriginalReferrer, kHttpStatusCode, kNewLocation, - base::nullopt /* referrer_policy_header */, kInsecureSchemeWasUpgraded, + absl::nullopt /* referrer_policy_header */, kInsecureSchemeWasUpgraded, kCopyFragment); EXPECT_TRUE(redirect_info.new_site_for_cookies.IsEquivalent( diff --git a/net/url_request/redirect_util.cc b/net/url_request/redirect_util.cc index dde030795adfa6..ff95dd67df9317 100644 --- a/net/url_request/redirect_util.cc +++ b/net/url_request/redirect_util.cc @@ -17,8 +17,8 @@ void RedirectUtil::UpdateHttpRequest( const GURL& original_url, const std::string& original_method, const RedirectInfo& redirect_info, - const base::Optional>& removed_headers, - const base::Optional& modified_headers, + const absl::optional>& removed_headers, + const absl::optional& modified_headers, HttpRequestHeaders* request_headers, bool* should_clear_upload) { DCHECK(request_headers); @@ -84,14 +84,14 @@ void RedirectUtil::UpdateHttpRequest( } // static -base::Optional RedirectUtil::GetReferrerPolicyHeader( +absl::optional RedirectUtil::GetReferrerPolicyHeader( const HttpResponseHeaders* response_headers) { if (!response_headers) - return base::nullopt; + return absl::nullopt; std::string referrer_policy_header; if (!response_headers->GetNormalizedHeader("Referrer-Policy", &referrer_policy_header)) { - return base::nullopt; + return absl::nullopt; } return referrer_policy_header; } diff --git a/net/url_request/redirect_util.h b/net/url_request/redirect_util.h index 9ec0eaf14cc2bc..b209006464ff03 100644 --- a/net/url_request/redirect_util.h +++ b/net/url_request/redirect_util.h @@ -7,8 +7,8 @@ #include -#include "base/optional.h" #include "net/base/net_export.h" +#include "third_party/abseil-cpp/absl/types/optional.h" class GURL; @@ -29,14 +29,14 @@ class RedirectUtil { const GURL& original_url, const std::string& original_method, const RedirectInfo& redirect_info, - const base::Optional>& removed_headers, - const base::Optional& modified_headers, + const absl::optional>& removed_headers, + const absl::optional& modified_headers, HttpRequestHeaders* request_headers, bool* should_clear_upload); // Returns the the "normalized" value of Referrer-Policy header if available. - // Otherwise returns base::nullopt. - NET_EXPORT static base::Optional GetReferrerPolicyHeader( + // Otherwise returns absl::nullopt. + NET_EXPORT static absl::optional GetReferrerPolicyHeader( const HttpResponseHeaders* response_headers); }; diff --git a/net/url_request/redirect_util_unittest.cc b/net/url_request/redirect_util_unittest.cc index 36408cf2208e0b..5019f2c86a83fb 100644 --- a/net/url_request/redirect_util_unittest.cc +++ b/net/url_request/redirect_util_unittest.cc @@ -125,7 +125,7 @@ TEST(RedirectUtilTest, UpdateHttpRequest) { RedirectUtil::UpdateHttpRequest( original_url, test.original_method, redirect_info, - base::nullopt /* removed_headers */, modified_headers, &request_headers, + absl::nullopt /* removed_headers */, modified_headers, &request_headers, &should_clear_upload); EXPECT_EQ(test.expected_should_clear_upload, should_clear_upload); @@ -258,13 +258,13 @@ TEST(RedirectUtilTest, RemovedHeaders) { } } -// Test with removed_headers = base::nullopt. +// Test with removed_headers = absl::nullopt. TEST(RedirectUtilTest, RemovedHeadersNullOpt) { HttpRequestHeaders initial_headers, final_headers; initial_headers.SetHeader("A", "0"); final_headers.SetHeader("A", "0"); - base::Optional> removed_headers(base::nullopt); - base::Optional modified_headers(absl::in_place); + absl::optional> removed_headers(absl::nullopt); + absl::optional modified_headers(absl::in_place); bool should_clear_upload(false); // unused. RedirectUtil::UpdateHttpRequest(GURL(), // original_url @@ -278,13 +278,13 @@ TEST(RedirectUtilTest, RemovedHeadersNullOpt) { EXPECT_EQ(initial_headers.ToString(), final_headers.ToString()); } -// Test with modified_headers = base::nullopt. +// Test with modified_headers = absl::nullopt. TEST(RedirectUtilTest, ModifyHeadersNullopt) { HttpRequestHeaders initial_headers, final_headers; initial_headers.SetHeader("A", "0"); final_headers.SetHeader("A", "0"); - base::Optional> removed_headers(absl::in_place); - base::Optional modified_headers(base::nullopt); + absl::optional> removed_headers(absl::in_place); + absl::optional modified_headers(absl::nullopt); bool should_clear_upload(false); // unused. RedirectUtil::UpdateHttpRequest(GURL(), // original_url diff --git a/net/url_request/test_url_fetcher_factory.cc b/net/url_request/test_url_fetcher_factory.cc index aeffb2347cdf1f..5321d875a683c4 100644 --- a/net/url_request/test_url_fetcher_factory.cc +++ b/net/url_request/test_url_fetcher_factory.cc @@ -121,7 +121,7 @@ void TestURLFetcher::SetRequestContext( } void TestURLFetcher::SetInitiator( - const base::Optional& initiator) {} + const absl::optional& initiator) {} void TestURLFetcher::SetURLRequestUserData( const void* key, diff --git a/net/url_request/test_url_fetcher_factory.h b/net/url_request/test_url_fetcher_factory.h index b886249d2eb4dc..44a4810826588b 100644 --- a/net/url_request/test_url_fetcher_factory.h +++ b/net/url_request/test_url_fetcher_factory.h @@ -121,7 +121,7 @@ class TestURLFetcher : public URLFetcher { const std::string& value) override; void SetRequestContext( URLRequestContextGetter* request_context_getter) override; - void SetInitiator(const base::Optional& initiator) override; + void SetInitiator(const absl::optional& initiator) override; void SetURLRequestUserData( const void* key, const CreateDataCallback& create_data_callback) override; diff --git a/net/url_request/url_fetcher.h b/net/url_request/url_fetcher.h index 3dba85da1ce4be..026663b4288b67 100644 --- a/net/url_request/url_fetcher.h +++ b/net/url_request/url_fetcher.h @@ -221,7 +221,7 @@ class NET_EXPORT URLFetcher { // Set the origin that should be considered as "initiating" the fetch. This // URL will be considered the "first-party" when applying cookie blocking // policy to requests, and treated as the request's initiator. - virtual void SetInitiator(const base::Optional& initiator) = 0; + virtual void SetInitiator(const absl::optional& initiator) = 0; // Set the key and data callback that is used when setting the user // data on any URLRequest objects this object creates. diff --git a/net/url_request/url_fetcher_core.cc b/net/url_request/url_fetcher_core.cc index 25528db8c18299..9c82262f92f54f 100644 --- a/net/url_request/url_fetcher_core.cc +++ b/net/url_request/url_fetcher_core.cc @@ -81,7 +81,7 @@ URLFetcherCore::URLFetcherCore( delegate_(d), delegate_task_runner_(base::SequencedTaskRunnerHandle::Get()), load_flags_(LOAD_NORMAL), - allow_credentials_(base::nullopt), + allow_credentials_(absl::nullopt), response_code_(URLFetcher::RESPONSE_CODE_INVALID), url_request_data_key_(nullptr), was_cached_(false), @@ -217,7 +217,7 @@ void URLFetcherCore::SetLoadFlags(int load_flags) { } void URLFetcherCore::SetAllowCredentials(bool allow_credentials) { - allow_credentials_ = base::make_optional(allow_credentials); + allow_credentials_ = absl::make_optional(allow_credentials); } int URLFetcherCore::GetLoadFlags() const { @@ -249,7 +249,7 @@ void URLFetcherCore::SetRequestContext( } void URLFetcherCore::SetInitiator( - const base::Optional& initiator) { + const absl::optional& initiator) { DCHECK(!initiator_.has_value()); initiator_ = initiator; } diff --git a/net/url_request/url_fetcher_core.h b/net/url_request/url_fetcher_core.h index 25c0976b07eacc..213e4abd1e5492 100644 --- a/net/url_request/url_fetcher_core.h +++ b/net/url_request/url_fetcher_core.h @@ -97,7 +97,7 @@ class URLFetcherCore : public base::RefCountedThreadSafe, // URL // will be considered the "first-party" when applying cookie blocking policy // to requests, and treated as the request's initiator. - void SetInitiator(const base::Optional& initiator); + void SetInitiator(const absl::optional& initiator); // Set the key and data callback that is used when setting the user // data on any URLRequest objects this object creates. void SetURLRequestUserData( @@ -249,13 +249,13 @@ class URLFetcherCore : public base::RefCountedThreadSafe, std::unique_ptr request_; // The actual request this wraps int load_flags_; // Flags for the load operation // Whether credentials are sent along with the request. - base::Optional allow_credentials_; + absl::optional allow_credentials_; int response_code_; // HTTP status code for the request scoped_refptr buffer_; // Read buffer scoped_refptr request_context_getter_; // Cookie/cache info for the request - base::Optional initiator_; // The request's initiator + absl::optional initiator_; // The request's initiator // The user data to add to each newly-created URLRequest. const void* url_request_data_key_; URLFetcher::CreateDataCallback url_request_create_data_callback_; diff --git a/net/url_request/url_fetcher_impl.cc b/net/url_request/url_fetcher_impl.cc index 255d2fcbbd5afb..c5aa57fbbb4433 100644 --- a/net/url_request/url_fetcher_impl.cc +++ b/net/url_request/url_fetcher_impl.cc @@ -90,7 +90,7 @@ void URLFetcherImpl::SetRequestContext( } void URLFetcherImpl::SetInitiator( - const base::Optional& initiator) { + const absl::optional& initiator) { core_->SetInitiator(initiator); } diff --git a/net/url_request/url_fetcher_impl.h b/net/url_request/url_fetcher_impl.h index 338ad08920cee3..15bf017087575e 100644 --- a/net/url_request/url_fetcher_impl.h +++ b/net/url_request/url_fetcher_impl.h @@ -60,7 +60,7 @@ class NET_EXPORT_PRIVATE URLFetcherImpl : public URLFetcher { const std::string& value) override; void SetRequestContext( URLRequestContextGetter* request_context_getter) override; - void SetInitiator(const base::Optional& initiator) override; + void SetInitiator(const absl::optional& initiator) override; void SetURLRequestUserData( const void* key, const CreateDataCallback& create_data_callback) override; diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc index 7215881e681f19..4b4018104957af 100644 --- a/net/url_request/url_request.cc +++ b/net/url_request/url_request.cc @@ -372,7 +372,7 @@ HttpResponseHeaders* URLRequest::response_headers() const { return response_info_.headers.get(); } -const base::Optional& URLRequest::auth_challenge_info() +const absl::optional& URLRequest::auth_challenge_info() const { return response_info_.auth_challenge; } @@ -453,7 +453,7 @@ void URLRequest::set_first_party_url_policy( first_party_url_policy_ = first_party_url_policy; } -void URLRequest::set_initiator(const base::Optional& initiator) { +void URLRequest::set_initiator(const absl::optional& initiator) { DCHECK(!is_pending_); DCHECK(!initiator.has_value() || initiator.value().opaque() || initiator.value().GetURL().is_valid()); @@ -826,8 +826,8 @@ void URLRequest::NotifyResponseStarted(int net_error) { } void URLRequest::FollowDeferredRedirect( - const base::Optional>& removed_headers, - const base::Optional& modified_headers) { + const absl::optional>& removed_headers, + const absl::optional& modified_headers) { DCHECK(job_.get()); DCHECK_EQ(OK, status_); @@ -911,8 +911,8 @@ void URLRequest::PrepareToRestart() { void URLRequest::Redirect( const RedirectInfo& redirect_info, - const base::Optional>& removed_headers, - const base::Optional& modified_headers) { + const absl::optional>& removed_headers, + const absl::optional& modified_headers) { // This method always succeeds. Whether |job_| is allowed to redirect to // |redirect_info| is checked in URLRequestJob::CanFollowRedirect, before // NotifyReceivedRedirect. This means the delegate can assume that, if it diff --git a/net/url_request/url_request.h b/net/url_request/url_request.h index b210964f322960..19f7e1f465fe66 100644 --- a/net/url_request/url_request.h +++ b/net/url_request/url_request.h @@ -14,7 +14,6 @@ #include "base/containers/flat_set.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "base/supports_user_data.h" #include "base/threading/thread_checker.h" #include "base/time/time.h" @@ -48,6 +47,7 @@ #include "net/traffic_annotation/network_traffic_annotation.h" #include "net/url_request/redirect_info.h" #include "net/url_request/referrer_policy.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/origin.h" @@ -308,9 +308,9 @@ class NET_EXPORT URLRequest : public base::SupportsUserData { // Note: the initiator can be null for browser-initiated top level // navigations. This is different from a unique Origin (e.g. in sandboxed // iframes). - const base::Optional& initiator() const { return initiator_; } + const absl::optional& initiator() const { return initiator_; } // This method may only be called before Start(). - void set_initiator(const base::Optional& initiator); + void set_initiator(const absl::optional& initiator); // The request method, as an uppercase string. "GET" is the default value. // The request method may only be changed before Start() is called and @@ -472,7 +472,7 @@ class NET_EXPORT URLRequest : public base::SupportsUserData { // Get the SSL connection info. const SSLInfo& ssl_info() const { return response_info_.ssl_info; } - const base::Optional& auth_challenge_info() const; + const absl::optional& auth_challenge_info() const; // Gets timing information related to the request. Events that have not yet // occurred are left uninitialized. After a second request starts, due to @@ -610,8 +610,8 @@ class NET_EXPORT URLRequest : public base::SupportsUserData { // |modified_headers| are changes applied to the request headers after // updating them for the redirect. void FollowDeferredRedirect( - const base::Optional>& removed_headers, - const base::Optional& modified_headers); + const absl::optional>& removed_headers, + const absl::optional& modified_headers); // One of the following two methods should be called in response to an // OnAuthRequired() callback (and only then). @@ -698,13 +698,13 @@ class NET_EXPORT URLRequest : public base::SupportsUserData { return accepted_stream_types_->contains(type); } - const base::Optional>& + const absl::optional>& accepted_stream_types() const { return accepted_stream_types_; } void set_accepted_stream_types( - const base::Optional>& + const absl::optional>& types) { if (types) { DCHECK(!types->contains(net::SourceStream::SourceType::TYPE_NONE)); @@ -788,8 +788,8 @@ class NET_EXPORT URLRequest : public base::SupportsUserData { // applied to the request headers after updating them for the redirect. void Redirect( const RedirectInfo& redirect_info, - const base::Optional>& removed_headers, - const base::Optional& modified_headers); + const absl::optional>& removed_headers, + const absl::optional& modified_headers); // Called by URLRequestJob to allow interception when a redirect occurs. void NotifyReceivedRedirect(const RedirectInfo& redirect_info, @@ -892,7 +892,7 @@ class NET_EXPORT URLRequest : public base::SupportsUserData { bool force_ignore_site_for_cookies_; bool force_ignore_top_frame_party_for_cookies_; - base::Optional initiator_; + absl::optional initiator_; GURL delegate_redirect_url_; std::string method_; // "GET", "POST", etc. Should be all uppercase. std::string referrer_; @@ -994,7 +994,7 @@ class NET_EXPORT URLRequest : public base::SupportsUserData { // If not null, the network service will not advertise any stream types // (via Accept-Encoding) that are not listed. Also, it will not attempt // decoding any non-listed stream types. - base::Optional> + absl::optional> accepted_stream_types_; const NetworkTrafficAnnotationTag traffic_annotation_; diff --git a/net/url_request/url_request_context_builder.cc b/net/url_request/url_request_context_builder.cc index 8773ed5a1b193e..788d82b5fabc1f 100644 --- a/net/url_request/url_request_context_builder.cc +++ b/net/url_request/url_request_context_builder.cc @@ -92,7 +92,7 @@ class BasicNetworkDelegate : public NetworkDelegateImpl { const HttpResponseHeaders* original_response_headers, scoped_refptr* override_response_headers, const IPEndPoint& endpoint, - base::Optional* preserve_fragment_on_redirect_url) override { + absl::optional* preserve_fragment_on_redirect_url) override { return OK; } diff --git a/net/url_request/url_request_context_builder_unittest.cc b/net/url_request/url_request_context_builder_unittest.cc index 585f4865546305..a4a694bc1136d9 100644 --- a/net/url_request/url_request_context_builder_unittest.cc +++ b/net/url_request/url_request_context_builder_unittest.cc @@ -232,7 +232,7 @@ TEST_F(URLRequestContextBuilderTest, ShutdownHostResolverWithPendingRequest) { std::unique_ptr request = context->host_resolver()->CreateRequest( HostPortPair("example.com", 1234), NetworkIsolationKey(), - NetLogWithSource(), base::nullopt); + NetLogWithSource(), absl::nullopt); TestCompletionCallback callback; int rv = request->Start(callback.callback()); ASSERT_TRUE(mock_host_resolver->has_pending_requests()); diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc index 86739a5f135413..f1750fe3a6ad53 100644 --- a/net/url_request/url_request_http_job.cc +++ b/net/url_request/url_request_http_job.cc @@ -21,7 +21,6 @@ #include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_macros.h" #include "base/numerics/safe_conversions.h" -#include "base/optional.h" #include "base/rand_util.h" #include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" @@ -79,6 +78,7 @@ #include "net/url_request/url_request_redirect_job.h" #include "net/url_request/url_request_throttler_manager.h" #include "net/url_request/websocket_handshake_userdata_key.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/origin.h" #if defined(OS_ANDROID) @@ -729,9 +729,9 @@ void URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete(int result) { } base::Time response_date; - base::Optional server_time = base::nullopt; + absl::optional server_time = absl::nullopt; if (GetResponseHeaders()->GetDateValue(&response_date)) - server_time = base::make_optional(response_date); + server_time = absl::make_optional(response_date); bool force_ignore_site_for_cookies = request_->force_ignore_site_for_cookies(); @@ -792,7 +792,7 @@ void URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete(int result) { request_->url(), cookie_string, base::Time::Now(), server_time, &returned_status); - base::Optional cookie_to_return = base::nullopt; + absl::optional cookie_to_return = absl::nullopt; if (returned_status.IsInclude()) { DCHECK(cookie); // Make a copy of the cookie if we successfully made one. @@ -824,7 +824,7 @@ void URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete(int result) { void URLRequestHttpJob::OnSetCookieResult( const CookieOptions& options, - base::Optional cookie, + absl::optional cookie, std::string cookie_string, CookieAccessResult access_result) { if (request_->net_log().IsCapturing()) { @@ -944,7 +944,7 @@ void URLRequestHttpJob::OnStartCompleted(int result) { // |URLRequestHttpJob::OnHeadersReceivedCallback()| or // |NetworkDelegate::URLRequestDestroyed()| has been called. OnCallToDelegate(NetLogEventType::NETWORK_DELEGATE_HEADERS_RECEIVED); - preserve_fragment_on_redirect_url_ = base::nullopt; + preserve_fragment_on_redirect_url_ = absl::nullopt; IPEndPoint endpoint; if (transaction_) transaction_->GetRemoteEndpoint(&endpoint); diff --git a/net/url_request/url_request_http_job.h b/net/url_request/url_request_http_job.h index 0321c7b019bed3..6207dc6938b949 100644 --- a/net/url_request/url_request_http_job.h +++ b/net/url_request/url_request_http_job.h @@ -16,7 +16,6 @@ #include "base/gtest_prod_util.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "base/time/time.h" #include "net/base/auth.h" #include "net/base/ip_endpoint.h" @@ -27,6 +26,7 @@ #include "net/socket/connection_attempts.h" #include "net/url_request/url_request_job.h" #include "net/url_request/url_request_throttler_entry_interface.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -183,7 +183,7 @@ class NET_EXPORT_PRIVATE URLRequestHttpJob : public URLRequestJob { // Another Cookie Monster callback void OnSetCookieResult(const CookieOptions& options, - base::Optional cookie, + absl::optional cookie, std::string cookie_string, CookieAccessResult access_result); int num_cookie_lines_left_; @@ -237,12 +237,12 @@ class NET_EXPORT_PRIVATE URLRequestHttpJob : public URLRequestJob { // Ordinarily the original URL's fragment is copied during redirects, unless // the destination URL already has one. However, the NetworkDelegate can // override this behavior by setting |preserve_fragment_on_redirect_url_|: - // * If set to base::nullopt, the default behavior is used. + // * If set to absl::nullopt, the default behavior is used. // * If the final URL in the redirect chain matches // |preserve_fragment_on_redirect_url_|, its fragment unchanged. So this // is basically a way for the embedder to force a redirect not to copy the // original URL's fragment when the original URL had one. - base::Optional preserve_fragment_on_redirect_url_; + absl::optional preserve_fragment_on_redirect_url_; // Flag used to verify that |this| is not deleted while we are awaiting // a callback from the NetworkDelegate. Used as a fail-fast mechanism. diff --git a/net/url_request/url_request_http_job_unittest.cc b/net/url_request/url_request_http_job_unittest.cc index 599ea24615f073..64c820821ad375 100644 --- a/net/url_request/url_request_http_job_unittest.cc +++ b/net/url_request/url_request_http_job_unittest.cc @@ -1325,8 +1325,8 @@ TEST_F(URLRequestHttpJobTest, HSTSInternalRedirectCallback) { raw_req_headers = HttpRawRequestHeaders(); - r->FollowDeferredRedirect(base::nullopt /* removed_headers */, - base::nullopt /* modified_headers */); + r->FollowDeferredRedirect(absl::nullopt /* removed_headers */, + absl::nullopt /* modified_headers */); delegate.RunUntilComplete(); EXPECT_FALSE(raw_req_headers.headers().empty()); @@ -1661,7 +1661,7 @@ bool CreateAndSetCookie(CookieStore* cs, const GURL& url, const std::string& cookie_line) { auto cookie = CanonicalCookie::Create(url, cookie_line, base::Time::Now(), - base::nullopt); + absl::nullopt); if (!cookie) return false; DCHECK(cs); @@ -1710,7 +1710,7 @@ TEST_F(URLRequestHttpJobTest, CookieSchemeRequestSchemeHistogram) { // would normally only happen during an existing cookie DB version upgrade. std::unique_ptr unset_cookie1 = CanonicalCookie::Create( secure_url_for_unset1, "NoSourceSchemeHttps=val", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); unset_cookie1->SetSourceScheme(net::CookieSourceScheme::kUnset); CookieList list1 = {*unset_cookie1}; @@ -1730,7 +1730,7 @@ TEST_F(URLRequestHttpJobTest, CookieSchemeRequestSchemeHistogram) { std::unique_ptr unset_cookie2 = CanonicalCookie::Create( nonsecure_url_for_unset2, "NoSourceSchemeHttp=val", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); unset_cookie2->SetSourceScheme(net::CookieSourceScheme::kUnset); CookieList list2 = {*unset_cookie2}; diff --git a/net/url_request/url_request_job.cc b/net/url_request/url_request_job.cc index 42e3e3c4eedb65..a9a44ddcf29dc3 100644 --- a/net/url_request/url_request_job.cc +++ b/net/url_request/url_request_job.cc @@ -232,14 +232,14 @@ void URLRequestJob::ContinueDespiteLastError() { } void URLRequestJob::FollowDeferredRedirect( - const base::Optional>& removed_headers, - const base::Optional& modified_headers) { + const absl::optional>& removed_headers, + const absl::optional& modified_headers) { // OnReceivedRedirect must have been called. DCHECK(deferred_redirect_info_); // It is possible that FollowRedirect will delete |this|, so it is not safe to // pass along a reference to |deferred_redirect_info_|. - base::Optional redirect_info = + absl::optional redirect_info = std::move(deferred_redirect_info_); FollowRedirect(*redirect_info, removed_headers, modified_headers); } @@ -475,8 +475,8 @@ void URLRequestJob::NotifyHeadersComplete() { if (defer_redirect) { deferred_redirect_info_ = std::move(redirect_info); } else { - FollowRedirect(redirect_info, base::nullopt, /* removed_headers */ - base::nullopt /* modified_headers */); + FollowRedirect(redirect_info, absl::nullopt, /* removed_headers */ + absl::nullopt /* modified_headers */); } return; } @@ -734,8 +734,8 @@ int URLRequestJob::CanFollowRedirect(const GURL& new_url) { void URLRequestJob::FollowRedirect( const RedirectInfo& redirect_info, - const base::Optional>& removed_headers, - const base::Optional& modified_headers) { + const absl::optional>& removed_headers, + const absl::optional& modified_headers) { request_->Redirect(redirect_info, removed_headers, modified_headers); } diff --git a/net/url_request/url_request_job.h b/net/url_request/url_request_job.h index 9d952e24e18e32..a1625e6a2a4c51 100644 --- a/net/url_request/url_request_job.h +++ b/net/url_request/url_request_job.h @@ -13,7 +13,6 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "net/base/completion_once_callback.h" #include "net/base/completion_repeating_callback.h" #include "net/base/ip_endpoint.h" @@ -30,6 +29,7 @@ #include "net/url_request/redirect_info.h" #include "net/url_request/referrer_policy.h" #include "net/url_request/url_request.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace net { @@ -191,8 +191,8 @@ class NET_EXPORT URLRequestJob { virtual void ContinueDespiteLastError(); void FollowDeferredRedirect( - const base::Optional>& removed_headers, - const base::Optional& modified_headers); + const absl::optional>& removed_headers, + const absl::optional& modified_headers); // Returns true if the Job is done producing response data and has called // NotifyDone on the request. @@ -380,8 +380,8 @@ class NET_EXPORT URLRequestJob { // given redirect destination. void FollowRedirect( const RedirectInfo& redirect_info, - const base::Optional>& removed_headers, - const base::Optional& modified_headers); + const absl::optional>& removed_headers, + const absl::optional& modified_headers); // Called after every raw read. If |bytes_read| is > 0, this indicates // a successful read of |bytes_read| unfiltered bytes. If |bytes_read| @@ -438,7 +438,7 @@ class NET_EXPORT URLRequestJob { // Set when a redirect is deferred. Redirects are deferred after validity // checks are performed, so this field must not be modified. - base::Optional deferred_redirect_info_; + absl::optional deferred_redirect_info_; // Non-null if ReadRawData() returned ERR_IO_PENDING, and the read has not // completed. diff --git a/net/url_request/url_request_netlog_params.cc b/net/url_request/url_request_netlog_params.cc index 4dbdc77256b706..dd9973a37174ff 100644 --- a/net/url_request/url_request_netlog_params.cc +++ b/net/url_request/url_request_netlog_params.cc @@ -34,7 +34,7 @@ base::Value NetLogURLRequestStartParams( PrivacyMode privacy_mode, const IsolationInfo& isolation_info, const SiteForCookies& site_for_cookies, - const base::Optional& initiator, + const absl::optional& initiator, int64_t upload_id) { base::Value dict(base::Value::Type::DICTIONARY); dict.SetStringKey("url", url.possibly_invalid_spec()); diff --git a/net/url_request/url_request_netlog_params.h b/net/url_request/url_request_netlog_params.h index 5990f3d64a8cb6..b5bd0b8b4f128b 100644 --- a/net/url_request/url_request_netlog_params.h +++ b/net/url_request/url_request_netlog_params.h @@ -10,13 +10,13 @@ #include #include -#include "base/optional.h" #include "net/base/isolation_info.h" #include "net/base/net_export.h" #include "net/base/privacy_mode.h" #include "net/base/request_priority.h" #include "net/log/net_log_capture_mode.h" #include "net/traffic_annotation/network_traffic_annotation.h" +#include "third_party/abseil-cpp/absl/types/optional.h" class GURL; @@ -46,7 +46,7 @@ NET_EXPORT base::Value NetLogURLRequestStartParams( PrivacyMode privacy_mode, const IsolationInfo& isolation_info, const SiteForCookies& site_for_cookies, - const base::Optional& initiator, + const absl::optional& initiator, int64_t upload_id); } // namespace net diff --git a/net/url_request/url_request_test_util.cc b/net/url_request/url_request_test_util.cc index 6ec09da926d87b..6bbc6caf23b858 100644 --- a/net/url_request/url_request_test_util.cc +++ b/net/url_request/url_request_test_util.cc @@ -471,7 +471,7 @@ int TestNetworkDelegate::OnHeadersReceived( const HttpResponseHeaders* original_response_headers, scoped_refptr* override_response_headers, const IPEndPoint& endpoint, - base::Optional* preserve_fragment_on_redirect_url) { + absl::optional* preserve_fragment_on_redirect_url) { EXPECT_FALSE(preserve_fragment_on_redirect_url->has_value()); int req_id = GetRequestId(request); bool is_first_response = @@ -499,7 +499,7 @@ int TestNetworkDelegate::OnHeadersReceived( redirect_on_headers_received_url_ = GURL(); - // Since both values are base::Optionals, can just copy this over. + // Since both values are absl::optionals, can just copy this over. *preserve_fragment_on_redirect_url = preserve_fragment_on_redirect_url_; } else if (add_header_to_first_response_ && is_first_response) { *override_response_headers = diff --git a/net/url_request/url_request_test_util.h b/net/url_request/url_request_test_util.h index 96d43b712981ec..73eaa17e39a208 100644 --- a/net/url_request/url_request_test_util.h +++ b/net/url_request/url_request_test_util.h @@ -16,7 +16,6 @@ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" -#include "base/optional.h" #include "base/path_service.h" #include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" @@ -44,6 +43,7 @@ #include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_storage.h" #include "net/url_request/url_request_interceptor.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/url_util.h" namespace net { @@ -311,7 +311,7 @@ class TestNetworkDelegate : public NetworkDelegateImpl { } void set_preserve_fragment_on_redirect_url( - const base::Optional& preserve_fragment_on_redirect_url) { + const absl::optional& preserve_fragment_on_redirect_url) { preserve_fragment_on_redirect_url_ = preserve_fragment_on_redirect_url; } @@ -355,7 +355,7 @@ class TestNetworkDelegate : public NetworkDelegateImpl { const HttpResponseHeaders* original_response_headers, scoped_refptr* override_response_headers, const IPEndPoint& endpoint, - base::Optional* preserve_fragment_on_redirect_url) override; + absl::optional* preserve_fragment_on_redirect_url) override; void OnBeforeRedirect(URLRequest* request, const GURL& new_location) override; void OnResponseStarted(URLRequest* request, int net_error) override; void OnCompleted(URLRequest* request, bool started, int net_error) override; @@ -381,7 +381,7 @@ class TestNetworkDelegate : public NetworkDelegateImpl { GURL redirect_on_headers_received_url_; // URL to mark as retaining its fragment if redirected to at the // OnHeadersReceived() stage. - base::Optional preserve_fragment_on_redirect_url_; + absl::optional preserve_fragment_on_redirect_url_; int last_error_; int error_count_; diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index deed3ce43673d3..d3140c08825a71 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc @@ -35,7 +35,6 @@ #include "base/json/json_reader.h" #include "base/location.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "base/path_service.h" #include "base/run_loop.h" #include "base/single_thread_task_runner.h" @@ -148,6 +147,7 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/url_util.h" #if !BUILDFLAG(DISABLE_FTP_SUPPORT) && !defined(OS_ANDROID) @@ -455,7 +455,7 @@ class BlockingNetworkDelegate : public TestNetworkDelegate { const HttpResponseHeaders* original_response_headers, scoped_refptr* override_response_headers, const IPEndPoint& endpoint, - base::Optional* preserve_fragment_on_redirect_url) override; + absl::optional* preserve_fragment_on_redirect_url) override; // Resets the callbacks and |stage_blocked_for_callback_|. void Reset(); @@ -561,7 +561,7 @@ int BlockingNetworkDelegate::OnHeadersReceived( const HttpResponseHeaders* original_response_headers, scoped_refptr* override_response_headers, const IPEndPoint& endpoint, - base::Optional* preserve_fragment_on_redirect_url) { + absl::optional* preserve_fragment_on_redirect_url) { // TestNetworkDelegate always completes synchronously. CHECK_NE(ERR_IO_PENDING, TestNetworkDelegate::OnHeadersReceived( @@ -873,8 +873,8 @@ TEST_F(URLRequestTest, RecordsReferrerHistogramAgainOnRedirect) { static_cast( ReferrerPolicy::CLEAR_ON_TRANSITION_FROM_SECURE_TO_INSECURE), 1); - req->FollowDeferredRedirect(/*removed_headers=*/base::nullopt, - /*modified_headers=*/base::nullopt); + req->FollowDeferredRedirect(/*removed_headers=*/absl::nullopt, + /*modified_headers=*/absl::nullopt); d.RunUntilComplete(); histograms.ExpectUniqueSample( "Net.URLRequest.ReferrerPolicyForRequest.CrossOrigin", @@ -907,8 +907,8 @@ TEST_F(URLRequestTest, RecordsReferrrerWithInformativePath) { "Net.URLRequest.ReferrerHasInformativePath.SameOrigin", /* Check the count of the "true" bucket in the boolean histogram. */ true, 1); - req->FollowDeferredRedirect(/*removed_headers=*/base::nullopt, - /*modified_headers=*/base::nullopt); + req->FollowDeferredRedirect(/*removed_headers=*/absl::nullopt, + /*modified_headers=*/absl::nullopt); d.RunUntilComplete(); histograms.ExpectUniqueSample( "Net.URLRequest.ReferrerHasInformativePath.CrossOrigin", true, 1); @@ -938,8 +938,8 @@ TEST_F(URLRequestTest, RecordsReferrerWithInformativeQuery) { "Net.URLRequest.ReferrerHasInformativePath.SameOrigin", /* Check the count of the "true" bucket in the boolean histogram. */ true, 1); - req->FollowDeferredRedirect(/*removed_headers=*/base::nullopt, - /*modified_headers=*/base::nullopt); + req->FollowDeferredRedirect(/*removed_headers=*/absl::nullopt, + /*modified_headers=*/absl::nullopt); d.RunUntilComplete(); histograms.ExpectUniqueSample( "Net.URLRequest.ReferrerHasInformativePath.CrossOrigin", true, 1); @@ -967,8 +967,8 @@ TEST_F(URLRequestTest, RecordsReferrerWithoutInformativePathOrQuery) { d.RunUntilRedirect(); histograms.ExpectUniqueSample( "Net.URLRequest.ReferrerHasInformativePath.CrossOrigin", false, 1); - req->FollowDeferredRedirect(/*removed_headers=*/base::nullopt, - /*modified_headers=*/base::nullopt); + req->FollowDeferredRedirect(/*removed_headers=*/absl::nullopt, + /*modified_headers=*/absl::nullopt); d.RunUntilComplete(); histograms.ExpectUniqueSample( "Net.URLRequest.ReferrerHasInformativePath.SameOrigin", false, 1); @@ -1717,13 +1717,13 @@ TEST_F(URLRequestTest, DelayedCookieCallbackAsync) { auto cookie1 = CanonicalCookie::Create(url, "AlreadySetCookie=1;Secure", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); delayed_cm->SetCanonicalCookieAsync(std::move(cookie1), url, net::CookieOptions::MakeAllInclusive(), CookieStore::SetCookiesCallback()); auto cookie2 = CanonicalCookie::Create(url, "AlreadySetCookie=1;Secure", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); cm->SetCanonicalCookieAsync(std::move(cookie2), url, net::CookieOptions::MakeAllInclusive(), CookieStore::SetCookiesCallback()); @@ -3406,7 +3406,7 @@ class FixedDateNetworkDelegate : public TestNetworkDelegate { const HttpResponseHeaders* original_response_headers, scoped_refptr* override_response_headers, const IPEndPoint& endpoint, - base::Optional* preserve_fragment_on_redirect_url) override; + absl::optional* preserve_fragment_on_redirect_url) override; private: std::string fixed_date_; @@ -3420,7 +3420,7 @@ int FixedDateNetworkDelegate::OnHeadersReceived( const HttpResponseHeaders* original_response_headers, scoped_refptr* override_response_headers, const IPEndPoint& endpoint, - base::Optional* preserve_fragment_on_redirect_url) { + absl::optional* preserve_fragment_on_redirect_url) { HttpResponseHeaders* new_response_headers = new HttpResponseHeaders(original_response_headers->raw_headers()); @@ -4000,8 +4000,8 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateRedirectRequest) { EXPECT_EQ(redirect_url, GURL(location)); // Let the request finish. - r->FollowDeferredRedirect(base::nullopt /* removed_headers */, - base::nullopt /* modified_headers */); + r->FollowDeferredRedirect(absl::nullopt /* removed_headers */, + absl::nullopt /* modified_headers */); d.RunUntilComplete(); EXPECT_EQ(OK, d.request_status()); EXPECT_EQ(ProxyServer(ProxyServer::SCHEME_HTTP, @@ -4049,8 +4049,8 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateRedirectRequestSynchronously) { EXPECT_EQ(redirect_url, GURL(location)); // Let the request finish. - r->FollowDeferredRedirect(base::nullopt /* removed_headers */, - base::nullopt /* modified_headers */); + r->FollowDeferredRedirect(absl::nullopt /* removed_headers */, + absl::nullopt /* modified_headers */); d.RunUntilComplete(); EXPECT_EQ(OK, d.request_status()); @@ -4108,8 +4108,8 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateRedirectRequestPost) { EXPECT_EQ(redirect_url, GURL(location)); // Let the request finish. - r->FollowDeferredRedirect(base::nullopt /* removed_headers */, - base::nullopt /* modified_headers */); + r->FollowDeferredRedirect(absl::nullopt /* removed_headers */, + absl::nullopt /* modified_headers */); d.RunUntilComplete(); EXPECT_EQ(OK, d.request_status()); @@ -4851,7 +4851,7 @@ class AsyncLoggingNetworkDelegate : public TestNetworkDelegate { const HttpResponseHeaders* original_response_headers, scoped_refptr* override_response_headers, const IPEndPoint& endpoint, - base::Optional* preserve_fragment_on_redirect_url) override { + absl::optional* preserve_fragment_on_redirect_url) override { // TestNetworkDelegate always completes synchronously. CHECK_NE(ERR_IO_PENDING, TestNetworkDelegate::OnHeadersReceived( @@ -4939,8 +4939,8 @@ class AsyncLoggingUrlRequestDelegate : public TestDelegate { if (cancel_stage_ == CANCEL_ON_RECEIVED_REDIRECT) return; if (!defer_redirect) { - request->FollowDeferredRedirect(base::nullopt /* removed_headers */, - base::nullopt /* modified_headers */); + request->FollowDeferredRedirect(absl::nullopt /* removed_headers */, + absl::nullopt /* modified_headers */); } } @@ -6725,8 +6725,8 @@ TEST_F(URLRequestTestHTTP, CacheRedirect) { EXPECT_EQ(0, d.response_started_count()); EXPECT_TRUE(req->was_cached()); - req->FollowDeferredRedirect(base::nullopt /* removed_headers */, - base::nullopt /* modified_headers */); + req->FollowDeferredRedirect(absl::nullopt /* removed_headers */, + absl::nullopt /* modified_headers */); d.RunUntilComplete(); EXPECT_EQ(1, d.received_redirect_count()); EXPECT_EQ(1, d.response_started_count()); @@ -7000,8 +7000,8 @@ TEST_F(URLRequestTestHTTP, DeferredRedirect) { EXPECT_EQ(1, d.received_redirect_count()); - req->FollowDeferredRedirect(base::nullopt /* removed_headers */, - base::nullopt /* modified_headers */); + req->FollowDeferredRedirect(absl::nullopt /* removed_headers */, + absl::nullopt /* modified_headers */); d.RunUntilComplete(); EXPECT_EQ(1, d.response_started_count()); @@ -7054,7 +7054,7 @@ TEST_F(URLRequestTestHTTP, DeferredRedirect_ModifiedHeaders) { modified_headers.SetHeader("Header2", ""); modified_headers.SetHeader("Header3", "Value3"); - req->FollowDeferredRedirect(base::nullopt /* removed_headers */, + req->FollowDeferredRedirect(absl::nullopt /* removed_headers */, modified_headers); d.RunUntilComplete(); @@ -7103,7 +7103,7 @@ TEST_F(URLRequestTestHTTP, DeferredRedirect_RemovedHeaders) { // Keep Header1 and remove Header2. std::vector removed_headers({"Header2"}); req->FollowDeferredRedirect(removed_headers, - base::nullopt /* modified_headers */); + absl::nullopt /* modified_headers */); d.RunUntilComplete(); EXPECT_EQ(1, d.response_started_count()); @@ -7749,7 +7749,7 @@ TEST_F(URLRequestTest, NoCookieInclusionStatusWarningIfWouldBeExcludedAnyway) { { GURL url = test_server.GetURL("/"); auto cookie1 = CanonicalCookie::Create(url, "cookienosamesite=1", - base::Time::Now(), base::nullopt); + base::Time::Now(), absl::nullopt); base::RunLoop run_loop; CookieAccessResult access_result; cm.SetCanonicalCookieAsync( @@ -7791,7 +7791,7 @@ TEST_F(URLRequestTest, NoCookieInclusionStatusWarningIfWouldBeExcludedAnyway) { { GURL url = test_server.GetURL("/"); auto cookie2 = CanonicalCookie::Create(url, "cookiewithpath=1;path=/foo", - base::Time::Now(), base::nullopt); + base::Time::Now(), absl::nullopt); base::RunLoop run_loop; // Note: cookie1 from the previous testcase is still in the cookie store. CookieAccessResult access_result; @@ -7936,7 +7936,7 @@ TEST_F(URLRequestTestHTTP, AuthChallengeWithFilteredCookies) { std::make_unique(nullptr, nullptr); auto another_cookie = CanonicalCookie::Create( url_requiring_auth_wo_cookies, "another_cookie=true", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); cm->SetCanonicalCookieAsync(std::move(another_cookie), url_requiring_auth_wo_cookies, net::CookieOptions::MakeAllInclusive(), @@ -7968,7 +7968,7 @@ TEST_F(URLRequestTestHTTP, AuthChallengeWithFilteredCookies) { cm->DeleteAllAsync(CookieStore::DeleteCallback()); auto one_more_cookie = CanonicalCookie::Create( url_requiring_auth_wo_cookies, "one_more_cookie=true", - base::Time::Now(), base::nullopt /* server_time */); + base::Time::Now(), absl::nullopt /* server_time */); cm->SetCanonicalCookieAsync(std::move(one_more_cookie), url_requiring_auth_wo_cookies, net::CookieOptions::MakeAllInclusive(), @@ -8315,7 +8315,7 @@ TEST_F(URLRequestTestHTTP, RedirectWithFilteredCookies) { // Check maybe_stored_cookies on second round trip (and clearing from the // first). - request->FollowDeferredRedirect(base::nullopt, base::nullopt); + request->FollowDeferredRedirect(absl::nullopt, absl::nullopt); delegate.RunUntilComplete(); EXPECT_THAT(delegate.request_status(), IsOk()); @@ -8347,7 +8347,7 @@ TEST_F(URLRequestTestHTTP, RedirectWithFilteredCookies) { std::make_unique(nullptr, nullptr); auto another_cookie = CanonicalCookie::Create( original_url, "another_cookie=true", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); cm->SetCanonicalCookieAsync(std::move(another_cookie), original_url, net::CookieOptions::MakeAllInclusive(), CookieStore::SetCookiesCallback()); @@ -8376,13 +8376,13 @@ TEST_F(URLRequestTestHTTP, RedirectWithFilteredCookies) { cm->DeleteAllAsync(CookieStore::DeleteCallback()); auto one_more_cookie = CanonicalCookie::Create( original_url_wo_cookie, "one_more_cookie=true", base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); cm->SetCanonicalCookieAsync(std::move(one_more_cookie), original_url_wo_cookie, net::CookieOptions::MakeAllInclusive(), CookieStore::SetCookiesCallback()); - request->FollowDeferredRedirect(base::nullopt, base::nullopt); + request->FollowDeferredRedirect(absl::nullopt, absl::nullopt); delegate.RunUntilComplete(); EXPECT_THAT(delegate.request_status(), IsOk()); @@ -8740,8 +8740,8 @@ TEST_F(URLRequestTestHTTP, SetSubsequentJobPriority) { std::make_unique(redirect_url, std::move(job)); // Should trigger |job| to be started. - req->FollowDeferredRedirect(base::nullopt /* removed_headers */, - base::nullopt /* modified_headers */); + req->FollowDeferredRedirect(absl::nullopt /* removed_headers */, + absl::nullopt /* modified_headers */); d.RunUntilComplete(); EXPECT_EQ(LOW, job_priority); } @@ -12230,8 +12230,8 @@ TEST_F(URLRequestTestHTTP, HeadersCallbacksWithRedirect) { raw_req_headers = HttpRawRequestHeaders(); raw_resp_headers = nullptr; - r->FollowDeferredRedirect(base::nullopt /* removed_headers */, - base::nullopt /* modified_headers */); + r->FollowDeferredRedirect(absl::nullopt /* removed_headers */, + absl::nullopt /* modified_headers */); delegate.RunUntilComplete(); EXPECT_TRUE(raw_req_headers.FindHeaderForTest("X-Foo", &value)); EXPECT_EQ("bar", value); diff --git a/net/websockets/websocket_basic_handshake_stream.cc b/net/websockets/websocket_basic_handshake_stream.cc index b89ca64415aae4..ab5b44d21739a5 100644 --- a/net/websockets/websocket_basic_handshake_stream.cc +++ b/net/websockets/websocket_basic_handshake_stream.cc @@ -463,7 +463,7 @@ int WebSocketBasicHandshakeStream::ValidateResponse(int rv) { // helpful, so use a different error message. if (headers->GetHttpVersion() == HttpVersion(0, 9)) { OnFailure("Error during WebSocket handshake: Invalid status line", - ERR_FAILED, base::nullopt); + ERR_FAILED, absl::nullopt); } else { OnFailure(base::StringPrintf("Error during WebSocket handshake: " "Unexpected response code: %d", @@ -476,13 +476,13 @@ int WebSocketBasicHandshakeStream::ValidateResponse(int rv) { } else { if (rv == ERR_EMPTY_RESPONSE) { OnFailure("Connection closed before receiving a handshake response", rv, - base::nullopt); + absl::nullopt); result_ = HandshakeResult::EMPTY_RESPONSE; return rv; } OnFailure( std::string("Error during WebSocket handshake: ") + ErrorToString(rv), - rv, base::nullopt); + rv, absl::nullopt); // Some error codes (for example ERR_CONNECTION_CLOSED) get changed to OK at // higher levels. To prevent an unvalidated connection getting erroneously // upgraded, don't pass through the status code unchanged if it is @@ -522,14 +522,14 @@ int WebSocketBasicHandshakeStream::ValidateUpgradeResponse( return OK; } OnFailure("Error during WebSocket handshake: " + failure_message, ERR_FAILED, - base::nullopt); + absl::nullopt); return ERR_INVALID_RESPONSE; } void WebSocketBasicHandshakeStream::OnFailure( const std::string& message, int net_error, - base::Optional response_code) { + absl::optional response_code) { // Avoid connection reuse if auth did not happen. state_.connection()->socket()->Disconnect(); stream_request_->OnFailure(message, net_error, response_code); diff --git a/net/websockets/websocket_basic_handshake_stream.h b/net/websockets/websocket_basic_handshake_stream.h index 48783472b48a46..003a11d9885068 100644 --- a/net/websockets/websocket_basic_handshake_stream.h +++ b/net/websockets/websocket_basic_handshake_stream.h @@ -12,12 +12,12 @@ #include #include "base/macros.h" -#include "base/optional.h" #include "base/strings/string_piece.h" #include "net/base/completion_once_callback.h" #include "net/base/net_export.h" #include "net/http/http_basic_state.h" #include "net/websockets/websocket_handshake_stream_base.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace net { @@ -105,7 +105,7 @@ class NET_EXPORT_PRIVATE WebSocketBasicHandshakeStream final void OnFailure(const std::string& message, int net_error, - base::Optional response_code); + absl::optional response_code); HttpStreamParser* parser() const { return state_.parser(); } @@ -126,7 +126,7 @@ class NET_EXPORT_PRIVATE WebSocketBasicHandshakeStream final // The key to be sent in the next Sec-WebSocket-Key header. Usually NULL (the // key is generated on the fly). - base::Optional handshake_challenge_for_testing_; + absl::optional handshake_challenge_for_testing_; // The required value for the Sec-WebSocket-Accept header. std::string handshake_challenge_response_; diff --git a/net/websockets/websocket_basic_stream_adapters_test.cc b/net/websockets/websocket_basic_stream_adapters_test.cc index 9c13feb70bce59..f23d13ba030e08 100644 --- a/net/websockets/websocket_basic_stream_adapters_test.cc +++ b/net/websockets/websocket_basic_stream_adapters_test.cc @@ -9,7 +9,6 @@ #include "base/bind.h" #include "base/memory/scoped_refptr.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "base/run_loop.h" #include "base/strings/string_piece.h" #include "net/base/host_port_pair.h" @@ -42,6 +41,7 @@ #include "net/websockets/websocket_test_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" using testing::Test; using testing::StrictMock; diff --git a/net/websockets/websocket_basic_stream_test.cc b/net/websockets/websocket_basic_stream_test.cc index f9f79e630a316b..cc056aad8f2c8b 100644 --- a/net/websockets/websocket_basic_stream_test.cc +++ b/net/websockets/websocket_basic_stream_test.cc @@ -15,7 +15,6 @@ #include "base/big_endian.h" #include "base/containers/span.h" -#include "base/optional.h" #include "base/stl_util.h" #include "net/base/io_buffer.h" #include "net/base/privacy_mode.h" @@ -30,6 +29,7 @@ #include "net/test/test_with_task_environment.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" using net::test::IsError; using net::test::IsOk; @@ -149,7 +149,7 @@ class WebSocketBasicStreamSocketTest : public TestWithTaskEnvironment { PrivacyMode::PRIVACY_MODE_DISABLED, NetworkIsolationKey(), SecureDnsPolicy::kAllow); transport_socket->Init( - group_id, null_params, base::nullopt /* proxy_annotation_tag */, MEDIUM, + group_id, null_params, absl::nullopt /* proxy_annotation_tag */, MEDIUM, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, CompletionOnceCallback(), ClientSocketPool::ProxyAuthCallback(), &pool_, NetLogWithSource()); diff --git a/net/websockets/websocket_channel.cc b/net/websockets/websocket_channel.cc index ab44881b4a9267..7311f33fa5127c 100644 --- a/net/websockets/websocket_channel.cc +++ b/net/websockets/websocket_channel.cc @@ -242,7 +242,7 @@ class WebSocketChannel::ConnectDelegate void OnFailure(const std::string& message, int net_error, - base::Optional response_code) override { + absl::optional response_code) override { creator_->OnConnectFailure(message, net_error, response_code); // |this| has been deleted. } @@ -266,7 +266,7 @@ class WebSocketChannel::ConnectDelegate scoped_refptr headers, const IPEndPoint& remote_endpoint, base::OnceCallback callback, - base::Optional* credentials) override { + absl::optional* credentials) override { return creator_->OnAuthRequired(auth_info, std::move(headers), remote_endpoint, std::move(callback), credentials); @@ -476,7 +476,7 @@ void WebSocketChannel::SendAddChannelRequestWithSuppliedCallback( // TODO(ricea): Kill the renderer (this error should have been caught by // Javascript). event_interface_->OnFailChannel("Invalid scheme", ERR_FAILED, - base::nullopt); + absl::nullopt); // |this| is deleted here. return; } @@ -513,7 +513,7 @@ void WebSocketChannel::OnConnectSuccess( void WebSocketChannel::OnConnectFailure(const std::string& message, int net_error, - base::Optional response_code) { + absl::optional response_code) { DCHECK_EQ(CONNECTING, state_); // Copy the message before we delete its owner. @@ -541,7 +541,7 @@ int WebSocketChannel::OnAuthRequired( scoped_refptr response_headers, const IPEndPoint& remote_endpoint, base::OnceCallback callback, - base::Optional* credentials) { + absl::optional* credentials) { return event_interface_->OnAuthRequired( auth_info, std::move(response_headers), remote_endpoint, std::move(callback), credentials); @@ -961,7 +961,7 @@ void WebSocketChannel::FailChannel(const std::string& message, // handshake. stream_->Close(); SetState(CLOSED); - event_interface_->OnFailChannel(message, ERR_FAILED, base::nullopt); + event_interface_->OnFailChannel(message, ERR_FAILED, absl::nullopt); } ChannelState WebSocketChannel::SendClose(uint16_t code, diff --git a/net/websockets/websocket_channel.h b/net/websockets/websocket_channel.h index 404498276f7e7c..2d9f4958bf0ab8 100644 --- a/net/websockets/websocket_channel.h +++ b/net/websockets/websocket_channel.h @@ -17,13 +17,13 @@ #include "base/i18n/streaming_utf8_validator.h" #include "base/macros.h" #include "base/memory/scoped_refptr.h" -#include "base/optional.h" #include "base/time/time.h" #include "base/timer/timer.h" #include "net/base/net_export.h" #include "net/websockets/websocket_event_interface.h" #include "net/websockets/websocket_frame.h" #include "net/websockets/websocket_stream.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace url { @@ -199,7 +199,7 @@ class NET_EXPORT WebSocketChannel { // failure to the event interface. May delete |this|. void OnConnectFailure(const std::string& message, int net_error, - base::Optional response_code); + absl::optional response_code); // SSL certificate error callback from // WebSocketStream::CreateAndConnectStream(). Forwards the request to the @@ -217,7 +217,7 @@ class NET_EXPORT WebSocketChannel { scoped_refptr response_headers, const IPEndPoint& remote_endpoint, base::OnceCallback callback, - base::Optional* credentials); + absl::optional* credentials); // Sets |state_| to |new_state| and updates UMA if necessary. void SetState(State new_state); diff --git a/net/websockets/websocket_channel_test.cc b/net/websockets/websocket_channel_test.cc index f3499de3703ec0..878aa77e471ad2 100644 --- a/net/websockets/websocket_channel_test.cc +++ b/net/websockets/websocket_channel_test.cc @@ -171,7 +171,7 @@ class MockWebSocketEventInterface : public WebSocketEventInterface { MOCK_METHOD0(OnSendDataFrameDone, void(void)); // NOLINT MOCK_METHOD0(OnClosingHandshake, void(void)); // NOLINT MOCK_METHOD3(OnFailChannel, - void(const std::string&, int, base::Optional)); // NOLINT + void(const std::string&, int, absl::optional)); // NOLINT MOCK_METHOD3(OnDropChannel, void(bool, uint16_t, const std::string&)); // NOLINT @@ -193,7 +193,7 @@ class MockWebSocketEventInterface : public WebSocketEventInterface { scoped_refptr response_headers, const IPEndPoint& remote_endpoint, base::OnceCallback callback, - base::Optional* credentials) override { + absl::optional* credentials) override { return OnAuthRequiredCalled(std::move(auth_info), std::move(response_headers), remote_endpoint, credentials); @@ -207,7 +207,7 @@ class MockWebSocketEventInterface : public WebSocketEventInterface { int(const AuthChallengeInfo&, scoped_refptr, const IPEndPoint&, - base::Optional*)); + absl::optional*)); }; // This fake EventInterface is for tests which need a WebSocketEventInterface @@ -226,7 +226,7 @@ class FakeWebSocketEventInterface : public WebSocketEventInterface { void OnClosingHandshake() override {} void OnFailChannel(const std::string& message, int net_error, - base::Optional response_code) override {} + absl::optional response_code) override {} void OnDropChannel(bool was_clean, uint16_t code, const std::string& reason) override {} @@ -242,8 +242,8 @@ class FakeWebSocketEventInterface : public WebSocketEventInterface { scoped_refptr response_headers, const IPEndPoint& remote_endpoint, base::OnceCallback callback, - base::Optional* credentials) override { - *credentials = base::nullopt; + absl::optional* credentials) override { + *credentials = absl::nullopt; return OK; } }; @@ -1021,7 +1021,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, ConnectFailureReported) { CreateChannelAndConnect(); connect_data_.argument_saver.connect_delegate->OnFailure("hello", ERR_FAILED, - base::nullopt); + absl::nullopt); } TEST_F(WebSocketChannelEventInterfaceTest, NonWebSocketSchemeRejected) { @@ -1582,7 +1582,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, FailJustAfterHandshake) { url, response_headers, IPEndPoint(), base::Time()); connect_delegate->OnStartOpeningHandshake(std::move(request_info)); - connect_delegate->OnFailure("bye", ERR_FAILED, base::nullopt); + connect_delegate->OnFailure("bye", ERR_FAILED, absl::nullopt); base::RunLoop().RunUntilIdle(); } @@ -2630,7 +2630,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, OnAuthRequiredCalled) { const GURL wss_url("wss://example.com/on_auth_required"); connect_data_.socket_url = wss_url; AuthChallengeInfo auth_info; - base::Optional credentials; + absl::optional credentials; scoped_refptr response_headers = base::MakeRefCounted("HTTP/1.1 200 OK"); IPEndPoint remote_endpoint(net::IPAddress(127, 0, 0, 1), 80); diff --git a/net/websockets/websocket_end_to_end_test.cc b/net/websockets/websocket_end_to_end_test.cc index 79b58de036796a..219b52b8c98d93 100644 --- a/net/websockets/websocket_end_to_end_test.cc +++ b/net/websockets/websocket_end_to_end_test.cc @@ -118,7 +118,7 @@ class ConnectTestingEventInterface : public WebSocketEventInterface { void OnFailChannel(const std::string& message, int net_error, - base::Optional response_code) override; + absl::optional response_code) override; void OnStartOpeningHandshake( std::unique_ptr request) override; @@ -134,7 +134,7 @@ class ConnectTestingEventInterface : public WebSocketEventInterface { scoped_refptr response_headers, const IPEndPoint& remote_endpoint, base::OnceCallback callback, - base::Optional* credentials) override; + absl::optional* credentials) override; private: void QuitNestedEventLoop(); @@ -193,7 +193,7 @@ void ConnectTestingEventInterface::OnDropChannel(bool was_clean, void ConnectTestingEventInterface::OnFailChannel( const std::string& message, int net_error, - base::Optional response_code) { + absl::optional response_code) { failed_ = true; failure_message_ = message; QuitNestedEventLoop(); @@ -219,8 +219,8 @@ int ConnectTestingEventInterface::OnAuthRequired( scoped_refptr response_headers, const IPEndPoint& remote_endpoint, base::OnceCallback callback, - base::Optional* credentials) { - *credentials = base::nullopt; + absl::optional* credentials) { + *credentials = absl::nullopt; return OK; } diff --git a/net/websockets/websocket_event_interface.h b/net/websockets/websocket_event_interface.h index 204ccf66eed501..1ee46eff7c46ec 100644 --- a/net/websockets/websocket_event_interface.h +++ b/net/websockets/websocket_event_interface.h @@ -16,8 +16,8 @@ #include "base/containers/span.h" #include "base/macros.h" #include "base/memory/scoped_refptr.h" -#include "base/optional.h" #include "net/base/net_export.h" +#include "third_party/abseil-cpp/absl/types/optional.h" class GURL; @@ -99,13 +99,13 @@ class NET_EXPORT WebSocketEventInterface { // |message| is a human readable string describing the failure. (It may be // empty.) |net_error| contains the network error code for the failure, which // may be |OK| if the failure was at a higher level. |response_code| contains - // the HTTP status code that caused the failure, or |base::nullopt| if the + // the HTTP status code that caused the failure, or |absl::nullopt| if the // attempt didn't get that far. // // This function deletes the Channel. virtual void OnFailChannel(const std::string& message, int net_error, - base::Optional response_code) = 0; + absl::optional response_code) = 0; // Called when the browser starts the WebSocket Opening Handshake. virtual void OnStartOpeningHandshake( @@ -152,7 +152,7 @@ class NET_EXPORT WebSocketEventInterface { scoped_refptr response_headers, const IPEndPoint& socket_address, base::OnceCallback callback, - base::Optional* credentials) = 0; + absl::optional* credentials) = 0; protected: WebSocketEventInterface() {} diff --git a/net/websockets/websocket_handshake_stream_create_helper_test.cc b/net/websockets/websocket_handshake_stream_create_helper_test.cc index 8eba4ca5dedfec..6db1feb520f6ec 100644 --- a/net/websockets/websocket_handshake_stream_create_helper_test.cc +++ b/net/websockets/websocket_handshake_stream_create_helper_test.cc @@ -10,7 +10,6 @@ #include "base/macros.h" #include "base/memory/scoped_refptr.h" -#include "base/optional.h" #include "net/base/completion_once_callback.h" #include "net/base/host_port_pair.h" #include "net/base/ip_endpoint.h" @@ -46,6 +45,7 @@ #include "net/websockets/websocket_test_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/origin.h" @@ -96,7 +96,7 @@ class MockClientSocketHandleFactory { PrivacyMode::PRIVACY_MODE_DISABLED, NetworkIsolationKey(), SecureDnsPolicy::kAllow), scoped_refptr(), - base::nullopt /* proxy_annotation_tag */, MEDIUM, SocketTag(), + absl::nullopt /* proxy_annotation_tag */, MEDIUM, SocketTag(), ClientSocketPool::RespectLimits::ENABLED, CompletionOnceCallback(), ClientSocketPool::ProxyAuthCallback(), &pool_, NetLogWithSource()); return socket_handle; @@ -120,7 +120,7 @@ class TestConnectDelegate : public WebSocketStream::ConnectDelegate { std::unique_ptr response) override {} void OnFailure(const std::string& failure_message, int net_error, - base::Optional response_code) override {} + absl::optional response_code) override {} void OnStartOpeningHandshake( std::unique_ptr request) override {} void OnSSLCertificateError( @@ -133,8 +133,8 @@ class TestConnectDelegate : public WebSocketStream::ConnectDelegate { scoped_refptr response_headers, const IPEndPoint& host_port_pair, base::OnceCallback callback, - base::Optional* credentials) override { - *credentials = base::nullopt; + absl::optional* credentials) override { + *credentials = absl::nullopt; return OK; } }; @@ -150,7 +150,7 @@ class MockWebSocketStreamRequestAPI : public WebSocketStreamRequestAPI { MOCK_METHOD3(OnFailure, void(const std::string& message, int net_error, - base::Optional response_code)); + absl::optional response_code)); }; class WebSocketHandshakeStreamCreateHelperTest diff --git a/net/websockets/websocket_http2_handshake_stream.cc b/net/websockets/websocket_http2_handshake_stream.cc index 3fa3cf6f682825..60526b5ac874b4 100644 --- a/net/websockets/websocket_http2_handshake_stream.cc +++ b/net/websockets/websocket_http2_handshake_stream.cc @@ -94,7 +94,7 @@ int WebSocketHttp2HandshakeStream::SendRequest( if (!session_) { const int rv = ERR_CONNECTION_CLOSED; - OnFailure("Connection closed before sending request.", rv, base::nullopt); + OnFailure("Connection closed before sending request.", rv, absl::nullopt); return rv; } @@ -103,7 +103,7 @@ int WebSocketHttp2HandshakeStream::SendRequest( IPEndPoint address; int result = session_->GetPeerAddress(&address); if (result != OK) { - OnFailure("Error getting IP address.", result, base::nullopt); + OnFailure("Error getting IP address.", result, absl::nullopt); return result; } http_response_info_->remote_endpoint = address; @@ -317,7 +317,7 @@ void WebSocketHttp2HandshakeStream::OnClose(int status) { result_ = HandshakeResult::HTTP2_FAILED; OnFailure(std::string("Stream closed with error: ") + ErrorToString(status), - status, base::nullopt); + status, absl::nullopt); if (callback_) std::move(callback_).Run(status); @@ -386,14 +386,14 @@ int WebSocketHttp2HandshakeStream::ValidateUpgradeResponse( const int rv = ERR_INVALID_RESPONSE; OnFailure("Error during WebSocket handshake: " + failure_message, rv, - base::nullopt); + absl::nullopt); return rv; } void WebSocketHttp2HandshakeStream::OnFailure( const std::string& message, int net_error, - base::Optional response_code) { + absl::optional response_code) { stream_request_->OnFailure(message, net_error, response_code); } diff --git a/net/websockets/websocket_http2_handshake_stream.h b/net/websockets/websocket_http2_handshake_stream.h index d0374c8ea8ee88..0f22df5971a6f1 100644 --- a/net/websockets/websocket_http2_handshake_stream.h +++ b/net/websockets/websocket_http2_handshake_stream.h @@ -13,7 +13,6 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" -#include "base/optional.h" #include "base/strings/string_piece.h" #include "net/base/completion_once_callback.h" #include "net/base/io_buffer.h" @@ -24,6 +23,7 @@ #include "net/websockets/websocket_basic_stream_adapters.h" #include "net/websockets/websocket_handshake_stream_base.h" #include "net/websockets/websocket_stream.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace net { @@ -120,7 +120,7 @@ class NET_EXPORT_PRIVATE WebSocketHttp2HandshakeStream void OnFailure(const std::string& message, int net_error, - base::Optional response_code); + absl::optional response_code); HandshakeResult result_; diff --git a/net/websockets/websocket_stream.cc b/net/websockets/websocket_stream.cc index 02754d44264dd0..d0ff777b8b3a71 100644 --- a/net/websockets/websocket_stream.cc +++ b/net/websockets/websocket_stream.cc @@ -10,7 +10,6 @@ #include "base/logging.h" #include "base/memory/weak_ptr.h" #include "base/metrics/histogram_functions.h" -#include "base/optional.h" #include "base/time/time.h" #include "base/timer/timer.h" #include "net/base/ip_endpoint.h" @@ -33,6 +32,7 @@ #include "net/websockets/websocket_handshake_stream_base.h" #include "net/websockets/websocket_handshake_stream_create_helper.h" #include "net/websockets/websocket_http2_handshake_stream.h" +#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/origin.h" @@ -150,7 +150,7 @@ class WebSocketStreamRequestImpl : public WebSocketStreamRequestAPI { void OnFailure(const std::string& message, int net_error, - base::Optional response_code) override { + absl::optional response_code) override { if (api_delegate_) api_delegate_->OnFailure(message, net_error, response_code); failure_message_ = message; @@ -179,7 +179,7 @@ class WebSocketStreamRequestImpl : public WebSocketStreamRequestAPI { ReportFailureWithMessage( "No handshake stream has been created or handshake stream is already " "destroyed.", - ERR_FAILED, base::nullopt); + ERR_FAILED, absl::nullopt); return; } @@ -211,7 +211,7 @@ class WebSocketStreamRequestImpl : public WebSocketStreamRequestAPI { } } - void ReportFailure(int net_error, base::Optional response_code) { + void ReportFailure(int net_error, absl::optional response_code) { DCHECK(timer_); timer_->Stop(); if (failure_message_.empty()) { @@ -238,7 +238,7 @@ class WebSocketStreamRequestImpl : public WebSocketStreamRequestAPI { void ReportFailureWithMessage(const std::string& failure_message, int net_error, - base::Optional response_code) { + absl::optional response_code) { connect_delegate_->OnFailure(failure_message, net_error, response_code); } @@ -278,8 +278,8 @@ class WebSocketStreamRequestImpl : public WebSocketStreamRequestAPI { // The failure information supplied by WebSocketBasicHandshakeStream, if any. std::string failure_message_; - base::Optional failure_net_error_; - base::Optional failure_response_code_; + absl::optional failure_net_error_; + absl::optional failure_response_code_; // A timer for handshake timeout. std::unique_ptr timer_; @@ -352,7 +352,7 @@ void Delegate::OnResponseStarted(URLRequest* request, int net_error) { if (net_error != OK) { DVLOG(3) << "OnResponseStarted (request failed)"; - owner_->ReportFailure(net_error, base::nullopt); + owner_->ReportFailure(net_error, absl::nullopt); return; } const int response_code = request->GetResponseCode(); @@ -365,7 +365,7 @@ void Delegate::OnResponseStarted(URLRequest* request, int net_error) { return; } - owner_->ReportFailure(net_error, base::nullopt); + owner_->ReportFailure(net_error, absl::nullopt); return; } @@ -392,7 +392,7 @@ void Delegate::OnResponseStarted(URLRequest* request, int net_error) { void Delegate::OnAuthRequired(URLRequest* request, const AuthChallengeInfo& auth_info) { - base::Optional credentials; + absl::optional credentials; // This base::Unretained(this) relies on an assumption that |callback| can // be called called during the opening handshake. int rv = owner_->connect_delegate()->OnAuthRequired( @@ -406,7 +406,7 @@ void Delegate::OnAuthRequired(URLRequest* request, return; if (rv != OK) { request->LogUnblocked(); - owner_->ReportFailure(rv, base::nullopt); + owner_->ReportFailure(rv, absl::nullopt); return; } OnAuthRequiredComplete(request, nullptr); diff --git a/net/websockets/websocket_stream.h b/net/websockets/websocket_stream.h index ce7f5f625a1080..8c3f483972e5d9 100644 --- a/net/websockets/websocket_stream.h +++ b/net/websockets/websocket_stream.h @@ -12,7 +12,6 @@ #include "base/callback_forward.h" #include "base/macros.h" #include "base/memory/scoped_refptr.h" -#include "base/optional.h" #include "base/time/time.h" #include "net/base/completion_once_callback.h" #include "net/base/isolation_info.h" @@ -21,6 +20,7 @@ #include "net/websockets/websocket_event_interface.h" #include "net/websockets/websocket_handshake_request_info.h" #include "net/websockets/websocket_handshake_response_info.h" +#include "third_party/abseil-cpp/absl/types/optional.h" class GURL; @@ -68,7 +68,7 @@ class NET_EXPORT_PRIVATE WebSocketStreamRequestAPI WebSocketHttp2HandshakeStream* handshake_stream) = 0; virtual void OnFailure(const std::string& message, int net_error, - base::Optional response_code) = 0; + absl::optional response_code) = 0; }; // WebSocketStream is a transport-agnostic interface for reading and writing @@ -104,7 +104,7 @@ class NET_EXPORT_PRIVATE WebSocketStream { // |message| contains defails of the failure. virtual void OnFailure(const std::string& message, int net_error, - base::Optional response_code) = 0; + absl::optional response_code) = 0; // Called when the WebSocket Opening Handshake starts. virtual void OnStartOpeningHandshake( @@ -134,7 +134,7 @@ class NET_EXPORT_PRIVATE WebSocketStream { scoped_refptr response_headers, const IPEndPoint& remote_endpoint, base::OnceCallback callback, - base::Optional* credentials) = 0; + absl::optional* credentials) = 0; }; // Create and connect a WebSocketStream of an appropriate type. The actual diff --git a/net/websockets/websocket_stream_cookie_test.cc b/net/websockets/websocket_stream_cookie_test.cc index 5d54b6e8b51fbc..e0ffcc6730fde5 100644 --- a/net/websockets/websocket_stream_cookie_test.cc +++ b/net/websockets/websocket_stream_cookie_test.cc @@ -155,7 +155,7 @@ TEST_P(WebSocketStreamClientUseCookieTest, ClientUseCookie) { base::RunLoop run_loop; auto cookie = CanonicalCookie::Create(cookie_url, cookie_line, base::Time::Now(), - base::nullopt /* server_time */); + absl::nullopt /* server_time */); store->SetCanonicalCookieAsync( std::move(cookie), cookie_url, net::CookieOptions::MakeAllInclusive(), base::BindOnce(&SetCookieHelperFunction, run_loop.QuitClosure(), diff --git a/net/websockets/websocket_stream_create_test_base.cc b/net/websockets/websocket_stream_create_test_base.cc index 9f141d53f375c5..21fe5757a56cde 100644 --- a/net/websockets/websocket_stream_create_test_base.cc +++ b/net/websockets/websocket_stream_create_test_base.cc @@ -47,7 +47,7 @@ class WebSocketStreamCreateTestBase::TestConnectDelegate void OnFailure(const std::string& message, int net_error, - base::Optional response_code) override { + absl::optional response_code) override { owner_->has_failed_ = true; owner_->failure_message_ = message; owner_->failure_response_code_ = response_code.value_or(-1); @@ -76,7 +76,7 @@ class WebSocketStreamCreateTestBase::TestConnectDelegate scoped_refptr response_headers, const IPEndPoint& remote_endpoint, base::OnceCallback callback, - base::Optional* credentials) override { + absl::optional* credentials) override { owner_->run_loop_waiting_for_on_auth_required_.Quit(); owner_->auth_challenge_info_ = auth_info; *credentials = owner_->auth_credentials_; diff --git a/net/websockets/websocket_stream_create_test_base.h b/net/websockets/websocket_stream_create_test_base.h index e80360cf5c2bae..3c86a1adf4edb2 100644 --- a/net/websockets/websocket_stream_create_test_base.h +++ b/net/websockets/websocket_stream_create_test_base.h @@ -89,7 +89,7 @@ class WebSocketStreamCreateTestBase : public WithTaskEnvironment { base::OnceCallback on_auth_required_callback_; // This value will be copied to |*credentials| on OnAuthRequired. - base::Optional auth_credentials_; + absl::optional auth_credentials_; // OnAuthRequired returns this value. int on_auth_required_rv_ = OK; diff --git a/net/websockets/websocket_test_util.cc b/net/websockets/websocket_test_util.cc index 33526167621801..23722ce16b0ee6 100644 --- a/net/websockets/websocket_test_util.cc +++ b/net/websockets/websocket_test_util.cc @@ -263,7 +263,7 @@ int DummyConnectDelegate::OnAuthRequired( scoped_refptr response_headers, const IPEndPoint& host_port_pair, base::OnceCallback callback, - base::Optional* credentials) { + absl::optional* credentials) { return OK; } diff --git a/net/websockets/websocket_test_util.h b/net/websockets/websocket_test_util.h index 69810f106eb21d..f59ba89a53c020 100644 --- a/net/websockets/websocket_test_util.h +++ b/net/websockets/websocket_test_util.h @@ -13,7 +13,6 @@ #include #include "base/macros.h" -#include "base/optional.h" #include "net/http/http_basic_state.h" #include "net/http/http_request_headers.h" #include "net/http/http_stream_parser.h" @@ -23,6 +22,7 @@ #include "net/url_request/url_request_test_util.h" #include "net/websockets/websocket_handshake_stream_create_helper.h" #include "net/websockets/websocket_stream.h" +#include "third_party/abseil-cpp/absl/types/optional.h" namespace url { class Origin; @@ -190,7 +190,7 @@ class DummyConnectDelegate : public WebSocketStream::ConnectDelegate { std::unique_ptr response) override {} void OnFailure(const std::string& message, int net_error, - base::Optional response_code) override {} + absl::optional response_code) override {} void OnStartOpeningHandshake( std::unique_ptr request) override {} void OnSSLCertificateError( @@ -203,7 +203,7 @@ class DummyConnectDelegate : public WebSocketStream::ConnectDelegate { scoped_refptr response_headers, const IPEndPoint& remote_endpoint, base::OnceCallback callback, - base::Optional* credentials) override; + absl::optional* credentials) override; }; // WebSocketStreamRequestAPI implementation that sets the value of @@ -218,7 +218,7 @@ class TestWebSocketStreamRequestAPI : public WebSocketStreamRequestAPI { WebSocketHttp2HandshakeStream* handshake_stream) override; void OnFailure(const std::string& message, int net_error, - base::Optional response_code) override {} + absl::optional response_code) override {} }; // A sub-class of WebSocketHandshakeStreamCreateHelper which sets a