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

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

Issue 15008004: Add device port unmapping support to forwarder2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address David's comments Created 7 years, 7 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 | « tools/android/forwarder2/device_listener.cc ('k') | tools/android/forwarder2/host_controller.h » ('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) 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 <errno.h> 7 #include <errno.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 DISALLOW_COPY_AND_ASSIGN(BufferedCopier); 87 DISALLOW_COPY_AND_ASSIGN(BufferedCopier);
88 }; 88 };
89 89
90 } // namespace 90 } // namespace
91 91
92 Forwarder::Forwarder(scoped_ptr<Socket> socket1, scoped_ptr<Socket> socket2) 92 Forwarder::Forwarder(scoped_ptr<Socket> socket1, scoped_ptr<Socket> socket2)
93 : socket1_(socket1.Pass()), 93 : socket1_(socket1.Pass()),
94 socket2_(socket2.Pass()) { 94 socket2_(socket2.Pass()) {
95 DCHECK(socket1_.get()); 95 DCHECK(socket1_.get());
96 DCHECK(socket2_.get()); 96 DCHECK(socket2_.get());
97 // The forwarder thread doesn't need to listen to notifications. It can be
98 // keept alive until either the conenction is broken or the program exit.
99 socket1_->reset_exit_notifier_fd();
100 socket2_->reset_exit_notifier_fd();
101 } 97 }
102 98
103 Forwarder::~Forwarder() { 99 Forwarder::~Forwarder() {}
104 socket1_->Close();
105 socket2_->Close();
106 }
107 100
108 void Forwarder::Run() { 101 void Forwarder::Run() {
109 const int nfds = Socket::GetHighestFileDescriptor(*socket1_, *socket2_) + 1; 102 const int nfds = Socket::GetHighestFileDescriptor(*socket1_, *socket2_) + 1;
110 fd_set read_fds; 103 fd_set read_fds;
111 fd_set write_fds; 104 fd_set write_fds;
112 105
113 // Copy from socket1 to socket2 106 // Copy from socket1 to socket2
114 BufferedCopier buffer1(socket1_.get(), socket2_.get()); 107 BufferedCopier buffer1(socket1_.get(), socket2_.get());
115 108
116 // Copy from socket2 to socket1 109 // Copy from socket2 to socket1
(...skipping 27 matching lines...) Expand all
144 } 137 }
145 138
146 delete this; 139 delete this;
147 } 140 }
148 141
149 void Forwarder::Join() { 142 void Forwarder::Join() {
150 NOTREACHED() << "Can't Join a Forwarder thread."; 143 NOTREACHED() << "Can't Join a Forwarder thread.";
151 } 144 }
152 145
153 } // namespace forwarder 146 } // namespace forwarder
OLDNEW
« no previous file with comments | « tools/android/forwarder2/device_listener.cc ('k') | tools/android/forwarder2/host_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698