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

Side by Side Diff: net/spdy/spdy_framer_test.cc

Issue 910393003: Rename WriteString to WriteStringPiece16 in SpdyFrameBuilder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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/spdy_framer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <algorithm> 5 #include <algorithm>
6 #include <iostream> 6 #include <iostream>
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 frame.WriteUInt32(3); // stream_id 864 frame.WriteUInt32(3); // stream_id
865 frame.WriteUInt32(0); // associated stream id 865 frame.WriteUInt32(0); // associated stream id
866 frame.WriteUInt16(0); // Priority. 866 frame.WriteUInt16(0); // Priority.
867 } else { 867 } else {
868 frame.BeginNewFrame(framer, HEADERS, HEADERS_FLAG_PRIORITY, 3); 868 frame.BeginNewFrame(framer, HEADERS, HEADERS_FLAG_PRIORITY, 3);
869 frame.WriteUInt32(framer.GetHighestPriority()); 869 frame.WriteUInt32(framer.GetHighestPriority());
870 } 870 }
871 871
872 if (IsSpdy2()) { 872 if (IsSpdy2()) {
873 frame.WriteUInt16(2); // Number of headers. 873 frame.WriteUInt16(2); // Number of headers.
874 frame.WriteString("name"); 874 frame.WriteStringPiece16("name");
875 frame.WriteString("value1"); 875 frame.WriteStringPiece16("value1");
876 frame.WriteString("name"); 876 frame.WriteStringPiece16("name");
877 frame.WriteString("value2"); 877 frame.WriteStringPiece16("value2");
878 } else { 878 } else {
879 frame.WriteUInt32(2); // Number of headers. 879 frame.WriteUInt32(2); // Number of headers.
880 frame.WriteStringPiece32("name"); 880 frame.WriteStringPiece32("name");
881 frame.WriteStringPiece32("value1"); 881 frame.WriteStringPiece32("value1");
882 frame.WriteStringPiece32("name"); 882 frame.WriteStringPiece32("name");
883 frame.WriteStringPiece32("value2"); 883 frame.WriteStringPiece32("value2");
884 } 884 }
885 // write the length 885 // write the length
886 frame.RewriteLength(framer); 886 frame.RewriteLength(framer);
887 887
(...skipping 22 matching lines...) Expand all
910 HEADERS, 910 HEADERS,
911 HEADERS_FLAG_PRIORITY | HEADERS_FLAG_END_HEADERS, 911 HEADERS_FLAG_PRIORITY | HEADERS_FLAG_END_HEADERS,
912 3); 912 3);
913 frame.WriteUInt32(0); // Priority exclusivity and dependent stream. 913 frame.WriteUInt32(0); // Priority exclusivity and dependent stream.
914 frame.WriteUInt8(255); // Priority weight. 914 frame.WriteUInt8(255); // Priority weight.
915 } 915 }
916 916
917 string value("value1\0value2", 13); 917 string value("value1\0value2", 13);
918 if (IsSpdy2()) { 918 if (IsSpdy2()) {
919 frame.WriteUInt16(1); // Number of headers. 919 frame.WriteUInt16(1); // Number of headers.
920 frame.WriteString("name"); 920 frame.WriteStringPiece16("name");
921 frame.WriteString(value); 921 frame.WriteStringPiece16(value);
922 } else if (spdy_version_ > SPDY3) { 922 } else if (spdy_version_ > SPDY3) {
923 // TODO(jgraettinger): If this pattern appears again, move to test class. 923 // TODO(jgraettinger): If this pattern appears again, move to test class.
924 std::map<string, string> header_set; 924 std::map<string, string> header_set;
925 header_set["name"] = value; 925 header_set["name"] = value;
926 string buffer; 926 string buffer;
927 HpackEncoder encoder(ObtainHpackHuffmanTable()); 927 HpackEncoder encoder(ObtainHpackHuffmanTable());
928 encoder.EncodeHeaderSetWithoutCompression(header_set, &buffer); 928 encoder.EncodeHeaderSetWithoutCompression(header_set, &buffer);
929 frame.WriteBytes(&buffer[0], buffer.size()); 929 frame.WriteBytes(&buffer[0], buffer.size());
930 } else { 930 } else {
931 frame.WriteUInt32(1); // Number of headers. 931 frame.WriteUInt32(1); // Number of headers.
(...skipping 5003 matching lines...) Expand 10 before | Expand all | Expand 10 after
5935 TestSpdyVisitor visitor(spdy_version_); 5935 TestSpdyVisitor visitor(spdy_version_);
5936 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); 5936 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData));
5937 5937
5938 EXPECT_EQ(SpdyFramer::SPDY_ERROR, visitor.framer_.state()); 5938 EXPECT_EQ(SpdyFramer::SPDY_ERROR, visitor.framer_.state());
5939 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, 5939 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME,
5940 visitor.framer_.error_code()) 5940 visitor.framer_.error_code())
5941 << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code()); 5941 << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code());
5942 } 5942 }
5943 5943
5944 } // namespace net 5944 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_framer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698