OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/test/perf_time_logger.h" | 10 #include "base/test/perf_time_logger.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // has effect on Windows. | 45 // has effect on Windows. |
46 void WriteBenchmark(bool use_nonblocking_io); | 46 void WriteBenchmark(bool use_nonblocking_io); |
47 | 47 |
48 protected: | 48 protected: |
49 static const int kPacketSize = 1024; | 49 static const int kPacketSize = 1024; |
50 scoped_refptr<IOBufferWithSize> buffer_; | 50 scoped_refptr<IOBufferWithSize> buffer_; |
51 base::WeakPtrFactory<UDPSocketPerfTest> weak_factory_; | 51 base::WeakPtrFactory<UDPSocketPerfTest> weak_factory_; |
52 }; | 52 }; |
53 | 53 |
54 // Creates and address from an ip/port and returns it in |address|. | 54 // Creates and address from an ip/port and returns it in |address|. |
55 void CreateUDPAddress(std::string ip_str, uint16 port, IPEndPoint* address) { | 55 void CreateUDPAddress(const std::string& ip_str, |
| 56 uint16 port, |
| 57 IPEndPoint* address) { |
56 IPAddressNumber ip_number; | 58 IPAddressNumber ip_number; |
57 bool rv = ParseIPLiteralToNumber(ip_str, &ip_number); | 59 bool rv = ParseIPLiteralToNumber(ip_str, &ip_number); |
58 if (!rv) | 60 if (!rv) |
59 return; | 61 return; |
60 *address = IPEndPoint(ip_number, port); | 62 *address = IPEndPoint(ip_number, port); |
61 } | 63 } |
62 | 64 |
63 void UDPSocketPerfTest::WritePacketsToSocket(UDPClientSocket* socket, | 65 void UDPSocketPerfTest::WritePacketsToSocket(UDPClientSocket* socket, |
64 int num_of_packets, | 66 int num_of_packets, |
65 base::Closure done_callback) { | 67 base::Closure done_callback) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 #if defined(OS_WIN) | 132 #if defined(OS_WIN) |
131 TEST_F(UDPSocketPerfTest, WriteNonBlocking) { | 133 TEST_F(UDPSocketPerfTest, WriteNonBlocking) { |
132 base::PerfTimeLogger timer("UDP_socket_write_nonblocking"); | 134 base::PerfTimeLogger timer("UDP_socket_write_nonblocking"); |
133 WriteBenchmark(true); | 135 WriteBenchmark(true); |
134 } | 136 } |
135 #endif | 137 #endif |
136 | 138 |
137 } // namespace | 139 } // namespace |
138 | 140 |
139 } // namespace net | 141 } // namespace net |
OLD | NEW |