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

Unified Diff: content/browser/devtools/render_view_devtools_agent_host.cc

Issue 12319114: Extract debugger target enumeration into a separate class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@debugger
Patch Set: Rebase Created 7 years, 9 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: content/browser/devtools/render_view_devtools_agent_host.cc
diff --git a/content/browser/devtools/render_view_devtools_agent_host.cc b/content/browser/devtools/render_view_devtools_agent_host.cc
index 26b14bf59886f502c74ddf9c310cb7fc4b9cbcb5..6bbb10315e691b85ee8bf0ec1071939484b71f99 100644
--- a/content/browser/devtools/render_view_devtools_agent_host.cc
+++ b/content/browser/devtools/render_view_devtools_agent_host.cc
@@ -104,32 +104,64 @@ bool DevToolsAgentHost::IsDebuggerAttached(WebContents* web_contents) {
}
// static
-int DevToolsAgentHost::DisconnectRenderViewHost(RenderViewHost* rvh) {
+std::string DevToolsAgentHost::DisconnectRenderViewHost(RenderViewHost* rvh) {
RenderViewDevToolsAgentHost* agent_host = FindAgentHost(rvh);
if (!agent_host)
- return -1;
+ return std::string();
agent_host->DisconnectRenderViewHost();
- return agent_host->id();
+ return agent_host->GetId();
}
// static
-void DevToolsAgentHost::ConnectRenderViewHost(int cookie,
+void DevToolsAgentHost::ConnectRenderViewHost(const std::string& cookie,
RenderViewHost* rvh) {
for (Instances::iterator it = g_instances.Get().begin();
it != g_instances.Get().end(); ++it) {
- if (cookie == (*it)->id()) {
+ if (cookie == (*it)->GetId()) {
(*it)->ConnectRenderViewHost(rvh, true);
break;
}
}
}
+//static
+std::vector<RenderViewHost*> DevToolsAgentHost::GetValidRenderViewHosts() {
+ std::vector<RenderViewHost*> result;
+ for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator());
+ !it.IsAtEnd(); it.Advance()) {
+ RenderProcessHost* render_process_host = it.GetCurrentValue();
+ DCHECK(render_process_host);
+
+ // Ignore processes that don't have a connection, such as crashed contents.
+ if (!render_process_host->HasConnection())
+ continue;
+
+ RenderProcessHost::RenderWidgetHostsIterator rwit(
+ render_process_host->GetRenderWidgetHostsIterator());
+ for (; !rwit.IsAtEnd(); rwit.Advance()) {
+ const RenderWidgetHost* widget = rwit.GetCurrentValue();
+ DCHECK(widget);
+ if (!widget || !widget->IsRenderView())
+ continue;
+
+ RenderViewHost* rvh =
+ RenderViewHost::From(const_cast<RenderWidgetHost*>(widget));
+ // Don't report swapped out views.
+ if (static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out())
+ continue;
+
+ result.push_back(rvh);
+ }
+ }
+ return result;
+}
+
// static
void RenderViewDevToolsAgentHost::OnCancelPendingNavigation(
RenderViewHost* pending,
RenderViewHost* current) {
- int cookie = DevToolsAgentHost::DisconnectRenderViewHost(pending);
- if (cookie != -1)
+ std::string cookie = DevToolsAgentHost::DisconnectRenderViewHost(pending);
+ if (cookie != std::string())
DevToolsAgentHost::ConnectRenderViewHost(cookie, current);
}
« no previous file with comments | « content/browser/devtools/devtools_http_handler_impl.cc ('k') | content/public/browser/devtools_agent_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698