| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "net/spdy/fuzzing/hpack_fuzz_util.h" | 10 #include "net/spdy/fuzzing/hpack_fuzz_util.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 using net::HpackFuzzUtil; | 24 using net::HpackFuzzUtil; |
| 25 using std::map; | 25 using std::map; |
| 26 using std::string; | 26 using std::string; |
| 27 | 27 |
| 28 // Generates a configurable number of header sets (using HpackFuzzUtil), and | 28 // Generates a configurable number of header sets (using HpackFuzzUtil), and |
| 29 // sequentially encodes each header set with an HpackEncoder. Encoded header | 29 // sequentially encodes each header set with an HpackEncoder. Encoded header |
| 30 // sets are written to the output file in length-prefixed blocks. | 30 // sets are written to the output file in length-prefixed blocks. |
| 31 int main(int argc, char** argv) { | 31 int main(int argc, char** argv) { |
| 32 base::AtExitManager exit_manager; | 32 base::AtExitManager exit_manager; |
| 33 | 33 |
| 34 CommandLine::Init(argc, argv); | 34 base::CommandLine::Init(argc, argv); |
| 35 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 35 const base::CommandLine& command_line = |
| 36 *base::CommandLine::ForCurrentProcess(); |
| 36 | 37 |
| 37 if (!command_line.HasSwitch(kFileToWrite) || | 38 if (!command_line.HasSwitch(kFileToWrite) || |
| 38 !command_line.HasSwitch(kExampleCount)) { | 39 !command_line.HasSwitch(kExampleCount)) { |
| 39 LOG(ERROR) << "Usage: " << argv[0] | 40 LOG(ERROR) << "Usage: " << argv[0] |
| 40 << " --" << kFileToWrite << "=/path/to/file.out" | 41 << " --" << kFileToWrite << "=/path/to/file.out" |
| 41 << " --" << kExampleCount << "=1000"; | 42 << " --" << kExampleCount << "=1000"; |
| 42 return -1; | 43 return -1; |
| 43 } | 44 } |
| 44 string file_to_write = command_line.GetSwitchValueASCII(kFileToWrite); | 45 string file_to_write = command_line.GetSwitchValueASCII(kFileToWrite); |
| 45 | 46 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 65 | 66 |
| 66 string prefix = HpackFuzzUtil::HeaderBlockPrefix(buffer.size()); | 67 string prefix = HpackFuzzUtil::HeaderBlockPrefix(buffer.size()); |
| 67 | 68 |
| 68 CHECK_LT(0, file_out.WriteAtCurrentPos(prefix.data(), prefix.size())); | 69 CHECK_LT(0, file_out.WriteAtCurrentPos(prefix.data(), prefix.size())); |
| 69 CHECK_LT(0, file_out.WriteAtCurrentPos(buffer.data(), buffer.size())); | 70 CHECK_LT(0, file_out.WriteAtCurrentPos(buffer.data(), buffer.size())); |
| 70 } | 71 } |
| 71 CHECK(file_out.Flush()); | 72 CHECK(file_out.Flush()); |
| 72 DVLOG(1) << "Generated " << example_count << " blocks."; | 73 DVLOG(1) << "Generated " << example_count << " blocks."; |
| 73 return 0; | 74 return 0; |
| 74 } | 75 } |
| OLD | NEW |