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