paint_preview_compositor_client.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_PAINT_PREVIEW_PUBLIC_PAINT_PREVIEW_COMPOSITOR_CLIENT_H_
  5. #define COMPONENTS_PAINT_PREVIEW_PUBLIC_PAINT_PREVIEW_COMPOSITOR_CLIENT_H_
  6. #include "base/callback_forward.h"
  7. #include "base/unguessable_token.h"
  8. #include "components/services/paint_preview_compositor/public/mojom/paint_preview_compositor.mojom.h"
  9. #include "third_party/abseil-cpp/absl/types/optional.h"
  10. #include "url/gurl.h"
  11. namespace gfx {
  12. class Rect;
  13. } // namespace gfx
  14. namespace paint_preview {
  15. // An instance of a paint preview compositor that is running in a utility
  16. // process service. The class' lifetime is tied to that of the compositor
  17. // running in the utility process (unless there is some kind of IPC disconnect
  18. // that occurs).
  19. class PaintPreviewCompositorClient {
  20. public:
  21. virtual ~PaintPreviewCompositorClient() = default;
  22. // Returns the token associated with the client. Will be null if the client
  23. // isn't started.
  24. virtual const absl::optional<base::UnguessableToken>& Token() const = 0;
  25. // Adds `closure` as a disconnect handler.
  26. virtual void SetDisconnectHandler(base::OnceClosure closure) = 0;
  27. // Note the BitmapFor* methods use `clip_rect` values relative to the captured
  28. // content.
  29. // mojom::PaintPreviewCompositor API
  30. virtual void BeginSeparatedFrameComposite(
  31. mojom::PaintPreviewBeginCompositeRequestPtr request,
  32. mojom::PaintPreviewCompositor::BeginSeparatedFrameCompositeCallback
  33. callback) = 0;
  34. virtual void BitmapForSeparatedFrame(
  35. const base::UnguessableToken& frame_guid,
  36. const gfx::Rect& clip_rect,
  37. float scale_factor,
  38. mojom::PaintPreviewCompositor::BitmapForSeparatedFrameCallback callback,
  39. bool run_callback_on_default_task_runner = true) = 0;
  40. virtual void BeginMainFrameComposite(
  41. mojom::PaintPreviewBeginCompositeRequestPtr request,
  42. mojom::PaintPreviewCompositor::BeginMainFrameCompositeCallback
  43. callback) = 0;
  44. virtual void BitmapForMainFrame(
  45. const gfx::Rect& clip_rect,
  46. float scale_factor,
  47. mojom::PaintPreviewCompositor::BitmapForMainFrameCallback callback,
  48. bool run_callback_on_default_task_runner = true) = 0;
  49. virtual void SetRootFrameUrl(const GURL& url) = 0;
  50. PaintPreviewCompositorClient(const PaintPreviewCompositorClient&) = delete;
  51. PaintPreviewCompositorClient& operator=(const PaintPreviewCompositorClient&) =
  52. delete;
  53. protected:
  54. PaintPreviewCompositorClient() = default;
  55. };
  56. } // namespace paint_preview
  57. #endif // COMPONENTS_PAINT_PREVIEW_PUBLIC_PAINT_PREVIEW_COMPOSITOR_CLIENT_H_