summaryrefslogtreecommitdiff
path: root/chromium/components/arc/common/timer.mojom
blob: 6efb88e8f8ee066f05bf6ecd38bd22cd03226da0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Next min version: 1

module arc.mojom;

import "mojo/public/mojom/base/time.mojom";

[Extensible]
enum ArcTimerResult {
  SUCCESS = 0,
  FAILURE = 1,
};

[Extensible]
enum ClockId {
  REALTIME_ALARM = 0,
  BOOTTIME_ALARM = 1,
};

struct CreateTimerRequest {
  // Type of the clock for which a timer needs to be created. This value
  // corresponds to the clock ids used by timerfd_create.
  ClockId clock_id;

  // File descriptor to write to when the timer is expired. This indicates to
  // the instance that the timer is expired. This fd is owned by the host.
  handle expiration_fd;
};

// Next method ID: 1
interface Timer {
  // Starts the timer to run at |absolute_expiration_time| in the future. If
  // the timer is already running, it will be replaced. Notification will be
  // performed as an 8-byte write to the associated expiration fd. Returns
  // |ArcTimerResult::SUCCESS| if the timer can be started and
  // |ArcTimerResult::FAILURE| otherwise.
  Start@0(mojo_base.mojom.TimeTicks absolute_expiration_time)
    => (ArcTimerResult result);
};

struct CreateTimerResponse {
  // Type of the clock associated with the timer.
  ClockId clock_id;

  // Timer object that will set timers of type |clock_id|.
  Timer timer;
};

// Next method ID: 1
interface TimerHost {
  // Creates timers with the given arguments. Returns a null array on failure
  // and an array of |Timer| objects of the same size as |arc_timer_requests|
  // on success. Only one |Timer| per clock id is created and
  // |arc_timer_requests| need to have unique clock ids for success.
  CreateTimers@0(array<CreateTimerRequest> timer_requests)
    => (array<CreateTimerResponse>? response);
};

// Next method ID: 1
interface TimerInstance {
  // Establishes full-duplex communication with the host.
  Init@0(TimerHost host_ptr) => ();
};