| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "content/common/indexed_db/indexed_db_enum_traits.h" | 5 #include "content/common/indexed_db/indexed_db_enum_traits.h" |
| 6 | 6 |
| 7 using indexed_db::mojom::CursorDirection; | 7 using indexed_db::mojom::CursorDirection; |
| 8 using indexed_db::mojom::DataLoss; | 8 using indexed_db::mojom::DataLoss; |
| 9 using indexed_db::mojom::OperationType; |
| 9 using indexed_db::mojom::PutMode; | 10 using indexed_db::mojom::PutMode; |
| 10 using indexed_db::mojom::TaskType; | 11 using indexed_db::mojom::TaskType; |
| 11 using indexed_db::mojom::TransactionMode; | 12 using indexed_db::mojom::TransactionMode; |
| 12 | 13 |
| 13 namespace mojo { | 14 namespace mojo { |
| 14 | 15 |
| 15 // static | 16 // static |
| 16 CursorDirection | 17 CursorDirection |
| 17 EnumTraits<CursorDirection, blink::WebIDBCursorDirection>::ToMojom( | 18 EnumTraits<CursorDirection, blink::WebIDBCursorDirection>::ToMojom( |
| 18 blink::WebIDBCursorDirection input) { | 19 blink::WebIDBCursorDirection input) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 *output = blink::WebIDBDataLossNone; | 74 *output = blink::WebIDBDataLossNone; |
| 74 return true; | 75 return true; |
| 75 case DataLoss::Total: | 76 case DataLoss::Total: |
| 76 *output = blink::WebIDBDataLossTotal; | 77 *output = blink::WebIDBDataLossTotal; |
| 77 return true; | 78 return true; |
| 78 } | 79 } |
| 79 return false; | 80 return false; |
| 80 } | 81 } |
| 81 | 82 |
| 82 // static | 83 // static |
| 84 OperationType EnumTraits<OperationType, blink::WebIDBOperationType>::ToMojom( |
| 85 blink::WebIDBOperationType input) { |
| 86 switch (input) { |
| 87 case blink::WebIDBAdd: |
| 88 return OperationType::Add; |
| 89 case blink::WebIDBPut: |
| 90 return OperationType::Put; |
| 91 case blink::WebIDBDelete: |
| 92 return OperationType::Delete; |
| 93 case blink::WebIDBClear: |
| 94 return OperationType::Clear; |
| 95 case blink::WebIDBOperationTypeCount: |
| 96 // WebIDBOperationTypeCount is not a valid option. |
| 97 break; |
| 98 } |
| 99 NOTREACHED(); |
| 100 return OperationType::Add; |
| 101 } |
| 102 |
| 103 // static |
| 104 bool EnumTraits<OperationType, blink::WebIDBOperationType>::FromMojom( |
| 105 OperationType input, |
| 106 blink::WebIDBOperationType* output) { |
| 107 switch (input) { |
| 108 case OperationType::Add: |
| 109 *output = blink::WebIDBAdd; |
| 110 return true; |
| 111 case OperationType::Put: |
| 112 *output = blink::WebIDBPut; |
| 113 return true; |
| 114 case OperationType::Delete: |
| 115 *output = blink::WebIDBDelete; |
| 116 return true; |
| 117 case OperationType::Clear: |
| 118 *output = blink::WebIDBClear; |
| 119 return true; |
| 120 } |
| 121 return false; |
| 122 } |
| 123 |
| 124 // static |
| 83 PutMode EnumTraits<PutMode, blink::WebIDBPutMode>::ToMojom( | 125 PutMode EnumTraits<PutMode, blink::WebIDBPutMode>::ToMojom( |
| 84 blink::WebIDBPutMode input) { | 126 blink::WebIDBPutMode input) { |
| 85 switch (input) { | 127 switch (input) { |
| 86 case blink::WebIDBPutModeAddOrUpdate: | 128 case blink::WebIDBPutModeAddOrUpdate: |
| 87 return PutMode::AddOrUpdate; | 129 return PutMode::AddOrUpdate; |
| 88 case blink::WebIDBPutModeAddOnly: | 130 case blink::WebIDBPutModeAddOnly: |
| 89 return PutMode::AddOnly; | 131 return PutMode::AddOnly; |
| 90 case blink::WebIDBPutModeCursorUpdate: | 132 case blink::WebIDBPutModeCursorUpdate: |
| 91 return PutMode::CursorUpdate; | 133 return PutMode::CursorUpdate; |
| 92 } | 134 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 *output = blink::WebIDBTransactionModeReadWrite; | 210 *output = blink::WebIDBTransactionModeReadWrite; |
| 169 return true; | 211 return true; |
| 170 case TransactionMode::VersionChange: | 212 case TransactionMode::VersionChange: |
| 171 *output = blink::WebIDBTransactionModeVersionChange; | 213 *output = blink::WebIDBTransactionModeVersionChange; |
| 172 return true; | 214 return true; |
| 173 } | 215 } |
| 174 return false; | 216 return false; |
| 175 } | 217 } |
| 176 | 218 |
| 177 } // namespace mojo | 219 } // namespace mojo |
| OLD | NEW |