| 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 #include "chrome/browser/net/load_timing_observer.h" | 5 #include "chrome/browser/net/load_timing_observer.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "base/string_util.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| 11 #include "content/browser/browser_thread.h" | 11 #include "content/browser/browser_thread.h" |
| 12 #include "net/base/load_flags.h" | 12 #include "net/base/load_flags.h" |
| 13 #include "net/url_request/url_request_netlog_params.h" | 13 #include "net/url_request/url_request_netlog_params.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 using net::NetLog; | 18 using net::NetLog; |
| 19 using base::TimeDelta; | 19 using base::TimeDelta; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 43 NetLog::EventType type, | 43 NetLog::EventType type, |
| 44 NetLog::EventParameters* params) { | 44 NetLog::EventParameters* params) { |
| 45 observer.OnAddEntry(type, current_time, source, NetLog::PHASE_END, params); | 45 observer.OnAddEntry(type, current_time, source, NetLog::PHASE_END, params); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void AddStartURLRequestEntries(LoadTimingObserver& observer, | 48 void AddStartURLRequestEntries(LoadTimingObserver& observer, |
| 49 uint32 id, | 49 uint32 id, |
| 50 bool request_timing) { | 50 bool request_timing) { |
| 51 scoped_refptr<net::URLRequestStartEventParameters> params( | 51 scoped_refptr<net::URLRequestStartEventParameters> params( |
| 52 new net::URLRequestStartEventParameters( | 52 new net::URLRequestStartEventParameters( |
| 53 GURL(StringPrintf("http://req%d", id)), | 53 GURL(base::StringPrintf("http://req%d", id)), |
| 54 "GET", | 54 "GET", |
| 55 request_timing ? net::LOAD_ENABLE_LOAD_TIMING : 0, | 55 request_timing ? net::LOAD_ENABLE_LOAD_TIMING : 0, |
| 56 net::LOW)); | 56 net::LOW)); |
| 57 NetLog::Source source(NetLog::SOURCE_URL_REQUEST, id); | 57 NetLog::Source source(NetLog::SOURCE_URL_REQUEST, id); |
| 58 AddStartEntry(observer, source, NetLog::TYPE_REQUEST_ALIVE, NULL); | 58 AddStartEntry(observer, source, NetLog::TYPE_REQUEST_ALIVE, NULL); |
| 59 AddStartEntry(observer, | 59 AddStartEntry(observer, |
| 60 source, | 60 source, |
| 61 NetLog::TYPE_URL_REQUEST_START_JOB, | 61 NetLog::TYPE_URL_REQUEST_START_JOB, |
| 62 params.get()); | 62 params.get()); |
| 63 } | 63 } |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 AddStartHTTPStreamJobEntries(observer, 2); | 393 AddStartHTTPStreamJobEntries(observer, 2); |
| 394 | 394 |
| 395 BindHTTPStreamJobToSocket(observer, http_stream_job_source, socket_source); | 395 BindHTTPStreamJobToSocket(observer, http_stream_job_source, socket_source); |
| 396 BindURLRequestToHTTPStreamJob(observer, source, http_stream_job_source); | 396 BindURLRequestToHTTPStreamJob(observer, source, http_stream_job_source); |
| 397 | 397 |
| 398 LoadTimingObserver::URLRequestRecord* record = | 398 LoadTimingObserver::URLRequestRecord* record = |
| 399 observer.GetURLRequestRecord(0); | 399 observer.GetURLRequestRecord(0); |
| 400 ASSERT_EQ(1000, record->timing.ssl_start); | 400 ASSERT_EQ(1000, record->timing.ssl_start); |
| 401 ASSERT_EQ(3000, record->timing.ssl_end); | 401 ASSERT_EQ(3000, record->timing.ssl_end); |
| 402 } | 402 } |
| OLD | NEW |