blob: a24e0b7d1c6801a0408d1570f750bc83f65b9b81 [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
Alex Deymo63784a52014-05-28 10:46:14 -07009#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_MANAGER_EVENT_LOOP_H_
10#define CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_MANAGER_EVENT_LOOP_H_
Alex Deymo53556ec2014-03-17 10:05:57 -070011
12#include <glib.h>
13
14#include <base/callback.h>
Alex Vakulenko75039d72014-03-25 12:36:28 -070015#include <base/time/time.h>
Alex Deymo53556ec2014-03-17 10:05:57 -070016
Alex Deymo63784a52014-05-28 10:46:14 -070017namespace chromeos_update_manager {
Alex Deymo53556ec2014-03-17 10:05:57 -070018
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
Alex Deymo63784a52014-05-28 10:46:14 -070035} // namespace chromeos_update_manager
Alex Deymo53556ec2014-03-17 10:05:57 -070036
Alex Deymo63784a52014-05-28 10:46:14 -070037#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UPDATE_MANAGER_EVENT_LOOP_H_