| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "net/url_request/url_request_job_metrics.h" | 5 #include "net/url_request/url_request_job_metrics.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 | 10 |
| 11 using base::TimeDelta; | 11 using base::TimeDelta; |
| 12 | 12 |
| 13 URLRequestJobMetrics::URLRequestJobMetrics() |
| 14 : total_bytes_read_(0), |
| 15 number_of_read_IO_(0), |
| 16 success_(false) { |
| 17 } |
| 18 |
| 19 URLRequestJobMetrics::~URLRequestJobMetrics() {} |
| 20 |
| 13 void URLRequestJobMetrics::AppendText(std::wstring* text) { | 21 void URLRequestJobMetrics::AppendText(std::wstring* text) { |
| 14 if (!text) | 22 if (!text) |
| 15 return; | 23 return; |
| 16 | 24 |
| 17 text->append(L"job url = "); | 25 text->append(L"job url = "); |
| 18 text->append(UTF8ToWide(original_url_->spec())); | 26 text->append(UTF8ToWide(original_url_->spec())); |
| 19 | 27 |
| 20 if (url_.get()) { | 28 if (url_.get()) { |
| 21 text->append(L"; redirected url = "); | 29 text->append(L"; redirected url = "); |
| 22 text->append(UTF8ToWide(url_->spec())); | 30 text->append(UTF8ToWide(url_->spec())); |
| 23 } | 31 } |
| 24 | 32 |
| 25 TimeDelta elapsed = end_time_ - start_time_; | 33 TimeDelta elapsed = end_time_ - start_time_; |
| 26 StringAppendF(text, | 34 StringAppendF(text, |
| 27 L"; total bytes read = %ld; read calls = %d; time = %lld ms;", | 35 L"; total bytes read = %ld; read calls = %d; time = %lld ms;", |
| 28 static_cast<long>(total_bytes_read_), | 36 static_cast<long>(total_bytes_read_), |
| 29 number_of_read_IO_, elapsed.InMilliseconds()); | 37 number_of_read_IO_, elapsed.InMilliseconds()); |
| 30 | 38 |
| 31 if (success_) { | 39 if (success_) { |
| 32 text->append(L" success."); | 40 text->append(L" success."); |
| 33 } else { | 41 } else { |
| 34 text->append(L" fail."); | 42 text->append(L" fail."); |
| 35 } | 43 } |
| 36 } | 44 } |
| OLD | NEW |