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

Side by Side Diff: extensions/browser/api/socket/tcp_socket.cc

Issue 1463293004: Reset server_socket_ when listen fails in extensions::TCPSocket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « chrome/test/data/extensions/api_test/socket/api/background.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "extensions/browser/api/socket/tcp_socket.h" 5 #include "extensions/browser/api/socket/tcp_socket.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "extensions/browser/api/api_resource.h" 10 #include "extensions/browser/api/api_resource.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 return net::ERR_NOT_IMPLEMENTED; 189 return net::ERR_NOT_IMPLEMENTED;
190 } 190 }
191 DCHECK(!socket_.get()); 191 DCHECK(!socket_.get());
192 socket_mode_ = SERVER; 192 socket_mode_ = SERVER;
193 193
194 if (!server_socket_.get()) { 194 if (!server_socket_.get()) {
195 server_socket_.reset(new net::TCPServerSocket(NULL, net::NetLog::Source())); 195 server_socket_.reset(new net::TCPServerSocket(NULL, net::NetLog::Source()));
196 } 196 }
197 197
198 int result = server_socket_->ListenWithAddressAndPort(address, port, backlog); 198 int result = server_socket_->ListenWithAddressAndPort(address, port, backlog);
199 if (result) 199 if (result) {
200 server_socket_.reset();
200 *error_msg = kSocketListenError; 201 *error_msg = kSocketListenError;
202 }
201 return result; 203 return result;
202 } 204 }
203 205
204 void TCPSocket::Accept(const AcceptCompletionCallback& callback) { 206 void TCPSocket::Accept(const AcceptCompletionCallback& callback) {
205 if (socket_mode_ != SERVER || !server_socket_.get()) { 207 if (socket_mode_ != SERVER || !server_socket_.get()) {
206 callback.Run(net::ERR_FAILED, NULL); 208 callback.Run(net::ERR_FAILED, NULL);
207 return; 209 return;
208 } 210 }
209 211
210 // Limits to only 1 blocked accept call. 212 // Limits to only 1 blocked accept call.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 344
343 bool ResumableTCPSocket::IsPersistent() const { return persistent(); } 345 bool ResumableTCPSocket::IsPersistent() const { return persistent(); }
344 346
345 ResumableTCPServerSocket::ResumableTCPServerSocket( 347 ResumableTCPServerSocket::ResumableTCPServerSocket(
346 const std::string& owner_extension_id) 348 const std::string& owner_extension_id)
347 : TCPSocket(owner_extension_id), persistent_(false), paused_(false) {} 349 : TCPSocket(owner_extension_id), persistent_(false), paused_(false) {}
348 350
349 bool ResumableTCPServerSocket::IsPersistent() const { return persistent(); } 351 bool ResumableTCPServerSocket::IsPersistent() const { return persistent(); }
350 352
351 } // namespace extensions 353 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/socket/api/background.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698