Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: content/browser/devtools/devtools_manager.cc

Issue 2115823004: Avoid using BrowserThread and ContentBrowserClient in NetLogObserver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build error Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/devtools/devtools_agent_host_impl.h"
10 #include "content/browser/loader/netlog_observer.h" 10 #include "content/browser/loader/netlog_observer.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/content_browser_client.h" 12 #include "content/public/browser/content_browser_client.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 // static 16 // static
17 DevToolsManager* DevToolsManager::GetInstance() { 17 DevToolsManager* DevToolsManager::GetInstance() {
18 return base::Singleton<DevToolsManager>::get(); 18 return base::Singleton<DevToolsManager>::get();
19 } 19 }
20 20
21 DevToolsManager::DevToolsManager() 21 DevToolsManager::DevToolsManager()
22 : delegate_(GetContentClient()->browser()->GetDevToolsManagerDelegate()), 22 : delegate_(GetContentClient()->browser()->GetDevToolsManagerDelegate()),
23 attached_hosts_count_(0) { 23 attached_hosts_count_(0) {
24 // Pass the IO thread task runner to the NetLogObserver class.
25 NetLogObserver::SetIOThreadTaskRunner(
pfeldman 2016/07/06 18:36:14 It is unclear why netlog observer is initialized w
ananta 2016/07/08 14:11:02 Passed it via Attach instead.
26 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
24 } 27 }
25 28
26 DevToolsManager::~DevToolsManager() { 29 DevToolsManager::~DevToolsManager() {
27 DCHECK(!attached_hosts_count_); 30 DCHECK(!attached_hosts_count_);
28 } 31 }
29 32
30 void DevToolsManager::AgentHostStateChanged( 33 void DevToolsManager::AgentHostStateChanged(
31 DevToolsAgentHostImpl* agent_host, bool attached) { 34 DevToolsAgentHostImpl* agent_host, bool attached) {
32 if (attached) { 35 if (attached) {
33 if (!attached_hosts_count_) { 36 if (!attached_hosts_count_) {
34 BrowserThread::PostTask( 37 BrowserThread::PostTask(
35 BrowserThread::IO, 38 BrowserThread::IO,
36 FROM_HERE, 39 FROM_HERE,
37 base::Bind(&NetLogObserver::Attach)); 40 base::Bind(&NetLogObserver::Attach,
41 GetContentClient()->browser()->GetNetLog()));
38 } 42 }
39 ++attached_hosts_count_; 43 ++attached_hosts_count_;
40 } else { 44 } else {
41 --attached_hosts_count_; 45 --attached_hosts_count_;
42 if (!attached_hosts_count_) { 46 if (!attached_hosts_count_) {
43 BrowserThread::PostTask( 47 BrowserThread::PostTask(
44 BrowserThread::IO, 48 BrowserThread::IO,
45 FROM_HERE, 49 FROM_HERE,
46 base::Bind(&NetLogObserver::Detach)); 50 base::Bind(&NetLogObserver::Detach));
47 } 51 }
48 } 52 }
49 } 53 }
50 54
51 } // namespace content 55 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/loader/netlog_observer.h » ('j') | content/browser/loader/netlog_observer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698