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 <cstdio> | 5 #include <cstdio> |
6 #include <cstdlib> | 6 #include <cstdlib> |
7 #include <deque> | 7 #include <deque> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/single_thread_task_runner.h" | |
17 #include "base/thread_task_runner_handle.h" | |
18 #include "media/cast/test/utility/udp_proxy.h" | 16 #include "media/cast/test/utility/udp_proxy.h" |
19 | 17 |
20 class ByteCounter { | 18 class ByteCounter { |
21 public: | 19 public: |
22 ByteCounter() : bytes_(0), packets_(0) { | 20 ByteCounter() : bytes_(0), packets_(0) { |
23 push(base::TimeTicks::Now()); | 21 push(base::TimeTicks::Now()); |
24 } | 22 } |
25 | 23 |
26 base::TimeDelta time_range() { | 24 base::TimeDelta time_range() { |
27 return time_data_.back() - time_data_.front(); | 25 return time_data_.back() - time_data_.front(); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 g_counter.Get().in_pipe_output_counter.packets_per_second(), | 108 g_counter.Get().in_pipe_output_counter.packets_per_second(), |
111 g_counter.Get().in_pipe_input_counter.packets_per_second()); | 109 g_counter.Get().in_pipe_input_counter.packets_per_second()); |
112 fprintf(stderr, "Receiving: %5.2f / %5.2f mbps %6.2f / %6.2f packets / s\n", | 110 fprintf(stderr, "Receiving: %5.2f / %5.2f mbps %6.2f / %6.2f packets / s\n", |
113 g_counter.Get().out_pipe_output_counter.megabits_per_second(), | 111 g_counter.Get().out_pipe_output_counter.megabits_per_second(), |
114 g_counter.Get().out_pipe_input_counter.megabits_per_second(), | 112 g_counter.Get().out_pipe_input_counter.megabits_per_second(), |
115 g_counter.Get().out_pipe_output_counter.packets_per_second(), | 113 g_counter.Get().out_pipe_output_counter.packets_per_second(), |
116 g_counter.Get().out_pipe_input_counter.packets_per_second()); | 114 g_counter.Get().out_pipe_input_counter.packets_per_second()); |
117 | 115 |
118 g_counter.Get().last_printout = now; | 116 g_counter.Get().last_printout = now; |
119 } | 117 } |
120 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 118 base::MessageLoopProxy::current()->PostDelayedTask( |
121 FROM_HERE, | 119 FROM_HERE, |
122 base::Bind(&CheckByteCounters), | 120 base::Bind(&CheckByteCounters), |
123 base::TimeDelta::FromMilliseconds(100)); | 121 base::TimeDelta::FromMilliseconds(100)); |
124 } | 122 } |
125 | 123 |
126 int main(int argc, char** argv) { | 124 int main(int argc, char** argv) { |
127 base::AtExitManager at_exit; | 125 base::AtExitManager at_exit; |
128 base::CommandLine::Init(argc, argv); | 126 base::CommandLine::Init(argc, argv); |
129 logging::LoggingSettings settings; | 127 logging::LoggingSettings settings; |
130 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 128 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 remote_endpoint, | 197 remote_endpoint, |
200 in_pipe.Pass(), | 198 in_pipe.Pass(), |
201 out_pipe.Pass(), | 199 out_pipe.Pass(), |
202 NULL)); | 200 NULL)); |
203 base::MessageLoop message_loop; | 201 base::MessageLoop message_loop; |
204 g_counter.Get().last_printout = base::TimeTicks::Now(); | 202 g_counter.Get().last_printout = base::TimeTicks::Now(); |
205 CheckByteCounters(); | 203 CheckByteCounters(); |
206 message_loop.Run(); | 204 message_loop.Run(); |
207 return 1; | 205 return 1; |
208 } | 206 } |
OLD | NEW |