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 #include "base/synchronization/waitable_event_watcher.h" | 5 #include "base/synchronization/waitable_event_watcher.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/profiler/scoped_tracker.h" | |
9 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
10 #include "base/win/object_watcher.h" | 9 #include "base/win/object_watcher.h" |
11 | 10 |
12 namespace base { | 11 namespace base { |
13 | 12 |
14 WaitableEventWatcher::WaitableEventWatcher() | 13 WaitableEventWatcher::WaitableEventWatcher() |
15 : event_(NULL) { | 14 : event_(NULL) { |
16 } | 15 } |
17 | 16 |
18 WaitableEventWatcher::~WaitableEventWatcher() { | 17 WaitableEventWatcher::~WaitableEventWatcher() { |
(...skipping 11 matching lines...) Expand all Loading... |
30 callback_.Reset(); | 29 callback_.Reset(); |
31 event_ = NULL; | 30 event_ = NULL; |
32 watcher_.StopWatching(); | 31 watcher_.StopWatching(); |
33 } | 32 } |
34 | 33 |
35 WaitableEvent* WaitableEventWatcher::GetWatchedEvent() { | 34 WaitableEvent* WaitableEventWatcher::GetWatchedEvent() { |
36 return event_; | 35 return event_; |
37 } | 36 } |
38 | 37 |
39 void WaitableEventWatcher::OnObjectSignaled(HANDLE h) { | 38 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( | |
43 "418183 WaitableEventWatcher::OnObjectSignaled")); | |
44 | |
45 WaitableEvent* event = event_; | 39 WaitableEvent* event = event_; |
46 EventCallback callback = callback_; | 40 EventCallback callback = callback_; |
47 event_ = NULL; | 41 event_ = NULL; |
48 callback_.Reset(); | 42 callback_.Reset(); |
49 DCHECK(event); | 43 DCHECK(event); |
50 | 44 |
51 callback.Run(event); | 45 callback.Run(event); |
52 } | 46 } |
53 | 47 |
54 } // namespace base | 48 } // namespace base |
OLD | NEW |