File: capture_result.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (87 lines) | stat: -rw-r--r-- 3,406 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_PAINT_PREVIEW_COMMON_CAPTURE_RESULT_H_
#define COMPONENTS_PAINT_PREVIEW_COMMON_CAPTURE_RESULT_H_

#include "base/containers/flat_map.h"
#include "base/unguessable_token.h"
#include "components/paint_preview/common/proto/paint_preview.pb.h"
#include "components/paint_preview/common/serialized_recording.h"
#include "mojo/public/cpp/base/big_buffer.h"
#include "ui/gfx/geometry/rect.h"

namespace paint_preview {

// A subset of PaintPreviewCaptureParams that will be filled in by
// PaintPreviewClient. This type mainly exists to aggregate related parameters.
struct RecordingParams {
  explicit RecordingParams(const base::UnguessableToken& document_guid);

  // The document GUID for this capture.
  const base::UnguessableToken document_guid;

  // The rect to which to clip the capture to.
  gfx::Rect clip_rect;

  // Whether the capture is for the main frame or an OOP subframe.
  bool is_main_frame;

  // For the following params, The values set here for the first frame apply to
  // all subframes that are captured.

  // Whether to record links.
  bool capture_links;

  // The maximum capture size allowed for the SkPicture captured. A size of 0 is
  // unlimited.
  // TODO(crbug.com/40126774): Ideally, this would cap the total size rather
  // than being a per SkPicture limit. However, that is non-trivial due to the
  // async ordering of captures from different frames making it hard to keep
  // track of available headroom at the time of each capture triggering.
  size_t max_capture_size;

  // Limit on the maximum size of a decoded image that can be serialized.
  // Any images with a decoded size exceeding this value will be discarded.
  // This can be used to reduce the chance of an OOM during serialization and
  // later during playback.
  uint64_t max_decoded_image_size_bytes{std::numeric_limits<uint64_t>::max()};

  // This flag will skip GPU accelerated content where applicable when
  // capturing. This reduces hangs, capture time and may also reduce OOM
  // crashes, but results in a lower fideltiy capture (i.e. the contents
  // captured may not accurately reflect the content visible to the user at
  // time of capture). See PaintPreviewBaseService::CaptureParams for a
  // description of the effects of this flag.
  bool skip_accelerated_content{false};
};

// The result of a capture of a WebContents, which may contain recordings of
// multiple subframes.
struct CaptureResult {
 public:
  explicit CaptureResult(RecordingPersistence persistence);
  ~CaptureResult();

  CaptureResult(CaptureResult&&);
  CaptureResult& operator=(CaptureResult&&);

  // Will match the |persistence| in the original capture request.
  RecordingPersistence persistence;

  PaintPreviewProto proto = {};

  // Maps frame embedding tokens to buffers containing the serialized
  // recordings. See |PaintPreviewCaptureResponse::skp| for information on how
  // to intepret these buffers. Empty if |RecordingPersistence::FileSystem|.
  base::flat_map<base::UnguessableToken, mojo_base::BigBuffer> serialized_skps =
      {};

  // Indicates that at least one subframe finished successfully.
  bool capture_success = false;
};

}  // namespace paint_preview

#endif  // COMPONENTS_PAINT_PREVIEW_COMMON_CAPTURE_RESULT_H_