#include "components/paint_preview/renderer/paint_preview_recorder_impl.h"
#include <memory>
#include <optional>
#include <utility>
#include "base/auto_reset.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_functions.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/time/time.h"
#include "base/trace_event/common/trace_event_common.h"
#include "base/trace_event/trace_event.h"
#include "cc/paint/paint_record.h"
#include "cc/paint/paint_recorder.h"
#include "components/paint_preview/common/paint_preview_tracker.h"
#include "components/paint_preview/common/serialized_recording.h"
#include "components/paint_preview/renderer/paint_preview_recorder_utils.h"
#include "content/public/renderer/render_frame.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
#include "third_party/blink/public/web/web_local_frame.h"
namespace paint_preview {
namespace {
int GetBoundOrigin(int document_dimension, int bounds_dimension, int offset) { … }
struct FinishedRecording { … };
CapturePaintPreviewCallback;
void BuildAndSendResponse(std::unique_ptr<PaintPreviewTracker> tracker,
FinishedRecording out,
CapturePaintPreviewCallback callback) { … }
void RecordToFileOnThreadPool(sk_sp<const SkPicture> skp,
base::File skp_file,
std::unique_ptr<PaintPreviewTracker> tracker,
std::optional<size_t> max_capture_size,
FinishedRecording out,
CapturePaintPreviewCallback callback) { … }
void SerializeFileRecording(sk_sp<const SkPicture> skp,
base::File skp_file,
std::unique_ptr<PaintPreviewTracker> tracker,
std::optional<size_t> max_capture_size,
FinishedRecording out,
CapturePaintPreviewCallback callback) { … }
void SerializeMemoryBufferRecording(
sk_sp<const SkPicture> skp,
std::unique_ptr<PaintPreviewTracker> tracker,
std::optional<size_t> max_capture_size,
FinishedRecording out,
CapturePaintPreviewCallback callback) { … }
void FinishRecordingOnUIThread(cc::PaintRecord recording,
const gfx::Rect& bounds,
std::unique_ptr<PaintPreviewTracker> tracker,
RecordingPersistence persistence,
base::File skp_file,
std::optional<size_t> max_capture_size,
mojom::PaintPreviewCaptureResponsePtr response,
CapturePaintPreviewCallback callback) { … }
}
PaintPreviewRecorderImpl::PaintPreviewRecorderImpl(
content::RenderFrame* render_frame)
: … { … }
PaintPreviewRecorderImpl::~PaintPreviewRecorderImpl() = default;
void PaintPreviewRecorderImpl::CapturePaintPreview(
mojom::PaintPreviewCaptureParamsPtr params,
CapturePaintPreviewCallback callback) { … }
void PaintPreviewRecorderImpl::OnDestruct() { … }
void PaintPreviewRecorderImpl::BindPaintPreviewRecorder(
mojo::PendingAssociatedReceiver<mojom::PaintPreviewRecorder> receiver) { … }
void PaintPreviewRecorderImpl::CapturePaintPreviewInternal(
const mojom::PaintPreviewCaptureParamsPtr& params,
mojom::PaintPreviewCaptureResponsePtr response,
CapturePaintPreviewCallback callback) { … }
}