| 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 <math.h> | 5 #include <math.h> |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "media/cast/test/utility/udp_proxy.h" | 9 #include "media/cast/test/utility/udp_proxy.h" |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
| 13 #include "base/single_thread_task_runner.h" |
| 13 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
| 15 #include "base/thread_task_runner_handle.h" |
| 14 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
| 15 #include "base/time/default_tick_clock.h" | 17 #include "base/time/default_tick_clock.h" |
| 16 #include "net/base/io_buffer.h" | 18 #include "net/base/io_buffer.h" |
| 17 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
| 18 #include "net/udp/udp_server_socket.h" | 20 #include "net/udp/udp_server_socket.h" |
| 19 | 21 |
| 20 namespace media { | 22 namespace media { |
| 21 namespace cast { | 23 namespace cast { |
| 22 namespace test { | 24 namespace test { |
| 23 | 25 |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 LOG(ERROR) << "Failed to write packet."; | 736 LOG(ERROR) << "Failed to write packet."; |
| 735 } | 737 } |
| 736 } | 738 } |
| 737 | 739 |
| 738 private: | 740 private: |
| 739 void Start(base::WaitableEvent* start_event, | 741 void Start(base::WaitableEvent* start_event, |
| 740 net::NetLog* net_log) { | 742 net::NetLog* net_log) { |
| 741 socket_.reset(new net::UDPServerSocket(net_log, net::NetLog::Source())); | 743 socket_.reset(new net::UDPServerSocket(net_log, net::NetLog::Source())); |
| 742 BuildPipe(&to_dest_pipe_, new PacketSender(this, &destination_)); | 744 BuildPipe(&to_dest_pipe_, new PacketSender(this, &destination_)); |
| 743 BuildPipe(&from_dest_pipe_, new PacketSender(this, &return_address_)); | 745 BuildPipe(&from_dest_pipe_, new PacketSender(this, &return_address_)); |
| 744 to_dest_pipe_->InitOnIOThread(base::MessageLoopProxy::current(), | 746 to_dest_pipe_->InitOnIOThread(base::ThreadTaskRunnerHandle::Get(), |
| 745 &tick_clock_); | 747 &tick_clock_); |
| 746 from_dest_pipe_->InitOnIOThread(base::MessageLoopProxy::current(), | 748 from_dest_pipe_->InitOnIOThread(base::ThreadTaskRunnerHandle::Get(), |
| 747 &tick_clock_); | 749 &tick_clock_); |
| 748 | 750 |
| 749 VLOG(0) << "From:" << local_port_.ToString(); | 751 VLOG(0) << "From:" << local_port_.ToString(); |
| 750 if (!destination_is_mutable_) | 752 if (!destination_is_mutable_) |
| 751 VLOG(0) << "To:" << destination_.ToString(); | 753 VLOG(0) << "To:" << destination_.ToString(); |
| 752 | 754 |
| 753 CHECK_GE(socket_->Listen(local_port_), 0); | 755 CHECK_GE(socket_->Listen(local_port_), 0); |
| 754 | 756 |
| 755 start_event->Signal(); | 757 start_event->Signal(); |
| 756 PollRead(); | 758 PollRead(); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 destination, | 857 destination, |
| 856 to_dest_pipe.Pass(), | 858 to_dest_pipe.Pass(), |
| 857 from_dest_pipe.Pass(), | 859 from_dest_pipe.Pass(), |
| 858 net_log)); | 860 net_log)); |
| 859 return ret.Pass(); | 861 return ret.Pass(); |
| 860 } | 862 } |
| 861 | 863 |
| 862 } // namespace test | 864 } // namespace test |
| 863 } // namespace cast | 865 } // namespace cast |
| 864 } // namespace media | 866 } // namespace media |
| OLD | NEW |