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