| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // hrseolv is a command line utility which runs the HostResolver in the | 5 // hrseolv is a command line utility which runs the HostResolver in the |
| 6 // Chromium network stack. | 6 // Chromium network stack. |
| 7 // | 7 // |
| 8 // The user specifies the hosts to lookup and when to look them up. | 8 // The user specifies the hosts to lookup and when to look them up. |
| 9 // The hosts must be specified in order. | 9 // The hosts must be specified in order. |
| 10 // The hosts can be contained in a file or on the command line. If no | 10 // The hosts can be contained in a file or on the command line. If no |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 bool ReadHostsAndTimesFromFile(const FilePath& path, | 375 bool ReadHostsAndTimesFromFile(const FilePath& path, |
| 376 std::vector<HostAndTime>* hosts_and_times) { | 376 std::vector<HostAndTime>* hosts_and_times) { |
| 377 // TODO(cbentzel): There are smarter and safer ways to do this. | 377 // TODO(cbentzel): There are smarter and safer ways to do this. |
| 378 std::string file_contents; | 378 std::string file_contents; |
| 379 if (!file_util::ReadFileToString(path, &file_contents)) { | 379 if (!file_util::ReadFileToString(path, &file_contents)) { |
| 380 return false; | 380 return false; |
| 381 } | 381 } |
| 382 std::vector<std::string> lines; | 382 std::vector<std::string> lines; |
| 383 // TODO(cbentzel): This should probably handle CRLF-style separators as well. | 383 // TODO(cbentzel): This should probably handle CRLF-style separators as well. |
| 384 // Maybe it's worth adding functionality like this to base tools. | 384 // Maybe it's worth adding functionality like this to base tools. |
| 385 SplitString(file_contents, '\n', &lines); | 385 base::SplitString(file_contents, '\n', &lines); |
| 386 std::vector<std::string>::const_iterator line_end = lines.end(); | 386 std::vector<std::string>::const_iterator line_end = lines.end(); |
| 387 int previous_timestamp = 0; | 387 int previous_timestamp = 0; |
| 388 for (std::vector<std::string>::const_iterator it = lines.begin(); | 388 for (std::vector<std::string>::const_iterator it = lines.begin(); |
| 389 it != line_end; | 389 it != line_end; |
| 390 ++it) { | 390 ++it) { |
| 391 std::vector<std::string> tokens; | 391 std::vector<std::string> tokens; |
| 392 SplitStringAlongWhitespace(*it, &tokens); | 392 SplitStringAlongWhitespace(*it, &tokens); |
| 393 switch (tokens.size()) { | 393 switch (tokens.size()) { |
| 394 case 0: | 394 case 0: |
| 395 // Unexpected, but keep going. | 395 // Unexpected, but keep going. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 base::TimeDelta::FromMilliseconds(options.cache_ttl), | 451 base::TimeDelta::FromMilliseconds(options.cache_ttl), |
| 452 base::TimeDelta::FromSeconds(0)); | 452 base::TimeDelta::FromSeconds(0)); |
| 453 | 453 |
| 454 net::HostResolverImpl host_resolver(NULL, cache, 100u, NULL); | 454 net::HostResolverImpl host_resolver(NULL, cache, 100u, NULL); |
| 455 ResolverInvoker invoker(&host_resolver); | 455 ResolverInvoker invoker(&host_resolver); |
| 456 invoker.ResolveAll(hosts_and_times, options.async); | 456 invoker.ResolveAll(hosts_and_times, options.async); |
| 457 | 457 |
| 458 CommandLine::Reset(); | 458 CommandLine::Reset(); |
| 459 return 0; | 459 return 0; |
| 460 } | 460 } |
| OLD | NEW |