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

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

Issue 2812253002: Headless: Support sending and receiving of raw protocol messages (Closed)
Patch Set: Fix tests 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..aea5aefc8f15bce048c19a4e765d00e8884c8c0e 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_frame_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_frame_tree_node_id_.erase(find_it->second);
+ render_frame_host_to_devtools_agent_host_id_.erase(find_it);
+}
+
+bool HeadlessWebContentsImpl::GetFrameTreeNodeIdForDevToolsAgentHostId(
+ const std::string& devtools_agent_host_id,
+ int* frame_tree_node_id) const {
+ const auto& find_it =
+ devtools_agent_id_to_frame_tree_node_id_.find(devtools_agent_host_id);
+ if (find_it == devtools_agent_id_to_frame_tree_node_id_.end())
+ return false;
+ *frame_tree_node_id = find_it->second;
+ return true;
}
bool HeadlessWebContentsImpl::OpenURL(const GURL& url) {
« no previous file with comments | « headless/lib/browser/headless_web_contents_impl.h ('k') | headless/lib/headless_devtools_client_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698