OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/browser/devtools/devtools_manager_impl.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/message_loop/message_loop.h" | |
9 #include "content/browser/devtools/devtools_netlog_observer.h" | |
10 #include "content/public/browser/browser_thread.h" | |
11 #include "content/public/browser/content_browser_client.h" | |
12 #include "content/public/browser/devtools_agent_host.h" | |
13 #include "content/public/browser/devtools_manager_delegate.h" | |
14 | |
15 namespace content { | |
16 | |
17 // static | |
18 DevToolsManagerImpl* DevToolsManagerImpl::GetInstance() { | |
19 return Singleton<DevToolsManagerImpl>::get(); | |
20 } | |
21 | |
22 DevToolsManagerImpl::DevToolsManagerImpl() | |
23 : delegate_(GetContentClient()->browser()->GetDevToolsManagerDelegate()), | |
24 client_count_(0) { | |
25 } | |
26 | |
27 DevToolsManagerImpl::~DevToolsManagerImpl() { | |
28 DCHECK(!client_count_); | |
29 } | |
30 | |
31 void DevToolsManagerImpl::OnClientAttached() { | |
32 if (!client_count_) { | |
33 BrowserThread::PostTask( | |
34 BrowserThread::IO, | |
35 FROM_HERE, | |
36 base::Bind(&DevToolsNetLogObserver::Attach)); | |
37 } | |
38 client_count_++; | |
39 } | |
40 | |
41 void DevToolsManagerImpl::OnClientDetached() { | |
42 client_count_--; | |
43 if (!client_count_) { | |
44 BrowserThread::PostTask( | |
45 BrowserThread::IO, | |
46 FROM_HERE, | |
47 base::Bind(&DevToolsNetLogObserver::Detach)); | |
48 } | |
49 } | |
50 | |
51 } // namespace content | |
OLD | NEW |