#include "third_party/blink/renderer/platform/media/url_index.h"
#include <set>
#include <utility>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/ranges/algorithm.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "media/base/media_switches.h"
#include "third_party/blink/renderer/platform/media/resource_multi_buffer_data_provider.h"
namespace blink {
const int kBlockSizeShift = …;
const int kUrlMappingTimeoutSeconds = …;
ResourceMultiBuffer::ResourceMultiBuffer(
UrlData* url_data,
int block_shift,
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: … { … }
ResourceMultiBuffer::~ResourceMultiBuffer() = default;
std::unique_ptr<MultiBuffer::DataProvider> ResourceMultiBuffer::CreateWriter(
const MultiBufferBlockId& pos,
bool is_client_audio_element) { … }
bool ResourceMultiBuffer::RangeSupported() const { … }
void ResourceMultiBuffer::OnEmpty() { … }
UrlData::UrlData(base::PassKey<UrlIndex>,
const GURL& url,
CorsMode cors_mode,
UrlIndex* url_index,
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: … { … }
UrlData::UrlData(const GURL& url,
CorsMode cors_mode,
UrlIndex* url_index,
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: … { … }
UrlData::~UrlData() = default;
std::pair<GURL, UrlData::CorsMode> UrlData::key() const { … }
void UrlData::set_valid_until(base::Time valid_until) { … }
void UrlData::MergeFrom(const scoped_refptr<UrlData>& other) { … }
void UrlData::set_cacheable(bool cacheable) { … }
void UrlData::set_length(int64_t length) { … }
void UrlData::set_is_cors_cross_origin(bool is_cors_cross_origin) { … }
void UrlData::set_has_access_control() { … }
void UrlData::set_mime_type(std::string mime_type) { … }
void UrlData::set_passed_timing_allow_origin_check(
bool passed_timing_allow_origin_check) { … }
void UrlData::RedirectTo(const scoped_refptr<UrlData>& url_data) { … }
void UrlData::Fail() { … }
void UrlData::OnRedirect(RedirectCB cb) { … }
void UrlData::Use() { … }
bool UrlData::ValidateDataOrigin(const GURL& origin) { … }
void UrlData::OnEmpty() { … }
bool UrlData::FullyCached() { … }
bool UrlData::Valid() { … }
void UrlData::set_last_modified(base::Time last_modified) { … }
void UrlData::set_etag(const std::string& etag) { … }
void UrlData::set_range_supported() { … }
ResourceMultiBuffer* UrlData::multibuffer() { … }
size_t UrlData::CachedSize() { … }
UrlIndex::UrlIndex(ResourceFetchContext* fetch_context,
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: … { … }
UrlIndex::UrlIndex(ResourceFetchContext* fetch_context,
int block_shift,
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: … { … }
UrlIndex::~UrlIndex() { … }
void UrlIndex::RemoveUrlData(const scoped_refptr<UrlData>& url_data) { … }
scoped_refptr<UrlData> UrlIndex::GetByUrl(const GURL& gurl,
UrlData::CorsMode cors_mode,
CacheMode cache_mode) { … }
scoped_refptr<UrlData> UrlIndex::NewUrlData(const GURL& url,
UrlData::CorsMode cors_mode) { … }
void UrlIndex::OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) { … }
namespace {
bool IsStrongEtag(const std::string& etag) { … }
bool IsNewDataForSameResource(const scoped_refptr<UrlData>& new_entry,
const scoped_refptr<UrlData>& old_entry) { … }
}
scoped_refptr<UrlData> UrlIndex::TryInsert(
const scoped_refptr<UrlData>& url_data) { … }
}