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

Unified Diff: components/sync/base/model_type.h

Issue 2859033002: [sync] Add constexpr to EnumSet (Closed)
Patch Set: Add constexpr to EnumSet Created 3 years, 7 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: components/sync/base/model_type.h
diff --git a/components/sync/base/model_type.h b/components/sync/base/model_type.h
index eb8365323f7beb9a8e4f57afde54870ea2e6b010..b0bf0fa0755b151e8711c74ce08367b7df0eca9c 100644
--- a/components/sync/base/model_type.h
+++ b/components/sync/base/model_type.h
@@ -12,6 +12,7 @@
#include <string>
#include "base/logging.h"
+#include "components/reading_list/core/reading_list_enable_flags.h"
#include "components/sync/base/enum_set.h"
namespace base {
@@ -201,11 +202,24 @@ ModelTypeSet ProtocolTypes();
// These are the normal user-controlled types. This is to distinguish from
// ControlTypes which are always enabled. Note that some of these share a
// preference flag, so not all of them are individually user-selectable.
-ModelTypeSet UserTypes();
+constexpr ModelTypeSet UserTypes() {
+ return ModelTypeSet::FromRange(FIRST_USER_MODEL_TYPE, LAST_USER_MODEL_TYPE);
+}
// These are the user-selectable data types.
-ModelTypeSet UserSelectableTypes();
-bool IsUserSelectableType(ModelType model_type);
+constexpr ModelTypeSet UserSelectableTypes() {
+ return ModelTypeSet(BOOKMARKS, PREFERENCES, PASSWORDS, AUTOFILL, THEMES,
+ TYPED_URLS, EXTENSIONS, APPS,
+#if BUILDFLAG(ENABLE_READING_LIST)
+ READING_LIST,
+#endif
+ PROXY_TABS);
+}
+
+constexpr bool IsUserSelectableType(ModelType model_type) {
skym 2017/05/05 23:15:42 Can you re-order these functions so all the conste
Patrick Noland 2017/05/08 20:29:19 Done.
+ return UserSelectableTypes().Has(model_type);
+}
+
ModelTypeNameMap GetUserSelectableTypeNameMap();
// This is the subset of UserTypes() that can be encrypted.
@@ -213,12 +227,16 @@ ModelTypeSet EncryptableUserTypes();
// This is the subset of UserTypes() that have priority over other types. These
// types are synced before other user types and are never encrypted.
-ModelTypeSet PriorityUserTypes();
+constexpr ModelTypeSet PriorityUserTypes() {
+ return ModelTypeSet(DEVICE_INFO, PRIORITY_PREFERENCES);
+}
// Proxy types are placeholder types for handling implicitly enabling real
// types. They do not exist at the server, and are simply used for
// UI/Configuration logic.
-ModelTypeSet ProxyTypes();
+constexpr ModelTypeSet ProxyTypes() {
+ return ModelTypeSet::FromRange(FIRST_PROXY_TYPE, LAST_PROXY_TYPE);
+}
// Returns a list of all control types.
//
@@ -230,12 +248,17 @@ ModelTypeSet ProxyTypes();
// - Their contents are not encrypted automatically.
// - They support custom update application and conflict resolution logic.
// - All change processing occurs on the sync thread (GROUP_PASSIVE).
-ModelTypeSet ControlTypes();
+constexpr ModelTypeSet ControlTypes() {
+ return ModelTypeSet::FromRange(FIRST_CONTROL_MODEL_TYPE,
+ LAST_CONTROL_MODEL_TYPE);
+}
// Returns true if this is a control type.
//
// See comment above for more information on what makes these types special.
-bool IsControlType(ModelType model_type);
+constexpr bool IsControlType(ModelType model_type) {
+ return ControlTypes().Has(model_type);
+}
// Core types are those data types used by sync's core functionality (i.e. not
// user data types). These types are always enabled, and include ControlTypes().

Powered by Google App Engine
This is Rietveld 408576698