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_NET_LOAD_TIMING_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_NET_LOAD_TIMING_OBSERVER_H_ |
| 7 |
| 8 #include "base/hash_tables.h" |
| 9 #include "base/time.h" |
| 10 #include "chrome/browser/net/chrome_net_log.h" |
| 11 #include "net/base/net_log.h" |
| 12 #include "webkit/glue/resource_loader_bridge.h" |
| 13 |
| 14 // LoadTimingObserver watches the NetLog event stream and collects the network |
| 15 // timing information. |
| 16 class LoadTimingObserver : public ChromeNetLog::Observer { |
| 17 public: |
| 18 struct URLRequestRecord { |
| 19 URLRequestRecord(); |
| 20 |
| 21 webkit_glue::ResourceLoaderBridge::LoadTimingInfo timing; |
| 22 uint32 connect_job_id; |
| 23 uint32 socket_log_id; |
| 24 bool socket_reused; |
| 25 base::TimeTicks base_ticks; |
| 26 }; |
| 27 |
| 28 struct ConnectJobRecord { |
| 29 base::TimeTicks dns_start; |
| 30 base::TimeTicks dns_end; |
| 31 }; |
| 32 |
| 33 LoadTimingObserver(); |
| 34 ~LoadTimingObserver(); |
| 35 |
| 36 URLRequestRecord* GetURLRequestRecord(uint32 source_id); |
| 37 |
| 38 // Observer implementation: |
| 39 virtual void OnAddEntry(net::NetLog::EventType type, |
| 40 const base::TimeTicks& time, |
| 41 const net::NetLog::Source& source, |
| 42 net::NetLog::EventPhase phase, |
| 43 net::NetLog::EventParameters* params); |
| 44 private: |
| 45 void OnAddURLRequestEntry(net::NetLog::EventType type, |
| 46 const base::TimeTicks& time, |
| 47 const net::NetLog::Source& source, |
| 48 net::NetLog::EventPhase phase, |
| 49 net::NetLog::EventParameters* params); |
| 50 |
| 51 void OnAddConnectJobEntry(net::NetLog::EventType type, |
| 52 const base::TimeTicks& time, |
| 53 const net::NetLog::Source& source, |
| 54 net::NetLog::EventPhase phase, |
| 55 net::NetLog::EventParameters* params); |
| 56 |
| 57 URLRequestRecord* CreateURLRequestRecord(uint32 source_id); |
| 58 void DeleteURLRequestRecord(uint32 source_id); |
| 59 |
| 60 typedef base::hash_map<uint32, URLRequestRecord> URLRequestToRecordMap; |
| 61 typedef base::hash_map<uint32, ConnectJobRecord> ConnectJobToRecordMap; |
| 62 URLRequestToRecordMap url_request_to_record_; |
| 63 ConnectJobToRecordMap connect_job_to_record_; |
| 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(LoadTimingObserver); |
| 66 }; |
| 67 |
| 68 #endif // CHROME_BROWSER_NET_LOAD_TIMING_OBSERVER_H_ |
OLD | NEW |