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

Side by Side Diff: ipc/ipc_send_fds_test.cc

Issue 1389163008: Don't use base::MessageLoop::{Quit,QuitClosure} in extensions/, ipc/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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_fuzzing_tests.cc ('k') | ipc/ipc_test_channel_listener.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 (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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 : MyChannelDescriptorListenerBase(), 66 : MyChannelDescriptorListenerBase(),
67 expected_inode_num_(expected_inode_num), 67 expected_inode_num_(expected_inode_num),
68 num_fds_received_(0) { 68 num_fds_received_(0) {
69 } 69 }
70 70
71 bool GotExpectedNumberOfDescriptors() const { 71 bool GotExpectedNumberOfDescriptors() const {
72 return num_fds_received_ == kNumFDsToSend * kNumMessages; 72 return num_fds_received_ == kNumFDsToSend * kNumMessages;
73 } 73 }
74 74
75 void OnChannelError() override { 75 void OnChannelError() override {
76 base::MessageLoop::current()->Quit(); 76 base::MessageLoop::current()->QuitWhenIdle();
77 } 77 }
78 78
79 protected: 79 protected:
80 void HandleFD(int fd) override { 80 void HandleFD(int fd) override {
81 ASSERT_GE(fd, 0); 81 ASSERT_GE(fd, 0);
82 // Check that we can read from the FD. 82 // Check that we can read from the FD.
83 char buf; 83 char buf;
84 ssize_t amt_read = read(fd, &buf, 1); 84 ssize_t amt_read = read(fd, &buf, 1);
85 ASSERT_EQ(amt_read, 1); 85 ASSERT_EQ(amt_read, 1);
86 ASSERT_EQ(buf, 0); // /dev/zero always reads 0 bytes. 86 ASSERT_EQ(buf, 0); // /dev/zero always reads 0 bytes.
87 87
88 struct stat st; 88 struct stat st;
89 ASSERT_EQ(fstat(fd, &st), 0); 89 ASSERT_EQ(fstat(fd, &st), 0);
90 90
91 ASSERT_EQ(close(fd), 0); 91 ASSERT_EQ(close(fd), 0);
92 92
93 // Compare inode numbers to check that the file sent over the wire is 93 // Compare inode numbers to check that the file sent over the wire is
94 // actually the one expected. 94 // actually the one expected.
95 ASSERT_EQ(expected_inode_num_, st.st_ino); 95 ASSERT_EQ(expected_inode_num_, st.st_ino);
96 96
97 ++num_fds_received_; 97 ++num_fds_received_;
98 if (num_fds_received_ == kNumFDsToSend * kNumMessages) 98 if (num_fds_received_ == kNumFDsToSend * kNumMessages)
99 base::MessageLoop::current()->Quit(); 99 base::MessageLoop::current()->QuitWhenIdle();
100 } 100 }
101 101
102 private: 102 private:
103 ino_t expected_inode_num_; 103 ino_t expected_inode_num_;
104 unsigned num_fds_received_; 104 unsigned num_fds_received_;
105 }; 105 };
106 106
107 107
108 class IPCSendFdsTest : public IPCTestBase { 108 class IPCSendFdsTest : public IPCTestBase {
109 protected: 109 protected:
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 base::WaitableEvent received_; 377 base::WaitableEvent received_;
378 }; 378 };
379 379
380 TEST_F(IPCMultiSendingFdsTest, StressTest) { 380 TEST_F(IPCMultiSendingFdsTest, StressTest) {
381 Run(); 381 Run();
382 } 382 }
383 383
384 } // namespace 384 } // namespace
385 385
386 #endif // defined(OS_POSIX) 386 #endif // defined(OS_POSIX)
OLDNEW
« no previous file with comments | « ipc/ipc_fuzzing_tests.cc ('k') | ipc/ipc_test_channel_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698