naiveproxy/components/arc/common/timer.mojom

67 lines
1.9 KiB
Plaintext
Raw Normal View History

2018-08-11 08:35:24 +03:00
// 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) => ();
};