| // 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. |
| |
| #include "components/arc/timer/arc_timer_mojom_traits.h" |
| |
| #include <utility> |
| |
| namespace mojo { |
| |
| // static |
| arc::mojom::ClockId EnumTraits<arc::mojom::ClockId, clockid_t>::ToMojom( |
| clockid_t clock_id) { |
| switch (clock_id) { |
| case CLOCK_REALTIME_ALARM: |
| return arc::mojom::ClockId::REALTIME_ALARM; |
| case CLOCK_BOOTTIME_ALARM: |
| return arc::mojom::ClockId::BOOTTIME_ALARM; |
| } |
| NOTREACHED(); |
| return arc::mojom::ClockId::BOOTTIME_ALARM; |
| } |
| |
| // static |
| bool EnumTraits<arc::mojom::ClockId, clockid_t>::FromMojom( |
| arc::mojom::ClockId input, |
| clockid_t* output) { |
| switch (input) { |
| case arc::mojom::ClockId::REALTIME_ALARM: |
| *output = CLOCK_REALTIME_ALARM; |
| return true; |
| case arc::mojom::ClockId::BOOTTIME_ALARM: |
| *output = CLOCK_BOOTTIME_ALARM; |
| return true; |
| } |
| NOTREACHED(); |
| return false; |
| } |
| |
| } // namespace mojo |