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

Side by Side 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: Fixed recv and immediate close scenario on Windows 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/device/port_forwarding_controller.h" 5 #include "chrome/browser/devtools/device/port_forwarding_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 remote_socket_->Disconnect(); 113 remote_socket_->Disconnect();
114 callback_.Run(-1); 114 callback_.Run(-1);
115 } 115 }
116 116
117 void OnConnected(int result) { 117 void OnConnected(int result) {
118 if (result < 0) { 118 if (result < 0) {
119 SelfDestruct(); 119 SelfDestruct();
120 return; 120 return;
121 } 121 }
122 122
123 ++pending_writes_; // avoid SelfDestruct in first Pump
123 Pump(host_socket_.get(), remote_socket_.get()); 124 Pump(host_socket_.get(), remote_socket_.get());
124 Pump(remote_socket_.get(), host_socket_.get()); 125 --pending_writes_;
126 if (pending_destruction_) {
127 SelfDestruct();
128 } else {
129 Pump(remote_socket_.get(), host_socket_.get());
130 }
125 } 131 }
126 132
127 void Pump(net::StreamSocket* from, net::StreamSocket* to) { 133 void Pump(net::StreamSocket* from, net::StreamSocket* to) {
128 scoped_refptr<net::IOBuffer> buffer = new net::IOBuffer(kBufferSize); 134 scoped_refptr<net::IOBuffer> buffer = new net::IOBuffer(kBufferSize);
129 int result = from->Read( 135 int result = from->Read(
130 buffer.get(), 136 buffer.get(),
131 kBufferSize, 137 kBufferSize,
132 base::Bind( 138 base::Bind(
133 &SocketTunnel::OnRead, base::Unretained(this), from, to, buffer)); 139 &SocketTunnel::OnRead, base::Unretained(this), from, to, buffer));
134 if (result != net::ERR_IO_PENDING) 140 if (result != net::ERR_IO_PENDING)
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 "PortForwardingController", 669 "PortForwardingController",
664 BrowserContextDependencyManager::GetInstance()) {} 670 BrowserContextDependencyManager::GetInstance()) {}
665 671
666 PortForwardingController::Factory::~Factory() {} 672 PortForwardingController::Factory::~Factory() {}
667 673
668 KeyedService* PortForwardingController::Factory::BuildServiceInstanceFor( 674 KeyedService* PortForwardingController::Factory::BuildServiceInstanceFor(
669 content::BrowserContext* context) const { 675 content::BrowserContext* context) const {
670 Profile* profile = Profile::FromBrowserContext(context); 676 Profile* profile = Profile::FromBrowserContext(context);
671 return new PortForwardingController(profile); 677 return new PortForwardingController(profile);
672 } 678 }
OLDNEW
« no previous file with comments | « chrome/browser/devtools/device/port_forwarding_browsertest.cc ('k') | content/browser/devtools/tethering_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698