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

Side by Side Diff: ipc/ipc_send_fds_test.cc

Issue 669953003: Revert of Standardize usage of virtual/override/final in ipc/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | « ipc/ipc_perftest_support.cc ('k') | ipc/ipc_sync_channel.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_POSIX) 7 #if defined(OS_POSIX)
8 #if defined(OS_MACOSX) 8 #if defined(OS_MACOSX)
9 extern "C" { 9 extern "C" {
10 #include <sandbox.h> 10 #include <sandbox.h>
(...skipping 15 matching lines...) Expand all
26 #include "ipc/ipc_message_utils.h" 26 #include "ipc/ipc_message_utils.h"
27 #include "ipc/ipc_test_base.h" 27 #include "ipc/ipc_test_base.h"
28 28
29 namespace { 29 namespace {
30 30
31 const unsigned kNumFDsToSend = 20; 31 const unsigned kNumFDsToSend = 20;
32 const char* kDevZeroPath = "/dev/zero"; 32 const char* kDevZeroPath = "/dev/zero";
33 33
34 class MyChannelDescriptorListenerBase : public IPC::Listener { 34 class MyChannelDescriptorListenerBase : public IPC::Listener {
35 public: 35 public:
36 bool OnMessageReceived(const IPC::Message& message) override { 36 virtual bool OnMessageReceived(const IPC::Message& message) override {
37 PickleIterator iter(message); 37 PickleIterator iter(message);
38 38
39 base::FileDescriptor descriptor; 39 base::FileDescriptor descriptor;
40 40
41 IPC::ParamTraits<base::FileDescriptor>::Read(&message, &iter, &descriptor); 41 IPC::ParamTraits<base::FileDescriptor>::Read(&message, &iter, &descriptor);
42 42
43 HandleFD(descriptor.fd); 43 HandleFD(descriptor.fd);
44 return true; 44 return true;
45 } 45 }
46 46
47 protected: 47 protected:
48 virtual void HandleFD(int fd) = 0; 48 virtual void HandleFD(int fd) = 0;
49 }; 49 };
50 50
51 class MyChannelDescriptorListener : public MyChannelDescriptorListenerBase { 51 class MyChannelDescriptorListener : public MyChannelDescriptorListenerBase {
52 public: 52 public:
53 explicit MyChannelDescriptorListener(ino_t expected_inode_num) 53 explicit MyChannelDescriptorListener(ino_t expected_inode_num)
54 : MyChannelDescriptorListenerBase(), 54 : MyChannelDescriptorListenerBase(),
55 expected_inode_num_(expected_inode_num), 55 expected_inode_num_(expected_inode_num),
56 num_fds_received_(0) { 56 num_fds_received_(0) {
57 } 57 }
58 58
59 bool GotExpectedNumberOfDescriptors() const { 59 bool GotExpectedNumberOfDescriptors() const {
60 return num_fds_received_ == kNumFDsToSend; 60 return num_fds_received_ == kNumFDsToSend;
61 } 61 }
62 62
63 void OnChannelError() override { base::MessageLoop::current()->Quit(); } 63 virtual void OnChannelError() override {
64 base::MessageLoop::current()->Quit();
65 }
64 66
65 protected: 67 protected:
66 void HandleFD(int fd) override { 68 virtual void HandleFD(int fd) override {
67 // Check that we can read from the FD. 69 // Check that we can read from the FD.
68 char buf; 70 char buf;
69 ssize_t amt_read = read(fd, &buf, 1); 71 ssize_t amt_read = read(fd, &buf, 1);
70 ASSERT_EQ(amt_read, 1); 72 ASSERT_EQ(amt_read, 1);
71 ASSERT_EQ(buf, 0); // /dev/zero always reads 0 bytes. 73 ASSERT_EQ(buf, 0); // /dev/zero always reads 0 bytes.
72 74
73 struct stat st; 75 struct stat st;
74 ASSERT_EQ(fstat(fd, &st), 0); 76 ASSERT_EQ(fstat(fd, &st), 0);
75 77
76 ASSERT_EQ(close(fd), 0); 78 ASSERT_EQ(close(fd), 0);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 195
194 196
195 class MyCBListener : public MyChannelDescriptorListenerBase { 197 class MyCBListener : public MyChannelDescriptorListenerBase {
196 public: 198 public:
197 MyCBListener(base::Callback<void(int)> cb, int fds_to_send) 199 MyCBListener(base::Callback<void(int)> cb, int fds_to_send)
198 : MyChannelDescriptorListenerBase(), 200 : MyChannelDescriptorListenerBase(),
199 cb_(cb) { 201 cb_(cb) {
200 } 202 }
201 203
202 protected: 204 protected:
203 void HandleFD(int fd) override { cb_.Run(fd); } 205 virtual void HandleFD(int fd) override {
206 cb_.Run(fd);
207 }
204 private: 208 private:
205 base::Callback<void(int)> cb_; 209 base::Callback<void(int)> cb_;
206 }; 210 };
207 211
208 std::pair<int, int> make_socket_pair() { 212 std::pair<int, int> make_socket_pair() {
209 int pipe_fds[2]; 213 int pipe_fds[2];
210 CHECK_EQ(0, HANDLE_EINTR(socketpair(AF_UNIX, SOCK_STREAM, 0, pipe_fds))); 214 CHECK_EQ(0, HANDLE_EINTR(socketpair(AF_UNIX, SOCK_STREAM, 0, pipe_fds)));
211 return std::pair<int, int>(pipe_fds[0], pipe_fds[1]); 215 return std::pair<int, int>(pipe_fds[0], pipe_fds[1]);
212 } 216 }
213 217
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 base::WaitableEvent received_; 367 base::WaitableEvent received_;
364 }; 368 };
365 369
366 TEST_F(IPCMultiSendingFdsTest, StressTest) { 370 TEST_F(IPCMultiSendingFdsTest, StressTest) {
367 Run(); 371 Run();
368 } 372 }
369 373
370 } // namespace 374 } // namespace
371 375
372 #endif // defined(OS_POSIX) 376 #endif // defined(OS_POSIX)
OLDNEW
« no previous file with comments | « ipc/ipc_perftest_support.cc ('k') | ipc/ipc_sync_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698