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

Side by Side Diff: base/message_pump_libevent_unittest.cc

Issue 9020008: Enable ThreadChecker in non-debug builds if DCHECK_ALWAYS_ON is (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to LKGR (pure merge). Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/threading/thread_checker.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/message_pump_libevent.h" 5 #include "base/message_pump_libevent.h"
6 6
7 #include <unistd.h> 7 #include <unistd.h>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // nothing useful. 52 // nothing useful.
53 class StupidWatcher : public MessagePumpLibevent::Watcher { 53 class StupidWatcher : public MessagePumpLibevent::Watcher {
54 public: 54 public:
55 virtual ~StupidWatcher() {} 55 virtual ~StupidWatcher() {}
56 56
57 // base:MessagePumpLibevent::Watcher interface 57 // base:MessagePumpLibevent::Watcher interface
58 virtual void OnFileCanReadWithoutBlocking(int fd) {} 58 virtual void OnFileCanReadWithoutBlocking(int fd) {}
59 virtual void OnFileCanWriteWithoutBlocking(int fd) {} 59 virtual void OnFileCanWriteWithoutBlocking(int fd) {}
60 }; 60 };
61 61
62 #if GTEST_HAS_DEATH_TEST 62 #if GTEST_HAS_DEATH_TEST && !defined(NDEBUG)
63 63
64 // Test to make sure that we catch calling WatchFileDescriptor off of the 64 // Test to make sure that we catch calling WatchFileDescriptor off of the
65 // wrong thread. 65 // wrong thread.
66 TEST_F(MessagePumpLibeventTest, TestWatchingFromBadThread) { 66 TEST_F(MessagePumpLibeventTest, TestWatchingFromBadThread) {
67 MessagePumpLibevent::FileDescriptorWatcher watcher; 67 MessagePumpLibevent::FileDescriptorWatcher watcher;
68 StupidWatcher delegate; 68 StupidWatcher delegate;
69 69
70 ASSERT_DEBUG_DEATH(io_loop()->WatchFileDescriptor( 70 ASSERT_DEATH(io_loop()->WatchFileDescriptor(
71 STDOUT_FILENO, false, MessageLoopForIO::WATCH_READ, &watcher, &delegate), 71 STDOUT_FILENO, false, MessageLoopForIO::WATCH_READ, &watcher, &delegate),
72 "Check failed: " 72 "Check failed: "
73 "watch_file_descriptor_caller_checker_.CalledOnValidThread()"); 73 "watch_file_descriptor_caller_checker_.CalledOnValidThread()");
74 } 74 }
75 75
76 #endif // GTEST_HAS_DEATH_TEST 76 #endif // GTEST_HAS_DEATH_TEST && !defined(NDEBUG)
77 77
78 class DeleteWatcher : public MessagePumpLibevent::Watcher { 78 class DeleteWatcher : public MessagePumpLibevent::Watcher {
79 public: 79 public:
80 explicit DeleteWatcher( 80 explicit DeleteWatcher(
81 MessagePumpLibevent::FileDescriptorWatcher* controller) 81 MessagePumpLibevent::FileDescriptorWatcher* controller)
82 : controller_(controller) { 82 : controller_(controller) {
83 DCHECK(controller_); 83 DCHECK(controller_);
84 } 84 }
85 virtual ~DeleteWatcher() {} 85 virtual ~DeleteWatcher() {}
86 86
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 pump->WatchFileDescriptor( 136 pump->WatchFileDescriptor(
137 0, false, MessagePumpLibevent::WATCH_READ_WRITE, &watcher, &delegate); 137 0, false, MessagePumpLibevent::WATCH_READ_WRITE, &watcher, &delegate);
138 138
139 // Spoof a libevent notification. 139 // Spoof a libevent notification.
140 OnLibeventNotification(pump, &watcher); 140 OnLibeventNotification(pump, &watcher);
141 } 141 }
142 142
143 } // namespace 143 } // namespace
144 144
145 } // namespace base 145 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/threading/thread_checker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698