1 // Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights 2 // reserved. Use of this source code is governed by a BSD-style license that can 3 // be found in the LICENSE file. 4 5 #include "libcef/common/frame_util.h" 6 7 #include "libcef/browser/thread_util.h" 8 9 #include <limits> 10 #include <sstream> 11 12 #include "content/public/browser/navigation_handle.h" 13 #include "content/public/browser/render_frame_host.h" 14 15 namespace frame_util { 16 GetGlobalId(content::NavigationHandle * navigation_handle)17content::GlobalRenderFrameHostId GetGlobalId( 18 content::NavigationHandle* navigation_handle) { 19 CEF_REQUIRE_UIT(); 20 return navigation_handle->HasCommitted() 21 ? navigation_handle->GetRenderFrameHost()->GetGlobalId() 22 : navigation_handle->GetPreviousRenderFrameHostId(); 23 } 24 GetFrameDebugString(int64_t frame_id)25std::string GetFrameDebugString(int64_t frame_id) { 26 uint32_t process_id = frame_id >> 32; 27 uint32_t routing_id = std::numeric_limits<uint32_t>::max() & frame_id; 28 29 std::stringstream ss; 30 ss << frame_id << " [" << process_id << "," << routing_id << "]"; 31 return ss.str(); 32 } 33 GetFrameDebugString(const content::GlobalRenderFrameHostId & global_id)34std::string GetFrameDebugString( 35 const content::GlobalRenderFrameHostId& global_id) { 36 return GetFrameDebugString(MakeFrameId(global_id)); 37 } 38 39 } // namespace frame_util 40