OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "services/preferences/public/cpp/preferences_struct_traits.h" | 5 #include "services/preferences/public/cpp/preferences_struct_traits.h" |
6 | 6 |
7 namespace mojo { | 7 namespace mojo { |
8 | 8 |
9 using PrefStoreType = prefs::mojom::PrefStoreType; | 9 using PrefStoreType = prefs::mojom::PrefStoreType; |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 case PrefStoreType::RECOMMENDED: | 54 case PrefStoreType::RECOMMENDED: |
55 *output = PrefValueStore::RECOMMENDED_STORE; | 55 *output = PrefValueStore::RECOMMENDED_STORE; |
56 return true; | 56 return true; |
57 case PrefStoreType::DEFAULT: | 57 case PrefStoreType::DEFAULT: |
58 *output = PrefValueStore::DEFAULT_STORE; | 58 *output = PrefValueStore::DEFAULT_STORE; |
59 return true; | 59 return true; |
60 } | 60 } |
61 return false; | 61 return false; |
62 } | 62 } |
63 | 63 |
| 64 using MojomReadError = prefs::mojom::PersistentPrefStoreConnector_ReadError; |
| 65 |
| 66 MojomReadError |
| 67 EnumTraits<MojomReadError, PersistentPrefStore::PrefReadError>::ToMojom( |
| 68 PersistentPrefStore::PrefReadError input) { |
| 69 switch (input) { |
| 70 case PersistentPrefStore::PREF_READ_ERROR_NONE: |
| 71 return MojomReadError::NONE; |
| 72 case PersistentPrefStore::PREF_READ_ERROR_JSON_PARSE: |
| 73 return MojomReadError::JSON_PARSE; |
| 74 case PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE: |
| 75 return MojomReadError::JSON_TYPE; |
| 76 case PersistentPrefStore::PREF_READ_ERROR_ACCESS_DENIED: |
| 77 return MojomReadError::ACCESS_DENIED; |
| 78 case PersistentPrefStore::PREF_READ_ERROR_FILE_OTHER: |
| 79 return MojomReadError::FILE_OTHER; |
| 80 case PersistentPrefStore::PREF_READ_ERROR_FILE_LOCKED: |
| 81 return MojomReadError::FILE_LOCKED; |
| 82 case PersistentPrefStore::PREF_READ_ERROR_NO_FILE: |
| 83 return MojomReadError::NO_FILE; |
| 84 case PersistentPrefStore::PREF_READ_ERROR_JSON_REPEAT: |
| 85 return MojomReadError::JSON_REPEAT; |
| 86 case PersistentPrefStore::PREF_READ_ERROR_FILE_NOT_SPECIFIED: |
| 87 return MojomReadError::FILE_NOT_SPECIFIED; |
| 88 case PersistentPrefStore::PREF_READ_ERROR_ASYNCHRONOUS_TASK_INCOMPLETE: |
| 89 return MojomReadError::ASYNCHRONOUS_TASK_INCOMPLETE; |
| 90 case PersistentPrefStore::PREF_READ_ERROR_MAX_ENUM: |
| 91 break; |
| 92 } |
| 93 NOTREACHED(); |
| 94 return {}; |
| 95 } |
| 96 |
| 97 bool EnumTraits<MojomReadError, PersistentPrefStore::PrefReadError>::FromMojom( |
| 98 MojomReadError input, |
| 99 PersistentPrefStore::PrefReadError* output) { |
| 100 switch (input) { |
| 101 case MojomReadError::NONE: |
| 102 *output = PersistentPrefStore::PREF_READ_ERROR_NONE; |
| 103 return true; |
| 104 case MojomReadError::JSON_PARSE: |
| 105 *output = PersistentPrefStore::PREF_READ_ERROR_JSON_PARSE; |
| 106 return true; |
| 107 case MojomReadError::JSON_TYPE: |
| 108 *output = PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE; |
| 109 return true; |
| 110 case MojomReadError::ACCESS_DENIED: |
| 111 *output = PersistentPrefStore::PREF_READ_ERROR_ACCESS_DENIED; |
| 112 return true; |
| 113 case MojomReadError::FILE_OTHER: |
| 114 *output = PersistentPrefStore::PREF_READ_ERROR_FILE_OTHER; |
| 115 return true; |
| 116 case MojomReadError::FILE_LOCKED: |
| 117 *output = PersistentPrefStore::PREF_READ_ERROR_FILE_LOCKED; |
| 118 return true; |
| 119 case MojomReadError::NO_FILE: |
| 120 *output = PersistentPrefStore::PREF_READ_ERROR_NO_FILE; |
| 121 return true; |
| 122 case MojomReadError::JSON_REPEAT: |
| 123 *output = PersistentPrefStore::PREF_READ_ERROR_JSON_REPEAT; |
| 124 return true; |
| 125 case MojomReadError::FILE_NOT_SPECIFIED: |
| 126 *output = PersistentPrefStore::PREF_READ_ERROR_FILE_NOT_SPECIFIED; |
| 127 return true; |
| 128 case MojomReadError::ASYNCHRONOUS_TASK_INCOMPLETE: |
| 129 *output = |
| 130 PersistentPrefStore::PREF_READ_ERROR_ASYNCHRONOUS_TASK_INCOMPLETE; |
| 131 return true; |
| 132 } |
| 133 return false; |
| 134 } |
| 135 |
64 } // namespace mojo | 136 } // namespace mojo |
OLD | NEW |