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

Side by Side 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: Addressed comments 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/devtools/render_view_devtools_agent_host.h" 5 #include "content/browser/devtools/render_view_devtools_agent_host.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "content/browser/child_process_security_policy_impl.h" 10 #include "content/browser/child_process_security_policy_impl.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 RenderViewHost* rvh = (*it)->render_view_host_; 97 RenderViewHost* rvh = (*it)->render_view_host_;
98 if (rvh && rvh->GetDelegate() != delegate) 98 if (rvh && rvh->GetDelegate() != delegate)
99 continue; 99 continue;
100 if (devtools_manager->GetDevToolsClientHostFor(*it)) 100 if (devtools_manager->GetDevToolsClientHostFor(*it))
101 return true; 101 return true;
102 } 102 }
103 return false; 103 return false;
104 } 104 }
105 105
106 // static 106 // static
107 int DevToolsAgentHost::DisconnectRenderViewHost(RenderViewHost* rvh) { 107 const std::string DevToolsAgentHost::NullId;
108
109 // static
110 std::string DevToolsAgentHost::DisconnectRenderViewHost(RenderViewHost* rvh) {
108 RenderViewDevToolsAgentHost* agent_host = FindAgentHost(rvh); 111 RenderViewDevToolsAgentHost* agent_host = FindAgentHost(rvh);
109 if (!agent_host) 112 if (!agent_host)
110 return -1; 113 return NullId;
111 agent_host->DisconnectRenderViewHost(); 114 agent_host->DisconnectRenderViewHost();
112 return agent_host->id(); 115 return agent_host->GetId();
113 } 116 }
114 117
115 // static 118 // static
116 void DevToolsAgentHost::ConnectRenderViewHost(int cookie, 119 void DevToolsAgentHost::ConnectRenderViewHost(const std::string& cookie,
117 RenderViewHost* rvh) { 120 RenderViewHost* rvh) {
118 for (Instances::iterator it = g_instances.Get().begin(); 121 for (Instances::iterator it = g_instances.Get().begin();
119 it != g_instances.Get().end(); ++it) { 122 it != g_instances.Get().end(); ++it) {
120 if (cookie == (*it)->id()) { 123 if (cookie == (*it)->GetId()) {
121 (*it)->ConnectRenderViewHost(rvh, true); 124 (*it)->ConnectRenderViewHost(rvh, true);
122 break; 125 break;
123 } 126 }
124 } 127 }
125 } 128 }
126 129
127 // static 130 // static
128 void RenderViewDevToolsAgentHost::OnCancelPendingNavigation( 131 void RenderViewDevToolsAgentHost::OnCancelPendingNavigation(
129 RenderViewHost* pending, 132 RenderViewHost* pending,
130 RenderViewHost* current) { 133 RenderViewHost* current) {
131 int cookie = DevToolsAgentHost::DisconnectRenderViewHost(pending); 134 std::string cookie = DevToolsAgentHost::DisconnectRenderViewHost(pending);
132 if (cookie != -1) 135 if (cookie != NullId)
133 DevToolsAgentHost::ConnectRenderViewHost(cookie, current); 136 DevToolsAgentHost::ConnectRenderViewHost(cookie, current);
134 } 137 }
135 138
136 RenderViewDevToolsAgentHost::RenderViewDevToolsAgentHost( 139 RenderViewDevToolsAgentHost::RenderViewDevToolsAgentHost(
137 RenderViewHost* rvh) 140 RenderViewHost* rvh)
138 : overrides_handler_(new RendererOverridesHandler(this)) { 141 : overrides_handler_(new RendererOverridesHandler(this)) {
139 ConnectRenderViewHost(rvh, false); 142 ConnectRenderViewHost(rvh, false);
140 g_instances.Get().push_back(this); 143 g_instances.Get().push_back(this);
141 RenderViewHostDelegate* delegate = render_view_host_->GetDelegate(); 144 RenderViewHostDelegate* delegate = render_view_host_->GetDelegate();
142 if (delegate && delegate->GetAsWebContents()) 145 if (delegate && delegate->GetAsWebContents())
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 snapshot_bounds)) 343 snapshot_bounds))
341 return false; 344 return false;
342 345
343 return base::Base64Encode(base::StringPiece( 346 return base::Base64Encode(base::StringPiece(
344 reinterpret_cast<char*>(&*png.begin()), 347 reinterpret_cast<char*>(&*png.begin()),
345 png.size()), 348 png.size()),
346 base_64_data); 349 base_64_data);
347 } 350 }
348 351
349 } // namespace content 352 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698