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_NET_LOAD_TIMING_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_NET_LOAD_TIMING_OBSERVER_H_ |
6 #define CHROME_BROWSER_NET_LOAD_TIMING_OBSERVER_H_ | 6 #define CHROME_BROWSER_NET_LOAD_TIMING_OBSERVER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 }; | 36 }; |
37 | 37 |
38 struct SocketRecord { | 38 struct SocketRecord { |
39 base::TimeTicks ssl_start; | 39 base::TimeTicks ssl_start; |
40 base::TimeTicks ssl_end; | 40 base::TimeTicks ssl_end; |
41 }; | 41 }; |
42 | 42 |
43 LoadTimingObserver(); | 43 LoadTimingObserver(); |
44 ~LoadTimingObserver(); | 44 ~LoadTimingObserver(); |
45 | 45 |
46 URLRequestRecord* GetURLRequestRecord(uint32 source_id); | |
47 | |
48 // Observer implementation: | 46 // Observer implementation: |
49 virtual void OnAddEntry(net::NetLog::EventType type, | 47 virtual void OnAddEntry(net::NetLog::EventType type, |
50 const base::TimeTicks& time, | 48 const base::TimeTicks& time, |
51 const net::NetLog::Source& source, | 49 const net::NetLog::Source& source, |
52 net::NetLog::EventPhase phase, | 50 net::NetLog::EventPhase phase, |
53 net::NetLog::EventParameters* params); | 51 net::NetLog::EventParameters* params); |
54 | 52 |
55 static void PopulateTimingInfo(URLRequest* request, | 53 static void PopulateTimingInfo(URLRequest* request, |
56 ResourceResponse* response); | 54 ResourceResponse* response); |
57 | 55 |
58 private: | 56 private: |
59 FRIEND_TEST_ALL_PREFIXES(LoadTimingObserverTest, | 57 FRIEND_TEST_ALL_PREFIXES(LoadTimingObserverTest, |
60 ConnectJobRecord); | 58 ConnectJobRecord); |
61 FRIEND_TEST_ALL_PREFIXES(LoadTimingObserverTest, | 59 FRIEND_TEST_ALL_PREFIXES(LoadTimingObserverTest, |
62 SocketRecord); | 60 SocketRecord); |
63 | 61 |
| 62 // Note that |lock_| must be acquired before calling all of the following |
| 63 // functions. |
64 void OnAddURLRequestEntry(net::NetLog::EventType type, | 64 void OnAddURLRequestEntry(net::NetLog::EventType type, |
65 const base::TimeTicks& time, | 65 const base::TimeTicks& time, |
66 const net::NetLog::Source& source, | 66 const net::NetLog::Source& source, |
67 net::NetLog::EventPhase phase, | 67 net::NetLog::EventPhase phase, |
68 net::NetLog::EventParameters* params); | 68 net::NetLog::EventParameters* params); |
69 | 69 |
70 void OnAddConnectJobEntry(net::NetLog::EventType type, | 70 void OnAddConnectJobEntry(net::NetLog::EventType type, |
71 const base::TimeTicks& time, | 71 const base::TimeTicks& time, |
72 const net::NetLog::Source& source, | 72 const net::NetLog::Source& source, |
73 net::NetLog::EventPhase phase, | 73 net::NetLog::EventPhase phase, |
74 net::NetLog::EventParameters* params); | 74 net::NetLog::EventParameters* params); |
75 | 75 |
76 void OnAddSocketEntry(net::NetLog::EventType type, | 76 void OnAddSocketEntry(net::NetLog::EventType type, |
77 const base::TimeTicks& time, | 77 const base::TimeTicks& time, |
78 const net::NetLog::Source& source, | 78 const net::NetLog::Source& source, |
79 net::NetLog::EventPhase phase, | 79 net::NetLog::EventPhase phase, |
80 net::NetLog::EventParameters* params); | 80 net::NetLog::EventParameters* params); |
81 | 81 |
82 URLRequestRecord* CreateURLRequestRecord(uint32 source_id); | 82 // |lock_| must be aquired for as long as the returned |URLRequestRecord*| |
83 void DeleteURLRequestRecord(uint32 source_id); | 83 // is in use. |
| 84 URLRequestRecord* GetURLRequestRecord(uint32 source_id); |
| 85 |
| 86 Lock lock_; |
84 | 87 |
85 typedef base::hash_map<uint32, URLRequestRecord> URLRequestToRecordMap; | 88 typedef base::hash_map<uint32, URLRequestRecord> URLRequestToRecordMap; |
86 typedef base::hash_map<uint32, ConnectJobRecord> ConnectJobToRecordMap; | 89 typedef base::hash_map<uint32, ConnectJobRecord> ConnectJobToRecordMap; |
87 typedef base::hash_map<uint32, SocketRecord> SocketToRecordMap; | 90 typedef base::hash_map<uint32, SocketRecord> SocketToRecordMap; |
88 URLRequestToRecordMap url_request_to_record_; | 91 URLRequestToRecordMap url_request_to_record_; |
89 ConnectJobToRecordMap connect_job_to_record_; | 92 ConnectJobToRecordMap connect_job_to_record_; |
90 SocketToRecordMap socket_to_record_; | 93 SocketToRecordMap socket_to_record_; |
91 uint32 last_connect_job_id_; | 94 uint32 last_connect_job_id_; |
92 ConnectJobRecord last_connect_job_record_; | 95 ConnectJobRecord last_connect_job_record_; |
93 | 96 |
94 DISALLOW_COPY_AND_ASSIGN(LoadTimingObserver); | 97 DISALLOW_COPY_AND_ASSIGN(LoadTimingObserver); |
95 }; | 98 }; |
96 | 99 |
97 #endif // CHROME_BROWSER_NET_LOAD_TIMING_OBSERVER_H_ | 100 #endif // CHROME_BROWSER_NET_LOAD_TIMING_OBSERVER_H_ |
OLD | NEW |