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

Side by Side Diff: base/message_loop/message_loop_unittest.cc

Issue 100253002: Don't HANDLE_EINTR(close). Either IGNORE_EINTR(close) or just close. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 MessageLoopForIO::FileDescriptorWatcher controller; 937 MessageLoopForIO::FileDescriptorWatcher controller;
938 { 938 {
939 MessageLoopForIO message_loop; 939 MessageLoopForIO message_loop;
940 940
941 QuitDelegate delegate; 941 QuitDelegate delegate;
942 message_loop.WatchFileDescriptor(fd, 942 message_loop.WatchFileDescriptor(fd,
943 true, MessageLoopForIO::WATCH_WRITE, &controller, &delegate); 943 true, MessageLoopForIO::WATCH_WRITE, &controller, &delegate);
944 // and don't run the message loop, just destroy it. 944 // and don't run the message loop, just destroy it.
945 } 945 }
946 } 946 }
947 if (HANDLE_EINTR(close(pipefds[0])) < 0) 947 if (IGNORE_EINTR(close(pipefds[0])) < 0)
948 PLOG(ERROR) << "close"; 948 PLOG(ERROR) << "close";
949 if (HANDLE_EINTR(close(pipefds[1])) < 0) 949 if (IGNORE_EINTR(close(pipefds[1])) < 0)
950 PLOG(ERROR) << "close"; 950 PLOG(ERROR) << "close";
951 } 951 }
952 952
953 TEST(MessageLoopTest, FileDescriptorWatcherDoubleStop) { 953 TEST(MessageLoopTest, FileDescriptorWatcherDoubleStop) {
954 // Verify that it's ok to call StopWatchingFileDescriptor(). 954 // Verify that it's ok to call StopWatchingFileDescriptor().
955 // (Errors only showed up in valgrind.) 955 // (Errors only showed up in valgrind.)
956 int pipefds[2]; 956 int pipefds[2];
957 int err = pipe(pipefds); 957 int err = pipe(pipefds);
958 ASSERT_EQ(0, err); 958 ASSERT_EQ(0, err);
959 int fd = pipefds[1]; 959 int fd = pipefds[1];
960 { 960 {
961 // Arrange for message loop to live longer than controller. 961 // Arrange for message loop to live longer than controller.
962 MessageLoopForIO message_loop; 962 MessageLoopForIO message_loop;
963 { 963 {
964 MessageLoopForIO::FileDescriptorWatcher controller; 964 MessageLoopForIO::FileDescriptorWatcher controller;
965 965
966 QuitDelegate delegate; 966 QuitDelegate delegate;
967 message_loop.WatchFileDescriptor(fd, 967 message_loop.WatchFileDescriptor(fd,
968 true, MessageLoopForIO::WATCH_WRITE, &controller, &delegate); 968 true, MessageLoopForIO::WATCH_WRITE, &controller, &delegate);
969 controller.StopWatchingFileDescriptor(); 969 controller.StopWatchingFileDescriptor();
970 } 970 }
971 } 971 }
972 if (HANDLE_EINTR(close(pipefds[0])) < 0) 972 if (IGNORE_EINTR(close(pipefds[0])) < 0)
973 PLOG(ERROR) << "close"; 973 PLOG(ERROR) << "close";
974 if (HANDLE_EINTR(close(pipefds[1])) < 0) 974 if (IGNORE_EINTR(close(pipefds[1])) < 0)
975 PLOG(ERROR) << "close"; 975 PLOG(ERROR) << "close";
976 } 976 }
977 977
978 } // namespace 978 } // namespace
979 979
980 #endif // defined(OS_POSIX) && !defined(OS_NACL) 980 #endif // defined(OS_POSIX) && !defined(OS_NACL)
981 981
982 namespace { 982 namespace {
983 // Inject a test point for recording the destructor calls for Closure objects 983 // Inject a test point for recording the destructor calls for Closure objects
984 // send to MessageLoop::PostTask(). It is awkward usage since we are trying to 984 // send to MessageLoop::PostTask(). It is awkward usage since we are trying to
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 1164
1165 ASSERT_TRUE(PostMessage(message_hwnd, kSignalMsg, 0, 1)); 1165 ASSERT_TRUE(PostMessage(message_hwnd, kSignalMsg, 0, 1));
1166 1166
1167 loop.Run(); 1167 loop.Run();
1168 1168
1169 ASSERT_TRUE(UnregisterClass(MAKEINTATOM(atom), instance)); 1169 ASSERT_TRUE(UnregisterClass(MAKEINTATOM(atom), instance));
1170 } 1170 }
1171 #endif // defined(OS_WIN) 1171 #endif // defined(OS_WIN)
1172 1172
1173 } // namespace base 1173 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/discardable_memory_android.cc ('k') | base/message_loop/message_pump_io_ios_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698