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

Unified Diff: services/preferences/public/cpp/preferences_struct_traits.cc

Issue 2635153002: Pref service: expose all read-only PrefStores through Mojo (Closed)
Patch Set: Address bauerb's review comments Created 3 years, 9 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
Index: services/preferences/public/cpp/preferences_struct_traits.cc
diff --git a/services/preferences/public/cpp/preferences_struct_traits.cc b/services/preferences/public/cpp/preferences_struct_traits.cc
new file mode 100644
index 0000000000000000000000000000000000000000..31b0dfb6c1ac9f9e86062b737ded6959ec6848cd
--- /dev/null
+++ b/services/preferences/public/cpp/preferences_struct_traits.cc
@@ -0,0 +1,64 @@
+// 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 "services/preferences/public/cpp/preferences_struct_traits.h"
+
+namespace mojo {
+
+using PrefStoreType = prefs::mojom::PrefStoreType;
+
+PrefStoreType EnumTraits<PrefStoreType, PrefValueStore::PrefStoreType>::ToMojom(
+ PrefValueStore::PrefStoreType input) {
+ switch (input) {
+ case PrefValueStore::INVALID_STORE:
+ break;
+ case PrefValueStore::MANAGED_STORE:
+ return PrefStoreType::MANAGED;
+ case PrefValueStore::SUPERVISED_USER_STORE:
+ return PrefStoreType::SUPERVISED_USER;
+ case PrefValueStore::EXTENSION_STORE:
+ return PrefStoreType::EXTENSION;
+ case PrefValueStore::COMMAND_LINE_STORE:
+ return PrefStoreType::COMMAND_LINE;
+ case PrefValueStore::USER_STORE:
+ return PrefStoreType::USER;
+ case PrefValueStore::RECOMMENDED_STORE:
+ return PrefStoreType::RECOMMENDED;
+ case PrefValueStore::DEFAULT_STORE:
+ return PrefStoreType::DEFAULT;
+ }
+ NOTREACHED();
+ return {};
+}
+
+bool EnumTraits<PrefStoreType, PrefValueStore::PrefStoreType>::FromMojom(
+ PrefStoreType input,
+ PrefValueStore::PrefStoreType* output) {
+ switch (input) {
+ case PrefStoreType::MANAGED:
+ *output = PrefValueStore::MANAGED_STORE;
+ return true;
+ case PrefStoreType::SUPERVISED_USER:
+ *output = PrefValueStore::SUPERVISED_USER_STORE;
+ return true;
+ case PrefStoreType::EXTENSION:
+ *output = PrefValueStore::EXTENSION_STORE;
+ return true;
+ case PrefStoreType::COMMAND_LINE:
+ *output = PrefValueStore::COMMAND_LINE_STORE;
+ return true;
+ case PrefStoreType::USER:
+ *output = PrefValueStore::USER_STORE;
+ return true;
+ case PrefStoreType::RECOMMENDED:
+ *output = PrefValueStore::RECOMMENDED_STORE;
+ return true;
+ case PrefStoreType::DEFAULT:
+ *output = PrefValueStore::DEFAULT_STORE;
+ return true;
+ }
+ return false;
+}
+
+} // namespace mojo
« no previous file with comments | « services/preferences/public/cpp/preferences_struct_traits.h ('k') | services/preferences/public/cpp/tests/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698