render_frame_host_proxy.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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_PERFORMANCE_MANAGER_PUBLIC_RENDER_FRAME_HOST_PROXY_H_
  5. #define COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_RENDER_FRAME_HOST_PROXY_H_
  6. #include "content/public/browser/global_routing_id.h"
  7. namespace content {
  8. class RenderFrameHost;
  9. } // namespace content
  10. namespace performance_manager {
  11. class FrameNodeImpl;
  12. // A RenderFrameHostProxy is used to post messages out of the performance
  13. // manager sequence that are bound for a RenderFrameHostProxy running on the UI
  14. // thread. The object is bound to the UI thread. A RenderFrameHostProxy is
  15. // conceptually equivalent to a WeakPtr<RenderFrameHost>. Copy and assignment
  16. // are explicitly allowed for this object.
  17. class RenderFrameHostProxy {
  18. public:
  19. RenderFrameHostProxy();
  20. RenderFrameHostProxy(const RenderFrameHostProxy& other);
  21. ~RenderFrameHostProxy();
  22. RenderFrameHostProxy& operator=(const RenderFrameHostProxy& other);
  23. // Allows resolving this proxy to the underlying RenderFrameHost. This must
  24. // only be called on the UI thread. Returns nullptr if the RenderFrameHost
  25. // no longer exists.
  26. content::RenderFrameHost* Get() const;
  27. // Returns the global routing ID.
  28. const content::GlobalRenderFrameHostId& global_frame_routing_id() const {
  29. return global_frame_routing_id_;
  30. }
  31. protected:
  32. friend class FrameNodeImpl;
  33. explicit RenderFrameHostProxy(
  34. const content::GlobalRenderFrameHostId& global_frame_routing_id);
  35. private:
  36. content::GlobalRenderFrameHostId global_frame_routing_id_;
  37. };
  38. } // namespace performance_manager
  39. #endif // COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_RENDER_FRAME_HOST_PROXY_H_