Revert of [DevTools] Implement DevToolsManager::Observer which notifies about target...
[chromium-blink-merge.git] / content / browser / devtools / devtools_manager.cc
blob6d8da5399e650920f57b84b69e2f36ba01b09f7c
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.
5 #include "content/browser/devtools/devtools_manager.h"
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_manager_delegate.h"
14 namespace content {
16 // static
17 DevToolsManager* DevToolsManager::GetInstance() {
18 return Singleton<DevToolsManager>::get();
21 DevToolsManager::DevToolsManager()
22 : delegate_(GetContentClient()->browser()->GetDevToolsManagerDelegate()),
23 client_count_(0) {
26 DevToolsManager::~DevToolsManager() {
27 DCHECK(!client_count_);
30 void DevToolsManager::OnClientAttached() {
31 if (!client_count_) {
32 BrowserThread::PostTask(
33 BrowserThread::IO,
34 FROM_HERE,
35 base::Bind(&DevToolsNetLogObserver::Attach));
37 client_count_++;
40 void DevToolsManager::OnClientDetached() {
41 client_count_--;
42 if (!client_count_) {
43 BrowserThread::PostTask(
44 BrowserThread::IO,
45 FROM_HERE,
46 base::Bind(&DevToolsNetLogObserver::Detach));
50 } // namespace content