// Copyright 2023 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "net/dns/public/host_resolver_source.h" #include #include "base/values.h" namespace net { base::Value ToValue(HostResolverSource source) { return base::Value(static_cast(source)); } std::optional HostResolverSourceFromValue( const base::Value& value) { std::optional value_int = value.GetIfInt(); if (!value_int.has_value() || value_int.value() < 0 || value_int.value() > static_cast(HostResolverSource::MAX)) { return std::nullopt; } return static_cast(value_int.value()); } } // namespace net