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

Unified Diff: net/quic/core/quic_framer.cc

Issue 2740453006: Add QuicStringPiece which is actually StringPiece. (Closed)
Patch Set: fix compile error and rebase Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/core/quic_framer.h ('k') | net/quic/core/quic_framer_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/core/quic_framer.cc
diff --git a/net/quic/core/quic_framer.cc b/net/quic/core/quic_framer.cc
index 00845110bac4f11345fa7e3bb45d3f1fb55db424..977fc2f925257a33c173b3332834b980a54a36b2 100644
--- a/net/quic/core/quic_framer.cc
+++ b/net/quic/core/quic_framer.cc
@@ -26,7 +26,6 @@
#include "net/quic/platform/api/quic_map_util.h"
#include "net/quic/platform/api/quic_ptr_util.h"
-using base::StringPiece;
using std::string;
namespace net {
@@ -636,7 +635,7 @@ bool QuicFramer::ProcessPublicResetPacket(
}
// TODO(satyamshekhar): validate nonce to protect against DoS.
- StringPiece address;
+ QuicStringPiece address;
if (reset->GetStringPiece(kCADR, &address)) {
QuicSocketAddressCoder address_coder;
if (address_coder.Decode(address.data(), address.length())) {
@@ -1175,8 +1174,8 @@ bool QuicFramer::ProcessStreamFrame(QuicDataReader* reader,
return false;
}
- // TODO(ianswett): Don't use StringPiece as an intermediary.
- StringPiece data;
+ // TODO(ianswett): Don't use QuicStringPiece as an intermediary.
+ QuicStringPiece data;
if (has_data_length) {
if (!reader->ReadStringPiece16(&data)) {
set_detailed_error("Unable to read frame data.");
@@ -1384,7 +1383,7 @@ bool QuicFramer::ProcessConnectionCloseFrame(QuicDataReader* reader,
frame->error_code = static_cast<QuicErrorCode>(error_code);
- StringPiece error_details;
+ QuicStringPiece error_details;
if (!reader->ReadStringPiece16(&error_details)) {
set_detailed_error("Unable to read connection close error details.");
return false;
@@ -1415,7 +1414,7 @@ bool QuicFramer::ProcessGoAwayFrame(QuicDataReader* reader,
}
frame->last_good_stream_id = static_cast<QuicStreamId>(stream_id);
- StringPiece reason_phrase;
+ QuicStringPiece reason_phrase;
if (!reader->ReadStringPiece16(&reason_phrase)) {
set_detailed_error("Unable to read goaway reason.");
return false;
@@ -1461,7 +1460,7 @@ bool QuicFramer::ProcessPathCloseFrame(QuicDataReader* reader,
}
// static
-StringPiece QuicFramer::GetAssociatedDataFromEncryptedPacket(
+QuicStringPiece QuicFramer::GetAssociatedDataFromEncryptedPacket(
QuicVersion version,
const QuicEncryptedPacket& encrypted,
QuicConnectionIdLength connection_id_length,
@@ -1469,10 +1468,11 @@ StringPiece QuicFramer::GetAssociatedDataFromEncryptedPacket(
bool includes_diversification_nonce,
QuicPacketNumberLength packet_number_length) {
// TODO(ianswett): This is identical to QuicData::AssociatedData.
- return StringPiece(encrypted.data(),
- GetStartOfEncryptedData(
- version, connection_id_length, includes_version,
- includes_diversification_nonce, packet_number_length));
+ return QuicStringPiece(
+ encrypted.data(),
+ GetStartOfEncryptedData(version, connection_id_length, includes_version,
+ includes_diversification_nonce,
+ packet_number_length));
}
void QuicFramer::SetDecrypter(EncryptionLevel level, QuicDecrypter* decrypter) {
@@ -1513,8 +1513,8 @@ size_t QuicFramer::EncryptInPlace(EncryptionLevel level,
size_t output_length = 0;
if (!encrypter_[level]->EncryptPacket(
quic_version_, packet_number,
- StringPiece(buffer, ad_len), // Associated data
- StringPiece(buffer + ad_len, total_len - ad_len), // Plaintext
+ QuicStringPiece(buffer, ad_len), // Associated data
+ QuicStringPiece(buffer + ad_len, total_len - ad_len), // Plaintext
buffer + ad_len, // Destination buffer
&output_length, buffer_len - ad_len)) {
RaiseError(QUIC_ENCRYPTION_FAILURE);
@@ -1531,7 +1531,7 @@ size_t QuicFramer::EncryptPayload(EncryptionLevel level,
size_t buffer_len) {
DCHECK(encrypter_[level].get() != nullptr);
- StringPiece associated_data = packet.AssociatedData(quic_version_);
+ QuicStringPiece associated_data = packet.AssociatedData(quic_version_);
// Copy in the header, because the encrypter only populates the encrypted
// plaintext content.
const size_t ad_len = associated_data.length();
@@ -1572,9 +1572,9 @@ bool QuicFramer::DecryptPayload(QuicDataReader* encrypted_reader,
char* decrypted_buffer,
size_t buffer_length,
size_t* decrypted_length) {
- StringPiece encrypted = encrypted_reader->ReadRemainingPayload();
+ QuicStringPiece encrypted = encrypted_reader->ReadRemainingPayload();
DCHECK(decrypter_.get() != nullptr);
- StringPiece associated_data = GetAssociatedDataFromEncryptedPacket(
+ QuicStringPiece associated_data = GetAssociatedDataFromEncryptedPacket(
quic_version_, packet, header.public_header.connection_id_length,
header.public_header.version_flag, header.public_header.nonce != nullptr,
header.public_header.packet_number_length);
« no previous file with comments | « net/quic/core/quic_framer.h ('k') | net/quic/core/quic_framer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698