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/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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 is_connected_ = false; | 110 is_connected_ = false; |
111 if (socket_.get()) | 111 if (socket_.get()) |
112 socket_->Disconnect(); | 112 socket_->Disconnect(); |
113 server_socket_.reset(NULL); | 113 server_socket_.reset(NULL); |
114 connect_callback_.Reset(); | 114 connect_callback_.Reset(); |
115 read_callback_.Reset(); | 115 read_callback_.Reset(); |
116 accept_callback_.Reset(); | 116 accept_callback_.Reset(); |
117 accept_socket_.reset(NULL); | 117 accept_socket_.reset(NULL); |
118 } | 118 } |
119 | 119 |
120 int TCPSocket::Bind(const std::string& address, uint16 port) { | 120 int TCPSocket::Bind(const std::string& address, uint16_t port) { |
121 return net::ERR_FAILED; | 121 return net::ERR_FAILED; |
122 } | 122 } |
123 | 123 |
124 void TCPSocket::Read(int count, const ReadCompletionCallback& callback) { | 124 void TCPSocket::Read(int count, const ReadCompletionCallback& callback) { |
125 DCHECK(!callback.is_null()); | 125 DCHECK(!callback.is_null()); |
126 | 126 |
127 if (socket_mode_ != CLIENT) { | 127 if (socket_mode_ != CLIENT) { |
128 callback.Run(net::ERR_FAILED, NULL); | 128 callback.Run(net::ERR_FAILED, NULL); |
129 return; | 129 return; |
130 } | 130 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 return socket_->SetKeepAlive(enable, delay); | 174 return socket_->SetKeepAlive(enable, delay); |
175 } | 175 } |
176 | 176 |
177 bool TCPSocket::SetNoDelay(bool no_delay) { | 177 bool TCPSocket::SetNoDelay(bool no_delay) { |
178 if (!socket_.get()) | 178 if (!socket_.get()) |
179 return false; | 179 return false; |
180 return socket_->SetNoDelay(no_delay); | 180 return socket_->SetNoDelay(no_delay); |
181 } | 181 } |
182 | 182 |
183 int TCPSocket::Listen(const std::string& address, | 183 int TCPSocket::Listen(const std::string& address, |
184 uint16 port, | 184 uint16_t port, |
185 int backlog, | 185 int backlog, |
186 std::string* error_msg) { | 186 std::string* error_msg) { |
187 if (socket_mode_ == CLIENT) { | 187 if (socket_mode_ == CLIENT) { |
188 *error_msg = kTCPSocketTypeInvalidError; | 188 *error_msg = kTCPSocketTypeInvalidError; |
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()) { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 | 344 |
345 bool ResumableTCPSocket::IsPersistent() const { return persistent(); } | 345 bool ResumableTCPSocket::IsPersistent() const { return persistent(); } |
346 | 346 |
347 ResumableTCPServerSocket::ResumableTCPServerSocket( | 347 ResumableTCPServerSocket::ResumableTCPServerSocket( |
348 const std::string& owner_extension_id) | 348 const std::string& owner_extension_id) |
349 : TCPSocket(owner_extension_id), persistent_(false), paused_(false) {} | 349 : TCPSocket(owner_extension_id), persistent_(false), paused_(false) {} |
350 | 350 |
351 bool ResumableTCPServerSocket::IsPersistent() const { return persistent(); } | 351 bool ResumableTCPServerSocket::IsPersistent() const { return persistent(); } |
352 | 352 |
353 } // namespace extensions | 353 } // namespace extensions |
OLD | NEW |