OLD | NEW |
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 "base/message_loop/message_pump_libevent.h" | 5 #include "base/message_loop/message_pump_libevent.h" |
6 | 6 |
7 #include <unistd.h> | 7 #include <unistd.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 #else | 86 #else |
87 #define MAYBE_TestWatchingFromBadThread TestWatchingFromBadThread | 87 #define MAYBE_TestWatchingFromBadThread TestWatchingFromBadThread |
88 #endif | 88 #endif |
89 TEST_F(MessagePumpLibeventTest, MAYBE_TestWatchingFromBadThread) { | 89 TEST_F(MessagePumpLibeventTest, MAYBE_TestWatchingFromBadThread) { |
90 MessagePumpLibevent::FileDescriptorWatcher watcher; | 90 MessagePumpLibevent::FileDescriptorWatcher watcher; |
91 StupidWatcher delegate; | 91 StupidWatcher delegate; |
92 | 92 |
93 ASSERT_DCHECK_DEATH( | 93 ASSERT_DCHECK_DEATH( |
94 io_loop()->WatchFileDescriptor(STDOUT_FILENO, false, | 94 io_loop()->WatchFileDescriptor(STDOUT_FILENO, false, |
95 MessageLoopForIO::WATCH_READ, &watcher, | 95 MessageLoopForIO::WATCH_READ, &watcher, |
96 &delegate), | 96 &delegate)); |
97 "Check failed: " | |
98 "watch_file_descriptor_caller_checker_.CalledOnValidThread\\(\\)"); | |
99 } | 97 } |
100 | 98 |
101 TEST_F(MessagePumpLibeventTest, QuitOutsideOfRun) { | 99 TEST_F(MessagePumpLibeventTest, QuitOutsideOfRun) { |
102 std::unique_ptr<MessagePumpLibevent> pump(new MessagePumpLibevent); | 100 std::unique_ptr<MessagePumpLibevent> pump(new MessagePumpLibevent); |
103 ASSERT_DCHECK_DEATH(pump->Quit(), | 101 ASSERT_DCHECK_DEATH(pump->Quit()); |
104 "Check failed: in_run_. " | |
105 "Quit was called outside of Run!"); | |
106 } | 102 } |
107 | 103 |
108 class BaseWatcher : public MessagePumpLibevent::Watcher { | 104 class BaseWatcher : public MessagePumpLibevent::Watcher { |
109 public: | 105 public: |
110 explicit BaseWatcher(MessagePumpLibevent::FileDescriptorWatcher* controller) | 106 explicit BaseWatcher(MessagePumpLibevent::FileDescriptorWatcher* controller) |
111 : controller_(controller) { | 107 : controller_(controller) { |
112 DCHECK(controller_); | 108 DCHECK(controller_); |
113 } | 109 } |
114 ~BaseWatcher() override {} | 110 ~BaseWatcher() override {} |
115 | 111 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 | 272 |
277 // StartWatching can move |watcher| to IO thread. Release on IO thread. | 273 // StartWatching can move |watcher| to IO thread. Release on IO thread. |
278 io_loop()->task_runner()->PostTask( | 274 io_loop()->task_runner()->PostTask( |
279 FROM_HERE, | 275 FROM_HERE, |
280 Bind(&WaitableEventWatcher::StopWatching, Owned(watcher.release()))); | 276 Bind(&WaitableEventWatcher::StopWatching, Owned(watcher.release()))); |
281 } | 277 } |
282 | 278 |
283 } // namespace | 279 } // namespace |
284 | 280 |
285 } // namespace base | 281 } // namespace base |
OLD | NEW |