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

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

Issue 684133002: [Android] Fix gn build for instrumentation tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Follow review Created 6 years, 1 month 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 | « tools/android/forwarder2/host_forwarder_main.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 (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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 284
285 int Socket::GetPort() { 285 int Socket::GetPort() {
286 if (!FamilyIsTCP(family_)) { 286 if (!FamilyIsTCP(family_)) {
287 LOG(ERROR) << "Can't call GetPort() on an unix domain socket."; 287 LOG(ERROR) << "Can't call GetPort() on an unix domain socket.";
288 return 0; 288 return 0;
289 } 289 }
290 return port_; 290 return port_;
291 } 291 }
292 292
293 int Socket::ReadNumBytes(void* buffer, size_t num_bytes) { 293 int Socket::ReadNumBytes(void* buffer, size_t num_bytes) {
294 int bytes_read = 0; 294 size_t bytes_read = 0;
295 int ret = 1; 295 int ret = 1;
296 while (bytes_read < num_bytes && ret > 0) { 296 while (bytes_read < num_bytes && ret > 0) {
297 ret = Read(static_cast<char*>(buffer) + bytes_read, num_bytes - bytes_read); 297 ret = Read(static_cast<char*>(buffer) + bytes_read, num_bytes - bytes_read);
298 if (ret >= 0) 298 if (ret >= 0)
299 bytes_read += ret; 299 bytes_read += ret;
300 } 300 }
301 return bytes_read; 301 return bytes_read;
302 } 302 }
303 303
304 void Socket::SetSocketError() { 304 void Socket::SetSocketError() {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 373 }
374 374
375 bool Socket::DidReceiveEvent() const { 375 bool Socket::DidReceiveEvent() const {
376 for (size_t i = 0; i < events_.size(); ++i) 376 for (size_t i = 0; i < events_.size(); ++i)
377 if (events_[i].was_fired) 377 if (events_[i].was_fired)
378 return true; 378 return true;
379 return false; 379 return false;
380 } 380 }
381 381
382 int Socket::WriteNumBytes(const void* buffer, size_t num_bytes) { 382 int Socket::WriteNumBytes(const void* buffer, size_t num_bytes) {
383 int bytes_written = 0; 383 size_t bytes_written = 0;
384 int ret = 1; 384 int ret = 1;
385 while (bytes_written < num_bytes && ret > 0) { 385 while (bytes_written < num_bytes && ret > 0) {
386 ret = Write(static_cast<const char*>(buffer) + bytes_written, 386 ret = Write(static_cast<const char*>(buffer) + bytes_written,
387 num_bytes - bytes_written); 387 num_bytes - bytes_written);
388 if (ret >= 0) 388 if (ret >= 0)
389 bytes_written += ret; 389 bytes_written += ret;
390 } 390 }
391 return bytes_written; 391 return bytes_written;
392 } 392 }
393 393
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 ucred ucred; 439 ucred ucred;
440 socklen_t len = sizeof(ucred); 440 socklen_t len = sizeof(ucred);
441 if (getsockopt(socket.socket_, SOL_SOCKET, SO_PEERCRED, &ucred, &len) == -1) { 441 if (getsockopt(socket.socket_, SOL_SOCKET, SO_PEERCRED, &ucred, &len) == -1) {
442 CHECK_NE(ENOPROTOOPT, errno); 442 CHECK_NE(ENOPROTOOPT, errno);
443 return -1; 443 return -1;
444 } 444 }
445 return ucred.pid; 445 return ucred.pid;
446 } 446 }
447 447
448 } // namespace forwarder2 448 } // namespace forwarder2
OLDNEW
« no previous file with comments | « tools/android/forwarder2/host_forwarder_main.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698