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/synchronization/waitable_event_watcher.h" | 5 #include "base/synchronization/waitable_event_watcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // No hairpinning - we can't call the delegate directly here. We have to | 161 // No hairpinning - we can't call the delegate directly here. We have to |
162 // enqueue a task on the MessageLoop as normal. | 162 // enqueue a task on the MessageLoop as normal. |
163 current_ml->PostTask(FROM_HERE, internal_callback_); | 163 current_ml->PostTask(FROM_HERE, internal_callback_); |
164 return true; | 164 return true; |
165 } | 165 } |
166 | 166 |
167 message_loop_ = current_ml; | 167 message_loop_ = current_ml; |
168 current_ml->AddDestructionObserver(this); | 168 current_ml->AddDestructionObserver(this); |
169 | 169 |
170 kernel_ = kernel; | 170 kernel_ = kernel; |
171 waiter_ = new AsyncWaiter(current_ml, internal_callback_, cancel_flag_); | 171 waiter_ = new AsyncWaiter(current_ml, internal_callback_, cancel_flag_.get()); |
172 event->Enqueue(waiter_); | 172 event->Enqueue(waiter_); |
173 | 173 |
174 return true; | 174 return true; |
175 } | 175 } |
176 | 176 |
177 void WaitableEventWatcher::StopWatching() { | 177 void WaitableEventWatcher::StopWatching() { |
178 callback_.Reset(); | 178 callback_.Reset(); |
179 | 179 |
180 if (message_loop_) { | 180 if (message_loop_) { |
181 message_loop_->RemoveDestructionObserver(this); | 181 message_loop_->RemoveDestructionObserver(this); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 // ----------------------------------------------------------------------------- | 262 // ----------------------------------------------------------------------------- |
263 // This is called when the MessageLoop which the callback will be run it is | 263 // This is called when the MessageLoop which the callback will be run it is |
264 // deleted. We need to cancel the callback as if we had been deleted, but we | 264 // deleted. We need to cancel the callback as if we had been deleted, but we |
265 // will still be deleted at some point in the future. | 265 // will still be deleted at some point in the future. |
266 // ----------------------------------------------------------------------------- | 266 // ----------------------------------------------------------------------------- |
267 void WaitableEventWatcher::WillDestroyCurrentMessageLoop() { | 267 void WaitableEventWatcher::WillDestroyCurrentMessageLoop() { |
268 StopWatching(); | 268 StopWatching(); |
269 } | 269 } |
270 | 270 |
271 } // namespace base | 271 } // namespace base |
OLD | NEW |