| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 // Send a test multicast packet every second. | 98 // Send a test multicast packet every second. |
| 99 // Once the target socket received the packet, the message loop will exit. | 99 // Once the target socket received the packet, the message loop will exit. |
| 100 static void SendMulticastPacket(const base::Closure& quit_run_loop, | 100 static void SendMulticastPacket(const base::Closure& quit_run_loop, |
| 101 UDPSocket* src, | 101 UDPSocket* src, |
| 102 int result) { | 102 int result) { |
| 103 if (result == 0) { | 103 if (result == 0) { |
| 104 scoped_refptr<net::IOBuffer> data = new net::WrappedIOBuffer(test_message); | 104 scoped_refptr<net::IOBuffer> data = new net::WrappedIOBuffer(test_message); |
| 105 src->Write(data, test_message_length, base::Bind(&OnSendCompleted)); | 105 src->Write(data, test_message_length, base::Bind(&OnSendCompleted)); |
| 106 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 106 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 107 FROM_HERE, base::Bind(&SendMulticastPacket, quit_run_loop, src, result), | 107 FROM_HERE, |
| 108 base::BindOnce(&SendMulticastPacket, quit_run_loop, src, result), |
| 108 base::TimeDelta::FromSeconds(1)); | 109 base::TimeDelta::FromSeconds(1)); |
| 109 } else { | 110 } else { |
| 110 quit_run_loop.Run(); | 111 quit_run_loop.Run(); |
| 111 FAIL() << "Failed to connect to multicast address. Error code: " << result; | 112 FAIL() << "Failed to connect to multicast address. Error code: " << result; |
| 112 } | 113 } |
| 113 } | 114 } |
| 114 | 115 |
| 115 static void OnMulticastReadCompleted(const base::Closure& quit_run_loop, | 116 static void OnMulticastReadCompleted(const base::Closure& quit_run_loop, |
| 116 bool* packet_received, | 117 bool* packet_received, |
| 117 int count, | 118 int count, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 147 // If not received within the test action timeout, quit the message loop. | 148 // If not received within the test action timeout, quit the message loop. |
| 148 io_loop.task_runner()->PostDelayedTask(FROM_HERE, run_loop.QuitClosure(), | 149 io_loop.task_runner()->PostDelayedTask(FROM_HERE, run_loop.QuitClosure(), |
| 149 TestTimeouts::action_timeout()); | 150 TestTimeouts::action_timeout()); |
| 150 | 151 |
| 151 run_loop.Run(); | 152 run_loop.Run(); |
| 152 | 153 |
| 153 EXPECT_TRUE(packet_received) << "Failed to receive from multicast address"; | 154 EXPECT_TRUE(packet_received) << "Failed to receive from multicast address"; |
| 154 } | 155 } |
| 155 | 156 |
| 156 } // namespace extensions | 157 } // namespace extensions |
| OLD | NEW |