| 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/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "content/browser/devtools/devtools_agent_host_impl.h" | 10 #include "content/browser/devtools/devtools_agent_host_impl.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 DevToolsManager* manager = DevToolsManager::GetInstance(); | 38 DevToolsManager* manager = DevToolsManager::GetInstance(); |
| 39 manager->SetHttpHandler(nullptr); | 39 manager->SetHttpHandler(nullptr); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // static | 42 // static |
| 43 DevToolsManager* DevToolsManager::GetInstance() { | 43 DevToolsManager* DevToolsManager::GetInstance() { |
| 44 return base::Singleton<DevToolsManager>::get(); | 44 return base::Singleton<DevToolsManager>::get(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 DevToolsManager::DevToolsManager() | 47 DevToolsManager::DevToolsManager() |
| 48 : delegate_(GetContentClient()->browser()->GetDevToolsManagerDelegate()), | 48 : delegate_(GetContentClient()->browser()->GetDevToolsManagerDelegate()) { |
| 49 attached_hosts_count_(0) { | |
| 50 } | 49 } |
| 51 | 50 |
| 52 DevToolsManager::~DevToolsManager() { | 51 DevToolsManager::~DevToolsManager() { |
| 53 DCHECK(!attached_hosts_count_); | |
| 54 } | |
| 55 | |
| 56 void DevToolsManager::AgentHostStateChanged( | |
| 57 DevToolsAgentHostImpl* agent_host, bool attached) { | |
| 58 if (attached) { | |
| 59 if (!attached_hosts_count_) { | |
| 60 BrowserThread::PostTask( | |
| 61 BrowserThread::IO, | |
| 62 FROM_HERE, | |
| 63 base::Bind(&NetLogObserver::Attach, | |
| 64 GetContentClient()->browser()->GetNetLog())); | |
| 65 } | |
| 66 ++attached_hosts_count_; | |
| 67 } else { | |
| 68 --attached_hosts_count_; | |
| 69 if (!attached_hosts_count_) { | |
| 70 BrowserThread::PostTask( | |
| 71 BrowserThread::IO, | |
| 72 FROM_HERE, | |
| 73 base::Bind(&NetLogObserver::Detach)); | |
| 74 } | |
| 75 } | |
| 76 } | 52 } |
| 77 | 53 |
| 78 void DevToolsManager::SetHttpHandler( | 54 void DevToolsManager::SetHttpHandler( |
| 79 std::unique_ptr<DevToolsHttpHandler> http_handler) { | 55 std::unique_ptr<DevToolsHttpHandler> http_handler) { |
| 80 http_handler_ = std::move(http_handler); | 56 http_handler_ = std::move(http_handler); |
| 81 } | 57 } |
| 82 | 58 |
| 83 } // namespace content | 59 } // namespace content |
| OLD | NEW |