| OLD | NEW |
| 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 "media/cast/test/utility/udp_proxy.h" | 5 #include "media/cast/test/utility/udp_proxy.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
| 15 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
| 16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
| 17 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "base/time/default_tick_clock.h" | 18 #include "base/time/default_tick_clock.h" |
| 19 #include "net/base/io_buffer.h" | 19 #include "net/base/io_buffer.h" |
| 20 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
| 21 #include "net/log/net_log_source.h" |
| 21 #include "net/udp/udp_server_socket.h" | 22 #include "net/udp/udp_server_socket.h" |
| 22 | 23 |
| 23 namespace media { | 24 namespace media { |
| 24 namespace cast { | 25 namespace cast { |
| 25 namespace test { | 26 namespace test { |
| 26 | 27 |
| 27 const size_t kMaxPacketSize = 65536; | 28 const size_t kMaxPacketSize = 65536; |
| 28 | 29 |
| 29 PacketPipe::PacketPipe() {} | 30 PacketPipe::PacketPipe() {} |
| 30 PacketPipe::~PacketPipe() {} | 31 PacketPipe::~PacketPipe() {} |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 if (result == net::ERR_IO_PENDING) { | 732 if (result == net::ERR_IO_PENDING) { |
| 732 blocked_ = true; | 733 blocked_ = true; |
| 733 } else if (result < 0) { | 734 } else if (result < 0) { |
| 734 LOG(ERROR) << "Failed to write packet."; | 735 LOG(ERROR) << "Failed to write packet."; |
| 735 } | 736 } |
| 736 } | 737 } |
| 737 | 738 |
| 738 private: | 739 private: |
| 739 void Start(base::WaitableEvent* start_event, | 740 void Start(base::WaitableEvent* start_event, |
| 740 net::NetLog* net_log) { | 741 net::NetLog* net_log) { |
| 741 socket_.reset(new net::UDPServerSocket(net_log, net::NetLog::Source())); | 742 socket_.reset(new net::UDPServerSocket(net_log, net::NetLogSource())); |
| 742 BuildPipe(&to_dest_pipe_, new PacketSender(this, &destination_)); | 743 BuildPipe(&to_dest_pipe_, new PacketSender(this, &destination_)); |
| 743 BuildPipe(&from_dest_pipe_, new PacketSender(this, &return_address_)); | 744 BuildPipe(&from_dest_pipe_, new PacketSender(this, &return_address_)); |
| 744 to_dest_pipe_->InitOnIOThread(base::ThreadTaskRunnerHandle::Get(), | 745 to_dest_pipe_->InitOnIOThread(base::ThreadTaskRunnerHandle::Get(), |
| 745 &tick_clock_); | 746 &tick_clock_); |
| 746 from_dest_pipe_->InitOnIOThread(base::ThreadTaskRunnerHandle::Get(), | 747 from_dest_pipe_->InitOnIOThread(base::ThreadTaskRunnerHandle::Get(), |
| 747 &tick_clock_); | 748 &tick_clock_); |
| 748 | 749 |
| 749 VLOG(0) << "From:" << local_port_.ToString(); | 750 VLOG(0) << "From:" << local_port_.ToString(); |
| 750 if (!destination_is_mutable_) | 751 if (!destination_is_mutable_) |
| 751 VLOG(0) << "To:" << destination_.ToString(); | 752 VLOG(0) << "To:" << destination_.ToString(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 net::NetLog* net_log) { | 854 net::NetLog* net_log) { |
| 854 std::unique_ptr<UDPProxy> ret( | 855 std::unique_ptr<UDPProxy> ret( |
| 855 new UDPProxyImpl(local_port, destination, std::move(to_dest_pipe), | 856 new UDPProxyImpl(local_port, destination, std::move(to_dest_pipe), |
| 856 std::move(from_dest_pipe), net_log)); | 857 std::move(from_dest_pipe), net_log)); |
| 857 return ret; | 858 return ret; |
| 858 } | 859 } |
| 859 | 860 |
| 860 } // namespace test | 861 } // namespace test |
| 861 } // namespace cast | 862 } // namespace cast |
| 862 } // namespace media | 863 } // namespace media |
| OLD | NEW |