OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "remoting/protocol/pseudotcp_adapter.h" | 5 #include "remoting/protocol/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/time.h" | 9 #include "base/time/time.h" |
10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 scoped_refptr<net::IOBuffer> socket_read_buffer_; | 107 scoped_refptr<net::IOBuffer> socket_read_buffer_; |
108 | 108 |
109 base::OneShotTimer timer_; | 109 base::OneShotTimer timer_; |
110 | 110 |
111 DISALLOW_COPY_AND_ASSIGN(Core); | 111 DISALLOW_COPY_AND_ASSIGN(Core); |
112 }; | 112 }; |
113 | 113 |
114 | 114 |
115 PseudoTcpAdapter::Core::Core(scoped_ptr<P2PDatagramSocket> socket) | 115 PseudoTcpAdapter::Core::Core(scoped_ptr<P2PDatagramSocket> socket) |
116 : pseudo_tcp_(this, 0), | 116 : pseudo_tcp_(this, 0), |
117 socket_(socket.Pass()), | 117 socket_(std::move(socket)), |
118 write_waits_for_send_(false), | 118 write_waits_for_send_(false), |
119 waiting_write_position_(false), | 119 waiting_write_position_(false), |
120 socket_write_pending_(false) { | 120 socket_write_pending_(false) { |
121 // Doesn't trigger callbacks. | 121 // Doesn't trigger callbacks. |
122 pseudo_tcp_.NotifyMTU(kDefaultMtu); | 122 pseudo_tcp_.NotifyMTU(kDefaultMtu); |
123 } | 123 } |
124 | 124 |
125 PseudoTcpAdapter::Core::~Core() { | 125 PseudoTcpAdapter::Core::~Core() { |
126 } | 126 } |
127 | 127 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 write_callback_.Reset(); | 442 write_callback_.Reset(); |
443 write_buffer_ = NULL; | 443 write_buffer_ = NULL; |
444 callback.Run(last_write_result_); | 444 callback.Run(last_write_result_); |
445 } | 445 } |
446 } | 446 } |
447 } | 447 } |
448 | 448 |
449 // Public interface implementation. | 449 // Public interface implementation. |
450 | 450 |
451 PseudoTcpAdapter::PseudoTcpAdapter(scoped_ptr<P2PDatagramSocket> socket) | 451 PseudoTcpAdapter::PseudoTcpAdapter(scoped_ptr<P2PDatagramSocket> socket) |
452 : core_(new Core(socket.Pass())) { | 452 : core_(new Core(std::move(socket))) { |
453 } | 453 } |
454 | 454 |
455 PseudoTcpAdapter::~PseudoTcpAdapter() { | 455 PseudoTcpAdapter::~PseudoTcpAdapter() { |
456 // Make sure that the underlying socket is destroyed before PseudoTcp. | 456 // Make sure that the underlying socket is destroyed before PseudoTcp. |
457 core_->DeleteSocket(); | 457 core_->DeleteSocket(); |
458 } | 458 } |
459 | 459 |
460 int PseudoTcpAdapter::Read(const scoped_refptr<net::IOBuffer>& buffer, | 460 int PseudoTcpAdapter::Read(const scoped_refptr<net::IOBuffer>& buffer, |
461 int buffer_size, | 461 int buffer_size, |
462 const net::CompletionCallback& callback) { | 462 const net::CompletionCallback& callback) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 core_->SetNoDelay(no_delay); | 498 core_->SetNoDelay(no_delay); |
499 } | 499 } |
500 | 500 |
501 void PseudoTcpAdapter::SetWriteWaitsForSend(bool write_waits_for_send) { | 501 void PseudoTcpAdapter::SetWriteWaitsForSend(bool write_waits_for_send) { |
502 DCHECK(CalledOnValidThread()); | 502 DCHECK(CalledOnValidThread()); |
503 core_->SetWriteWaitsForSend(write_waits_for_send); | 503 core_->SetWriteWaitsForSend(write_waits_for_send); |
504 } | 504 } |
505 | 505 |
506 } // namespace protocol | 506 } // namespace protocol |
507 } // namespace remoting | 507 } // namespace remoting |
OLD | NEW |