| 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.h" | 5 #include "content/browser/devtools/devtools_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "content/browser/devtools/devtools_agent_host_impl.h" | 9 #include "content/browser/loader/network_service_interface.h" |
| 10 #include "content/browser/devtools/devtools_netlog_observer.h" | |
| 11 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 12 #include "content/public/browser/content_browser_client.h" | 11 #include "content/public/browser/content_browser_client.h" |
| 13 | 12 |
| 14 namespace content { | 13 namespace content { |
| 15 | 14 |
| 16 // static | 15 // static |
| 17 DevToolsManager* DevToolsManager::GetInstance() { | 16 DevToolsManager* DevToolsManager::GetInstance() { |
| 18 return base::Singleton<DevToolsManager>::get(); | 17 return base::Singleton<DevToolsManager>::get(); |
| 19 } | 18 } |
| 20 | 19 |
| 21 DevToolsManager::DevToolsManager() | 20 DevToolsManager::DevToolsManager() |
| 22 : delegate_(GetContentClient()->browser()->GetDevToolsManagerDelegate()), | 21 : delegate_(GetContentClient()->browser()->GetDevToolsManagerDelegate()), |
| 23 attached_hosts_count_(0) { | 22 attached_hosts_count_(0) { |
| 24 } | 23 } |
| 25 | 24 |
| 26 DevToolsManager::~DevToolsManager() { | 25 DevToolsManager::~DevToolsManager() { |
| 27 DCHECK(!attached_hosts_count_); | 26 DCHECK(!attached_hosts_count_); |
| 28 } | 27 } |
| 29 | 28 |
| 30 void DevToolsManager::AgentHostStateChanged( | 29 void DevToolsManager::AgentHostStateChanged( |
| 31 DevToolsAgentHostImpl* agent_host, bool attached) { | 30 DevToolsAgentHostImpl* agent_host, bool attached) { |
| 32 if (attached) { | 31 if (attached) { |
| 33 if (!attached_hosts_count_) { | 32 if (!attached_hosts_count_) |
| 34 BrowserThread::PostTask( | 33 NetworkServiceInterface::GetInstance()->EnableNetLogObserver(); |
| 35 BrowserThread::IO, | |
| 36 FROM_HERE, | |
| 37 base::Bind(&DevToolsNetLogObserver::Attach)); | |
| 38 } | |
| 39 ++attached_hosts_count_; | 34 ++attached_hosts_count_; |
| 40 } else { | 35 } else { |
| 41 --attached_hosts_count_; | 36 --attached_hosts_count_; |
| 42 if (!attached_hosts_count_) { | 37 if (!attached_hosts_count_) |
| 43 BrowserThread::PostTask( | 38 NetworkServiceInterface::GetInstance()->DisableNetLogObserver(); |
| 44 BrowserThread::IO, | |
| 45 FROM_HERE, | |
| 46 base::Bind(&DevToolsNetLogObserver::Detach)); | |
| 47 } | |
| 48 } | 39 } |
| 49 } | 40 } |
| 50 | 41 |
| 51 } // namespace content | 42 } // namespace content |
| OLD | NEW |