Transfer serviceworker state during cross site navigations too.
[chromium-blink-merge.git] / base / synchronization / waitable_event_watcher_win.cc
blobf5218f1361db873f4edae934399978672a5c523b
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"
12 namespace base {
14 WaitableEventWatcher::WaitableEventWatcher()
15 : event_(NULL) {
18 WaitableEventWatcher::~WaitableEventWatcher() {
21 bool WaitableEventWatcher::StartWatching(
22 WaitableEvent* event,
23 const EventCallback& callback) {
24 callback_ = callback;
25 event_ = event;
26 return watcher_.StartWatching(event->handle(), this);
29 void WaitableEventWatcher::StopWatching() {
30 callback_.Reset();
31 event_ = NULL;
32 watcher_.StopWatching();
35 WaitableEvent* WaitableEventWatcher::GetWatchedEvent() {
36 return event_;
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_;
46 event_ = NULL;
47 callback_.Reset();
48 DCHECK(event);
50 callback.Run(event);
53 } // namespace base