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
3 // found in the LICENSE file.
5 #include "base/synchronization/waitable_event_watcher.h"
7 #include "base/compiler_specific.h"
8 #include "base/synchronization/waitable_event.h"
9 #include "base/win/object_watcher.h"
13 WaitableEventWatcher::ObjectWatcherHelper::ObjectWatcherHelper(
14 WaitableEventWatcher
* watcher
)
18 void WaitableEventWatcher::ObjectWatcherHelper::OnObjectSignaled(HANDLE h
) {
19 watcher_
->OnObjectSignaled();
23 WaitableEventWatcher::WaitableEventWatcher()
24 : ALLOW_THIS_IN_INITIALIZER_LIST(helper_(this)),
29 WaitableEventWatcher::~WaitableEventWatcher() {
32 bool WaitableEventWatcher::StartWatching(WaitableEvent
* event
,
37 return watcher_
.StartWatching(event
->handle(), &helper_
);
40 void WaitableEventWatcher::StopWatching() {
43 watcher_
.StopWatching();
46 WaitableEvent
* WaitableEventWatcher::GetWatchedEvent() {
50 void WaitableEventWatcher::OnObjectSignaled() {
51 WaitableEvent
* event
= event_
;
52 Delegate
* delegate
= delegate_
;
57 delegate
->OnWaitableEventSignaled(event
);