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 |
204 int result = server_socket_->ListenWithAddressAndPort(address, port, backlog); | 205 int result = server_socket_->ListenWithAddressAndPort(address, port, backlog); |
205 if (result) | 206 if (result) |
206 *error_msg = kSocketListenError; | 207 *error_msg = kSocketListenError; |
207 return result; | 208 return result; |
208 } | 209 } |
209 | 210 |
210 void TCPSocket::Accept(const AcceptCompletionCallback& callback) { | 211 void TCPSocket::Accept(const AcceptCompletionCallback& callback) { |
211 if (socket_mode_ != SERVER || !server_socket_.get()) { | 212 if (socket_mode_ != SERVER || !server_socket_.get()) { |
212 callback.Run(net::ERR_FAILED, NULL); | 213 callback.Run(net::ERR_FAILED, NULL); |
213 return; | 214 return; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 | 349 |
349 bool ResumableTCPSocket::IsPersistent() const { return persistent(); } | 350 bool ResumableTCPSocket::IsPersistent() const { return persistent(); } |
350 | 351 |
351 ResumableTCPServerSocket::ResumableTCPServerSocket( | 352 ResumableTCPServerSocket::ResumableTCPServerSocket( |
352 const std::string& owner_extension_id) | 353 const std::string& owner_extension_id) |
353 : TCPSocket(owner_extension_id), persistent_(false), paused_(false) {} | 354 : TCPSocket(owner_extension_id), persistent_(false), paused_(false) {} |
354 | 355 |
355 bool ResumableTCPServerSocket::IsPersistent() const { return persistent(); } | 356 bool ResumableTCPServerSocket::IsPersistent() const { return persistent(); } |
356 | 357 |
357 } // namespace extensions | 358 } // namespace extensions |
OLD | NEW |