Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2832)

Unified Diff: headless/lib/browser/headless_web_contents_impl.cc

Issue 2812253002: Headless: Support sending and receiving of raw protocol messages (Closed)
Patch Set: Add ability to find render tree node id for devtools agent host ids Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: headless/lib/browser/headless_web_contents_impl.cc
diff --git a/headless/lib/browser/headless_web_contents_impl.cc b/headless/lib/browser/headless_web_contents_impl.cc
index ad43eb9b12e01dc9497c381538041e3892fdeeb7..5af3fe04e45934520ad9caf7b94a792d8486829c 100644
--- a/headless/lib/browser/headless_web_contents_impl.cc
+++ b/headless/lib/browser/headless_web_contents_impl.cc
@@ -213,6 +213,35 @@ void HeadlessWebContentsImpl::RenderFrameCreated(
service.service_factory,
browser()->BrowserMainThread());
}
+
+ std::string devtools_agent_host_id =
+ content::DevToolsAgentHost::GetOrCreateFor(render_frame_host)->GetId();
+ render_frame_host_to_devtools_agent_host_id_[render_frame_host] =
+ devtools_agent_host_id;
+ devtools_agent_id_to_render_tree_node_id_[devtools_agent_host_id] =
+ render_frame_host->GetFrameTreeNodeId();
+}
+
+void HeadlessWebContentsImpl::RenderFrameDeleted(
+ content::RenderFrameHost* render_frame_host) {
+ auto find_it =
+ render_frame_host_to_devtools_agent_host_id_.find(render_frame_host);
+ if (find_it == render_frame_host_to_devtools_agent_host_id_.end())
+ return;
+
+ devtools_agent_id_to_render_tree_node_id_.erase(find_it->second);
+ render_frame_host_to_devtools_agent_host_id_.erase(find_it);
+}
+
+bool HeadlessWebContentsImpl::GetRenderTreeNodeIdForDevToolsAgentHostId(
+ const std::string& devtools_agent_host_id,
+ int* render_tree_node_id) const {
+ const auto& find_it =
+ devtools_agent_id_to_render_tree_node_id_.find(devtools_agent_host_id);
+ if (find_it == devtools_agent_id_to_render_tree_node_id_.end())
+ return false;
+ *render_tree_node_id = find_it->second;
+ return true;
}
bool HeadlessWebContentsImpl::OpenURL(const GURL& url) {

Powered by Google App Engine
This is Rietveld 408576698