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

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

Issue 661163004: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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/cast/test/end2end_unittest.cc ('k') | media/ffmpeg/ffmpeg_common_unittest.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>
(...skipping 23 matching lines...) Expand all
34 namespace media { 34 namespace media {
35 namespace cast { 35 namespace cast {
36 namespace test { 36 namespace test {
37 37
38 const size_t kMaxPacketSize = 4096; 38 const size_t kMaxPacketSize = 4096;
39 39
40 class SendToFDPipe : public PacketPipe { 40 class SendToFDPipe : public PacketPipe {
41 public: 41 public:
42 explicit SendToFDPipe(int fd) : fd_(fd) { 42 explicit SendToFDPipe(int fd) : fd_(fd) {
43 } 43 }
44 virtual void Send(scoped_ptr<Packet> packet) override { 44 void Send(scoped_ptr<Packet> packet) override {
45 while (1) { 45 while (1) {
46 int written = write( 46 int written = write(
47 fd_, 47 fd_,
48 reinterpret_cast<char*>(&packet->front()), 48 reinterpret_cast<char*>(&packet->front()),
49 packet->size()); 49 packet->size());
50 if (written < 0) { 50 if (written < 0) {
51 if (errno == EINTR) continue; 51 if (errno == EINTR) continue;
52 perror("write"); 52 perror("write");
53 exit(1); 53 exit(1);
54 } 54 }
(...skipping 23 matching lines...) Expand all
78 scoped_ptr<PacketPipe> tmp(new SendToFDPipe(output_fd)); 78 scoped_ptr<PacketPipe> tmp(new SendToFDPipe(output_fd));
79 if (packet_pipe_) { 79 if (packet_pipe_) {
80 packet_pipe_->AppendToPipe(tmp.Pass()); 80 packet_pipe_->AppendToPipe(tmp.Pass());
81 } else { 81 } else {
82 packet_pipe_ = tmp.Pass(); 82 packet_pipe_ = tmp.Pass();
83 } 83 }
84 packet_pipe_->InitOnIOThread(base::MessageLoopProxy::current(), 84 packet_pipe_->InitOnIOThread(base::MessageLoopProxy::current(),
85 &tick_clock_); 85 &tick_clock_);
86 } 86 }
87 87
88 virtual ~QueueManager() { 88 ~QueueManager() override {}
89 }
90 89
91 // MessageLoopForIO::Watcher methods 90 // MessageLoopForIO::Watcher methods
92 virtual void OnFileCanReadWithoutBlocking(int fd) override { 91 void OnFileCanReadWithoutBlocking(int fd) override {
93 scoped_ptr<Packet> packet(new Packet(kMaxPacketSize)); 92 scoped_ptr<Packet> packet(new Packet(kMaxPacketSize));
94 int nread = read(input_fd_, 93 int nread = read(input_fd_,
95 reinterpret_cast<char*>(&packet->front()), 94 reinterpret_cast<char*>(&packet->front()),
96 kMaxPacketSize); 95 kMaxPacketSize);
97 if (nread < 0) { 96 if (nread < 0) {
98 if (errno == EINTR) return; 97 if (errno == EINTR) return;
99 perror("read"); 98 perror("read");
100 exit(1); 99 exit(1);
101 } 100 }
102 if (nread == 0) return; 101 if (nread == 0) return;
103 packet->resize(nread); 102 packet->resize(nread);
104 packet_pipe_->Send(packet.Pass()); 103 packet_pipe_->Send(packet.Pass());
105 } 104 }
106 virtual void OnFileCanWriteWithoutBlocking(int fd) override { 105 void OnFileCanWriteWithoutBlocking(int fd) override { NOTREACHED(); }
107 NOTREACHED();
108 }
109 106
110 private: 107 private:
111 int input_fd_; 108 int input_fd_;
112 scoped_ptr<PacketPipe> packet_pipe_; 109 scoped_ptr<PacketPipe> packet_pipe_;
113 base::MessageLoopForIO::FileDescriptorWatcher read_socket_watcher_; 110 base::MessageLoopForIO::FileDescriptorWatcher read_socket_watcher_;
114 base::DefaultTickClock tick_clock_; 111 base::DefaultTickClock tick_clock_;
115 }; 112 };
116 113
117 } // namespace test 114 } // namespace test
118 } // namespace cast 115 } // namespace cast
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 }; 162 };
166 163
167 ByteCounter in_pipe_input_counter; 164 ByteCounter in_pipe_input_counter;
168 ByteCounter in_pipe_output_counter; 165 ByteCounter in_pipe_output_counter;
169 ByteCounter out_pipe_input_counter; 166 ByteCounter out_pipe_input_counter;
170 ByteCounter out_pipe_output_counter; 167 ByteCounter out_pipe_output_counter;
171 168
172 class ByteCounterPipe : public media::cast::test::PacketPipe { 169 class ByteCounterPipe : public media::cast::test::PacketPipe {
173 public: 170 public:
174 ByteCounterPipe(ByteCounter* counter) : counter_(counter) {} 171 ByteCounterPipe(ByteCounter* counter) : counter_(counter) {}
175 virtual void Send(scoped_ptr<media::cast::Packet> packet) 172 void Send(scoped_ptr<media::cast::Packet> packet) override {
176 override {
177 counter_->Increment(packet->size()); 173 counter_->Increment(packet->size());
178 pipe_->Send(packet.Pass()); 174 pipe_->Send(packet.Pass());
179 } 175 }
180 private: 176 private:
181 ByteCounter* counter_; 177 ByteCounter* counter_;
182 }; 178 };
183 179
184 void SetupByteCounters(scoped_ptr<media::cast::test::PacketPipe>* pipe, 180 void SetupByteCounters(scoped_ptr<media::cast::test::PacketPipe>* pipe,
185 ByteCounter* pipe_input_counter, 181 ByteCounter* pipe_input_counter,
186 ByteCounter* pipe_output_counter) { 182 ByteCounter* pipe_output_counter) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 int fd2 = tun_alloc(argv[2], IFF_TAP); 305 int fd2 = tun_alloc(argv[2], IFF_TAP);
310 306
311 base::MessageLoopForIO message_loop; 307 base::MessageLoopForIO message_loop;
312 last_printout = base::TimeTicks::Now(); 308 last_printout = base::TimeTicks::Now();
313 media::cast::test::QueueManager qm1(fd1, fd2, in_pipe.Pass()); 309 media::cast::test::QueueManager qm1(fd1, fd2, in_pipe.Pass());
314 media::cast::test::QueueManager qm2(fd2, fd1, out_pipe.Pass()); 310 media::cast::test::QueueManager qm2(fd2, fd1, out_pipe.Pass());
315 CheckByteCounters(); 311 CheckByteCounters();
316 printf("Press Ctrl-C when done.\n"); 312 printf("Press Ctrl-C when done.\n");
317 message_loop.Run(); 313 message_loop.Run();
318 } 314 }
OLDNEW
« no previous file with comments | « media/cast/test/end2end_unittest.cc ('k') | media/ffmpeg/ffmpeg_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698