| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 content { |
| 17 struct ResourceResponse; |
| 18 } |
| 19 |
| 16 namespace net { | 20 namespace net { |
| 17 class URLRequest; | 21 class URLRequest; |
| 18 } // namespace net | 22 } // namespace net |
| 19 | 23 |
| 20 struct ResourceResponse; | |
| 21 | |
| 22 // LoadTimingObserver watches the NetLog event stream and collects the network | 24 // LoadTimingObserver watches the NetLog event stream and collects the network |
| 23 // timing information. | 25 // timing information. |
| 24 // | 26 // |
| 25 // LoadTimingObserver lives completely on the IOThread and ignores events from | 27 // LoadTimingObserver lives completely on the IOThread and ignores events from |
| 26 // other threads. It is not safe to use from other threads. | 28 // other threads. It is not safe to use from other threads. |
| 27 class LoadTimingObserver : public ChromeNetLog::ThreadSafeObserverImpl { | 29 class LoadTimingObserver : public ChromeNetLog::ThreadSafeObserverImpl { |
| 28 public: | 30 public: |
| 29 struct URLRequestRecord { | 31 struct URLRequestRecord { |
| 30 URLRequestRecord(); | 32 URLRequestRecord(); |
| 31 | 33 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 URLRequestRecord* GetURLRequestRecord(uint32 source_id); | 67 URLRequestRecord* GetURLRequestRecord(uint32 source_id); |
| 66 | 68 |
| 67 // ThreadSafeObserver implementation: | 69 // ThreadSafeObserver implementation: |
| 68 virtual void OnAddEntry(net::NetLog::EventType type, | 70 virtual void OnAddEntry(net::NetLog::EventType type, |
| 69 const base::TimeTicks& time, | 71 const base::TimeTicks& time, |
| 70 const net::NetLog::Source& source, | 72 const net::NetLog::Source& source, |
| 71 net::NetLog::EventPhase phase, | 73 net::NetLog::EventPhase phase, |
| 72 net::NetLog::EventParameters* params) OVERRIDE; | 74 net::NetLog::EventParameters* params) OVERRIDE; |
| 73 | 75 |
| 74 static void PopulateTimingInfo(net::URLRequest* request, | 76 static void PopulateTimingInfo(net::URLRequest* request, |
| 75 ResourceResponse* response); | 77 content::ResourceResponse* response); |
| 76 | 78 |
| 77 private: | 79 private: |
| 78 FRIEND_TEST_ALL_PREFIXES(LoadTimingObserverTest, | 80 FRIEND_TEST_ALL_PREFIXES(LoadTimingObserverTest, |
| 79 HTTPStreamJobRecord); | 81 HTTPStreamJobRecord); |
| 80 FRIEND_TEST_ALL_PREFIXES(LoadTimingObserverTest, | 82 FRIEND_TEST_ALL_PREFIXES(LoadTimingObserverTest, |
| 81 ConnectJobRecord); | 83 ConnectJobRecord); |
| 82 FRIEND_TEST_ALL_PREFIXES(LoadTimingObserverTest, | 84 FRIEND_TEST_ALL_PREFIXES(LoadTimingObserverTest, |
| 83 SocketRecord); | 85 SocketRecord); |
| 84 | 86 |
| 85 void OnAddURLRequestEntry(net::NetLog::EventType type, | 87 void OnAddURLRequestEntry(net::NetLog::EventType type, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 HTTPStreamJobToRecordMap http_stream_job_to_record_; | 119 HTTPStreamJobToRecordMap http_stream_job_to_record_; |
| 118 ConnectJobToRecordMap connect_job_to_record_; | 120 ConnectJobToRecordMap connect_job_to_record_; |
| 119 SocketToRecordMap socket_to_record_; | 121 SocketToRecordMap socket_to_record_; |
| 120 uint32 last_connect_job_id_; | 122 uint32 last_connect_job_id_; |
| 121 ConnectJobRecord last_connect_job_record_; | 123 ConnectJobRecord last_connect_job_record_; |
| 122 | 124 |
| 123 DISALLOW_COPY_AND_ASSIGN(LoadTimingObserver); | 125 DISALLOW_COPY_AND_ASSIGN(LoadTimingObserver); |
| 124 }; | 126 }; |
| 125 | 127 |
| 126 #endif // CHROME_BROWSER_NET_LOAD_TIMING_OBSERVER_H_ | 128 #endif // CHROME_BROWSER_NET_LOAD_TIMING_OBSERVER_H_ |
| OLD | NEW |