| OLD | NEW |
| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "extensions/browser/api/api_resource.h" | 9 #include "extensions/browser/api/api_resource.h" |
| 10 #include "net/base/address_list.h" | 10 #include "net/base/address_list.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 if (socket_mode_ == CLIENT) { | 194 if (socket_mode_ == CLIENT) { |
| 195 *error_msg = kTCPSocketTypeInvalidError; | 195 *error_msg = kTCPSocketTypeInvalidError; |
| 196 return net::ERR_NOT_IMPLEMENTED; | 196 return net::ERR_NOT_IMPLEMENTED; |
| 197 } | 197 } |
| 198 DCHECK(!socket_.get()); | 198 DCHECK(!socket_.get()); |
| 199 socket_mode_ = SERVER; | 199 socket_mode_ = SERVER; |
| 200 | 200 |
| 201 if (!server_socket_.get()) { | 201 if (!server_socket_.get()) { |
| 202 server_socket_.reset(new net::TCPServerSocket(NULL, net::NetLog::Source())); | 202 server_socket_.reset(new net::TCPServerSocket(NULL, net::NetLog::Source())); |
| 203 } | 203 } |
| 204 | |
| 205 int result = server_socket_->ListenWithAddressAndPort(address, port, backlog); | 204 int result = server_socket_->ListenWithAddressAndPort(address, port, backlog); |
| 206 if (result) | 205 if (result) |
| 207 *error_msg = kSocketListenError; | 206 *error_msg = kSocketListenError; |
| 208 return result; | 207 return result; |
| 209 } | 208 } |
| 210 | 209 |
| 211 void TCPSocket::Accept(const AcceptCompletionCallback& callback) { | 210 void TCPSocket::Accept(const AcceptCompletionCallback& callback) { |
| 212 if (socket_mode_ != SERVER || !server_socket_.get()) { | 211 if (socket_mode_ != SERVER || !server_socket_.get()) { |
| 213 callback.Run(net::ERR_FAILED, NULL); | 212 callback.Run(net::ERR_FAILED, NULL); |
| 214 return; | 213 return; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 | 348 |
| 350 bool ResumableTCPSocket::IsPersistent() const { return persistent(); } | 349 bool ResumableTCPSocket::IsPersistent() const { return persistent(); } |
| 351 | 350 |
| 352 ResumableTCPServerSocket::ResumableTCPServerSocket( | 351 ResumableTCPServerSocket::ResumableTCPServerSocket( |
| 353 const std::string& owner_extension_id) | 352 const std::string& owner_extension_id) |
| 354 : TCPSocket(owner_extension_id), persistent_(false), paused_(false) {} | 353 : TCPSocket(owner_extension_id), persistent_(false), paused_(false) {} |
| 355 | 354 |
| 356 bool ResumableTCPServerSocket::IsPersistent() const { return persistent(); } | 355 bool ResumableTCPServerSocket::IsPersistent() const { return persistent(); } |
| 357 | 356 |
| 358 } // namespace extensions | 357 } // namespace extensions |
| OLD | NEW |