// Copyright 2024 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef NET_SOCKET_CONNECT_JOB_PARAMS_H_ #define NET_SOCKET_CONNECT_JOB_PARAMS_H_ #include "base/memory/scoped_refptr.h" #include "net/base/net_export.h" #include "third_party/abseil-cpp/absl/types/variant.h" namespace net { class HttpProxySocketParams; class SOCKSSocketParams; class TransportSocketParams; class SSLSocketParams; // Abstraction over the param types for various connect jobs. class NET_EXPORT_PRIVATE ConnectJobParams { public: ConnectJobParams(); explicit ConnectJobParams(scoped_refptr params); explicit ConnectJobParams(scoped_refptr params); explicit ConnectJobParams(scoped_refptr params); explicit ConnectJobParams(scoped_refptr params); ~ConnectJobParams(); ConnectJobParams(ConnectJobParams&); ConnectJobParams& operator=(ConnectJobParams&); ConnectJobParams(ConnectJobParams&&); ConnectJobParams& operator=(ConnectJobParams&&); bool is_http_proxy() const { return absl::holds_alternative>( params_); } bool is_socks() const { return absl::holds_alternative>(params_); } bool is_transport() const { return absl::holds_alternative>( params_); } bool is_ssl() const { return absl::holds_alternative>(params_); } // Get lvalue references to the contained params. const scoped_refptr& http_proxy() const { return get>(params_); } const scoped_refptr& socks() const { return get>(params_); } const scoped_refptr& transport() const { return get>(params_); } const scoped_refptr& ssl() const { return get>(params_); } // Take params out of this value. scoped_refptr&& take_http_proxy() { return get>(std::move(params_)); } scoped_refptr&& take_socks() { return get>(std::move(params_)); } scoped_refptr&& take_transport() { return get>(std::move(params_)); } scoped_refptr&& take_ssl() { return get>(std::move(params_)); } private: absl::variant, scoped_refptr, scoped_refptr, scoped_refptr> params_; }; } // namespace net #endif // NET_SOCKET_CONNECT_JOB_PARAMS_H_