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

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

Issue 2601873002: Add a mojo bridge for PersistentPrefStore. (Closed)
Patch Set: rebase 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..8365e686808358f2611bf8f9c2a35c37d06acfc5
--- /dev/null
+++ b/services/preferences/public/cpp/preferences_struct_traits.cc
@@ -0,0 +1,81 @@
+// 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 MojomReadError = prefs::mojom::PersistentPrefStoreConnector_ReadError;
+
+MojomReadError
+EnumTraits<MojomReadError, PersistentPrefStore::PrefReadError>::ToMojom(
+ PersistentPrefStore::PrefReadError input) {
+ switch (input) {
+ case PersistentPrefStore::PREF_READ_ERROR_NONE:
+ return MojomReadError::NONE;
+ case PersistentPrefStore::PREF_READ_ERROR_JSON_PARSE:
+ return MojomReadError::JSON_PARSE;
+ case PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE:
+ return MojomReadError::JSON_TYPE;
+ case PersistentPrefStore::PREF_READ_ERROR_ACCESS_DENIED:
+ return MojomReadError::ACCESS_DENIED;
+ case PersistentPrefStore::PREF_READ_ERROR_FILE_OTHER:
+ return MojomReadError::FILE_OTHER;
+ case PersistentPrefStore::PREF_READ_ERROR_FILE_LOCKED:
+ return MojomReadError::FILE_LOCKED;
+ case PersistentPrefStore::PREF_READ_ERROR_NO_FILE:
+ return MojomReadError::NO_FILE;
+ case PersistentPrefStore::PREF_READ_ERROR_JSON_REPEAT:
+ return MojomReadError::JSON_REPEAT;
+ case PersistentPrefStore::PREF_READ_ERROR_FILE_NOT_SPECIFIED:
+ return MojomReadError::FILE_NOT_SPECIFIED;
+ case PersistentPrefStore::PREF_READ_ERROR_ASYNCHRONOUS_TASK_INCOMPLETE:
+ return MojomReadError::ASYNCHRONOUS_TASK_INCOMPLETE;
+ case PersistentPrefStore::PREF_READ_ERROR_MAX_ENUM:
+ break;
+ }
+ NOTREACHED();
+ return {};
+}
+
+bool EnumTraits<MojomReadError, PersistentPrefStore::PrefReadError>::FromMojom(
+ MojomReadError input,
+ PersistentPrefStore::PrefReadError* output) {
+ switch (input) {
+ case MojomReadError::NONE:
+ *output = PersistentPrefStore::PREF_READ_ERROR_NONE;
+ return true;
+ case MojomReadError::JSON_PARSE:
+ *output = PersistentPrefStore::PREF_READ_ERROR_JSON_PARSE;
+ return true;
+ case MojomReadError::JSON_TYPE:
+ *output = PersistentPrefStore::PREF_READ_ERROR_JSON_TYPE;
+ return true;
+ case MojomReadError::ACCESS_DENIED:
+ *output = PersistentPrefStore::PREF_READ_ERROR_ACCESS_DENIED;
+ return true;
+ case MojomReadError::FILE_OTHER:
+ *output = PersistentPrefStore::PREF_READ_ERROR_FILE_OTHER;
+ return true;
+ case MojomReadError::FILE_LOCKED:
+ *output = PersistentPrefStore::PREF_READ_ERROR_FILE_LOCKED;
+ return true;
+ case MojomReadError::NO_FILE:
+ *output = PersistentPrefStore::PREF_READ_ERROR_NO_FILE;
+ return true;
+ case MojomReadError::JSON_REPEAT:
+ *output = PersistentPrefStore::PREF_READ_ERROR_JSON_REPEAT;
+ return true;
+ case MojomReadError::FILE_NOT_SPECIFIED:
+ *output = PersistentPrefStore::PREF_READ_ERROR_FILE_NOT_SPECIFIED;
+ return true;
+ case MojomReadError::ASYNCHRONOUS_TASK_INCOMPLETE:
+ *output =
+ PersistentPrefStore::PREF_READ_ERROR_ASYNCHRONOUS_TASK_INCOMPLETE;
+ return true;
+ }
+ return false;
+}
+
+} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698