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

Side by Side Diff: media/cast/test/utility/tap_proxy.cc

Issue 1105163004: Revert of [media] Replace MessageLoopProxy usage with ThreadTaskRunnerHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | « media/blink/webmediaplayer_impl.cc ('k') | media/cast/test/utility/udp_proxy.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 #include <fcntl.h> 5 #include <fcntl.h>
6 #include <linux/if_tun.h> 6 #include <linux/if_tun.h>
7 #include <linux/types.h> 7 #include <linux/types.h>
8 #include <math.h> 8 #include <math.h>
9 #include <net/if.h> 9 #include <net/if.h>
10 #include <netinet/in.h> 10 #include <netinet/in.h>
11 #include <stdio.h> 11 #include <stdio.h>
12 #include <stdlib.h> 12 #include <stdlib.h>
13 #include <sys/ioctl.h> 13 #include <sys/ioctl.h>
14 #include <sys/stat.h> 14 #include <sys/stat.h>
15 #include <sys/types.h> 15 #include <sys/types.h>
16 #include <unistd.h> 16 #include <unistd.h>
17 17
18 #include <deque> 18 #include <deque>
19 #include <map> 19 #include <map>
20 20
21 #include "base/at_exit.h" 21 #include "base/at_exit.h"
22 #include "base/bind.h" 22 #include "base/bind.h"
23 #include "base/command_line.h" 23 #include "base/command_line.h"
24 #include "base/logging.h" 24 #include "base/logging.h"
25 #include "base/rand_util.h" 25 #include "base/rand_util.h"
26 #include "base/single_thread_task_runner.h"
27 #include "base/synchronization/waitable_event.h" 26 #include "base/synchronization/waitable_event.h"
28 #include "base/thread_task_runner_handle.h"
29 #include "base/threading/thread.h" 27 #include "base/threading/thread.h"
30 #include "base/time/default_tick_clock.h" 28 #include "base/time/default_tick_clock.h"
31 #include "media/cast/test/utility/udp_proxy.h" 29 #include "media/cast/test/utility/udp_proxy.h"
32 #include "net/base/io_buffer.h" 30 #include "net/base/io_buffer.h"
33 #include "net/base/net_errors.h" 31 #include "net/base/net_errors.h"
34 #include "net/udp/udp_socket.h" 32 #include "net/udp/udp_socket.h"
35 33
36 namespace media { 34 namespace media {
37 namespace cast { 35 namespace cast {
38 namespace test { 36 namespace test {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 CHECK(base::MessageLoopForIO::current()->WatchFileDescriptor( 74 CHECK(base::MessageLoopForIO::current()->WatchFileDescriptor(
77 input_fd_, true, base::MessageLoopForIO::WATCH_READ, 75 input_fd_, true, base::MessageLoopForIO::WATCH_READ,
78 &read_socket_watcher_, this)); 76 &read_socket_watcher_, this));
79 77
80 scoped_ptr<PacketPipe> tmp(new SendToFDPipe(output_fd)); 78 scoped_ptr<PacketPipe> tmp(new SendToFDPipe(output_fd));
81 if (packet_pipe_) { 79 if (packet_pipe_) {
82 packet_pipe_->AppendToPipe(tmp.Pass()); 80 packet_pipe_->AppendToPipe(tmp.Pass());
83 } else { 81 } else {
84 packet_pipe_ = tmp.Pass(); 82 packet_pipe_ = tmp.Pass();
85 } 83 }
86 packet_pipe_->InitOnIOThread(base::ThreadTaskRunnerHandle::Get(), 84 packet_pipe_->InitOnIOThread(base::MessageLoopProxy::current(),
87 &tick_clock_); 85 &tick_clock_);
88 } 86 }
89 87
90 ~QueueManager() override {} 88 ~QueueManager() override {}
91 89
92 // MessageLoopForIO::Watcher methods 90 // MessageLoopForIO::Watcher methods
93 void OnFileCanReadWithoutBlocking(int fd) override { 91 void OnFileCanReadWithoutBlocking(int fd) override {
94 scoped_ptr<Packet> packet(new Packet(kMaxPacketSize)); 92 scoped_ptr<Packet> packet(new Packet(kMaxPacketSize));
95 int nread = read(input_fd_, 93 int nread = read(input_fd_,
96 reinterpret_cast<char*>(&packet->front()), 94 reinterpret_cast<char*>(&packet->front()),
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 in_pipe_output_counter.packets_per_second(), 202 in_pipe_output_counter.packets_per_second(),
205 in_pipe_input_counter.packets_per_second()); 203 in_pipe_input_counter.packets_per_second());
206 fprintf(stderr, "Receiving: %5.2f / %5.2f mbps %6.2f / %6.2f packets / s\n", 204 fprintf(stderr, "Receiving: %5.2f / %5.2f mbps %6.2f / %6.2f packets / s\n",
207 out_pipe_output_counter.megabits_per_second(), 205 out_pipe_output_counter.megabits_per_second(),
208 out_pipe_input_counter.megabits_per_second(), 206 out_pipe_input_counter.megabits_per_second(),
209 out_pipe_output_counter.packets_per_second(), 207 out_pipe_output_counter.packets_per_second(),
210 out_pipe_input_counter.packets_per_second()); 208 out_pipe_input_counter.packets_per_second());
211 209
212 last_printout = now; 210 last_printout = now;
213 } 211 }
214 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 212 base::MessageLoopProxy::current()->PostDelayedTask(
215 FROM_HERE, 213 FROM_HERE,
216 base::Bind(&CheckByteCounters), 214 base::Bind(&CheckByteCounters),
217 base::TimeDelta::FromMilliseconds(100)); 215 base::TimeDelta::FromMilliseconds(100));
218 } 216 }
219 217
220 int tun_alloc(char *dev, int flags) { 218 int tun_alloc(char *dev, int flags) {
221 struct ifreq ifr; 219 struct ifreq ifr;
222 int fd, err; 220 int fd, err;
223 const char *clonedev = "/dev/net/tun"; 221 const char *clonedev = "/dev/net/tun";
224 222
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 int fd2 = tun_alloc(argv[2], IFF_TAP); 305 int fd2 = tun_alloc(argv[2], IFF_TAP);
308 306
309 base::MessageLoopForIO message_loop; 307 base::MessageLoopForIO message_loop;
310 last_printout = base::TimeTicks::Now(); 308 last_printout = base::TimeTicks::Now();
311 media::cast::test::QueueManager qm1(fd1, fd2, in_pipe.Pass()); 309 media::cast::test::QueueManager qm1(fd1, fd2, in_pipe.Pass());
312 media::cast::test::QueueManager qm2(fd2, fd1, out_pipe.Pass()); 310 media::cast::test::QueueManager qm2(fd2, fd1, out_pipe.Pass());
313 CheckByteCounters(); 311 CheckByteCounters();
314 printf("Press Ctrl-C when done.\n"); 312 printf("Press Ctrl-C when done.\n");
315 message_loop.Run(); 313 message_loop.Run();
316 } 314 }
OLDNEW
« no previous file with comments | « media/blink/webmediaplayer_impl.cc ('k') | media/cast/test/utility/udp_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698