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

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: Add a typemap for Chromium to use 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..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
« 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