Chromium Code Reviews| Index: components/chrome_cleaner/public/typemaps/chrome_prompt_struct_traits.cc |
| diff --git a/components/chrome_cleaner/public/typemaps/chrome_prompt_struct_traits.cc b/components/chrome_cleaner/public/typemaps/chrome_prompt_struct_traits.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3660b6ea79dcb29c550b8b6b2a0b8eefaeeaf79d |
| --- /dev/null |
| +++ b/components/chrome_cleaner/public/typemaps/chrome_prompt_struct_traits.cc |
| @@ -0,0 +1,40 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "components/chrome_cleaner/public/typemaps/chrome_prompt_struct_traits.h" |
| + |
| +namespace mojo { |
| + |
| +// static |
| +std::vector<uint16_t> |
| +StructTraits<chrome_cleaner::mojom::FilePathDataView, base::FilePath>::value( |
| + const base::FilePath& file_path) { |
| +#if defined(OS_WIN) |
| + return std::vector<uint16_t>(file_path.value().begin(), |
|
dcheng
2017/06/13 23:45:35
I have bad news... this gets called twice on seria
proberge
2017/06/14 14:13:58
Done.
|
| + file_path.value().end()); |
| +#else |
| + NOTREACHED(); |
| + return std::vector<uint16_t>(); |
| +#endif |
| +} |
| + |
| +// static |
| +bool StructTraits<chrome_cleaner::mojom::FilePathDataView, |
| + base::FilePath>::Read(chrome_cleaner::mojom::FilePathDataView |
| + path_view, |
| + base::FilePath* out) { |
| +#if defined(OS_WIN) |
| + ArrayDataView<uint16_t> view; |
| + path_view.GetValueDataView(&view); |
| + base::FilePath path = base::FilePath(base::string16( |
| + reinterpret_cast<const base::char16*>(view.data()), view.size())); |
|
ftirelo
2017/06/13 23:29:29
Nit: could we use base::FilePath::StringType::valu
proberge
2017/06/14 14:13:58
Maybe. Is this so we can remove the defined(OS_WIN
|
| + *out = std::move(path); |
| + return true; |
| +#else |
| + NOTREACHED(); |
| + return false; |
| +#endif |
| +} |
| + |
| +} // namespace mojo |