| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdio.h> | 5 #include <stdio.h> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 file_path.MaybeAsASCII().c_str()); | 126 file_path.MaybeAsASCII().c_str()); |
| 127 return false; | 127 return false; |
| 128 } | 128 } |
| 129 | 129 |
| 130 // Strip out \r characters for Windows files. This isn't as efficient as a | 130 // Strip out \r characters for Windows files. This isn't as efficient as a |
| 131 // smarter line splitter, but this particular use does not need to target | 131 // smarter line splitter, but this particular use does not need to target |
| 132 // efficiency. | 132 // efficiency. |
| 133 std::string replay_log_contents; | 133 std::string replay_log_contents; |
| 134 base::RemoveChars(original_replay_log_contents, "\r", &replay_log_contents); | 134 base::RemoveChars(original_replay_log_contents, "\r", &replay_log_contents); |
| 135 | 135 |
| 136 std::vector<std::string> lines; | 136 std::vector<std::string> lines = base::SplitString( |
| 137 base::SplitString(replay_log_contents, '\n', &lines); | 137 replay_log_contents, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 138 base::TimeDelta previous_delta; | 138 base::TimeDelta previous_delta; |
| 139 bool bad_parse = false; | 139 bool bad_parse = false; |
| 140 for (unsigned i = 0; i < lines.size(); ++i) { | 140 for (unsigned i = 0; i < lines.size(); ++i) { |
| 141 if (lines[i].empty()) | 141 if (lines[i].empty()) |
| 142 continue; | 142 continue; |
| 143 std::vector<std::string> time_and_name; | 143 std::vector<std::string> time_and_name = base::SplitString( |
| 144 base::SplitString(lines[i], ' ', &time_and_name); | 144 lines[i], " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 145 if (time_and_name.size() != 2) { | 145 if (time_and_name.size() != 2) { |
| 146 fprintf( | 146 fprintf( |
| 147 stderr, | 147 stderr, |
| 148 "[%s %u] replay log should have format 'timestamp domain_name\\n'\n", | 148 "[%s %u] replay log should have format 'timestamp domain_name\\n'\n", |
| 149 file_path.MaybeAsASCII().c_str(), | 149 file_path.MaybeAsASCII().c_str(), |
| 150 i + 1); | 150 i + 1); |
| 151 bad_parse = true; | 151 bad_parse = true; |
| 152 continue; | 152 continue; |
| 153 } | 153 } |
| 154 | 154 |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 } | 512 } |
| 513 | 513 |
| 514 } // empty namespace | 514 } // empty namespace |
| 515 | 515 |
| 516 } // namespace net | 516 } // namespace net |
| 517 | 517 |
| 518 int main(int argc, const char* argv[]) { | 518 int main(int argc, const char* argv[]) { |
| 519 net::GDig dig; | 519 net::GDig dig; |
| 520 return dig.Main(argc, argv); | 520 return dig.Main(argc, argv); |
| 521 } | 521 } |
| OLD | NEW |