chromium/third_party/blink/renderer/core/loader/resource/image_resource.cc

/*
    Copyright (C) 1998 Lars Knoll ([email protected])
    Copyright (C) 2001 Dirk Mueller ([email protected])
    Copyright (C) 2002 Waldo Bastian ([email protected])
    Copyright (C) 2006 Samuel Weinig ([email protected])
    Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
*/

#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 {

// The amount of time to wait before informing the clients that the image has
// been updated (in seconds). This effectively throttles invalidations that
// result from new data arriving for this image.
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) {}

}  // namespace

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 {}

// TODO(crbug.com/41496436): Rename this to `CreateForImageDocument`,
// or remove ImageDocument dependency to this function.
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) {}

// TODO(tsepez): should be declared UNSAFE_BUFFER_USAGE in the header.
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() {}

}  // namespace blink