summaryrefslogtreecommitdiffstats
path: root/net/url_request/url_request_job_metrics.cc
blob: 87ef205d28e8e1cdf21a748ed9547b7a51c520f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/url_request/url_request_job_metrics.h"

#include "base/basictypes.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"

namespace net {

URLRequestJobMetrics::URLRequestJobMetrics()
    : total_bytes_read_(0),
      number_of_read_IO_(0),
      success_(false) {
}

URLRequestJobMetrics::~URLRequestJobMetrics() {}

void URLRequestJobMetrics::AppendText(std::wstring* text) {
  if (!text)
    return;

  text->append(L"job url = ");
  text->append(UTF8ToWide(original_url_->spec()));

  if (url_.get()) {
    text->append(L"; redirected url = ");
    text->append(UTF8ToWide(url_->spec()));
  }

  base::TimeDelta elapsed = end_time_ - start_time_;
  base::StringAppendF(text,
      L"; total bytes read = %ld; read calls = %d; time = %lld ms;",
      static_cast<long>(total_bytes_read_),
      number_of_read_IO_, elapsed.InMilliseconds());

  if (success_) {
    text->append(L" success.");
  } else {
    text->append(L" fail.");
  }
}

}  // namespace net