| 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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "content/browser/devtools/devtools_netlog_observer.h" | 11 #include "content/browser/devtools/devtools_netlog_observer.h" |
| 12 #include "content/browser/devtools/render_view_devtools_agent_host.h" | 12 #include "content/browser/devtools/render_view_devtools_agent_host.h" |
| 13 #include "content/browser/renderer_host/render_view_host_impl.h" | 13 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 14 #include "content/browser/web_contents/web_contents_impl.h" | 14 #include "content/browser/web_contents/web_contents_impl.h" |
| 15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/content_browser_client.h" |
| 16 #include "content/public/browser/devtools_client_host.h" | 17 #include "content/public/browser/devtools_client_host.h" |
| 18 #include "content/public/browser/devtools_manager_delegate.h" |
| 17 | 19 |
| 18 namespace content { | 20 namespace content { |
| 19 | 21 |
| 20 // static | 22 // static |
| 21 DevToolsManager* DevToolsManager::GetInstance() { | 23 DevToolsManager* DevToolsManager::GetInstance() { |
| 22 return DevToolsManagerImpl::GetInstance(); | 24 return DevToolsManagerImpl::GetInstance(); |
| 23 } | 25 } |
| 24 | 26 |
| 25 // static | 27 // static |
| 26 DevToolsManagerImpl* DevToolsManagerImpl::GetInstance() { | 28 DevToolsManagerImpl* DevToolsManagerImpl::GetInstance() { |
| 27 return Singleton<DevToolsManagerImpl>::get(); | 29 return Singleton<DevToolsManagerImpl>::get(); |
| 28 } | 30 } |
| 29 | 31 |
| 30 DevToolsManagerImpl::DevToolsManagerImpl() { | 32 DevToolsManagerImpl::DevToolsManagerImpl() |
| 33 : delegate_(GetContentClient()->browser()->GetDevToolsManagerDelegate()) { |
| 31 } | 34 } |
| 32 | 35 |
| 33 DevToolsManagerImpl::~DevToolsManagerImpl() { | 36 DevToolsManagerImpl::~DevToolsManagerImpl() { |
| 34 DCHECK(agent_to_client_host_.empty()); | 37 DCHECK(agent_to_client_host_.empty()); |
| 35 DCHECK(client_to_agent_host_.empty()); | 38 DCHECK(client_to_agent_host_.empty()); |
| 36 } | 39 } |
| 37 | 40 |
| 38 DevToolsClientHost* DevToolsManagerImpl::GetDevToolsClientHostFor( | 41 DevToolsClientHost* DevToolsManagerImpl::GetDevToolsClientHostFor( |
| 39 DevToolsAgentHostImpl* agent_host_impl) { | 42 DevToolsAgentHostImpl* agent_host_impl) { |
| 40 AgentToClientHostMap::iterator it = | 43 AgentToClientHostMap::iterator it = |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 callbacks_.push_back(&callback); | 177 callbacks_.push_back(&callback); |
| 175 } | 178 } |
| 176 | 179 |
| 177 void DevToolsManagerImpl::RemoveAgentStateCallback(const Callback& callback) { | 180 void DevToolsManagerImpl::RemoveAgentStateCallback(const Callback& callback) { |
| 178 CallbackContainer::iterator it = | 181 CallbackContainer::iterator it = |
| 179 std::find(callbacks_.begin(), callbacks_.end(), &callback); | 182 std::find(callbacks_.begin(), callbacks_.end(), &callback); |
| 180 DCHECK(it != callbacks_.end()); | 183 DCHECK(it != callbacks_.end()); |
| 181 callbacks_.erase(it); | 184 callbacks_.erase(it); |
| 182 } | 185 } |
| 183 | 186 |
| 187 void DevToolsManagerImpl::Inspect(BrowserContext* browser_context, |
| 188 DevToolsAgentHost* agent_host) { |
| 189 if (delegate_) |
| 190 delegate_->Inspect(browser_context, agent_host); |
| 191 } |
| 192 |
| 184 void DevToolsManagerImpl::NotifyObservers(DevToolsAgentHost* agent_host, | 193 void DevToolsManagerImpl::NotifyObservers(DevToolsAgentHost* agent_host, |
| 185 bool attached) { | 194 bool attached) { |
| 186 CallbackContainer copy(callbacks_); | 195 CallbackContainer copy(callbacks_); |
| 187 for (CallbackContainer::iterator it = copy.begin(); it != copy.end(); ++it) | 196 for (CallbackContainer::iterator it = copy.begin(); it != copy.end(); ++it) |
| 188 (*it)->Run(agent_host, attached); | 197 (*it)->Run(agent_host, attached); |
| 189 } | 198 } |
| 190 | 199 |
| 191 } // namespace content | 200 } // namespace content |
| OLD | NEW |