blob: a8474ba6648a0248cda78ddf6da8d92bb2c1fd73 [file] [log] [blame]
Alex Deymo53556ec2014-03-17 10:05:57 -07001// Copyright (c) 2014 The Chromium OS 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.
4
5// TODO(deymo): These functions interact with the glib's main loop. This should
6// be replaced by the libbase main loop once the process is migrated to that
7// main loop.
8
9#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_EVENT_LOOP_H_
10#define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_EVENT_LOOP_H_
11
12#include <glib.h>
13
14#include <base/callback.h>
15#include <base/time.h>
16
17namespace chromeos_policy_manager {
18
19typedef guint EventId;
20
21// A null EventId doesn't idenify any valid event.
22static constexpr EventId kEventIdNull = 0;
23
24// Schedules the passed |callback| to run from the GLib's main loop after a
25// timeout if it is given.
26EventId RunFromMainLoop(const base::Closure& callback);
27EventId RunFromMainLoopAfterTimeout(const base::Closure& callback,
28 base::TimeDelta timeout);
29
30// Removes the pending call |event| from the main loop. The value passed is the
31// one returned by the functions RunFromMainLoop*() when the call was scheduled.
32// Returns whether the event was found and removed.
33bool CancelMainLoopEvent(EventId event);
34
35} // namespace chromeos_policy_manager
36
37#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_EVENT_LOOP_H_