Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(705)

Unified Diff: components/chrome_cleaner/public/typemaps/chrome_prompt_struct_traits.cc

Issue 2932703006: Chrome Cleaner: Remove indirect base::FilePath mojo dependency. (Closed)
Patch Set: Address review comments on #5 Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/chrome_cleaner/public/typemaps/chrome_prompt_struct_traits.h ('k') | components/typemaps.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d15c172ebefc5c7d8ce576fb57df04bab9f260af
--- /dev/null
+++ b/components/chrome_cleaner/public/typemaps/chrome_prompt_struct_traits.cc
@@ -0,0 +1,41 @@
+// 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
+ConstCArray<uint16_t>
+StructTraits<chrome_cleaner::mojom::FilePathDataView, base::FilePath>::value(
+ const base::FilePath& file_path) {
+#if defined(OS_WIN)
+ return ConstCArray<uint16_t>(
+ file_path.value().size(),
+ reinterpret_cast<const uint16_t*>(file_path.value().data()));
+#else
+ NOTREACHED();
+ return ConstCArray<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()));
+ *out = std::move(path);
+ return true;
+#else
+ NOTREACHED();
+ return false;
+#endif
+}
+
+} // namespace mojo
« no previous file with comments | « components/chrome_cleaner/public/typemaps/chrome_prompt_struct_traits.h ('k') | components/typemaps.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698