#include "chrome/browser/media/router/discovery/dial/device_description_service.h"
#include <map>
#include <memory>
#include <utility>
#include <vector>
#if DCHECK_IS_ON()
#include <sstream>
#endif
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/ranges/algorithm.h"
#include "chrome/browser/media/router/discovery/dial/device_description_fetcher.h"
#include "chrome/browser/media/router/discovery/dial/safe_dial_device_description_parser.h"
#include "net/base/ip_address.h"
#include "url/gurl.h"
namespace media_router {
ParsingResult;
namespace {
constexpr int kDeviceDescriptionCacheTimeHours = …;
constexpr int kCacheCleanUpTimeoutMins = …;
constexpr int kCacheMaxEntries = …;
ParsingResult ValidateParsedDeviceDescription(
const DialDeviceData& device_data,
const ParsedDialDeviceDescription& description_data) { … }
void RecordDialParsingResult(
SafeDialDeviceDescriptionParser::ParsingResult parse_result) { … }
}
DeviceDescriptionService::DeviceDescriptionService(
const DeviceDescriptionParseSuccessCallback& success_cb,
const DeviceDescriptionParseErrorCallback& error_cb)
: … { … }
DeviceDescriptionService::~DeviceDescriptionService() { … }
void DeviceDescriptionService::GetDeviceDescriptions(
const std::vector<DialDeviceData>& devices) { … }
void DeviceDescriptionService::CleanUpCacheEntries() { … }
void DeviceDescriptionService::FetchDeviceDescription(
const DialDeviceData& device_data) { … }
void DeviceDescriptionService::ParseDeviceDescription(
const DialDeviceData& device_data,
const DialDeviceDescriptionData& description_data) { … }
std::unique_ptr<DeviceDescriptionFetcher>
DeviceDescriptionService::CreateFetcher(
const DialDeviceData& device_data,
base::OnceCallback<void(const DialDeviceDescriptionData&)> success_cb,
base::OnceCallback<void(const std::string&)> error_cb) { … }
const DeviceDescriptionService::CacheEntry*
DeviceDescriptionService::CheckAndUpdateCache(
const DialDeviceData& device_data) { … }
void DeviceDescriptionService::OnParsedDeviceDescription(
const DialDeviceData& device_data,
const ParsedDialDeviceDescription& device_description,
SafeDialDeviceDescriptionParser::ParsingResult parsing_result) { … }
void DeviceDescriptionService::OnDeviceDescriptionFetchComplete(
const DialDeviceData& device_data,
const DialDeviceDescriptionData& description_data) { … }
void DeviceDescriptionService::OnDeviceDescriptionFetchError(
const DialDeviceData& device_data,
const std::string& error_message) { … }
base::Time DeviceDescriptionService::GetNow() { … }
DeviceDescriptionService::CacheEntry::CacheEntry() : … { … }
DeviceDescriptionService::CacheEntry::CacheEntry(const CacheEntry& other) =
default;
DeviceDescriptionService::CacheEntry::~CacheEntry() = default;
}