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

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

Issue 3056029: Move the number conversions from string_util to a new file.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « net/url_request/url_request_unittest.cc ('k') | tools/memory_watcher/call_stack.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_handshake.h" 5 #include "net/websockets/websocket_handshake.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h"
10 #include "base/md5.h" 11 #include "base/md5.h"
11 #include "base/rand_util.h" 12 #include "base/rand_util.h"
12 #include "base/ref_counted.h" 13 #include "base/ref_counted.h"
14 #include "base/string_number_conversions.h"
13 #include "base/string_util.h" 15 #include "base/string_util.h"
14 #include "net/http/http_response_headers.h" 16 #include "net/http/http_response_headers.h"
15 #include "net/http/http_util.h" 17 #include "net/http/http_util.h"
16 18
17 namespace net { 19 namespace net {
18 20
19 const int WebSocketHandshake::kWebSocketPort = 80; 21 const int WebSocketHandshake::kWebSocketPort = 80;
20 const int WebSocketHandshake::kSecureWebSocketPort = 443; 22 const int WebSocketHandshake::kSecureWebSocketPort = 443;
21 23
22 WebSocketHandshake::WebSocketHandshake( 24 WebSocketHandshake::WebSocketHandshake(
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // url_.host() is expected to be encoded in punnycode here. 129 // url_.host() is expected to be encoded in punnycode here.
128 std::string host = StringToLowerASCII(url_.host()); 130 std::string host = StringToLowerASCII(url_.host());
129 if (url_.has_port()) { 131 if (url_.has_port()) {
130 bool secure = is_secure(); 132 bool secure = is_secure();
131 int port = url_.EffectiveIntPort(); 133 int port = url_.EffectiveIntPort();
132 if ((!secure && 134 if ((!secure &&
133 port != kWebSocketPort && port != url_parse::PORT_UNSPECIFIED) || 135 port != kWebSocketPort && port != url_parse::PORT_UNSPECIFIED) ||
134 (secure && 136 (secure &&
135 port != kSecureWebSocketPort && port != url_parse::PORT_UNSPECIFIED)) { 137 port != kSecureWebSocketPort && port != url_parse::PORT_UNSPECIFIED)) {
136 host += ":"; 138 host += ":";
137 host += IntToString(port); 139 host += base::IntToString(port);
138 } 140 }
139 } 141 }
140 return host; 142 return host;
141 } 143 }
142 144
143 std::string WebSocketHandshake::GetOriginFieldValue() const { 145 std::string WebSocketHandshake::GetOriginFieldValue() const {
144 // It's OK to lowercase the origin as the Origin header does not contain 146 // It's OK to lowercase the origin as the Origin header does not contain
145 // the path or query portions, as per 147 // the path or query portions, as per
146 // http://tools.ietf.org/html/draft-abarth-origin-00. 148 // http://tools.ietf.org/html/draft-abarth-origin-00.
147 // 149 //
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 } 296 }
295 297
296 void WebSocketHandshake::Parameter::GenerateKey3() { 298 void WebSocketHandshake::Parameter::GenerateKey3() {
297 key_3_.clear(); 299 key_3_.clear();
298 for (int i = 0; i < 8; i++) { 300 for (int i = 0; i < 8; i++) {
299 key_3_.append(1, rand_(0, 255)); 301 key_3_.append(1, rand_(0, 255));
300 } 302 }
301 } 303 }
302 304
303 } // namespace net 305 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_unittest.cc ('k') | tools/memory_watcher/call_stack.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698