Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / events / test / platform_event_waiter.cc
blobe024da5d304537311a1ddf0b1b735c6e61a7dca6
1 // Copyright 2014 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 "ui/events/test/platform_event_waiter.h"
7 #include "base/message_loop/message_loop.h"
8 #include "ui/events/platform/platform_event_source.h"
10 namespace ui {
12 PlatformEventWaiter::PlatformEventWaiter(
13 const base::Closure& success_callback,
14 const PlatformEventMatcher& event_matcher)
15 : success_callback_(success_callback),
16 event_matcher_(event_matcher) {
17 PlatformEventSource::GetInstance()->AddPlatformEventObserver(this);
20 PlatformEventWaiter::~PlatformEventWaiter() {
21 PlatformEventSource::GetInstance()->RemovePlatformEventObserver(this);
24 void PlatformEventWaiter::WillProcessEvent(const PlatformEvent& event) {
25 if (event_matcher_.Run(event)) {
26 base::MessageLoop::current()->PostTask(FROM_HERE, success_callback_);
27 delete this;
31 void PlatformEventWaiter::DidProcessEvent(const PlatformEvent& event) {
34 // static
35 PlatformEventWaiter* PlatformEventWaiter::Create(
36 const base::Closure& success_callback,
37 const PlatformEventMatcher& event_matcher) {
38 return new PlatformEventWaiter(success_callback, event_matcher);
41 } // namespace ui