OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_DEBUGGER_DEVTOOLS_NETLOG_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_DEBUGGER_DEVTOOLS_NETLOG_OBSERVER_H_ |
6 #define CHROME_BROWSER_DEBUGGER_DEVTOOLS_NETLOG_OBSERVER_H_ | 6 #define CHROME_BROWSER_DEBUGGER_DEVTOOLS_NETLOG_OBSERVER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
11 #include "chrome/browser/net/chrome_net_log.h" | 11 #include "chrome/browser/net/chrome_net_log.h" |
12 #include "webkit/glue/resource_loader_bridge.h" | 12 #include "webkit/glue/resource_loader_bridge.h" |
13 | 13 |
| 14 namespace net { |
| 15 class URLRequest; |
| 16 } // namespace net |
| 17 |
14 class IOThread; | 18 class IOThread; |
15 class URLRequest; | |
16 struct ResourceResponse; | 19 struct ResourceResponse; |
17 | 20 |
18 // DevToolsNetLogObserver watches the NetLog event stream and collects the | 21 // DevToolsNetLogObserver watches the NetLog event stream and collects the |
19 // stuff that may be of interest to DevTools. Currently, this only includes | 22 // stuff that may be of interest to DevTools. Currently, this only includes |
20 // actual HTTP/SPDY headers sent and received over the network. | 23 // actual HTTP/SPDY headers sent and received over the network. |
21 class DevToolsNetLogObserver: public ChromeNetLog::Observer { | 24 class DevToolsNetLogObserver: public ChromeNetLog::Observer { |
22 typedef webkit_glue::ResourceDevToolsInfo ResourceInfo; | 25 typedef webkit_glue::ResourceDevToolsInfo ResourceInfo; |
23 | 26 |
24 public: | 27 public: |
25 // Observer implementation: | 28 // Observer implementation: |
26 virtual void OnAddEntry(net::NetLog::EventType type, | 29 virtual void OnAddEntry(net::NetLog::EventType type, |
27 const base::TimeTicks& time, | 30 const base::TimeTicks& time, |
28 const net::NetLog::Source& source, | 31 const net::NetLog::Source& source, |
29 net::NetLog::EventPhase phase, | 32 net::NetLog::EventPhase phase, |
30 net::NetLog::EventParameters* params); | 33 net::NetLog::EventParameters* params); |
31 | 34 |
32 static void Attach(IOThread* thread); | 35 static void Attach(IOThread* thread); |
33 static void Detach(); | 36 static void Detach(); |
34 | 37 |
35 // Must be called on the IO thread. May return NULL if no observers | 38 // Must be called on the IO thread. May return NULL if no observers |
36 // are active. | 39 // are active. |
37 static DevToolsNetLogObserver* GetInstance(); | 40 static DevToolsNetLogObserver* GetInstance(); |
38 static void PopulateResponseInfo(URLRequest*, ResourceResponse*); | 41 static void PopulateResponseInfo(net::URLRequest*, ResourceResponse*); |
39 | 42 |
40 private: | 43 private: |
41 typedef base::hash_map<uint32, scoped_refptr<ResourceInfo> > | 44 typedef base::hash_map<uint32, scoped_refptr<ResourceInfo> > |
42 RequestToInfoMap; | 45 RequestToInfoMap; |
43 | 46 |
44 static DevToolsNetLogObserver* instance_; | 47 static DevToolsNetLogObserver* instance_; |
45 | 48 |
46 explicit DevToolsNetLogObserver(ChromeNetLog* chrome_net_log); | 49 explicit DevToolsNetLogObserver(ChromeNetLog* chrome_net_log); |
47 ~DevToolsNetLogObserver(); | 50 ~DevToolsNetLogObserver(); |
48 | 51 |
49 ResourceInfo* GetResourceInfo(uint32 id); | 52 ResourceInfo* GetResourceInfo(uint32 id); |
50 | 53 |
51 ChromeNetLog* chrome_net_log_; | 54 ChromeNetLog* chrome_net_log_; |
52 RequestToInfoMap request_to_info_; | 55 RequestToInfoMap request_to_info_; |
53 | 56 |
54 DISALLOW_COPY_AND_ASSIGN(DevToolsNetLogObserver); | 57 DISALLOW_COPY_AND_ASSIGN(DevToolsNetLogObserver); |
55 }; | 58 }; |
56 | 59 |
57 #endif // CHROME_BROWSER_DEBUGGER_DEVTOOLS_NETLOG_OBSERVER_H_ | 60 #endif // CHROME_BROWSER_DEBUGGER_DEVTOOLS_NETLOG_OBSERVER_H_ |
OLD | NEW |