2019-05-24 22:23:43 +02:00
|
|
|
// Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that can
|
|
|
|
// be found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "libcef/common/frame_util.h"
|
|
|
|
|
2021-08-19 23:07:44 +02:00
|
|
|
#include "libcef/browser/thread_util.h"
|
|
|
|
|
2021-05-21 03:42:58 +02:00
|
|
|
#include <limits>
|
|
|
|
#include <sstream>
|
|
|
|
|
2021-08-19 23:07:44 +02:00
|
|
|
#include "content/public/browser/navigation_handle.h"
|
|
|
|
#include "content/public/browser/render_frame_host.h"
|
|
|
|
|
2019-05-24 22:23:43 +02:00
|
|
|
namespace frame_util {
|
|
|
|
|
2021-08-19 23:07:44 +02:00
|
|
|
content::GlobalRenderFrameHostId GetGlobalId(
|
|
|
|
content::NavigationHandle* navigation_handle) {
|
|
|
|
CEF_REQUIRE_UIT();
|
|
|
|
return navigation_handle->HasCommitted()
|
|
|
|
? navigation_handle->GetRenderFrameHost()->GetGlobalId()
|
|
|
|
: navigation_handle->GetPreviousRenderFrameHostId();
|
2019-05-24 22:23:43 +02:00
|
|
|
}
|
|
|
|
|
2021-05-21 03:42:58 +02:00
|
|
|
std::string GetFrameDebugString(int64_t frame_id) {
|
|
|
|
uint32_t process_id = frame_id >> 32;
|
|
|
|
uint32_t routing_id = std::numeric_limits<uint32_t>::max() & frame_id;
|
|
|
|
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << frame_id << " [" << process_id << "," << routing_id << "]";
|
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
|
2021-08-19 23:07:44 +02:00
|
|
|
std::string GetFrameDebugString(
|
|
|
|
const content::GlobalRenderFrameHostId& global_id) {
|
|
|
|
return GetFrameDebugString(MakeFrameId(global_id));
|
|
|
|
}
|
|
|
|
|
2019-05-24 22:23:43 +02:00
|
|
|
} // namespace frame_util
|