| 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 "mojo/common/common_custom_types_struct_traits.h" | 5 #include "mojo/common/common_custom_types_struct_traits.h" |
| 6 | 6 |
| 7 #include "mojo/public/cpp/system/platform_handle.h" | 7 #include "mojo/public/cpp/system/platform_handle.h" |
| 8 | 8 |
| 9 namespace mojo { | 9 namespace mojo { |
| 10 | 10 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 base::File* file) { | 64 base::File* file) { |
| 65 base::PlatformFile platform_handle = base::kInvalidPlatformFile; | 65 base::PlatformFile platform_handle = base::kInvalidPlatformFile; |
| 66 if (mojo::UnwrapPlatformFile(data.TakeFd(), &platform_handle) != | 66 if (mojo::UnwrapPlatformFile(data.TakeFd(), &platform_handle) != |
| 67 MOJO_RESULT_OK) { | 67 MOJO_RESULT_OK) { |
| 68 return false; | 68 return false; |
| 69 } | 69 } |
| 70 *file = base::File(platform_handle); | 70 *file = base::File(platform_handle); |
| 71 return true; | 71 return true; |
| 72 } | 72 } |
| 73 | 73 |
| 74 // static |
| 75 common::mojom::TextDirection |
| 76 EnumTraits<common::mojom::TextDirection, base::i18n::TextDirection>::ToMojom( |
| 77 base::i18n::TextDirection text_direction) { |
| 78 switch (text_direction) { |
| 79 case base::i18n::UNKNOWN_DIRECTION: |
| 80 return common::mojom::TextDirection::UNKNOWN_DIRECTION; |
| 81 case base::i18n::RIGHT_TO_LEFT: |
| 82 return common::mojom::TextDirection::RIGHT_TO_LEFT; |
| 83 case base::i18n::LEFT_TO_RIGHT: |
| 84 return common::mojom::TextDirection::LEFT_TO_RIGHT; |
| 85 } |
| 86 NOTREACHED(); |
| 87 return common::mojom::TextDirection::UNKNOWN_DIRECTION; |
| 88 } |
| 89 |
| 90 // static |
| 91 bool EnumTraits<common::mojom::TextDirection, base::i18n::TextDirection>:: |
| 92 FromMojom(common::mojom::TextDirection input, |
| 93 base::i18n::TextDirection* out) { |
| 94 switch (input) { |
| 95 case common::mojom::TextDirection::UNKNOWN_DIRECTION: |
| 96 *out = base::i18n::UNKNOWN_DIRECTION; |
| 97 return true; |
| 98 case common::mojom::TextDirection::RIGHT_TO_LEFT: |
| 99 *out = base::i18n::RIGHT_TO_LEFT; |
| 100 return true; |
| 101 case common::mojom::TextDirection::LEFT_TO_RIGHT: |
| 102 *out = base::i18n::LEFT_TO_RIGHT; |
| 103 return true; |
| 104 } |
| 105 return false; |
| 106 } |
| 107 |
| 74 } // namespace mojo | 108 } // namespace mojo |
| OLD | NEW |