OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "net/base/address_list.h" | 9 #include "net/base/address_list.h" |
10 #include "net/base/completion_callback.h" | 10 #include "net/base/completion_callback.h" |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 socket_write_pending_ = false; | 362 socket_write_pending_ = false; |
363 if (result < 0) { | 363 if (result < 0) { |
364 LOG(WARNING) << "Write failed. Error code: " << result; | 364 LOG(WARNING) << "Write failed. Error code: " << result; |
365 } | 365 } |
366 } | 366 } |
367 | 367 |
368 void PseudoTcpAdapter::Core::AdjustClock() { | 368 void PseudoTcpAdapter::Core::AdjustClock() { |
369 long timeout = 0; | 369 long timeout = 0; |
370 if (pseudo_tcp_.GetNextClock(PseudoTcp::Now(), timeout)) { | 370 if (pseudo_tcp_.GetNextClock(PseudoTcp::Now(), timeout)) { |
371 timer_.Stop(); | 371 timer_.Stop(); |
372 timer_.Start(FROM_HERE, | 372 timer_.Start(base::TimeDelta::FromMilliseconds(std::max(timeout, 0L)), this, |
373 base::TimeDelta::FromMilliseconds(std::max(timeout, 0L)), this, | |
374 &PseudoTcpAdapter::Core::HandleTcpClock); | 373 &PseudoTcpAdapter::Core::HandleTcpClock); |
375 } | 374 } |
376 } | 375 } |
377 | 376 |
378 void PseudoTcpAdapter::Core::HandleTcpClock() { | 377 void PseudoTcpAdapter::Core::HandleTcpClock() { |
379 // Reference the Core in case a callback deletes the adapter. | 378 // Reference the Core in case a callback deletes the adapter. |
380 scoped_refptr<Core> core(this); | 379 scoped_refptr<Core> core(this); |
381 | 380 |
382 pseudo_tcp_.NotifyClock(PseudoTcp::Now()); | 381 pseudo_tcp_.NotifyClock(PseudoTcp::Now()); |
383 AdjustClock(); | 382 AdjustClock(); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 DCHECK(CalledOnValidThread()); | 499 DCHECK(CalledOnValidThread()); |
501 core_->SetAckDelay(delay_ms); | 500 core_->SetAckDelay(delay_ms); |
502 } | 501 } |
503 | 502 |
504 void PseudoTcpAdapter::SetNoDelay(bool no_delay) { | 503 void PseudoTcpAdapter::SetNoDelay(bool no_delay) { |
505 DCHECK(CalledOnValidThread()); | 504 DCHECK(CalledOnValidThread()); |
506 core_->SetNoDelay(no_delay); | 505 core_->SetNoDelay(no_delay); |
507 } | 506 } |
508 | 507 |
509 } // namespace jingle_glue | 508 } // namespace jingle_glue |
OLD | NEW |