Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: net/spdy/fuzzing/hpack_example_generator.cc

Issue 1263803002: Replace SpdyNameValueBlock typedef with SpdyHeaderBlock. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/spdy/buffered_spdy_framer.cc ('k') | net/spdy/fuzzing/hpack_fuzz_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/files/file.h" 7 #include "base/files/file.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.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"
11 #include "net/spdy/hpack_constants.h" 11 #include "net/spdy/hpack_constants.h"
12 #include "net/spdy/hpack_encoder.h" 12 #include "net/spdy/hpack_encoder.h"
13 #include "net/spdy/spdy_protocol.h"
13 14
14 namespace { 15 namespace {
15 16
16 // Target file for generated HPACK header sets. 17 // Target file for generated HPACK header sets.
17 const char kFileToWrite[] = "file-to-write"; 18 const char kFileToWrite[] = "file-to-write";
18 19
19 // Number of header sets to generate. 20 // Number of header sets to generate.
20 const char kExampleCount[] = "example-count"; 21 const char kExampleCount[] = "example-count";
21 22
22 } // namespace 23 } // namespace
(...skipping 28 matching lines...) Expand all
51 DVLOG(1) << "Writing output to " << file_to_write; 52 DVLOG(1) << "Writing output to " << file_to_write;
52 base::File file_out(base::FilePath::FromUTF8Unsafe(file_to_write), 53 base::File file_out(base::FilePath::FromUTF8Unsafe(file_to_write),
53 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); 54 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE);
54 CHECK(file_out.IsValid()) << file_out.error_details(); 55 CHECK(file_out.IsValid()) << file_out.error_details();
55 56
56 HpackFuzzUtil::GeneratorContext context; 57 HpackFuzzUtil::GeneratorContext context;
57 HpackFuzzUtil::InitializeGeneratorContext(&context); 58 HpackFuzzUtil::InitializeGeneratorContext(&context);
58 net::HpackEncoder encoder(net::ObtainHpackHuffmanTable()); 59 net::HpackEncoder encoder(net::ObtainHpackHuffmanTable());
59 60
60 for (int i = 0; i != example_count; ++i) { 61 for (int i = 0; i != example_count; ++i) {
61 map<string, string> headers = 62 net::SpdyHeaderBlock headers =
62 HpackFuzzUtil::NextGeneratedHeaderSet(&context); 63 HpackFuzzUtil::NextGeneratedHeaderSet(&context);
63 64
64 string buffer; 65 string buffer;
65 CHECK(encoder.EncodeHeaderSet(headers, &buffer)); 66 CHECK(encoder.EncodeHeaderSet(headers, &buffer));
66 67
67 string prefix = HpackFuzzUtil::HeaderBlockPrefix(buffer.size()); 68 string prefix = HpackFuzzUtil::HeaderBlockPrefix(buffer.size());
68 69
69 CHECK_LT(0, file_out.WriteAtCurrentPos(prefix.data(), prefix.size())); 70 CHECK_LT(0, file_out.WriteAtCurrentPos(prefix.data(), prefix.size()));
70 CHECK_LT(0, file_out.WriteAtCurrentPos(buffer.data(), buffer.size())); 71 CHECK_LT(0, file_out.WriteAtCurrentPos(buffer.data(), buffer.size()));
71 } 72 }
72 CHECK(file_out.Flush()); 73 CHECK(file_out.Flush());
73 DVLOG(1) << "Generated " << example_count << " blocks."; 74 DVLOG(1) << "Generated " << example_count << " blocks.";
74 return 0; 75 return 0;
75 } 76 }
OLDNEW
« no previous file with comments | « net/spdy/buffered_spdy_framer.cc ('k') | net/spdy/fuzzing/hpack_fuzz_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698