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

Side by Side Diff: net/server/web_socket.cc

Issue 9716020: Add base::HostToNetXX() & NetToHostXX(), and use them to replace htonX() & ntohX() in Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 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 | Annotate | Revision Log
« no previous file with comments | « net/dns/dns_transaction_unittest.cc ('k') | net/socket/socks5_client_socket.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/server/web_socket.h" 5 #include "net/server/web_socket.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 19 matching lines...) Expand all
30 if (p_char[i] >= '0' && p_char[i] <= '9') 30 if (p_char[i] >= '0' && p_char[i] <= '9')
31 result.append(&p_char[i], 1); 31 result.append(&p_char[i], 1);
32 else if (p_char[i] == ' ') 32 else if (p_char[i] == ' ')
33 spaces++; 33 spaces++;
34 } 34 }
35 if (spaces == 0) 35 if (spaces == 0)
36 return 0; 36 return 0;
37 int64 number = 0; 37 int64 number = 0;
38 if (!base::StringToInt64(result, &number)) 38 if (!base::StringToInt64(result, &number))
39 return 0; 39 return 0;
40 return htonl(static_cast<uint32>(number / spaces)); 40 return base::HostToNet32(static_cast<uint32>(number / spaces));
41 } 41 }
42 42
43 class WebSocketHixie76 : public net::WebSocket { 43 class WebSocketHixie76 : public net::WebSocket {
44 public: 44 public:
45 static net::WebSocket* Create(HttpConnection* connection, 45 static net::WebSocket* Create(HttpConnection* connection,
46 const HttpServerRequestInfo& request, 46 const HttpServerRequestInfo& request,
47 size_t* pos) { 47 size_t* pos) {
48 if (connection->recv_data().length() < *pos + kWebSocketHandshakeBodyLen) 48 if (connection->recv_data().length() < *pos + kWebSocketHandshakeBodyLen)
49 return NULL; 49 return NULL;
50 return new WebSocketHixie76(connection, request, pos); 50 return new WebSocketHixie76(connection, request, pos);
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 if (socket) 360 if (socket)
361 return socket; 361 return socket;
362 362
363 return WebSocketHixie76::Create(connection, request, pos); 363 return WebSocketHixie76::Create(connection, request, pos);
364 } 364 }
365 365
366 WebSocket::WebSocket(HttpConnection* connection) : connection_(connection) { 366 WebSocket::WebSocket(HttpConnection* connection) : connection_(connection) {
367 } 367 }
368 368
369 } // namespace net 369 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/dns_transaction_unittest.cc ('k') | net/socket/socks5_client_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698