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

Side by Side Diff: jingle/glue/pseudotcp_adapter.cc

Issue 11275088: Remove implicit scoped_refptr operator T* Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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 (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 "jingle/glue/pseudotcp_adapter.h" 5 #include "jingle/glue/pseudotcp_adapter.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "net/base/address_list.h" 10 #include "net/base/address_list.h"
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 if (socket_write_pending_) 353 if (socket_write_pending_)
354 return IPseudoTcpNotify::WR_SUCCESS; 354 return IPseudoTcpNotify::WR_SUCCESS;
355 355
356 scoped_refptr<net::IOBuffer> write_buffer = new net::IOBuffer(len); 356 scoped_refptr<net::IOBuffer> write_buffer = new net::IOBuffer(len);
357 memcpy(write_buffer->data(), buffer, len); 357 memcpy(write_buffer->data(), buffer, len);
358 358
359 // Our underlying socket is datagram-oriented, which means it should either 359 // Our underlying socket is datagram-oriented, which means it should either
360 // send exactly as many bytes as we requested, or fail. 360 // send exactly as many bytes as we requested, or fail.
361 int result; 361 int result;
362 if (socket_.get()) { 362 if (socket_.get()) {
363 result = socket_->Write(write_buffer, len, 363 result = socket_->Write(write_buffer.get(), len,
364 base::Bind(&PseudoTcpAdapter::Core::OnWritten, 364 base::Bind(&PseudoTcpAdapter::Core::OnWritten,
365 base::Unretained(this))); 365 base::Unretained(this)));
366 } else { 366 } else {
367 result = net::ERR_CONNECTION_CLOSED; 367 result = net::ERR_CONNECTION_CLOSED;
368 } 368 }
369 if (result == net::ERR_IO_PENDING) { 369 if (result == net::ERR_IO_PENDING) {
370 socket_write_pending_ = true; 370 socket_write_pending_ = true;
371 return IPseudoTcpNotify::WR_SUCCESS; 371 return IPseudoTcpNotify::WR_SUCCESS;
372 } if (result == net::ERR_MSG_TOO_BIG) { 372 } if (result == net::ERR_MSG_TOO_BIG) {
373 return IPseudoTcpNotify::WR_TOO_LARGE; 373 return IPseudoTcpNotify::WR_TOO_LARGE;
374 } else if (result < 0) { 374 } else if (result < 0) {
375 return IPseudoTcpNotify::WR_FAIL; 375 return IPseudoTcpNotify::WR_FAIL;
376 } else { 376 } else {
377 return IPseudoTcpNotify::WR_SUCCESS; 377 return IPseudoTcpNotify::WR_SUCCESS;
378 } 378 }
379 } 379 }
380 380
381 void PseudoTcpAdapter::Core::DoReadFromSocket() { 381 void PseudoTcpAdapter::Core::DoReadFromSocket() {
382 if (!socket_read_buffer_) 382 if (!socket_read_buffer_.get())
383 socket_read_buffer_ = new net::IOBuffer(kReadBufferSize); 383 socket_read_buffer_ = new net::IOBuffer(kReadBufferSize);
384 384
385 int result = 1; 385 int result = 1;
386 while (socket_.get() && result > 0) { 386 while (socket_.get() && result > 0) {
387 result = socket_->Read(socket_read_buffer_, kReadBufferSize, 387 result = socket_->Read(socket_read_buffer_.get(), kReadBufferSize,
388 base::Bind(&PseudoTcpAdapter::Core::OnRead, 388 base::Bind(&PseudoTcpAdapter::Core::OnRead,
389 base::Unretained(this))); 389 base::Unretained(this)));
390 if (result != net::ERR_IO_PENDING) 390 if (result != net::ERR_IO_PENDING)
391 HandleReadResults(result); 391 HandleReadResults(result);
392 } 392 }
393 } 393 }
394 394
395 void PseudoTcpAdapter::Core::HandleReadResults(int result) { 395 void PseudoTcpAdapter::Core::HandleReadResults(int result) {
396 if (result <= 0) { 396 if (result <= 0) {
397 LOG(ERROR) << "Read returned " << result; 397 LOG(ERROR) << "Read returned " << result;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 DCHECK(CalledOnValidThread()); 597 DCHECK(CalledOnValidThread());
598 core_->SetNoDelay(no_delay); 598 core_->SetNoDelay(no_delay);
599 } 599 }
600 600
601 void PseudoTcpAdapter::SetWriteWaitsForSend(bool write_waits_for_send) { 601 void PseudoTcpAdapter::SetWriteWaitsForSend(bool write_waits_for_send) {
602 DCHECK(CalledOnValidThread()); 602 DCHECK(CalledOnValidThread());
603 core_->SetWriteWaitsForSend(write_waits_for_send); 603 core_->SetWriteWaitsForSend(write_waits_for_send);
604 } 604 }
605 605
606 } // namespace jingle_glue 606 } // namespace jingle_glue
OLDNEW
« no previous file with comments | « jingle/glue/channel_socket_adapter_unittest.cc ('k') | jingle/glue/pseudotcp_adapter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698