| 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" |
| 11 #include "base/time.h" | 11 #include "base/time.h" |
| 12 #include "chrome/browser/net/chrome_net_log.h" | 12 #include "chrome/browser/net/chrome_net_log.h" |
| 13 #include "net/base/net_log.h" | 13 #include "net/base/net_log.h" |
| 14 #include "webkit/glue/resource_loader_bridge.h" | 14 #include "webkit/glue/resource_loader_bridge.h" |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 class URLRequest; | 17 class URLRequest; |
| 18 } // namespace net | 18 } // namespace net |
| 19 | 19 |
| 20 struct ResourceResponse; | 20 struct ResourceResponse; |
| 21 | 21 |
| 22 // LoadTimingObserver watches the NetLog event stream and collects the network | 22 // LoadTimingObserver watches the NetLog event stream and collects the network |
| 23 // timing information. | 23 // timing information. |
| 24 class LoadTimingObserver : public ChromeNetLog::Observer { | 24 // |
| 25 // LoadTimingObserver lives completely on the IOThread and ignores events from |
| 26 // other threads. It is not safe to use from other threads. |
| 27 class LoadTimingObserver : public ChromeNetLog::ThreadSafeObserver { |
| 25 public: | 28 public: |
| 26 struct URLRequestRecord { | 29 struct URLRequestRecord { |
| 27 URLRequestRecord(); | 30 URLRequestRecord(); |
| 28 | 31 |
| 29 webkit_glue::ResourceLoadTimingInfo timing; | 32 webkit_glue::ResourceLoadTimingInfo timing; |
| 30 uint32 connect_job_id; | 33 uint32 connect_job_id; |
| 31 uint32 socket_log_id; | 34 uint32 socket_log_id; |
| 32 bool socket_reused; | 35 bool socket_reused; |
| 33 base::TimeTicks base_ticks; | 36 base::TimeTicks base_ticks; |
| 34 }; | 37 }; |
| 35 | 38 |
| 36 struct ConnectJobRecord { | 39 struct ConnectJobRecord { |
| 37 base::TimeTicks dns_start; | 40 base::TimeTicks dns_start; |
| 38 base::TimeTicks dns_end; | 41 base::TimeTicks dns_end; |
| 39 }; | 42 }; |
| 40 | 43 |
| 41 struct SocketRecord { | 44 struct SocketRecord { |
| 42 base::TimeTicks ssl_start; | 45 base::TimeTicks ssl_start; |
| 43 base::TimeTicks ssl_end; | 46 base::TimeTicks ssl_end; |
| 44 }; | 47 }; |
| 45 | 48 |
| 46 LoadTimingObserver(); | 49 LoadTimingObserver(); |
| 47 ~LoadTimingObserver(); | 50 ~LoadTimingObserver(); |
| 48 | 51 |
| 49 URLRequestRecord* GetURLRequestRecord(uint32 source_id); | 52 URLRequestRecord* GetURLRequestRecord(uint32 source_id); |
| 50 | 53 |
| 51 // Observer implementation: | 54 // ThreadSafeObserver implementation: |
| 52 virtual void OnAddEntry(net::NetLog::EventType type, | 55 virtual void OnAddEntry(net::NetLog::EventType type, |
| 53 const base::TimeTicks& time, | 56 const base::TimeTicks& time, |
| 54 const net::NetLog::Source& source, | 57 const net::NetLog::Source& source, |
| 55 net::NetLog::EventPhase phase, | 58 net::NetLog::EventPhase phase, |
| 56 net::NetLog::EventParameters* params); | 59 net::NetLog::EventParameters* params); |
| 57 | 60 |
| 58 static void PopulateTimingInfo(net::URLRequest* request, | 61 static void PopulateTimingInfo(net::URLRequest* request, |
| 59 ResourceResponse* response); | 62 ResourceResponse* response); |
| 60 | 63 |
| 61 private: | 64 private: |
| (...skipping 29 matching lines...) Expand all Loading... |
| 91 URLRequestToRecordMap url_request_to_record_; | 94 URLRequestToRecordMap url_request_to_record_; |
| 92 ConnectJobToRecordMap connect_job_to_record_; | 95 ConnectJobToRecordMap connect_job_to_record_; |
| 93 SocketToRecordMap socket_to_record_; | 96 SocketToRecordMap socket_to_record_; |
| 94 uint32 last_connect_job_id_; | 97 uint32 last_connect_job_id_; |
| 95 ConnectJobRecord last_connect_job_record_; | 98 ConnectJobRecord last_connect_job_record_; |
| 96 | 99 |
| 97 DISALLOW_COPY_AND_ASSIGN(LoadTimingObserver); | 100 DISALLOW_COPY_AND_ASSIGN(LoadTimingObserver); |
| 98 }; | 101 }; |
| 99 | 102 |
| 100 #endif // CHROME_BROWSER_NET_LOAD_TIMING_OBSERVER_H_ | 103 #endif // CHROME_BROWSER_NET_LOAD_TIMING_OBSERVER_H_ |
| OLD | NEW |