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

Side by Side Diff: net/quic/core/crypto/crypto_handshake_message.cc

Issue 2355493004: Adds CryptoHandshakeMessage::HasStringPiece method. (Closed)
Patch Set: Created 4 years, 3 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/quic/core/crypto/crypto_handshake_message.h" 5 #include "net/quic/core/crypto/crypto_handshake_message.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/stl_util.h"
9 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
11 #include "net/quic/core/crypto/crypto_framer.h" 12 #include "net/quic/core/crypto/crypto_framer.h"
12 #include "net/quic/core/crypto/crypto_protocol.h" 13 #include "net/quic/core/crypto/crypto_protocol.h"
13 #include "net/quic/core/crypto/crypto_utils.h" 14 #include "net/quic/core/crypto/crypto_utils.h"
14 #include "net/quic/core/quic_socket_address_coder.h" 15 #include "net/quic/core/quic_socket_address_coder.h"
15 #include "net/quic/core/quic_utils.h" 16 #include "net/quic/core/quic_utils.h"
16 17
17 using base::StringPiece; 18 using base::StringPiece;
18 using base::StringPrintf; 19 using base::StringPrintf;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 bool CryptoHandshakeMessage::GetStringPiece(QuicTag tag, 104 bool CryptoHandshakeMessage::GetStringPiece(QuicTag tag,
104 StringPiece* out) const { 105 StringPiece* out) const {
105 QuicTagValueMap::const_iterator it = tag_value_map_.find(tag); 106 QuicTagValueMap::const_iterator it = tag_value_map_.find(tag);
106 if (it == tag_value_map_.end()) { 107 if (it == tag_value_map_.end()) {
107 return false; 108 return false;
108 } 109 }
109 *out = it->second; 110 *out = it->second;
110 return true; 111 return true;
111 } 112 }
112 113
114 bool CryptoHandshakeMessage::HasStringPiece(QuicTag tag) const {
115 return base::ContainsKey(tag_value_map_, tag);
116 }
117
113 QuicErrorCode CryptoHandshakeMessage::GetNthValue24(QuicTag tag, 118 QuicErrorCode CryptoHandshakeMessage::GetNthValue24(QuicTag tag,
114 unsigned index, 119 unsigned index,
115 StringPiece* out) const { 120 StringPiece* out) const {
116 StringPiece value; 121 StringPiece value;
117 if (!GetStringPiece(tag, &value)) { 122 if (!GetStringPiece(tag, &value)) {
118 return QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND; 123 return QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND;
119 } 124 }
120 125
121 for (unsigned i = 0;; i++) { 126 for (unsigned i = 0;; i++) {
122 if (value.empty()) { 127 if (value.empty()) {
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 ret += "0x" + QuicUtils::HexEncode(it->second); 319 ret += "0x" + QuicUtils::HexEncode(it->second);
315 } 320 }
316 ret += "\n"; 321 ret += "\n";
317 } 322 }
318 --indent; 323 --indent;
319 ret += string(2 * indent, ' ') + ">"; 324 ret += string(2 * indent, ' ') + ">";
320 return ret; 325 return ret;
321 } 326 }
322 327
323 } // namespace net 328 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/crypto/crypto_handshake_message.h ('k') | net/quic/core/crypto/crypto_handshake_message_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698