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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/cancelable_callback.h" | 10 #include "base/cancelable_callback.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // contents of |replay_log| are undefined. | 107 // contents of |replay_log| are undefined. |
108 // | 108 // |
109 // The replay log is a text file where each line contains | 109 // The replay log is a text file where each line contains |
110 // | 110 // |
111 // timestamp_in_milliseconds domain_name | 111 // timestamp_in_milliseconds domain_name |
112 // | 112 // |
113 // The timestamp_in_milliseconds needs to be an integral delta from start of | 113 // The timestamp_in_milliseconds needs to be an integral delta from start of |
114 // resolution and is in milliseconds. domain_name is the name to be resolved. | 114 // resolution and is in milliseconds. domain_name is the name to be resolved. |
115 // | 115 // |
116 // The file should be sorted by timestamp in ascending time. | 116 // The file should be sorted by timestamp in ascending time. |
117 bool LoadReplayLog(const FilePath& file_path, ReplayLog* replay_log) { | 117 bool LoadReplayLog(const base::FilePath& file_path, ReplayLog* replay_log) { |
118 std::string original_replay_log_contents; | 118 std::string original_replay_log_contents; |
119 if (!file_util::ReadFileToString(file_path, &original_replay_log_contents)) { | 119 if (!file_util::ReadFileToString(file_path, &original_replay_log_contents)) { |
120 fprintf(stderr, "Unable to open replay file %s\n", | 120 fprintf(stderr, "Unable to open replay file %s\n", |
121 file_path.MaybeAsASCII().c_str()); | 121 file_path.MaybeAsASCII().c_str()); |
122 return false; | 122 return false; |
123 } | 123 } |
124 | 124 |
125 // Strip out \r characters for Windows files. This isn't as efficient as a | 125 // Strip out \r characters for Windows files. This isn't as efficient as a |
126 // smarter line splitter, but this particular use does not need to target | 126 // smarter line splitter, but this particular use does not need to target |
127 // efficiency. | 127 // efficiency. |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 &timeout_millis); | 322 &timeout_millis); |
323 if (parsed && timeout_millis > 0) { | 323 if (parsed && timeout_millis > 0) { |
324 timeout_ = base::TimeDelta::FromMilliseconds(timeout_millis); | 324 timeout_ = base::TimeDelta::FromMilliseconds(timeout_millis); |
325 } else { | 325 } else { |
326 fprintf(stderr, "Invalid timeout parameter\n"); | 326 fprintf(stderr, "Invalid timeout parameter\n"); |
327 return false; | 327 return false; |
328 } | 328 } |
329 } | 329 } |
330 | 330 |
331 if (parsed_command_line.HasSwitch("replay_file")) { | 331 if (parsed_command_line.HasSwitch("replay_file")) { |
332 FilePath replay_path = | 332 base::FilePath replay_path = |
333 parsed_command_line.GetSwitchValuePath("replay_file"); | 333 parsed_command_line.GetSwitchValuePath("replay_file"); |
334 if (!LoadReplayLog(replay_path, &replay_log_)) | 334 if (!LoadReplayLog(replay_path, &replay_log_)) |
335 return false; | 335 return false; |
336 } | 336 } |
337 | 337 |
338 if (parsed_command_line.HasSwitch("j")) { | 338 if (parsed_command_line.HasSwitch("j")) { |
339 int parallellism = 0; | 339 int parallellism = 0; |
340 bool parsed = base::StringToInt( | 340 bool parsed = base::StringToInt( |
341 parsed_command_line.GetSwitchValueASCII("j"), | 341 parsed_command_line.GetSwitchValueASCII("j"), |
342 ¶llellism); | 342 ¶llellism); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 } | 493 } |
494 | 494 |
495 } // empty namespace | 495 } // empty namespace |
496 | 496 |
497 } // namespace net | 497 } // namespace net |
498 | 498 |
499 int main(int argc, const char* argv[]) { | 499 int main(int argc, const char* argv[]) { |
500 net::GDig dig; | 500 net::GDig dig; |
501 return dig.Main(argc, argv); | 501 return dig.Main(argc, argv); |
502 } | 502 } |
OLD | NEW |