Move EnumSet to base/util/enum_set.

This is no-op. It will be used in https://crrev.com/c/2971674

Change-Id: I3dcc17360d697db2b8949499cf6bbdc82a58bbb2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2955146
Commit-Queue: Fergal Daly <fergal@chromium.org>
Reviewed-by: Wez <wez@chromium.org>
Reviewed-by: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#898504}
diff --git a/base/util/BUILD.gn b/base/util/BUILD.gn
index 8739822..af2cd88 100644
--- a/base/util/BUILD.gn
+++ b/base/util/BUILD.gn
@@ -6,6 +6,7 @@
 
 test("base_util_unittests") {
   deps = [
+    "enum_set:unittests",
     "memory_pressure:unittests",
     "timer:unittests",
     "type_safety:tests",
diff --git a/base/util/enum_set/BUILD.gn b/base/util/enum_set/BUILD.gn
new file mode 100644
index 0000000..3c4414d
--- /dev/null
+++ b/base/util/enum_set/BUILD.gn
@@ -0,0 +1,19 @@
+# Copyright 2019 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.
+
+source_set("enum_set") {
+  sources = [ "enum_set.h" ]
+  deps = [ "//base" ]
+}
+
+source_set("unittests") {
+  testonly = true
+  sources = [ "enum_set_unittest.cc" ]
+
+  deps = [
+    ":enum_set",
+    "//base",
+    "//testing/gtest",
+  ]
+}
diff --git a/base/util/enum_set/OWNERS b/base/util/enum_set/OWNERS
new file mode 100644
index 0000000..261ab18
--- /dev/null
+++ b/base/util/enum_set/OWNERS
@@ -0,0 +1 @@
+file://components/sync/OWNERS
diff --git a/components/sync/base/enum_set.h b/base/util/enum_set/enum_set.h
similarity index 97%
rename from components/sync/base/enum_set.h
rename to base/util/enum_set/enum_set.h
index 138e222..441b2bb 100644
--- a/components/sync/base/enum_set.h
+++ b/base/util/enum_set/enum_set.h
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifndef COMPONENTS_SYNC_BASE_ENUM_SET_H_
-#define COMPONENTS_SYNC_BASE_ENUM_SET_H_
+#ifndef BASE_UTIL_ENUM_SET_ENUM_SET_H_
+#define BASE_UTIL_ENUM_SET_ENUM_SET_H_
 
 #include <bitset>
 #include <cstddef>
@@ -12,7 +12,8 @@
 
 #include "base/check_op.h"
 
-namespace syncer {
+namespace base {
+namespace util {
 
 // Forward declarations needed for friend declarations.
 template <typename E, E MinEnumValue, E MaxEnumValue>
@@ -313,6 +314,7 @@
   return EnumSet<E, Min, Max>(set1.enums_ & ~set2.enums_);
 }
 
-}  // namespace syncer
+}  // namespace util
+}  // namespace base
 
-#endif  // COMPONENTS_SYNC_BASE_ENUM_SET_H_
+#endif  // BASE_UTIL_ENUM_SET_ENUM_SET_H_
diff --git a/components/sync/base/enum_set_unittest.cc b/base/util/enum_set/enum_set_unittest.cc
similarity index 98%
rename from components/sync/base/enum_set_unittest.cc
rename to base/util/enum_set/enum_set_unittest.cc
index 4f23136..4d9d33c7 100644
--- a/components/sync/base/enum_set_unittest.cc
+++ b/base/util/enum_set/enum_set_unittest.cc
@@ -2,13 +2,14 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "components/sync/base/enum_set.h"
+#include "base/util/enum_set/enum_set.h"
 
 #include <stddef.h>
 
 #include "testing/gtest/include/gtest/gtest.h"
 
-namespace syncer {
+namespace base {
+namespace util {
 namespace {
 
 enum class TestEnum {
@@ -300,4 +301,5 @@
 }
 
 }  // namespace
-}  // namespace syncer
+}  // namespace util
+}  // namespace base
diff --git a/chrome/browser/sync/test/integration/configuration_refresher.cc b/chrome/browser/sync/test/integration/configuration_refresher.cc
index af09532..50cae8d 100644
--- a/chrome/browser/sync/test/integration/configuration_refresher.cc
+++ b/chrome/browser/sync/test/integration/configuration_refresher.cc
@@ -17,7 +17,7 @@
     syncer::SyncService* sync_service) {
   // Only allowed to trigger refresh/schedule nudges for protocol types, things
   // like PROXY_TABS are not allowed.
-  sync_service->TriggerRefresh(syncer::Intersection(
+  sync_service->TriggerRefresh(base::util::Intersection(
       sync_service->GetActiveDataTypes(), syncer::ProtocolTypes()));
 }
 
diff --git a/chrome/browser/sync/test/integration/single_client_secondary_account_sync_test.cc b/chrome/browser/sync/test/integration/single_client_secondary_account_sync_test.cc
index fe3b912..c983d4e 100644
--- a/chrome/browser/sync/test/integration/single_client_secondary_account_sync_test.cc
+++ b/chrome/browser/sync/test/integration/single_client_secondary_account_sync_test.cc
@@ -99,8 +99,8 @@
   // on some other feature flags, not all of the allowed types are necessarily
   // active, and that's okay.
   syncer::ModelTypeSet bad_types =
-      syncer::Difference(GetSyncService(0)->GetActiveDataTypes(),
-                         AllowedTypesInStandaloneTransportMode());
+      base::util::Difference(GetSyncService(0)->GetActiveDataTypes(),
+                             AllowedTypesInStandaloneTransportMode());
   EXPECT_TRUE(bad_types.Empty()) << syncer::ModelTypeSetToString(bad_types);
 }
 #else
diff --git a/chrome/browser/sync/test/integration/single_client_standalone_transport_sync_test.cc b/chrome/browser/sync/test/integration/single_client_standalone_transport_sync_test.cc
index 72fd35d..de3cab5 100644
--- a/chrome/browser/sync/test/integration/single_client_standalone_transport_sync_test.cc
+++ b/chrome/browser/sync/test/integration/single_client_standalone_transport_sync_test.cc
@@ -113,8 +113,8 @@
   // on some other feature flags, not all of the allowed types are necessarily
   // active, and that's okay.
   syncer::ModelTypeSet bad_types =
-      syncer::Difference(GetSyncService(0)->GetActiveDataTypes(),
-                         AllowedTypesInStandaloneTransportMode());
+      base::util::Difference(GetSyncService(0)->GetActiveDataTypes(),
+                             AllowedTypesInStandaloneTransportMode());
   EXPECT_TRUE(bad_types.Empty()) << syncer::ModelTypeSetToString(bad_types);
 }
 
@@ -147,8 +147,8 @@
   EXPECT_FALSE(GetSyncService(0)->IsSyncFeatureActive());
 
   syncer::ModelTypeSet bad_types =
-      syncer::Difference(GetSyncService(0)->GetActiveDataTypes(),
-                         AllowedTypesInStandaloneTransportMode());
+      base::util::Difference(GetSyncService(0)->GetActiveDataTypes(),
+                             AllowedTypesInStandaloneTransportMode());
   EXPECT_TRUE(bad_types.Empty()) << syncer::ModelTypeSetToString(bad_types);
 
   // Finally, turn Sync-the-feature on again.
diff --git a/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc b/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc
index f9c2dcf4..ef9e7fe 100644
--- a/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc
+++ b/chrome/browser/ui/webui/sync_internals/sync_internals_message_handler.cc
@@ -305,8 +305,8 @@
 
   // Only allowed to trigger refresh/schedule nudges for protocol types, things
   // like PROXY_TABS are not allowed.
-  service->TriggerRefresh(syncer::Intersection(service->GetActiveDataTypes(),
-                                               syncer::ProtocolTypes()));
+  service->TriggerRefresh(base::util::Intersection(
+      service->GetActiveDataTypes(), syncer::ProtocolTypes()));
 }
 
 void SyncInternalsMessageHandler::OnReceivedAllNodes(
diff --git a/components/sync/BUILD.gn b/components/sync/BUILD.gn
index 41c3771..1d80a91 100644
--- a/components/sync/BUILD.gn
+++ b/components/sync/BUILD.gn
@@ -123,7 +123,6 @@
   testonly = true
   sources = [
     "base/client_tag_hash_unittest.cc",
-    "base/enum_set_unittest.cc",
     "base/immutable_unittest.cc",
     "base/model_type_unittest.cc",
     "base/node_ordinal_unittest.cc",
diff --git a/components/sync/base/BUILD.gn b/components/sync/base/BUILD.gn
index f8e2494..93e7529 100644
--- a/components/sync/base/BUILD.gn
+++ b/components/sync/base/BUILD.gn
@@ -17,7 +17,6 @@
     "client_tag_hash.h",
     "data_type_histogram.cc",
     "data_type_histogram.h",
-    "enum_set.h",
     "extensions_activity.cc",
     "extensions_activity.h",
     "hash_util.cc",
@@ -75,6 +74,7 @@
   ]
   deps = [
     "//base:i18n",
+    "//base/util/enum_set",
     "//build:chromeos_buildflags",
     "//components/pref_registry",
     "//components/prefs",
diff --git a/components/sync/base/model_type.h b/components/sync/base/model_type.h
index 46b8944..485adcd 100644
--- a/components/sync/base/model_type.h
+++ b/components/sync/base/model_type.h
@@ -11,7 +11,7 @@
 #include <string>
 
 #include "base/compiler_specific.h"
-#include "components/sync/base/enum_set.h"
+#include "base/util/enum_set/enum_set.h"
 
 namespace base {
 class ListValue;
@@ -158,8 +158,9 @@
 };
 
 using ModelTypeSet =
-    EnumSet<ModelType, FIRST_REAL_MODEL_TYPE, LAST_REAL_MODEL_TYPE>;
-using FullModelTypeSet = EnumSet<ModelType, UNSPECIFIED, LAST_REAL_MODEL_TYPE>;
+    base::util::EnumSet<ModelType, FIRST_REAL_MODEL_TYPE, LAST_REAL_MODEL_TYPE>;
+using FullModelTypeSet =
+    base::util::EnumSet<ModelType, UNSPECIFIED, LAST_REAL_MODEL_TYPE>;
 using ModelTypeNameMap = std::map<ModelType, const char*>;
 
 constexpr int GetNumModelTypes() {
diff --git a/components/sync/base/user_selectable_type.h b/components/sync/base/user_selectable_type.h
index 8a87c1cd..babcde0f 100644
--- a/components/sync/base/user_selectable_type.h
+++ b/components/sync/base/user_selectable_type.h
@@ -7,8 +7,8 @@
 
 #include <string>
 
+#include "base/util/enum_set/enum_set.h"
 #include "build/chromeos_buildflags.h"
-#include "components/sync/base/enum_set.h"
 #include "components/sync/base/model_type.h"
 #include "third_party/abseil-cpp/absl/types/optional.h"
 
@@ -31,9 +31,10 @@
   kLastType = kWifiConfigurations
 };
 
-using UserSelectableTypeSet = EnumSet<UserSelectableType,
-                                      UserSelectableType::kFirstType,
-                                      UserSelectableType::kLastType>;
+using UserSelectableTypeSet =
+    base::util::EnumSet<UserSelectableType,
+                        UserSelectableType::kFirstType,
+                        UserSelectableType::kLastType>;
 
 const char* GetUserSelectableTypeName(UserSelectableType type);
 // Returns the type if the string matches a known type.
@@ -58,9 +59,10 @@
   kLastType = kOsWifiConfigurations
 };
 
-using UserSelectableOsTypeSet = EnumSet<UserSelectableOsType,
-                                        UserSelectableOsType::kFirstType,
-                                        UserSelectableOsType::kLastType>;
+using UserSelectableOsTypeSet =
+    base::util::EnumSet<UserSelectableOsType,
+                        UserSelectableOsType::kFirstType,
+                        UserSelectableOsType::kLastType>;
 
 const char* GetUserSelectableOsTypeName(UserSelectableOsType type);
 ModelTypeSet UserSelectableOsTypeToAllModelTypes(UserSelectableOsType type);
diff --git a/components/sync/driver/BUILD.gn b/components/sync/driver/BUILD.gn
index 99b3b2f..1d02961 100644
--- a/components/sync/driver/BUILD.gn
+++ b/components/sync/driver/BUILD.gn
@@ -86,6 +86,7 @@
   ]
   deps = [
     "//base:i18n",
+    "//base/util/enum_set",
     "//build:chromeos_buildflags",
     "//components/data_use_measurement/core",
     "//components/invalidation/impl:feature_list",
diff --git a/components/sync/driver/sync_service.h b/components/sync/driver/sync_service.h
index d50b5d1f..58d159e9 100644
--- a/components/sync/driver/sync_service.h
+++ b/components/sync/driver/sync_service.h
@@ -14,8 +14,8 @@
 #include "base/macros.h"
 #include "base/memory/weak_ptr.h"
 #include "base/time/time.h"
+#include "base/util/enum_set/enum_set.h"
 #include "components/keyed_service/core/keyed_service.h"
-#include "components/sync/base/enum_set.h"
 #include "components/sync/base/model_type.h"
 #include "components/sync/driver/sync_service_observer.h"
 
@@ -139,7 +139,7 @@
     DISABLE_REASON_LAST = DISABLE_REASON_UNRECOVERABLE_ERROR,
   };
 
-  using DisableReasonSet =
+  using DisableReasonSet = base::util::
       EnumSet<DisableReason, DISABLE_REASON_FIRST, DISABLE_REASON_LAST>;
 
   // The overall state of Sync-the-transport, in ascending order of
diff --git a/ios/components/webui/sync_internals/sync_internals_message_handler.mm b/ios/components/webui/sync_internals/sync_internals_message_handler.mm
index 725b22e7..cda2b53 100644
--- a/ios/components/webui/sync_internals/sync_internals_message_handler.mm
+++ b/ios/components/webui/sync_internals/sync_internals_message_handler.mm
@@ -217,8 +217,8 @@
 
   // Only allowed to trigger refresh/schedule nudges for protocol types, things
   // like PROXY_TABS are not allowed.
-  service->TriggerRefresh(syncer::Intersection(service->GetActiveDataTypes(),
-                                               syncer::ProtocolTypes()));
+  service->TriggerRefresh(base::util::Intersection(
+      service->GetActiveDataTypes(), syncer::ProtocolTypes()));
 }
 
 void SyncInternalsMessageHandler::OnReceivedAllNodes(