| OLD | NEW |
| 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/debugger/devtools_manager_impl.h" | 5 #include "content/browser/debugger/devtools_manager_impl.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 } | 31 } |
| 32 | 32 |
| 33 DevToolsManagerImpl::DevToolsManagerImpl() | 33 DevToolsManagerImpl::DevToolsManagerImpl() |
| 34 : last_orphan_cookie_(0) { | 34 : last_orphan_cookie_(0) { |
| 35 } | 35 } |
| 36 | 36 |
| 37 DevToolsManagerImpl::~DevToolsManagerImpl() { | 37 DevToolsManagerImpl::~DevToolsManagerImpl() { |
| 38 DCHECK(agent_to_client_host_.empty()); | 38 DCHECK(agent_to_client_host_.empty()); |
| 39 DCHECK(client_to_agent_host_.empty()); | 39 DCHECK(client_to_agent_host_.empty()); |
| 40 // By the time we destroy devtools manager, all orphan client hosts should | 40 // By the time we destroy devtools manager, all orphan client hosts should |
| 41 // have been delelted, no need to notify them upon tab closing. | 41 // have been deleted; no need to notify them upon contents closing. |
| 42 DCHECK(orphan_client_hosts_.empty()); | 42 DCHECK(orphan_client_hosts_.empty()); |
| 43 } | 43 } |
| 44 | 44 |
| 45 DevToolsClientHost* DevToolsManagerImpl::GetDevToolsClientHostFor( | 45 DevToolsClientHost* DevToolsManagerImpl::GetDevToolsClientHostFor( |
| 46 DevToolsAgentHost* agent_host) { | 46 DevToolsAgentHost* agent_host) { |
| 47 AgentToClientHostMap::iterator it = agent_to_client_host_.find(agent_host); | 47 AgentToClientHostMap::iterator it = agent_to_client_host_.find(agent_host); |
| 48 if (it != agent_to_client_host_.end()) | 48 if (it != agent_to_client_host_.end()) |
| 49 return it->second; | 49 return it->second; |
| 50 return NULL; | 50 return NULL; |
| 51 } | 51 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 void DevToolsManagerImpl::AgentHostClosing(DevToolsAgentHost* agent_host) { | 126 void DevToolsManagerImpl::AgentHostClosing(DevToolsAgentHost* agent_host) { |
| 127 UnregisterDevToolsClientHostFor(agent_host); | 127 UnregisterDevToolsClientHostFor(agent_host); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void DevToolsManagerImpl::UnregisterDevToolsClientHostFor( | 130 void DevToolsManagerImpl::UnregisterDevToolsClientHostFor( |
| 131 DevToolsAgentHost* agent_host) { | 131 DevToolsAgentHost* agent_host) { |
| 132 DevToolsClientHost* client_host = GetDevToolsClientHostFor(agent_host); | 132 DevToolsClientHost* client_host = GetDevToolsClientHostFor(agent_host); |
| 133 if (!client_host) | 133 if (!client_host) |
| 134 return; | 134 return; |
| 135 UnbindClientHost(agent_host, client_host); | 135 UnbindClientHost(agent_host, client_host); |
| 136 client_host->InspectedTabClosing(); | 136 client_host->InspectedContentsClosing(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void DevToolsManagerImpl::OnNavigatingToPendingEntry( | 139 void DevToolsManagerImpl::OnNavigatingToPendingEntry( |
| 140 RenderViewHost* rvh, | 140 RenderViewHost* rvh, |
| 141 RenderViewHost* dest_rvh, | 141 RenderViewHost* dest_rvh, |
| 142 const GURL& gurl) { | 142 const GURL& gurl) { |
| 143 if (rvh == dest_rvh && static_cast<RenderViewHostImpl*>( | 143 if (rvh == dest_rvh && static_cast<RenderViewHostImpl*>( |
| 144 rvh)->render_view_termination_status() == | 144 rvh)->render_view_termination_status() == |
| 145 base::TERMINATION_STATUS_STILL_RUNNING) | 145 base::TERMINATION_STATUS_STILL_RUNNING) |
| 146 return; | 146 return; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 160 void DevToolsManagerImpl::OnCancelPendingNavigation( | 160 void DevToolsManagerImpl::OnCancelPendingNavigation( |
| 161 RenderViewHost* pending, | 161 RenderViewHost* pending, |
| 162 RenderViewHost* current) { | 162 RenderViewHost* current) { |
| 163 int cookie = DetachClientHost(pending); | 163 int cookie = DetachClientHost(pending); |
| 164 if (cookie != -1) { | 164 if (cookie != -1) { |
| 165 // Navigating to URL in the inspected window. | 165 // Navigating to URL in the inspected window. |
| 166 AttachClientHost(cookie, current); | 166 AttachClientHost(cookie, current); |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 | 169 |
| 170 void DevToolsManagerImpl::TabReplaced(WebContents* old_tab, | 170 void DevToolsManagerImpl::ContentsReplaced(WebContents* old_contents, |
| 171 WebContents* new_tab) { | 171 WebContents* new_contents) { |
| 172 RenderViewHost* old_rvh = old_tab->GetRenderViewHost(); | 172 RenderViewHost* old_rvh = old_contents->GetRenderViewHost(); |
| 173 if (!DevToolsAgentHostRegistry::HasDevToolsAgentHost(old_rvh)) | 173 if (!DevToolsAgentHostRegistry::HasDevToolsAgentHost(old_rvh)) |
| 174 return; | 174 return; |
| 175 | 175 |
| 176 DevToolsAgentHost* old_agent_host = | 176 DevToolsAgentHost* old_agent_host = |
| 177 DevToolsAgentHostRegistry::GetDevToolsAgentHost(old_rvh); | 177 DevToolsAgentHostRegistry::GetDevToolsAgentHost(old_rvh); |
| 178 DevToolsClientHost* client_host = GetDevToolsClientHostFor(old_agent_host); | 178 DevToolsClientHost* client_host = GetDevToolsClientHostFor(old_agent_host); |
| 179 if (!client_host) | 179 if (!client_host) |
| 180 return; // Didn't know about old_tab. | 180 return; // Didn't know about old_contents. |
| 181 int cookie = DetachClientHost(old_rvh); | 181 int cookie = DetachClientHost(old_rvh); |
| 182 if (cookie == -1) | 182 if (cookie == -1) |
| 183 return; // Didn't know about old_tab. | 183 return; // Didn't know about old_contents. |
| 184 | 184 |
| 185 client_host->TabReplaced(new_tab); | 185 client_host->ContentsReplaced(new_contents); |
| 186 AttachClientHost(cookie, new_tab->GetRenderViewHost()); | 186 AttachClientHost(cookie, new_contents->GetRenderViewHost()); |
| 187 } | 187 } |
| 188 | 188 |
| 189 int DevToolsManagerImpl::DetachClientHost(RenderViewHost* from_rvh) { | 189 int DevToolsManagerImpl::DetachClientHost(RenderViewHost* from_rvh) { |
| 190 DevToolsAgentHost* agent_host = | 190 DevToolsAgentHost* agent_host = |
| 191 DevToolsAgentHostRegistry::GetDevToolsAgentHost(from_rvh); | 191 DevToolsAgentHostRegistry::GetDevToolsAgentHost(from_rvh); |
| 192 return DetachClientHost(agent_host); | 192 return DetachClientHost(agent_host); |
| 193 } | 193 } |
| 194 | 194 |
| 195 int DevToolsManagerImpl::DetachClientHost(DevToolsAgentHost* agent_host) { | 195 int DevToolsManagerImpl::DetachClientHost(DevToolsAgentHost* agent_host) { |
| 196 DevToolsClientHost* client_host = GetDevToolsClientHostFor(agent_host); | 196 DevToolsClientHost* client_host = GetDevToolsClientHostFor(agent_host); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 it != agent_to_client_host_.end(); ++it) { | 295 it != agent_to_client_host_.end(); ++it) { |
| 296 agents.push_back(it->first); | 296 agents.push_back(it->first); |
| 297 } | 297 } |
| 298 for (std::vector<DevToolsAgentHost*>::iterator it = agents.begin(); | 298 for (std::vector<DevToolsAgentHost*>::iterator it = agents.begin(); |
| 299 it != agents.end(); ++it) { | 299 it != agents.end(); ++it) { |
| 300 UnregisterDevToolsClientHostFor(*it); | 300 UnregisterDevToolsClientHostFor(*it); |
| 301 } | 301 } |
| 302 } | 302 } |
| 303 | 303 |
| 304 } // namespace content | 304 } // namespace content |
| OLD | NEW |