mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Remove usage of FrameTreeNode IDs (see issue #2421)
With the introduction of prerendering in Chromium it is now possible for RenderFrameHosts (RFH) to move between FrameTrees. As a consequence we can no longer rely on FrameTreeNode IDs to uniquely identify a RFH over its lifespan. We must now switch to using GlobalRenderFrameHostId (child_id, frame_routing_id) instead for that purpose. Additionally, we simplify existing code by using the GlobalRenderFrameHostId struct in all places that previously used a (render_process_id, render_frame_id) pair, since these concepts are equivalent. See https://crbug.com/1179502#c8 for additional background.
This commit is contained in:
@ -4,14 +4,22 @@
|
||||
|
||||
#include "libcef/common/frame_util.h"
|
||||
|
||||
#include "libcef/browser/thread_util.h"
|
||||
|
||||
#include <limits>
|
||||
#include <sstream>
|
||||
|
||||
#include "content/public/browser/navigation_handle.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
|
||||
namespace frame_util {
|
||||
|
||||
int64_t MakeFrameId(int32_t render_process_id, int32_t render_routing_id) {
|
||||
return (static_cast<uint64_t>(render_process_id) << 32) |
|
||||
static_cast<uint64_t>(render_routing_id);
|
||||
content::GlobalRenderFrameHostId GetGlobalId(
|
||||
content::NavigationHandle* navigation_handle) {
|
||||
CEF_REQUIRE_UIT();
|
||||
return navigation_handle->HasCommitted()
|
||||
? navigation_handle->GetRenderFrameHost()->GetGlobalId()
|
||||
: navigation_handle->GetPreviousRenderFrameHostId();
|
||||
}
|
||||
|
||||
std::string GetFrameDebugString(int64_t frame_id) {
|
||||
@ -23,4 +31,9 @@ std::string GetFrameDebugString(int64_t frame_id) {
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string GetFrameDebugString(
|
||||
const content::GlobalRenderFrameHostId& global_id) {
|
||||
return GetFrameDebugString(MakeFrameId(global_id));
|
||||
}
|
||||
|
||||
} // namespace frame_util
|
||||
|
Reference in New Issue
Block a user