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

Side by Side Diff: net/socket/tcp_client_socket_libevent.cc

Issue 199048: Add methods for setting socket buffers to the Socket (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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/socket/tcp_client_socket_libevent.h ('k') | net/socket/tcp_client_socket_pool_unittest.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/socket/tcp_client_socket_libevent.h" 5 #include "net/socket/tcp_client_socket_libevent.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <netdb.h> 9 #include <netdb.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 return MapPosixError(errno); 255 return MapPosixError(errno);
256 } 256 }
257 257
258 258
259 write_buf_ = buf; 259 write_buf_ = buf;
260 write_buf_len_ = buf_len; 260 write_buf_len_ = buf_len;
261 write_callback_ = callback; 261 write_callback_ = callback;
262 return ERR_IO_PENDING; 262 return ERR_IO_PENDING;
263 } 263 }
264 264
265 bool TCPClientSocketLibevent::SetReceiveBufferSize(int32 size) {
266 int rv = setsockopt(socket_, SOL_SOCKET, SO_RCVBUF,
267 reinterpret_cast<const char*>(&size),
268 sizeof(size));
269 DCHECK(!rv) << "Could not set socket receive buffer size: " << errno;
270 return rv == 0;
271 }
272
273 bool TCPClientSocketLibevent::SetSendBufferSize(int32 size) {
274 int rv = setsockopt(socket_, SOL_SOCKET, SO_SNDBUF,
275 reinterpret_cast<const char*>(&size),
276 sizeof(size));
277 DCHECK(!rv) << "Could not set socket send buffer size: " << errno;
278 return rv == 0;
279 }
280
281
265 int TCPClientSocketLibevent::CreateSocket(const addrinfo* ai) { 282 int TCPClientSocketLibevent::CreateSocket(const addrinfo* ai) {
266 socket_ = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); 283 socket_ = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
267 if (socket_ == kInvalidSocket) 284 if (socket_ == kInvalidSocket)
268 return MapPosixError(errno); 285 return MapPosixError(errno);
269 286
270 if (SetNonBlocking(socket_)) 287 if (SetNonBlocking(socket_))
271 return MapPosixError(errno); 288 return MapPosixError(errno);
272 289
273 return OK; 290 return OK;
274 } 291 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 DoWriteCallback(result); 392 DoWriteCallback(result);
376 } 393 }
377 } 394 }
378 395
379 int TCPClientSocketLibevent::GetPeerName(struct sockaddr *name, 396 int TCPClientSocketLibevent::GetPeerName(struct sockaddr *name,
380 socklen_t *namelen) { 397 socklen_t *namelen) {
381 return ::getpeername(socket_, name, namelen); 398 return ::getpeername(socket_, name, namelen);
382 } 399 }
383 400
384 } // namespace net 401 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/tcp_client_socket_libevent.h ('k') | net/socket/tcp_client_socket_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698