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/profiler/scoped_tracker.h"
9 #include "base/synchronization/waitable_event.h"
10 #include "base/win/object_watcher.h"
14 WaitableEventWatcher::WaitableEventWatcher()
18 WaitableEventWatcher::~WaitableEventWatcher() {
21 bool WaitableEventWatcher::StartWatching(
23 const EventCallback
& callback
) {
26 return watcher_
.StartWatching(event
->handle(), this);
29 void WaitableEventWatcher::StopWatching() {
32 watcher_
.StopWatching();
35 WaitableEvent
* WaitableEventWatcher::GetWatchedEvent() {
39 void WaitableEventWatcher::OnObjectSignaled(HANDLE h
) {
40 // TODO(vadimt): Remove ScopedTracker below once crbug.com/418183 is fixed.
41 tracked_objects::ScopedTracker
tracking_profile(
42 FROM_HERE_WITH_EXPLICIT_FUNCTION("WaitableEventWatche_OnObjectSignaled"));
44 WaitableEvent
* event
= event_
;
45 EventCallback callback
= callback_
;