| OLD | NEW |
| 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 #ifndef BASE_WIN_OBJECT_WATCHER_H_ | 5 #ifndef BASE_WIN_OBJECT_WATCHER_H_ |
| 6 #define BASE_WIN_OBJECT_WATCHER_H_ | 6 #define BASE_WIN_OBJECT_WATCHER_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 bool StartWatching(HANDLE object, Delegate* delegate); | 67 bool StartWatching(HANDLE object, Delegate* delegate); |
| 68 | 68 |
| 69 // Stops watching. Does nothing if the watch has already completed. If the | 69 // Stops watching. Does nothing if the watch has already completed. If the |
| 70 // watch is still active, then it is canceled, and the associated delegate is | 70 // watch is still active, then it is canceled, and the associated delegate is |
| 71 // not notified. | 71 // not notified. |
| 72 // | 72 // |
| 73 // Returns true if the watch was canceled. Otherwise, false is returned. | 73 // Returns true if the watch was canceled. Otherwise, false is returned. |
| 74 // | 74 // |
| 75 bool StopWatching(); | 75 bool StopWatching(); |
| 76 | 76 |
| 77 // Returns the handle of the object being watched, or NULL if the object | 77 // Returns true if currently watching an object. |
| 78 // watcher is stopped. | 78 bool IsWatching() const; |
| 79 HANDLE GetWatchedObject(); | 79 |
| 80 // Returns the handle of the object being watched. |
| 81 HANDLE GetWatchedObject() const; |
| 80 | 82 |
| 81 private: | 83 private: |
| 82 // Called on a background thread when done waiting. | 84 // Called on a background thread when done waiting. |
| 83 static void CALLBACK DoneWaiting(void* param, BOOLEAN timed_out); | 85 static void CALLBACK DoneWaiting(void* param, BOOLEAN timed_out); |
| 84 | 86 |
| 85 void Signal(Delegate* delegate); | 87 void Signal(Delegate* delegate); |
| 86 | 88 |
| 87 // MessageLoop::DestructionObserver implementation: | 89 // MessageLoop::DestructionObserver implementation: |
| 88 virtual void WillDestroyCurrentMessageLoop(); | 90 virtual void WillDestroyCurrentMessageLoop(); |
| 89 | 91 |
| 90 // Internal state. | 92 // Internal state. |
| 91 Closure callback_; | 93 Closure callback_; |
| 92 HANDLE object_; // The object being watched | 94 HANDLE object_; // The object being watched |
| 93 HANDLE wait_object_; // Returned by RegisterWaitForSingleObject | 95 HANDLE wait_object_; // Returned by RegisterWaitForSingleObject |
| 94 MessageLoop* origin_loop_; // Used to get back to the origin thread | 96 MessageLoop* origin_loop_; // Used to get back to the origin thread |
| 95 | 97 |
| 96 WeakPtrFactory<ObjectWatcher> weak_factory_; | 98 WeakPtrFactory<ObjectWatcher> weak_factory_; |
| 97 | 99 |
| 98 DISALLOW_COPY_AND_ASSIGN(ObjectWatcher); | 100 DISALLOW_COPY_AND_ASSIGN(ObjectWatcher); |
| 99 }; | 101 }; |
| 100 | 102 |
| 101 } // namespace win | 103 } // namespace win |
| 102 } // namespace base | 104 } // namespace base |
| 103 | 105 |
| 104 #endif // BASE_OBJECT_WATCHER_H_ | 106 #endif // BASE_OBJECT_WATCHER_H_ |
| OLD | NEW |