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

Side by Side Diff: net/tools/quic/chlo_extractor.cc

Issue 2603723002: Add a new QUIC platform API for text utilities. (Closed)
Patch Set: Tests Created 3 years, 12 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
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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 "net/tools/quic/chlo_extractor.h" 5 #include "net/tools/quic/chlo_extractor.h"
6 6
7 #include "base/strings/string_util.h"
8 #include "net/quic/core/crypto/crypto_framer.h" 7 #include "net/quic/core/crypto/crypto_framer.h"
9 #include "net/quic/core/crypto/crypto_handshake_message.h" 8 #include "net/quic/core/crypto/crypto_handshake_message.h"
10 #include "net/quic/core/crypto/crypto_protocol.h" 9 #include "net/quic/core/crypto/crypto_protocol.h"
11 #include "net/quic/core/crypto/quic_decrypter.h" 10 #include "net/quic/core/crypto/quic_decrypter.h"
12 #include "net/quic/core/crypto/quic_encrypter.h" 11 #include "net/quic/core/crypto/quic_encrypter.h"
13 #include "net/quic/core/quic_framer.h" 12 #include "net/quic/core/quic_framer.h"
13 #include "net/quic/platform/api/quic_text_utils.h"
14 14
15 using base::StringPiece; 15 using base::StringPiece;
16 16
17 namespace net { 17 namespace net {
18 18
19 namespace { 19 namespace {
20 20
21 class ChloFramerVisitor : public QuicFramerVisitorInterface, 21 class ChloFramerVisitor : public QuicFramerVisitorInterface,
22 public CryptoFramerVisitorInterface { 22 public CryptoFramerVisitorInterface {
23 public: 23 public:
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 bool ChloFramerVisitor::OnUnauthenticatedHeader( 86 bool ChloFramerVisitor::OnUnauthenticatedHeader(
87 const QuicPacketHeader& header) { 87 const QuicPacketHeader& header) {
88 return true; 88 return true;
89 } 89 }
90 bool ChloFramerVisitor::OnPacketHeader(const QuicPacketHeader& header) { 90 bool ChloFramerVisitor::OnPacketHeader(const QuicPacketHeader& header) {
91 return true; 91 return true;
92 } 92 }
93 bool ChloFramerVisitor::OnStreamFrame(const QuicStreamFrame& frame) { 93 bool ChloFramerVisitor::OnStreamFrame(const QuicStreamFrame& frame) {
94 StringPiece data(frame.data_buffer, frame.data_length); 94 StringPiece data(frame.data_buffer, frame.data_length);
95 if (frame.stream_id == kCryptoStreamId && frame.offset == 0 && 95 if (frame.stream_id == kCryptoStreamId && frame.offset == 0 &&
96 base::StartsWith(data, "CHLO", base::CompareCase::INSENSITIVE_ASCII)) { 96 QuicTextUtils::StartsWith(data, "CHLO")) {
97 CryptoFramer crypto_framer; 97 CryptoFramer crypto_framer;
98 crypto_framer.set_visitor(this); 98 crypto_framer.set_visitor(this);
99 if (!crypto_framer.ProcessInput(data)) { 99 if (!crypto_framer.ProcessInput(data)) {
100 return false; 100 return false;
101 } 101 }
102 } 102 }
103 return true; 103 return true;
104 } 104 }
105 105
106 bool ChloFramerVisitor::OnAckFrame(const QuicAckFrame& frame) { 106 bool ChloFramerVisitor::OnAckFrame(const QuicAckFrame& frame) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 QuicFramer framer(versions, QuicTime::Zero(), Perspective::IS_SERVER); 164 QuicFramer framer(versions, QuicTime::Zero(), Perspective::IS_SERVER);
165 ChloFramerVisitor visitor(&framer, delegate); 165 ChloFramerVisitor visitor(&framer, delegate);
166 framer.set_visitor(&visitor); 166 framer.set_visitor(&visitor);
167 if (!framer.ProcessPacket(packet)) { 167 if (!framer.ProcessPacket(packet)) {
168 return false; 168 return false;
169 } 169 }
170 return visitor.found_chlo(); 170 return visitor.found_chlo();
171 } 171 }
172 172
173 } // namespace net 173 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698