OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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/preferences/public/cpp/preferences_struct_traits.h" |
| 6 |
| 7 namespace mojo { |
| 8 |
| 9 using MojomReadError = prefs::mojom::PersistentPrefStoreConnector_ReadError; |
| 10 |
| 11 MojomReadError |
| 12 EnumTraits<MojomReadError, PersistentPrefStore::PrefReadError>::ToMojom( |
| 13 PersistentPrefStore::PrefReadError input) { |
| 14 switch (input) { |
| 15 case PersistentPrefStore::PREF_READ_ERROR_NONE: |
| 16 return MojomReadError::NONE; |
| 17 case PersistentPrefStore::PREF_READ_ERROR_JSON_PARSE: |
| 18 return MojomReadError::JSON_PARSE; |
| 19 case PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE: |
| 20 return MojomReadError::JSON_TYPE; |
| 21 case PersistentPrefStore::PREF_READ_ERROR_ACCESS_DENIED: |
| 22 return MojomReadError::ACCESS_DENIED; |
| 23 case PersistentPrefStore::PREF_READ_ERROR_FILE_OTHER: |
| 24 return MojomReadError::FILE_OTHER; |
| 25 case PersistentPrefStore::PREF_READ_ERROR_FILE_LOCKED: |
| 26 return MojomReadError::FILE_LOCKED; |
| 27 case PersistentPrefStore::PREF_READ_ERROR_NO_FILE: |
| 28 return MojomReadError::NO_FILE; |
| 29 case PersistentPrefStore::PREF_READ_ERROR_JSON_REPEAT: |
| 30 return MojomReadError::JSON_REPEAT; |
| 31 case PersistentPrefStore::PREF_READ_ERROR_FILE_NOT_SPECIFIED: |
| 32 return MojomReadError::FILE_NOT_SPECIFIED; |
| 33 case PersistentPrefStore::PREF_READ_ERROR_ASYNCHRONOUS_TASK_INCOMPLETE: |
| 34 return MojomReadError::ASYNCHRONOUS_TASK_INCOMPLETE; |
| 35 case PersistentPrefStore::PREF_READ_ERROR_MAX_ENUM: |
| 36 break; |
| 37 } |
| 38 NOTREACHED(); |
| 39 return {}; |
| 40 } |
| 41 |
| 42 bool EnumTraits<MojomReadError, PersistentPrefStore::PrefReadError>::FromMojom( |
| 43 MojomReadError input, |
| 44 PersistentPrefStore::PrefReadError* output) { |
| 45 switch (input) { |
| 46 case MojomReadError::NONE: |
| 47 *output = PersistentPrefStore::PREF_READ_ERROR_NONE; |
| 48 return true; |
| 49 case MojomReadError::JSON_PARSE: |
| 50 *output = PersistentPrefStore::PREF_READ_ERROR_JSON_PARSE; |
| 51 return true; |
| 52 case MojomReadError::JSON_TYPE: |
| 53 *output = PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE; |
| 54 return true; |
| 55 case MojomReadError::ACCESS_DENIED: |
| 56 *output = PersistentPrefStore::PREF_READ_ERROR_ACCESS_DENIED; |
| 57 return true; |
| 58 case MojomReadError::FILE_OTHER: |
| 59 *output = PersistentPrefStore::PREF_READ_ERROR_FILE_OTHER; |
| 60 return true; |
| 61 case MojomReadError::FILE_LOCKED: |
| 62 *output = PersistentPrefStore::PREF_READ_ERROR_FILE_LOCKED; |
| 63 return true; |
| 64 case MojomReadError::NO_FILE: |
| 65 *output = PersistentPrefStore::PREF_READ_ERROR_NO_FILE; |
| 66 return true; |
| 67 case MojomReadError::JSON_REPEAT: |
| 68 *output = PersistentPrefStore::PREF_READ_ERROR_JSON_REPEAT; |
| 69 return true; |
| 70 case MojomReadError::FILE_NOT_SPECIFIED: |
| 71 *output = PersistentPrefStore::PREF_READ_ERROR_FILE_NOT_SPECIFIED; |
| 72 return true; |
| 73 case MojomReadError::ASYNCHRONOUS_TASK_INCOMPLETE: |
| 74 *output = |
| 75 PersistentPrefStore::PREF_READ_ERROR_ASYNCHRONOUS_TASK_INCOMPLETE; |
| 76 return true; |
| 77 } |
| 78 return false; |
| 79 } |
| 80 |
| 81 } // namespace mojo |
OLD | NEW |