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

Unified Diff: chrome/browser/devtools/device/port_forwarding_controller.cc

Issue 285263003: DevTools: Fixed suspected bug in port forwarding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Counting pending reads before destruction Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/devtools/device/port_forwarding_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/devtools/device/port_forwarding_controller.cc
diff --git a/chrome/browser/devtools/device/port_forwarding_controller.cc b/chrome/browser/devtools/device/port_forwarding_controller.cc
index c22789b157fd2ce513c955aa2f39892140b0e517..1a6928ce0db5aeffb90dc33ebf93734041f60081 100644
--- a/chrome/browser/devtools/device/port_forwarding_controller.cc
+++ b/chrome/browser/devtools/device/port_forwarding_controller.cc
@@ -68,7 +68,7 @@ class SocketTunnel : public base::NonThreadSafe {
private:
explicit SocketTunnel(const CounterCallback& callback)
- : pending_writes_(0),
+ : pending_io_(0),
pending_destruction_(false),
callback_(callback),
about_to_destroy_(false) {
@@ -126,6 +126,7 @@ class SocketTunnel : public base::NonThreadSafe {
void Pump(net::StreamSocket* from, net::StreamSocket* to) {
scoped_refptr<net::IOBuffer> buffer = new net::IOBuffer(kBufferSize);
+ pending_io_++;
int result = from->Read(
buffer.get(),
kBufferSize,
@@ -139,6 +140,7 @@ class SocketTunnel : public base::NonThreadSafe {
net::StreamSocket* to,
scoped_refptr<net::IOBuffer> buffer,
int result) {
+ pending_io_--;
pfeldman 2014/05/18 06:17:06 To recap offline discussion: we don't have read ti
if (result <= 0) {
SelfDestruct();
return;
@@ -148,7 +150,7 @@ class SocketTunnel : public base::NonThreadSafe {
scoped_refptr<net::DrainableIOBuffer> drainable =
new net::DrainableIOBuffer(buffer.get(), total);
- ++pending_writes_;
+ ++pending_io_;
result = to->Write(drainable.get(),
total,
base::Bind(&SocketTunnel::OnWritten,
@@ -164,7 +166,7 @@ class SocketTunnel : public base::NonThreadSafe {
net::StreamSocket* from,
net::StreamSocket* to,
int result) {
- --pending_writes_;
+ --pending_io_;
if (result < 0) {
SelfDestruct();
return;
@@ -172,7 +174,7 @@ class SocketTunnel : public base::NonThreadSafe {
drainable->DidConsume(result);
if (drainable->BytesRemaining() > 0) {
- ++pending_writes_;
+ ++pending_io_;
result = to->Write(drainable.get(),
drainable->BytesRemaining(),
base::Bind(&SocketTunnel::OnWritten,
@@ -198,7 +200,7 @@ class SocketTunnel : public base::NonThreadSafe {
// read callbacks.
if (about_to_destroy_)
return;
- if (pending_writes_ > 0) {
+ if (pending_io_ > 0) {
pending_destruction_ = true;
return;
}
@@ -209,7 +211,7 @@ class SocketTunnel : public base::NonThreadSafe {
scoped_ptr<net::StreamSocket> host_socket_;
scoped_ptr<net::HostResolver> host_resolver_;
net::AddressList address_list_;
- int pending_writes_;
+ int pending_io_;
bool pending_destruction_;
CounterCallback callback_;
bool about_to_destroy_;
« no previous file with comments | « chrome/browser/devtools/device/port_forwarding_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698