SoupNetworkProxySettings.h [plain text]
#pragma once
#include <wtf/EnumTraits.h>
#include <wtf/HashMap.h>
#include <wtf/glib/GUniquePtr.h>
#include <wtf/text/CString.h>
namespace WebCore {
struct SoupNetworkProxySettings {
enum class Mode { Default, NoProxy, Custom };
SoupNetworkProxySettings() = default;
explicit SoupNetworkProxySettings(Mode proxyMode)
: mode(proxyMode)
{
}
SoupNetworkProxySettings(const WebCore::SoupNetworkProxySettings& other)
: mode(other.mode)
, defaultProxyURL(other.defaultProxyURL)
, ignoreHosts(g_strdupv(other.ignoreHosts.get()))
, proxyMap(other.proxyMap)
{
}
SoupNetworkProxySettings& operator=(const WebCore::SoupNetworkProxySettings& other)
{
mode = other.mode;
defaultProxyURL = other.defaultProxyURL;
ignoreHosts.reset(g_strdupv(other.ignoreHosts.get()));
proxyMap = other.proxyMap;
return *this;
}
bool isEmpty() const { return mode == Mode::Custom && defaultProxyURL.isNull() && !ignoreHosts && proxyMap.isEmpty(); }
Mode mode { Mode::Default };
CString defaultProxyURL;
GUniquePtr<char*> ignoreHosts;
HashMap<CString, CString> proxyMap;
};
}
namespace WTF {
template<> struct EnumTraits<WebCore::SoupNetworkProxySettings::Mode> {
using values = EnumValues<
WebCore::SoupNetworkProxySettings::Mode,
WebCore::SoupNetworkProxySettings::Mode::Default,
WebCore::SoupNetworkProxySettings::Mode::NoProxy,
WebCore::SoupNetworkProxySettings::Mode::Custom
>;
};
}