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/devtools/devtools_manager_impl.h" | 5 #include "content/browser/devtools/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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 agent_to_client_host_.find(agent_host_impl); | 42 agent_to_client_host_.find(agent_host_impl); |
43 if (it != agent_to_client_host_.end()) | 43 if (it != agent_to_client_host_.end()) |
44 return it->second; | 44 return it->second; |
45 return NULL; | 45 return NULL; |
46 } | 46 } |
47 | 47 |
48 DevToolsAgentHost* DevToolsManagerImpl::GetDevToolsAgentHostFor( | 48 DevToolsAgentHost* DevToolsManagerImpl::GetDevToolsAgentHostFor( |
49 DevToolsClientHost* client_host) { | 49 DevToolsClientHost* client_host) { |
50 ClientToAgentHostMap::iterator it = client_to_agent_host_.find(client_host); | 50 ClientToAgentHostMap::iterator it = client_to_agent_host_.find(client_host); |
51 if (it != client_to_agent_host_.end()) | 51 if (it != client_to_agent_host_.end()) |
52 return it->second; | 52 return it->second.get(); |
53 return NULL; | 53 return NULL; |
54 } | 54 } |
55 | 55 |
56 void DevToolsManagerImpl::RegisterDevToolsClientHostFor( | 56 void DevToolsManagerImpl::RegisterDevToolsClientHostFor( |
57 DevToolsAgentHost* agent_host, | 57 DevToolsAgentHost* agent_host, |
58 DevToolsClientHost* client_host) { | 58 DevToolsClientHost* client_host) { |
59 DevToolsAgentHostImpl* agent_host_impl = | 59 DevToolsAgentHostImpl* agent_host_impl = |
60 static_cast<DevToolsAgentHostImpl*>(agent_host); | 60 static_cast<DevToolsAgentHostImpl*>(agent_host); |
61 DevToolsClientHost* old_client_host = | 61 DevToolsClientHost* old_client_host = |
62 GetDevToolsClientHostFor(agent_host_impl); | 62 GetDevToolsClientHostFor(agent_host_impl); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 agent_host->set_close_listener(this); | 135 agent_host->set_close_listener(this); |
136 NotifyObservers(agent_host, true); | 136 NotifyObservers(agent_host, true); |
137 } | 137 } |
138 | 138 |
139 void DevToolsManagerImpl::UnbindClientHost(DevToolsAgentHostImpl* agent_host, | 139 void DevToolsManagerImpl::UnbindClientHost(DevToolsAgentHostImpl* agent_host, |
140 DevToolsClientHost* client_host) { | 140 DevToolsClientHost* client_host) { |
141 DCHECK(agent_host); | 141 DCHECK(agent_host); |
142 scoped_refptr<DevToolsAgentHostImpl> protect(agent_host); | 142 scoped_refptr<DevToolsAgentHostImpl> protect(agent_host); |
143 DCHECK(agent_to_client_host_.find(agent_host)->second == | 143 DCHECK(agent_to_client_host_.find(agent_host)->second == |
144 client_host); | 144 client_host); |
145 DCHECK(client_to_agent_host_.find(client_host)->second == | 145 DCHECK(client_to_agent_host_.find(client_host)->second.get() == agent_host); |
146 agent_host); | |
147 agent_host->set_close_listener(NULL); | 146 agent_host->set_close_listener(NULL); |
148 | 147 |
149 agent_to_client_host_.erase(agent_host); | 148 agent_to_client_host_.erase(agent_host); |
150 client_to_agent_host_.erase(client_host); | 149 client_to_agent_host_.erase(client_host); |
151 | 150 |
152 if (client_to_agent_host_.empty()) { | 151 if (client_to_agent_host_.empty()) { |
153 BrowserThread::PostTask( | 152 BrowserThread::PostTask( |
154 BrowserThread::IO, | 153 BrowserThread::IO, |
155 FROM_HERE, | 154 FROM_HERE, |
156 base::Bind(&DevToolsNetLogObserver::Detach)); | 155 base::Bind(&DevToolsNetLogObserver::Detach)); |
(...skipping 29 matching lines...) Expand all Loading... |
186 } | 185 } |
187 | 186 |
188 void DevToolsManagerImpl::NotifyObservers(DevToolsAgentHost* agent_host, | 187 void DevToolsManagerImpl::NotifyObservers(DevToolsAgentHost* agent_host, |
189 bool attached) { | 188 bool attached) { |
190 CallbackContainer copy(callbacks_); | 189 CallbackContainer copy(callbacks_); |
191 for (CallbackContainer::iterator it = copy.begin(); it != copy.end(); ++it) | 190 for (CallbackContainer::iterator it = copy.begin(); it != copy.end(); ++it) |
192 (*it)->Run(agent_host, attached); | 191 (*it)->Run(agent_host, attached); |
193 } | 192 } |
194 | 193 |
195 } // namespace content | 194 } // namespace content |
OLD | NEW |