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/win/object_watcher.h" | 5 #include "base/win/object_watcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 | 9 |
10 namespace base { | 10 namespace base { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 return object_; | 85 return object_; |
86 } | 86 } |
87 | 87 |
88 // static | 88 // static |
89 void CALLBACK ObjectWatcher::DoneWaiting(void* param, BOOLEAN timed_out) { | 89 void CALLBACK ObjectWatcher::DoneWaiting(void* param, BOOLEAN timed_out) { |
90 DCHECK(!timed_out); | 90 DCHECK(!timed_out); |
91 | 91 |
92 // The destructor blocks on any callbacks that are in flight, so we know that | 92 // The destructor blocks on any callbacks that are in flight, so we know that |
93 // that is always a pointer to a valid ObjectWater. | 93 // that is always a pointer to a valid ObjectWater. |
94 ObjectWatcher* that = static_cast<ObjectWatcher*>(param); | 94 ObjectWatcher* that = static_cast<ObjectWatcher*>(param); |
95 that->origin_loop_->PostTask(FROM_HERE, that->callback_); | 95 that->origin_loop_->task_runner()->PostTask(FROM_HERE, that->callback_); |
96 that->callback_.Reset(); | 96 that->callback_.Reset(); |
97 } | 97 } |
98 | 98 |
99 void ObjectWatcher::Signal(Delegate* delegate) { | 99 void ObjectWatcher::Signal(Delegate* delegate) { |
100 // Signaling the delegate may result in our destruction or a nested call to | 100 // Signaling the delegate may result in our destruction or a nested call to |
101 // StartWatching(). As a result, we save any state we need and clear previous | 101 // StartWatching(). As a result, we save any state we need and clear previous |
102 // watcher state before signaling the delegate. | 102 // watcher state before signaling the delegate. |
103 HANDLE object = object_; | 103 HANDLE object = object_; |
104 StopWatching(); | 104 StopWatching(); |
105 delegate->OnObjectSignaled(object); | 105 delegate->OnObjectSignaled(object); |
106 } | 106 } |
107 | 107 |
108 void ObjectWatcher::WillDestroyCurrentMessageLoop() { | 108 void ObjectWatcher::WillDestroyCurrentMessageLoop() { |
109 // Need to shutdown the watch so that we don't try to access the MessageLoop | 109 // Need to shutdown the watch so that we don't try to access the MessageLoop |
110 // after this point. | 110 // after this point. |
111 StopWatching(); | 111 StopWatching(); |
112 } | 112 } |
113 | 113 |
114 } // namespace win | 114 } // namespace win |
115 } // namespace base | 115 } // namespace base |
OLD | NEW |