| 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 std::vector<std::string> lines; | 383 std::vector<std::string> lines; |
| 384 // TODO(cbentzel): This should probably handle CRLF-style separators as well. | 384 // TODO(cbentzel): This should probably handle CRLF-style separators as well. |
| 385 // Maybe it's worth adding functionality like this to base tools. | 385 // Maybe it's worth adding functionality like this to base tools. |
| 386 base::SplitString(file_contents, '\n', &lines); | 386 base::SplitString(file_contents, '\n', &lines); |
| 387 std::vector<std::string>::const_iterator line_end = lines.end(); | 387 std::vector<std::string>::const_iterator line_end = lines.end(); |
| 388 int previous_timestamp = 0; | 388 int previous_timestamp = 0; |
| 389 for (std::vector<std::string>::const_iterator it = lines.begin(); | 389 for (std::vector<std::string>::const_iterator it = lines.begin(); |
| 390 it != line_end; | 390 it != line_end; |
| 391 ++it) { | 391 ++it) { |
| 392 std::vector<std::string> tokens; | 392 std::vector<std::string> tokens; |
| 393 SplitStringAlongWhitespace(*it, &tokens); | 393 base::SplitStringAlongWhitespace(*it, &tokens); |
| 394 switch (tokens.size()) { | 394 switch (tokens.size()) { |
| 395 case 0: | 395 case 0: |
| 396 // Unexpected, but keep going. | 396 // Unexpected, but keep going. |
| 397 break; | 397 break; |
| 398 case 1: { | 398 case 1: { |
| 399 HostAndTime host_and_time = {tokens[0], previous_timestamp}; | 399 HostAndTime host_and_time = {tokens[0], previous_timestamp}; |
| 400 hosts_and_times->push_back(host_and_time); | 400 hosts_and_times->push_back(host_and_time); |
| 401 break; | 401 break; |
| 402 } | 402 } |
| 403 case 2: { | 403 case 2: { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 base::TimeDelta::FromMilliseconds(options.cache_ttl), | 452 base::TimeDelta::FromMilliseconds(options.cache_ttl), |
| 453 base::TimeDelta::FromSeconds(0)); | 453 base::TimeDelta::FromSeconds(0)); |
| 454 | 454 |
| 455 net::HostResolverImpl host_resolver(NULL, cache, 100u, NULL); | 455 net::HostResolverImpl host_resolver(NULL, cache, 100u, NULL); |
| 456 ResolverInvoker invoker(&host_resolver); | 456 ResolverInvoker invoker(&host_resolver); |
| 457 invoker.ResolveAll(hosts_and_times, options.async); | 457 invoker.ResolveAll(hosts_and_times, options.async); |
| 458 | 458 |
| 459 CommandLine::Reset(); | 459 CommandLine::Reset(); |
| 460 return 0; | 460 return 0; |
| 461 } | 461 } |
| OLD | NEW |