OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/base/load_log_util.h" | 5 #include "net/base/load_log_util.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 | 8 |
9 namespace net { | 9 namespace net { |
10 namespace { | 10 namespace { |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 // Pass 3: Assemble the string. | 27 // Pass 3: Assemble the string. |
28 std::string result; | 28 std::string result; |
29 | 29 |
30 const int kSpacesPerIndentation = 2; | 30 const int kSpacesPerIndentation = 2; |
31 | 31 |
32 for (size_t i = 0; i < entries_.size(); ++i) { | 32 for (size_t i = 0; i < entries_.size(); ++i) { |
33 if (i > 0) | 33 if (i > 0) |
34 result += "\n"; | 34 result += "\n"; |
35 | 35 |
| 36 if (log->num_entries_truncated() > 0 && i + 1 == entries_.size()) { |
| 37 result += StringPrintf(" ... Truncated %d entries ...\n", |
| 38 log->num_entries_truncated()); |
| 39 } |
| 40 |
36 int indentation_spaces = entries_[i].indentation * kSpacesPerIndentation; | 41 int indentation_spaces = entries_[i].indentation * kSpacesPerIndentation; |
37 std::string event_str = GetEventString(i); | 42 std::string event_str = GetEventString(i); |
38 | 43 |
39 result += StringPrintf("t=%s: %s%s", | 44 result += StringPrintf("t=%s: %s%s", |
40 PadStringLeft(GetTimeString(i), max_time_width).c_str(), | 45 PadStringLeft(GetTimeString(i), max_time_width).c_str(), |
41 PadStringLeft("", indentation_spaces).c_str(), | 46 PadStringLeft("", indentation_spaces).c_str(), |
42 event_str.c_str()); | 47 event_str.c_str()); |
43 | 48 |
44 if (entries_[i].event->phase == LoadLog::PHASE_BEGIN) { | 49 if (entries_[i].event->phase == LoadLog::PHASE_BEGIN) { |
45 // Summarize how long this block lasted. | 50 // Summarize how long this block lasted. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 175 |
171 } // namespace | 176 } // namespace |
172 | 177 |
173 // static | 178 // static |
174 std::string LoadLogUtil::PrettyPrintAsEventTree(const LoadLog* log) { | 179 std::string LoadLogUtil::PrettyPrintAsEventTree(const LoadLog* log) { |
175 FormatHelper helper; | 180 FormatHelper helper; |
176 return helper.ToString(log); | 181 return helper.ToString(log); |
177 } | 182 } |
178 | 183 |
179 } // namespace net | 184 } // namespace net |
OLD | NEW |