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

Side by Side Diff: tools/android/forwarder2/socket.cc

Issue 13812005: net: move socket files from net/base to net/socket (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sort gyp Created 7 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/tools/fetch/http_listen_socket.h ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "tools/android/forwarder2/socket.h" 5 #include "tools/android/forwarder2/socket.h"
6 6
7 #include <arpa/inet.h> 7 #include <arpa/inet.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <netdb.h> 9 #include <netdb.h>
10 #include <netinet/in.h> 10 #include <netinet/in.h>
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 if ((abstract && path.size() + 2 /* '\0' */ > kPathMax) || 115 if ((abstract && path.size() + 2 /* '\0' */ > kPathMax) ||
116 (!abstract && path.size() + 1 /* '\0' */ > kPathMax)) { 116 (!abstract && path.size() + 1 /* '\0' */ > kPathMax)) {
117 LOG(ERROR) << "The provided path is too big to create a unix " 117 LOG(ERROR) << "The provided path is too big to create a unix "
118 << "domain socket: " << path; 118 << "domain socket: " << path;
119 return false; 119 return false;
120 } 120 }
121 abstract_ = abstract; 121 abstract_ = abstract;
122 family_ = PF_UNIX; 122 family_ = PF_UNIX;
123 addr_.addr_un.sun_family = family_; 123 addr_.addr_un.sun_family = family_;
124 if (abstract) { 124 if (abstract) {
125 // Copied from net/base/unix_domain_socket_posix.cc 125 // Copied from net/socket/unix_domain_socket_posix.cc
126 // Convert the path given into abstract socket name. It must start with 126 // Convert the path given into abstract socket name. It must start with
127 // the '\0' character, so we are adding it. |addr_len| must specify the 127 // the '\0' character, so we are adding it. |addr_len| must specify the
128 // length of the structure exactly, as potentially the socket name may 128 // length of the structure exactly, as potentially the socket name may
129 // have '\0' characters embedded (although we don't support this). 129 // have '\0' characters embedded (although we don't support this).
130 // Note that addr_.addr_un.sun_path is already zero initialized. 130 // Note that addr_.addr_un.sun_path is already zero initialized.
131 memcpy(addr_.addr_un.sun_path + 1, path.c_str(), path.size()); 131 memcpy(addr_.addr_un.sun_path + 1, path.c_str(), path.size());
132 addr_len_ = path.size() + offsetof(struct sockaddr_un, sun_path) + 1; 132 addr_len_ = path.size() + offsetof(struct sockaddr_un, sun_path) + 1;
133 } else { 133 } else {
134 memcpy(addr_.addr_un.sun_path, path.c_str(), path.size()); 134 memcpy(addr_.addr_un.sun_path, path.c_str(), path.size());
135 addr_len_ = sizeof(sockaddr_un); 135 addr_len_ = sizeof(sockaddr_un);
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 return true; 380 return true;
381 } 381 }
382 382
383 // static 383 // static
384 int Socket::GetHighestFileDescriptor( 384 int Socket::GetHighestFileDescriptor(
385 const Socket& s1, const Socket& s2) { 385 const Socket& s1, const Socket& s2) {
386 return std::max(s1.socket_, s2.socket_); 386 return std::max(s1.socket_, s2.socket_);
387 } 387 }
388 388
389 } // namespace forwarder 389 } // namespace forwarder
OLDNEW
« no previous file with comments | « net/tools/fetch/http_listen_socket.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698