Index: net/spdy/hpack_encoder.cc |
diff --git a/net/spdy/hpack_encoder.cc b/net/spdy/hpack_encoder.cc |
index 480b719277f008df41198f0722971d40602f9d82..c841907ec1ec92390ce33471fc2bafeebff0e877 100644 |
--- a/net/spdy/hpack_encoder.cc |
+++ b/net/spdy/hpack_encoder.cc |
@@ -33,9 +33,11 @@ HpackEncoder::HpackEncoder(const HpackHuffmanTable& table) |
allow_huffman_compression_(true), |
huffman_table_(table), |
char_counts_(NULL), |
- total_char_counts_(NULL) {} |
+ total_char_counts_(NULL) { |
+} |
-HpackEncoder::~HpackEncoder() {} |
+HpackEncoder::~HpackEncoder() { |
+} |
bool HpackEncoder::EncodeHeaderSet(const std::map<string, string>& header_set, |
string* output) { |
@@ -43,7 +45,8 @@ bool HpackEncoder::EncodeHeaderSet(const std::map<string, string>& header_set, |
// header table's reference set. They must be explicitly emitted. |
Representations explicit_set(DetermineEncodingDelta(header_set)); |
for (Representations::const_iterator it = explicit_set.begin(); |
- it != explicit_set.end(); ++it) { |
+ it != explicit_set.end(); |
+ ++it) { |
// Try to find an exact match. Note that dynamic entries are preferred |
// by the header table index. |
HpackEntry* entry = header_table_.GetByNameAndValue(it->first, it->second); |
@@ -81,7 +84,7 @@ bool HpackEncoder::EncodeHeaderSet(const std::map<string, string>& header_set, |
} |
// Walk the reference set, toggling off as needed and clearing encoding state. |
for (HpackEntry::OrderedSet::const_iterator it = |
- header_table_.reference_set().begin(); |
+ header_table_.reference_set().begin(); |
it != header_table_.reference_set().end();) { |
HpackEntry* entry = *(it++); // Step to prevent invalidation. |
CHECK_NE(kNoState, entry->state()); |
@@ -99,10 +102,10 @@ bool HpackEncoder::EncodeHeaderSet(const std::map<string, string>& header_set, |
bool HpackEncoder::EncodeHeaderSetWithoutCompression( |
const std::map<string, string>& header_set, |
string* output) { |
- |
allow_huffman_compression_ = false; |
for (std::map<string, string>::const_iterator it = header_set.begin(); |
- it != header_set.end(); ++it) { |
+ it != header_set.end(); |
+ ++it) { |
// Note that cookies are not crumbled in this case. |
EmitNonIndexedLiteral(*it); |
} |
@@ -128,8 +131,8 @@ void HpackEncoder::EmitStaticIndex(HpackEntry* entry) { |
output_stream_.AppendPrefix(kIndexedOpcode); |
output_stream_.AppendUint32(entry->Index()); |
- HpackEntry* new_entry = header_table_.TryAddEntry(entry->name(), |
- entry->value()); |
+ HpackEntry* new_entry = |
+ header_table_.TryAddEntry(entry->name(), entry->value()); |
if (new_entry) { |
// This is a static entry: no need to pin. |
header_table_.Toggle(new_entry); |
@@ -141,16 +144,15 @@ void HpackEncoder::EmitIndexedLiteral(const Representation& representation) { |
output_stream_.AppendPrefix(kLiteralIncrementalIndexOpcode); |
EmitLiteral(representation); |
- HpackEntry* new_entry = header_table_.TryAddEntry(representation.first, |
- representation.second); |
+ HpackEntry* new_entry = |
+ header_table_.TryAddEntry(representation.first, representation.second); |
if (new_entry) { |
header_table_.Toggle(new_entry); |
new_entry->set_state(kReferencedThisEncoding); |
} |
} |
-void HpackEncoder::EmitNonIndexedLiteral( |
- const Representation& representation) { |
+void HpackEncoder::EmitNonIndexedLiteral(const Representation& representation) { |
output_stream_.AppendPrefix(kLiteralNoIndexOpcode); |
output_stream_.AppendUint32(0); |
EmitString(representation.first); |
@@ -169,8 +171,9 @@ void HpackEncoder::EmitLiteral(const Representation& representation) { |
} |
void HpackEncoder::EmitString(StringPiece str) { |
- size_t encoded_size = (!allow_huffman_compression_ ? str.size() |
- : huffman_table_.EncodedSize(str)); |
+ size_t encoded_size = |
+ (!allow_huffman_compression_ ? str.size() |
+ : huffman_table_.EncodedSize(str)); |
if (encoded_size < str.size()) { |
output_stream_.AppendPrefix(kStringLiteralHuffmanEncoded); |
output_stream_.AppendUint32(encoded_size); |
@@ -189,14 +192,15 @@ HpackEncoder::Representations HpackEncoder::DetermineEncodingDelta( |
// Flatten & crumble headers into an ordered list of representations. |
Representations full_set; |
for (std::map<string, string>::const_iterator it = header_set.begin(); |
- it != header_set.end(); ++it) { |
+ it != header_set.end(); |
+ ++it) { |
if (it->first == "cookie") { |
// |CookieToCrumbs()| produces ordered crumbs. |
CookieToCrumbs(*it, &full_set); |
} else { |
// Note std::map guarantees representations are ordered. |
- full_set.push_back(make_pair( |
- StringPiece(it->first), StringPiece(it->second))); |
+ full_set.push_back( |
+ make_pair(StringPiece(it->first), StringPiece(it->second))); |
} |
} |
// Perform a linear merge of ordered representations with the (also ordered) |
@@ -267,14 +271,11 @@ void HpackEncoder::CookieToCrumbs(const Representation& cookie, |
size_t end = cookie.second.find(";", pos); |
if (end == StringPiece::npos) { |
- out->push_back(make_pair( |
- cookie.first, |
- cookie.second.substr(pos))); |
+ out->push_back(make_pair(cookie.first, cookie.second.substr(pos))); |
break; |
} |
- out->push_back(make_pair( |
- cookie.first, |
- cookie.second.substr(pos, end - pos))); |
+ out->push_back( |
+ make_pair(cookie.first, cookie.second.substr(pos, end - pos))); |
// Consume next space if present. |
pos = end + 1; |
@@ -284,8 +285,7 @@ void HpackEncoder::CookieToCrumbs(const Representation& cookie, |
} |
// Sort crumbs and remove duplicates. |
std::sort(out->begin() + prior_size, out->end()); |
- out->erase(std::unique(out->begin() + prior_size, out->end()), |
- out->end()); |
+ out->erase(std::unique(out->begin() + prior_size, out->end()), out->end()); |
} |
} // namespace net |