| 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> |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 : local_port_(local_port), | 669 : local_port_(local_port), |
| 670 destination_(destination), | 670 destination_(destination), |
| 671 destination_is_mutable_(destination.address().empty()), | 671 destination_is_mutable_(destination.address().empty()), |
| 672 proxy_thread_("media::cast::test::UdpProxy Thread"), | 672 proxy_thread_("media::cast::test::UdpProxy Thread"), |
| 673 to_dest_pipe_(std::move(to_dest_pipe)), | 673 to_dest_pipe_(std::move(to_dest_pipe)), |
| 674 from_dest_pipe_(std::move(from_dest_pipe)), | 674 from_dest_pipe_(std::move(from_dest_pipe)), |
| 675 blocked_(false), | 675 blocked_(false), |
| 676 weak_factory_(this) { | 676 weak_factory_(this) { |
| 677 proxy_thread_.StartWithOptions( | 677 proxy_thread_.StartWithOptions( |
| 678 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 678 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 679 base::WaitableEvent start_event(false, false); | 679 base::WaitableEvent start_event( |
| 680 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 681 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 680 proxy_thread_.task_runner()->PostTask( | 682 proxy_thread_.task_runner()->PostTask( |
| 681 FROM_HERE, | 683 FROM_HERE, |
| 682 base::Bind(&UDPProxyImpl::Start, | 684 base::Bind(&UDPProxyImpl::Start, |
| 683 base::Unretained(this), | 685 base::Unretained(this), |
| 684 base::Unretained(&start_event), | 686 base::Unretained(&start_event), |
| 685 net_log)); | 687 net_log)); |
| 686 start_event.Wait(); | 688 start_event.Wait(); |
| 687 } | 689 } |
| 688 | 690 |
| 689 ~UDPProxyImpl() final { | 691 ~UDPProxyImpl() final { |
| 690 base::WaitableEvent stop_event(false, false); | 692 base::WaitableEvent stop_event( |
| 693 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 694 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 691 proxy_thread_.task_runner()->PostTask( | 695 proxy_thread_.task_runner()->PostTask( |
| 692 FROM_HERE, | 696 FROM_HERE, |
| 693 base::Bind(&UDPProxyImpl::Stop, | 697 base::Bind(&UDPProxyImpl::Stop, |
| 694 base::Unretained(this), | 698 base::Unretained(this), |
| 695 base::Unretained(&stop_event))); | 699 base::Unretained(&stop_event))); |
| 696 stop_event.Wait(); | 700 stop_event.Wait(); |
| 697 proxy_thread_.Stop(); | 701 proxy_thread_.Stop(); |
| 698 } | 702 } |
| 699 | 703 |
| 700 void Send(std::unique_ptr<Packet> packet, | 704 void Send(std::unique_ptr<Packet> packet, |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 net::NetLog* net_log) { | 853 net::NetLog* net_log) { |
| 850 std::unique_ptr<UDPProxy> ret( | 854 std::unique_ptr<UDPProxy> ret( |
| 851 new UDPProxyImpl(local_port, destination, std::move(to_dest_pipe), | 855 new UDPProxyImpl(local_port, destination, std::move(to_dest_pipe), |
| 852 std::move(from_dest_pipe), net_log)); | 856 std::move(from_dest_pipe), net_log)); |
| 853 return ret; | 857 return ret; |
| 854 } | 858 } |
| 855 | 859 |
| 856 } // namespace test | 860 } // namespace test |
| 857 } // namespace cast | 861 } // namespace cast |
| 858 } // namespace media | 862 } // namespace media |
| OLD | NEW |