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

Side by Side Diff: content/browser/renderer_host/pepper/pepper_tcp_socket.cc

Issue 12220050: Provide a way to disable Nagle's algorithm on Pepper TCP sockets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/pepper/pepper_tcp_socket.h" 5 #include "content/browser/renderer_host/pepper/pepper_tcp_socket.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 NOTREACHED(); 189 NOTREACHED();
190 data_size = ppapi::TCPSocketPrivateImpl::kMaxWriteSize; 190 data_size = ppapi::TCPSocketPrivateImpl::kMaxWriteSize;
191 } 191 }
192 192
193 write_buffer_base_ = new net::IOBuffer(data_size); 193 write_buffer_base_ = new net::IOBuffer(data_size);
194 memcpy(write_buffer_base_->data(), data.data(), data_size); 194 memcpy(write_buffer_base_->data(), data.data(), data_size);
195 write_buffer_ = new net::DrainableIOBuffer(write_buffer_base_, data_size); 195 write_buffer_ = new net::DrainableIOBuffer(write_buffer_base_, data_size);
196 DoWrite(); 196 DoWrite();
197 } 197 }
198 198
199 void PepperTCPSocket::SetBoolOption(uint32_t name, bool value) {
200 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
201 DCHECK(socket_.get());
202
203 switch (name) {
204 case PP_TCPSOCKETOPTION_NO_DELAY:
205 if (!IsSsl()) {
206 net::TCPClientSocket* tcp_socket =
207 static_cast<net::TCPClientSocket*>(socket_.get());
208 SendSetBoolOptionACK(tcp_socket->SetNoDelay(value));
209 } else {
210 SendSetBoolOptionACK(false);
211 }
212 return;
213 default:
214 break;
215 }
216
217 NOTREACHED();
218 SendSetBoolOptionACK(false);
219 }
220
199 void PepperTCPSocket::StartConnect(const net::AddressList& addresses) { 221 void PepperTCPSocket::StartConnect(const net::AddressList& addresses) {
200 DCHECK(connection_state_ == CONNECT_IN_PROGRESS); 222 DCHECK(connection_state_ == CONNECT_IN_PROGRESS);
201 223
202 socket_.reset( 224 socket_.reset(new net::TCPClientSocket(addresses, NULL,
203 new net::TCPClientSocket(addresses, NULL, net::NetLog::Source())); 225 net::NetLog::Source()));
204 int result = socket_->Connect( 226 int result = socket_->Connect(
205 base::Bind(&PepperTCPSocket::OnConnectCompleted, 227 base::Bind(&PepperTCPSocket::OnConnectCompleted,
206 base::Unretained(this))); 228 base::Unretained(this)));
207 if (result != net::ERR_IO_PENDING) 229 if (result != net::ERR_IO_PENDING)
208 OnConnectCompleted(result); 230 OnConnectCompleted(result);
209 } 231 }
210 232
211 void PepperTCPSocket::SendConnectACKError() { 233 void PepperTCPSocket::SendConnectACKError() {
212 manager_->Send(new PpapiMsg_PPBTCPSocket_ConnectACK( 234 manager_->Send(new PpapiMsg_PPBTCPSocket_ConnectACK(
213 routing_id_, plugin_dispatcher_id_, socket_id_, false, 235 routing_id_, plugin_dispatcher_id_, socket_id_, false,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 GetCertificateFields(*ssl_info.cert, &certificate_fields); 318 GetCertificateFields(*ssl_info.cert, &certificate_fields);
297 } 319 }
298 manager_->Send(new PpapiMsg_PPBTCPSocket_SSLHandshakeACK( 320 manager_->Send(new PpapiMsg_PPBTCPSocket_SSLHandshakeACK(
299 routing_id_, 321 routing_id_,
300 plugin_dispatcher_id_, 322 plugin_dispatcher_id_,
301 socket_id_, 323 socket_id_,
302 succeeded, 324 succeeded,
303 certificate_fields)); 325 certificate_fields));
304 } 326 }
305 327
328 void PepperTCPSocket::SendSetBoolOptionACK(bool succeeded) {
329 manager_->Send(new PpapiMsg_PPBTCPSocket_SetBoolOptionACK(
330 routing_id_, plugin_dispatcher_id_, socket_id_, succeeded));
331 }
332
306 void PepperTCPSocket::OnResolveCompleted(int result) { 333 void PepperTCPSocket::OnResolveCompleted(int result) {
307 DCHECK(connection_state_ == CONNECT_IN_PROGRESS); 334 DCHECK(connection_state_ == CONNECT_IN_PROGRESS);
308 335
309 if (result != net::OK) { 336 if (result != net::OK) {
310 SendConnectACKError(); 337 SendConnectACKError();
311 connection_state_ = BEFORE_CONNECT; 338 connection_state_ = BEFORE_CONNECT;
312 return; 339 return;
313 } 340 }
314 341
315 StartConnect(address_list_); 342 StartConnect(address_list_);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 } 425 }
399 426
400 write_buffer_ = NULL; 427 write_buffer_ = NULL;
401 write_buffer_base_ = NULL; 428 write_buffer_base_ = NULL;
402 } 429 }
403 430
404 bool PepperTCPSocket::IsConnected() const { 431 bool PepperTCPSocket::IsConnected() const {
405 return connection_state_ == CONNECTED || connection_state_ == SSL_CONNECTED; 432 return connection_state_ == CONNECTED || connection_state_ == SSL_CONNECTED;
406 } 433 }
407 434
435 bool PepperTCPSocket::IsSsl() const {
436 return connection_state_ == SSL_HANDSHAKE_IN_PROGRESS ||
437 connection_state_ == SSL_CONNECTED ||
438 connection_state_ == SSL_HANDSHAKE_FAILED;
439 }
440
408 void PepperTCPSocket::DoWrite() { 441 void PepperTCPSocket::DoWrite() {
409 DCHECK(write_buffer_base_.get()); 442 DCHECK(write_buffer_base_.get());
410 DCHECK(write_buffer_.get()); 443 DCHECK(write_buffer_.get());
411 DCHECK_GT(write_buffer_->BytesRemaining(), 0); 444 DCHECK_GT(write_buffer_->BytesRemaining(), 0);
412 445
413 int result = socket_->Write(write_buffer_, write_buffer_->BytesRemaining(), 446 int result = socket_->Write(write_buffer_, write_buffer_->BytesRemaining(),
414 base::Bind(&PepperTCPSocket::OnWriteCompleted, 447 base::Bind(&PepperTCPSocket::OnWriteCompleted,
415 base::Unretained(this))); 448 base::Unretained(this)));
416 if (result != net::ERR_IO_PENDING) 449 if (result != net::ERR_IO_PENDING)
417 OnWriteCompleted(result); 450 OnWriteCompleted(result);
418 } 451 }
419 452
420 } // namespace content 453 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/pepper/pepper_tcp_socket.h ('k') | content/renderer/pepper/pepper_plugin_delegate_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698