Index: services/ui/common/image_cursors_set.cc |
diff --git a/services/ui/common/image_cursors_set.cc b/services/ui/common/image_cursors_set.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4e0a92ad9800470c6f2c6ac9d83f2eb34fccfb6a |
--- /dev/null |
+++ b/services/ui/common/image_cursors_set.cc |
@@ -0,0 +1,37 @@ |
+// 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/ui/common/image_cursors_set.h" |
+ |
+#include <algorithm> |
+ |
+#include "ui/base/cursor/image_cursors.h" |
+ |
+namespace ui { |
+ |
+ImageCursorsSet::ImageCursorsSet() : weak_ptr_factory_(this) {} |
+ |
+ImageCursorsSet::~ImageCursorsSet() {} |
+ |
+void ImageCursorsSet::AddImageCursors( |
+ std::unique_ptr<ImageCursors> image_cursors) { |
+ auto result = image_cursors_set_.insert(std::move(image_cursors)); |
+ DCHECK(result.second); |
+} |
+ |
+void ImageCursorsSet::RemoveImageCursors(ImageCursors* image_cursors) { |
+ auto it = |
+ std::find_if(image_cursors_set_.begin(), image_cursors_set_.end(), |
+ [image_cursors](const std::unique_ptr<ImageCursors>& elmt) { |
+ return elmt.get() == image_cursors; |
+ }); |
+ DCHECK(it != image_cursors_set_.end()); |
+ image_cursors_set_.erase(it); |
+} |
+ |
+base::WeakPtr<ImageCursorsSet> ImageCursorsSet::GetWeakPtr() { |
+ return weak_ptr_factory_.GetWeakPtr(); |
+} |
+ |
+} // namespace ui |