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

Side by Side Diff: tools/android/forwarder2/forwarder.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
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/forwarder.h" 5 #include "tools/android/forwarder2/forwarder.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/posix/eintr_wrapper.h" 9 #include "base/posix/eintr_wrapper.h"
10 #include "tools/android/forwarder2/socket.h" 10 #include "tools/android/forwarder2/socket.h"
11 11
12 namespace forwarder2 { 12 namespace forwarder2 {
13 namespace { 13 namespace {
14 14
15 const int kBufferSize = 32 * 1024; 15 const int kBufferSize = 32 * 1024;
16 16
17 } // namespace 17 } // namespace
18 18
19 19
20 // Helper class to buffer reads and writes from one socket to another. 20 // Helper class to buffer reads and writes from one socket to another.
21 // Each implements a small buffer connected two one input socket, and 21 // Each implements a small buffer connected two one input socket, and
22 // one output socket. 22 // one output socket.
23 // 23 //
24 // socket_from_ ---> [BufferedCopier] ---> socket_to_ 24 // socket_from_ ---> [BufferedCopier] ---> socket_to_
25 // 25 //
26 // These objects are used in a pair to handle duplex traffic, as in: 26 // These objects are used in a pair to handle duplex traffic, as in:
27 // 27 //
28 // ------> [BufferedCopier_1] ---> 28 // -------> [BufferedCopier_1] --->
29 // / \ 29 // | |
30 // socket_1 * * socket_2 30 // socket_1 * * socket_2
31 // \ / 31 // | |
32 // <------ [BufferedCopier_2] <---- 32 // <------ [BufferedCopier_2] <----
33 // 33 //
34 // When a BufferedCopier is in the READING state (see below), it only listens 34 // When a BufferedCopier is in the READING state (see below), it only listens
35 // to events on its input socket, and won't detect when its output socket 35 // to events on its input socket, and won't detect when its output socket
36 // disconnects. To work around this, its peer will call its Close() method 36 // disconnects. To work around this, its peer will call its Close() method
37 // when that happens. 37 // when that happens.
38 38
39 class Forwarder::BufferedCopier { 39 class Forwarder::BufferedCopier {
40 public: 40 public:
41 // Possible states: 41 // Possible states:
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 return buffer1_->is_closed() && buffer2_->is_closed(); 246 return buffer1_->is_closed() && buffer2_->is_closed();
247 } 247 }
248 248
249 void Forwarder::Shutdown() { 249 void Forwarder::Shutdown() {
250 DCHECK(thread_checker_.CalledOnValidThread()); 250 DCHECK(thread_checker_.CalledOnValidThread());
251 buffer1_->Close(); 251 buffer1_->Close();
252 buffer2_->Close(); 252 buffer2_->Close();
253 } 253 }
254 254
255 } // namespace forwarder2 255 } // namespace forwarder2
OLDNEW
« no previous file with comments | « tools/android/forwarder2/device_forwarder_main.cc ('k') | tools/android/forwarder2/forwarder.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698