- Code: Select all
void ClientHandler::OnLoadStart(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefLoadHandler::TransitionType transition_type)
{
...
if(frame) {
int64 fid = frame->GetIdentifier(); ==> 0x0000000400000001
int ifid = (int)fid; ==> 0x00000001
int brk__ = 0; brk__++;
}
...
Browser identifier is 1, but frame identifier is not 1, but 0x0000000400000001 (or 0x0000000300000001 etc.).
This looks to come from
- Code: Select all
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);
}
where render_process_id is also used.
On the other hand, in InitState, for example, both parameters are explicitely passed to Initialize:
- Code: Select all
void Initialize(content::BrowserContext* browser_context,
CefRefPtr<CefBrowserHostImpl> browser,
CefRefPtr<CefFrame> frame,
int render_process_id,
int render_frame_id,
...
render_process_id_ = render_process_id; // 4
render_frame_id_ = render_frame_id; // 1
...
(render_frame_id_ seems unused, btw).
CefFrame::GetIdentifier returns the frame_id passed in constructor, in GetWebFrameImpl, where is
int64_t frame_id = render_frame_util::GetIdentifier(frame);
so it's the 0x0000000400000001 value.
I would say two things are needed:
- clarify the documentation of CefFrame::GetIdentifier to clearly state it returns a 64 bit integer composed from 32-bit render pid and 32 bit frame ID
- maybe add two helper methods (without being in a class), such as
- Code: Select all
int32_t RenderProcessIdFromFrameIdentifier(int64_t render_frame_id) {
return (static_cast<uint64_t>(render_frame_id) >> 32);
}
int32_t FrameRoutingIdFromFrameIdentifier(int64_t render_frame_id) {
return (static_cast<uint64_t>(render_frame_id) & 0xffffffff);
}
The question is: this behavior of int64 frame identifier is intentional and I need to do the unmasking to get the frame ID without the render process id?
The reason I am asking this is - without getting into too much details - is because I need to know a variable inside a v8 extension running in the context of a frame to not be tampered by function replacement or object shadowing.