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

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

Issue 296053012: Replace StreamListenSocket with StreamSocket in HttpServer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compilation error Created 6 years, 5 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 "extensions/browser/api/socket/tcp_socket.h" 5 #include "extensions/browser/api/socket/tcp_socket.h"
6 6
7 #include "extensions/browser/api/api_resource.h" 7 #include "extensions/browser/api/api_resource.h"
8 #include "net/base/address_list.h" 8 #include "net/base/address_list.h"
9 #include "net/base/ip_endpoint.h" 9 #include "net/base/ip_endpoint.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 if (socket_mode_ == CLIENT) { 192 if (socket_mode_ == CLIENT) {
193 *error_msg = kTCPSocketTypeInvalidError; 193 *error_msg = kTCPSocketTypeInvalidError;
194 return net::ERR_NOT_IMPLEMENTED; 194 return net::ERR_NOT_IMPLEMENTED;
195 } 195 }
196 DCHECK(!socket_.get()); 196 DCHECK(!socket_.get());
197 socket_mode_ = SERVER; 197 socket_mode_ = SERVER;
198 198
199 if (!server_socket_.get()) { 199 if (!server_socket_.get()) {
200 server_socket_.reset(new net::TCPServerSocket(NULL, net::NetLog::Source())); 200 server_socket_.reset(new net::TCPServerSocket(NULL, net::NetLog::Source()));
201 } 201 }
202
202 int result = server_socket_->ListenWithAddressAndPort(address, port, backlog); 203 int result = server_socket_->ListenWithAddressAndPort(address, port, backlog);
203 if (result) 204 if (result)
204 *error_msg = kSocketListenError; 205 *error_msg = kSocketListenError;
205 return result; 206 return result;
206 } 207 }
207 208
208 void TCPSocket::Accept(const AcceptCompletionCallback& callback) { 209 void TCPSocket::Accept(const AcceptCompletionCallback& callback) {
209 if (socket_mode_ != SERVER || !server_socket_.get()) { 210 if (socket_mode_ != SERVER || !server_socket_.get()) {
210 callback.Run(net::ERR_FAILED, NULL); 211 callback.Run(net::ERR_FAILED, NULL);
211 return; 212 return;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 317
317 bool ResumableTCPSocket::IsPersistent() const { return persistent(); } 318 bool ResumableTCPSocket::IsPersistent() const { return persistent(); }
318 319
319 ResumableTCPServerSocket::ResumableTCPServerSocket( 320 ResumableTCPServerSocket::ResumableTCPServerSocket(
320 const std::string& owner_extension_id) 321 const std::string& owner_extension_id)
321 : TCPSocket(owner_extension_id), persistent_(false), paused_(false) {} 322 : TCPSocket(owner_extension_id), persistent_(false), paused_(false) {}
322 323
323 bool ResumableTCPServerSocket::IsPersistent() const { return persistent(); } 324 bool ResumableTCPServerSocket::IsPersistent() const { return persistent(); }
324 325
325 } // namespace extensions 326 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698