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

Side by Side Diff: chrome/browser/devtools/tethering_adb_filter.cc

Issue 16295003: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/browser/devtools/tethering_adb_filter.h" 5 #include "chrome/browser/devtools/tethering_adb_filter.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 SelfDestruct(); 93 SelfDestruct();
94 return; 94 return;
95 } 95 }
96 96
97 Pump(host_socket_.get(), remote_socket_.get()); 97 Pump(host_socket_.get(), remote_socket_.get());
98 Pump(remote_socket_.get(), host_socket_.get()); 98 Pump(remote_socket_.get(), host_socket_.get());
99 } 99 }
100 100
101 void Pump(net::StreamSocket* from, net::StreamSocket* to) { 101 void Pump(net::StreamSocket* from, net::StreamSocket* to) {
102 scoped_refptr<net::IOBuffer> buffer = new net::IOBuffer(kBufferSize); 102 scoped_refptr<net::IOBuffer> buffer = new net::IOBuffer(kBufferSize);
103 int result = from->Read(buffer, kBufferSize, 103 int result = from->Read(
104 base::Bind(&SocketTunnel::OnRead, base::Unretained(this), from, to, 104 buffer.get(),
105 buffer)); 105 kBufferSize,
106 base::Bind(
107 &SocketTunnel::OnRead, base::Unretained(this), from, to, buffer));
106 if (result != net::ERR_IO_PENDING) 108 if (result != net::ERR_IO_PENDING)
107 OnRead(from, to, buffer, result); 109 OnRead(from, to, buffer, result);
108 } 110 }
109 111
110 void OnRead(net::StreamSocket* from, 112 void OnRead(net::StreamSocket* from,
111 net::StreamSocket* to, 113 net::StreamSocket* to,
112 scoped_refptr<net::IOBuffer> buffer, 114 scoped_refptr<net::IOBuffer> buffer,
113 int result) { 115 int result) {
114 if (result <= 0) { 116 if (result <= 0) {
115 SelfDestruct(); 117 SelfDestruct();
116 return; 118 return;
117 } 119 }
118 120
119 int total = result; 121 int total = result;
120 scoped_refptr<net::DrainableIOBuffer> drainable = 122 scoped_refptr<net::DrainableIOBuffer> drainable =
121 new net::DrainableIOBuffer(buffer, total); 123 new net::DrainableIOBuffer(buffer.get(), total);
122 124
123 ++pending_writes_; 125 ++pending_writes_;
124 result = to->Write(drainable, total, 126 result = to->Write(drainable.get(),
127 total,
125 base::Bind(&SocketTunnel::OnWritten, 128 base::Bind(&SocketTunnel::OnWritten,
126 base::Unretained(this), drainable, from, to)); 129 base::Unretained(this),
130 drainable,
131 from,
132 to));
127 if (result != net::ERR_IO_PENDING) 133 if (result != net::ERR_IO_PENDING)
128 OnWritten(drainable, from, to, result); 134 OnWritten(drainable, from, to, result);
129 } 135 }
130 136
131 void OnWritten(scoped_refptr<net::DrainableIOBuffer> drainable, 137 void OnWritten(scoped_refptr<net::DrainableIOBuffer> drainable,
132 net::StreamSocket* from, 138 net::StreamSocket* from,
133 net::StreamSocket* to, 139 net::StreamSocket* to,
134 int result) { 140 int result) {
135 --pending_writes_; 141 --pending_writes_;
136 if (result < 0) { 142 if (result < 0) {
137 SelfDestruct(); 143 SelfDestruct();
138 return; 144 return;
139 } 145 }
140 146
141 drainable->DidConsume(result); 147 drainable->DidConsume(result);
142 if (drainable->BytesRemaining() > 0) { 148 if (drainable->BytesRemaining() > 0) {
143 ++pending_writes_; 149 ++pending_writes_;
144 result = to->Write(drainable, drainable->BytesRemaining(), 150 result = to->Write(drainable.get(),
151 drainable->BytesRemaining(),
145 base::Bind(&SocketTunnel::OnWritten, 152 base::Bind(&SocketTunnel::OnWritten,
146 base::Unretained(this), drainable, from, 153 base::Unretained(this),
154 drainable,
155 from,
147 to)); 156 to));
148 if (result != net::ERR_IO_PENDING) 157 if (result != net::ERR_IO_PENDING)
149 OnWritten(drainable, from, to, result); 158 OnWritten(drainable, from, to, result);
150 return; 159 return;
151 } 160 }
152 161
153 if (pending_destruction_) { 162 if (pending_destruction_) {
154 SelfDestruct(); 163 SelfDestruct();
155 return; 164 return;
156 } 165 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 263
255 std::string location; 264 std::string location;
256 if (!params->GetString(kLocationAttribute, &location)) 265 if (!params->GetString(kLocationAttribute, &location))
257 return; 266 return;
258 267
259 if (method == kTetheringBind) 268 if (method == kTetheringBind)
260 requested_ports_[port] = location; 269 requested_ports_[port] = location;
261 else 270 else
262 requested_ports_.erase(port); 271 requested_ports_.erase(port);
263 } 272 }
OLDNEW
« no previous file with comments | « chrome/browser/devtools/devtools_window.cc ('k') | chrome/browser/download/chrome_download_manager_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698