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

Side by Side Diff: net/websockets/websocket_basic_handshake_stream.cc

Issue 1897033002: Reland 'Convert //net and //chromecast to std::unordered_*' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix TestDownloadRequestHandler Created 4 years, 8 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/url_request/url_request_filter.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/websockets/websocket_basic_handshake_stream.h" 5 #include "net/websockets/websocket_basic_handshake_stream.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <iterator> 9 #include <iterator>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <unordered_set>
12 #include <utility> 13 #include <utility>
13 #include <vector> 14 #include <vector>
14 15
15 #include "base/base64.h" 16 #include "base/base64.h"
16 #include "base/bind.h" 17 #include "base/bind.h"
17 #include "base/compiler_specific.h" 18 #include "base/compiler_specific.h"
18 #include "base/containers/hash_tables.h"
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/metrics/histogram_macros.h" 20 #include "base/metrics/histogram_macros.h"
21 #include "base/metrics/sparse_histogram.h" 21 #include "base/metrics/sparse_histogram.h"
22 #include "base/stl_util.h" 22 #include "base/stl_util.h"
23 #include "base/strings/string_number_conversions.h" 23 #include "base/strings/string_number_conversions.h"
24 #include "base/strings/string_piece.h" 24 #include "base/strings/string_piece.h"
25 #include "base/strings/string_util.h" 25 #include "base/strings/string_util.h"
26 #include "base/strings/stringprintf.h" 26 #include "base/strings/stringprintf.h"
27 #include "base/time/time.h" 27 #include "base/time/time.h"
28 #include "crypto/random.h" 28 #include "crypto/random.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 return true; 180 return true;
181 } 181 }
182 182
183 bool ValidateSubProtocol( 183 bool ValidateSubProtocol(
184 const HttpResponseHeaders* headers, 184 const HttpResponseHeaders* headers,
185 const std::vector<std::string>& requested_sub_protocols, 185 const std::vector<std::string>& requested_sub_protocols,
186 std::string* sub_protocol, 186 std::string* sub_protocol,
187 std::string* failure_message) { 187 std::string* failure_message) {
188 size_t iter = 0; 188 size_t iter = 0;
189 std::string value; 189 std::string value;
190 base::hash_set<std::string> requested_set(requested_sub_protocols.begin(), 190 std::unordered_set<std::string> requested_set(requested_sub_protocols.begin(),
191 requested_sub_protocols.end()); 191 requested_sub_protocols.end());
192 int count = 0; 192 int count = 0;
193 bool has_multiple_protocols = false; 193 bool has_multiple_protocols = false;
194 bool has_invalid_protocol = false; 194 bool has_invalid_protocol = false;
195 195
196 while (!has_invalid_protocol || !has_multiple_protocols) { 196 while (!has_invalid_protocol || !has_multiple_protocols) {
197 std::string temp_value; 197 std::string temp_value;
198 if (!headers->EnumerateHeader(&iter, websockets::kSecWebSocketProtocol, 198 if (!headers->EnumerateHeader(&iter, websockets::kSecWebSocketProtocol,
199 &temp_value)) 199 &temp_value))
200 break; 200 break;
201 value = temp_value; 201 value = temp_value;
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 set_failure_message("Error during WebSocket handshake: " + failure_message); 595 set_failure_message("Error during WebSocket handshake: " + failure_message);
596 return ERR_INVALID_RESPONSE; 596 return ERR_INVALID_RESPONSE;
597 } 597 }
598 598
599 void WebSocketBasicHandshakeStream::set_failure_message( 599 void WebSocketBasicHandshakeStream::set_failure_message(
600 const std::string& failure_message) { 600 const std::string& failure_message) {
601 *failure_message_ = failure_message; 601 *failure_message_ = failure_message;
602 } 602 }
603 603
604 } // namespace net 604 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_filter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698