Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: remoting/test/fake_socket_factory.cc

Issue 1642793002: Add performance test for WebRTC protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@client_webrtc_support
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/test/cyclic_frame_generator.cc ('k') | remoting/test/protocol_perftest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // MSVC++ requires this to be set before any other includes to get M_PI. 5 // MSVC++ requires this to be set before any other includes to get M_PI.
6 #define _USE_MATH_DEFINES 6 #define _USE_MATH_DEFINES
7 7
8 #include "remoting/test/fake_socket_factory.h" 8 #include "remoting/test/fake_socket_factory.h"
9 9
10 #include <math.h> 10 #include <math.h>
11 #include <stddef.h> 11 #include <stddef.h>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/rand_util.h" 17 #include "base/rand_util.h"
18 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
19 #include "base/thread_task_runner_handle.h" 19 #include "base/thread_task_runner_handle.h"
20 #include "base/time/time.h"
20 #include "net/base/io_buffer.h" 21 #include "net/base/io_buffer.h"
21 #include "remoting/test/leaky_bucket.h" 22 #include "remoting/test/leaky_bucket.h"
23 #include "third_party/libjingle/source/talk/media/base/rtputils.h"
22 #include "third_party/webrtc/base/asyncpacketsocket.h" 24 #include "third_party/webrtc/base/asyncpacketsocket.h"
23 25
24 namespace remoting { 26 namespace remoting {
25 27
26 namespace { 28 namespace {
27 29
28 const int kPortRangeStart = 1024; 30 const int kPortRangeStart = 1024;
29 const int kPortRangeEnd = 65535; 31 const int kPortRangeEnd = 65535;
30 32
31 double GetNormalRandom(double average, double stddev) { 33 double GetNormalRandom(double average, double stddev) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 const rtc::PacketOptions& options) { 110 const rtc::PacketOptions& options) {
109 NOTREACHED(); 111 NOTREACHED();
110 return EINVAL; 112 return EINVAL;
111 } 113 }
112 114
113 int FakeUdpSocket::SendTo(const void* data, size_t data_size, 115 int FakeUdpSocket::SendTo(const void* data, size_t data_size,
114 const rtc::SocketAddress& address, 116 const rtc::SocketAddress& address,
115 const rtc::PacketOptions& options) { 117 const rtc::PacketOptions& options) {
116 scoped_refptr<net::IOBuffer> buffer = new net::IOBuffer(data_size); 118 scoped_refptr<net::IOBuffer> buffer = new net::IOBuffer(data_size);
117 memcpy(buffer->data(), data, data_size); 119 memcpy(buffer->data(), data, data_size);
120 cricket::ApplyPacketOptions(
121 reinterpret_cast<uint8_t*>(buffer->data()), data_size,
122 options.packet_time_params,
123 (base::TimeTicks::Now() - base::TimeTicks()).InMilliseconds());
118 dispatcher_->DeliverPacket(local_address_, address, buffer, data_size); 124 dispatcher_->DeliverPacket(local_address_, address, buffer, data_size);
119 return data_size; 125 return data_size;
120 } 126 }
121 127
122 int FakeUdpSocket::Close() { 128 int FakeUdpSocket::Close() {
123 state_ = STATE_CLOSED; 129 state_ = STATE_CLOSED;
124 return 0; 130 return 0;
125 } 131 }
126 132
127 rtc::AsyncPacketSocket::State FakeUdpSocket::GetState() const { 133 rtc::AsyncPacketSocket::State FakeUdpSocket::GetState() const {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 UdpSocketsMap::iterator iter = udp_sockets_.find(packet.to.port()); 331 UdpSocketsMap::iterator iter = udp_sockets_.find(packet.to.port());
326 if (iter == udp_sockets_.end()) { 332 if (iter == udp_sockets_.end()) {
327 // Invalid port number. 333 // Invalid port number.
328 return; 334 return;
329 } 335 }
330 336
331 iter->second.Run(packet.from, packet.to, packet.data, packet.data_size); 337 iter->second.Run(packet.from, packet.to, packet.data, packet.data_size);
332 } 338 }
333 339
334 } // namespace remoting 340 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/test/cyclic_frame_generator.cc ('k') | remoting/test/protocol_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698