#include "third_party/blink/renderer/core/loader/resource/image_resource.h"
#include <stdint.h>
#include <algorithm>
#include <memory>
#include <utility>
#include "base/compiler_specific.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/safe_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/loader/referrer_utils.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/core/loader/resource/image_resource_content.h"
#include "third_party/blink/renderer/core/loader/resource/image_resource_info.h"
#include "third_party/blink/renderer/platform/graphics/bitmap_image.h"
#include "third_party/blink/renderer/platform/graphics/image.h"
#include "third_party/blink/renderer/platform/instrumentation/instance_counters.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_initiator_type_names.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_parameters.h"
#include "third_party/blink/renderer/platform/loader/fetch/memory_cache.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_client.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_load_timing.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_loader.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_loader_options.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_loading_log.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_status.h"
#include "third_party/blink/renderer/platform/loader/fetch/unique_identifier.h"
#include "third_party/blink/renderer/platform/network/http_parsers.h"
#include "third_party/blink/renderer/platform/network/network_utils.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/weborigin/reporting_disposition.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/shared_buffer.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/wtf_size_t.h"
#include "v8/include/v8.h"
namespace blink {
namespace {
constexpr auto kFlushDelay = …;
wtf_size_t FindTransparentPlaceholderIndex(KURL image_url) { … }
scoped_refptr<SharedBuffer> GetDataForTransparentPlaceholderImageIndex(
wtf_size_t index) { … }
void MarkKnownTransparentPlaceholderResourceRequestIfNeeded(
ResourceRequest& resource_request) { … }
ImageResource* CreateResourceForTransparentPlaceholderImage(
const ResourceRequest& request,
const ResourceLoaderOptions& options) { … }
}
class ImageResource::ImageResourceInfoImpl final
: public GarbageCollected<ImageResourceInfoImpl>,
public ImageResourceInfo { … };
class ImageResource::ImageResourceFactory : public NonTextResourceFactory { … };
ImageResource* ImageResource::Fetch(FetchParameters& params,
ResourceFetcher* fetcher) { … }
bool ImageResource::CanUseCacheValidator() const { … }
ImageResource* ImageResource::Create(const ResourceRequest& request,
const DOMWrapperWorld* world) { … }
ImageResource* ImageResource::CreateForTest(const KURL& url) { … }
ImageResource::ImageResource(const ResourceRequest& resource_request,
const ResourceLoaderOptions& options,
ImageResourceContent* content)
: … { … }
ImageResource::~ImageResource() { … }
void ImageResource::OnMemoryDump(WebMemoryDumpLevelOfDetail level_of_detail,
WebProcessMemoryDump* memory_dump) const { … }
void ImageResource::Trace(Visitor* visitor) const { … }
bool ImageResource::HasClientsOrObservers() const { … }
void ImageResource::DidAddClient(ResourceClient* client) { … }
void ImageResource::DestroyDecodedDataForFailedRevalidation() { … }
void ImageResource::DestroyDecodedDataIfPossible() { … }
void ImageResource::AllClientsAndObserversRemoved() { … }
scoped_refptr<const SharedBuffer> ImageResource::ResourceBuffer() const { … }
void ImageResource::AppendData(
absl::variant<SegmentedBuffer, base::span<const char>> data) { … }
void ImageResource::FlushImageIfNeeded() { … }
void ImageResource::DecodeError(bool all_data_received) { … }
void ImageResource::UpdateImageAndClearBuffer() { … }
void ImageResource::NotifyStartLoad() { … }
void ImageResource::Finish(base::TimeTicks load_finish_time,
base::SingleThreadTaskRunner* task_runner) { … }
void ImageResource::FinishAsError(const ResourceError& error,
base::SingleThreadTaskRunner* task_runner) { … }
void ImageResource::ResponseReceived(const ResourceResponse& response) { … }
void ImageResource::OnePartInMultipartReceived(
const ResourceResponse& response) { … }
void ImageResource::MultipartDataReceived(const char* bytes, size_t size) { … }
bool ImageResource::IsAccessAllowed(
ImageResourceInfo::DoesCurrentFrameHaveSingleSecurityOrigin
does_current_frame_has_single_security_origin) const { … }
ImageResourceContent* ImageResource::GetContent() { … }
const ImageResourceContent* ImageResource::GetContent() const { … }
std::pair<ResourcePriority, ResourcePriority>
ImageResource::PriorityFromObservers() { … }
void ImageResource::UpdateImage(
scoped_refptr<SharedBuffer> shared_buffer,
ImageResourceContent::UpdateImageOption update_image_option,
bool all_data_received) { … }
void ImageResource::FlagAsUserAgentResource() { … }
}