Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: services/resource_coordinator/public/cpp/coordination_unit_struct_traits.cc

Issue 2798713002: Global Resource Coordinator: Basic service internals (Closed)
Patch Set: Wrap EventType directly in resource_coordinator namespace when using helper Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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 "services/resource_coordinator/public/cpp/coordination_unit_struct_trai ts.h"
6
7 namespace mojo {
8
9 // static
10 resource_coordinator::mojom::CoordinationUnitType
11 EnumTraits<resource_coordinator::mojom::CoordinationUnitType,
12 resource_coordinator::CoordinationUnitType>::
13 ToMojom(resource_coordinator::CoordinationUnitType type) {
14 switch (type) {
15 case resource_coordinator::CoordinationUnitType::INVALID_TYPE:
16 return resource_coordinator::mojom::CoordinationUnitType::INVALID_TYPE;
17 case resource_coordinator::CoordinationUnitType::WEBCONTENTS:
18 return resource_coordinator::mojom::CoordinationUnitType::WEBCONTENTS;
19 case resource_coordinator::CoordinationUnitType::FRAME:
20 return resource_coordinator::mojom::CoordinationUnitType::FRAME;
21 case resource_coordinator::CoordinationUnitType::NAVIGATION:
22 return resource_coordinator::mojom::CoordinationUnitType::NAVIGATION;
23 case resource_coordinator::CoordinationUnitType::PROCESS:
24 return resource_coordinator::mojom::CoordinationUnitType::PROCESS;
25 default:
26 CHECK(false) << "Invalid type: " << static_cast<uint8_t>(type);
dcheng 2017/04/18 05:40:46 NOTREACHED() is more appropriate here.
oystein (OOO til 10th of July) 2017/04/18 20:55:33 Done.
27 // This should not be reached. Just return a random value.
28 return resource_coordinator::mojom::CoordinationUnitType::INVALID_TYPE;
29 }
30 }
31
32 // static
33 bool EnumTraits<resource_coordinator::mojom::CoordinationUnitType,
34 resource_coordinator::CoordinationUnitType>::
35 FromMojom(resource_coordinator::mojom::CoordinationUnitType input,
36 resource_coordinator::CoordinationUnitType* out) {
37 switch (input) {
38 case resource_coordinator::mojom::CoordinationUnitType::INVALID_TYPE:
39 *out = resource_coordinator::CoordinationUnitType::INVALID_TYPE;
40 break;
41 case resource_coordinator::mojom::CoordinationUnitType::WEBCONTENTS:
42 *out = resource_coordinator::CoordinationUnitType::WEBCONTENTS;
43 break;
44 case resource_coordinator::mojom::CoordinationUnitType::FRAME:
45 *out = resource_coordinator::CoordinationUnitType::FRAME;
46 break;
47 case resource_coordinator::mojom::CoordinationUnitType::NAVIGATION:
48 *out = resource_coordinator::CoordinationUnitType::NAVIGATION;
49 break;
50 case resource_coordinator::mojom::CoordinationUnitType::PROCESS:
51 *out = resource_coordinator::CoordinationUnitType::PROCESS;
52 break;
53 default:
54 NOTREACHED() << "Invalid type: " << static_cast<uint8_t>(input);
55 return false;
56 }
57 return true;
58 }
59
60 // static
61 bool StructTraits<resource_coordinator::mojom::CoordinationUnitIDDataView,
62 resource_coordinator::CoordinationUnitID>::
63 Read(resource_coordinator::mojom::CoordinationUnitIDDataView input,
64 resource_coordinator::CoordinationUnitID* out) {
65 out->id = input.id();
66 if (!input.ReadType(&out->type))
67 return false;
68 return true;
69 }
70
71 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698