• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Chromium 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 #include "mojo/public/cpp/base/thread_priority_mojom_traits.h"
6 
7 namespace mojo {
8 
9 // static
10 mojo_base::mojom::ThreadPriority
ToMojom(base::ThreadPriority thread_priority)11 EnumTraits<mojo_base::mojom::ThreadPriority, base::ThreadPriority>::ToMojom(
12     base::ThreadPriority thread_priority) {
13   switch (thread_priority) {
14     case base::ThreadPriority::BACKGROUND:
15       return mojo_base::mojom::ThreadPriority::BACKGROUND;
16     case base::ThreadPriority::NORMAL:
17       return mojo_base::mojom::ThreadPriority::NORMAL;
18     case base::ThreadPriority::DISPLAY:
19       return mojo_base::mojom::ThreadPriority::DISPLAY;
20     case base::ThreadPriority::REALTIME_AUDIO:
21       return mojo_base::mojom::ThreadPriority::REALTIME_AUDIO;
22   }
23   NOTREACHED();
24   return mojo_base::mojom::ThreadPriority::BACKGROUND;
25 }
26 
27 // static
28 bool EnumTraits<mojo_base::mojom::ThreadPriority, base::ThreadPriority>::
FromMojom(mojo_base::mojom::ThreadPriority input,base::ThreadPriority * out)29     FromMojom(mojo_base::mojom::ThreadPriority input,
30               base::ThreadPriority* out) {
31   switch (input) {
32     case mojo_base::mojom::ThreadPriority::BACKGROUND:
33       *out = base::ThreadPriority::BACKGROUND;
34       return true;
35     case mojo_base::mojom::ThreadPriority::NORMAL:
36       *out = base::ThreadPriority::NORMAL;
37       return true;
38     case mojo_base::mojom::ThreadPriority::DISPLAY:
39       *out = base::ThreadPriority::DISPLAY;
40       return true;
41     case mojo_base::mojom::ThreadPriority::REALTIME_AUDIO:
42       *out = base::ThreadPriority::REALTIME_AUDIO;
43       return true;
44   }
45   return false;
46 }
47 
48 }  // namespace mojo