OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "services/ui/common/image_cursors_set.h" |
| 6 |
| 7 #include <algorithm> |
| 8 |
| 9 #include "ui/base/cursor/image_cursors.h" |
| 10 |
| 11 namespace ui { |
| 12 |
| 13 ImageCursorsSet::ImageCursorsSet() : weak_ptr_factory_(this) {} |
| 14 |
| 15 ImageCursorsSet::~ImageCursorsSet() {} |
| 16 |
| 17 void ImageCursorsSet::AddImageCursors( |
| 18 std::unique_ptr<ImageCursors> image_cursors) { |
| 19 auto result = image_cursors_set_.insert(std::move(image_cursors)); |
| 20 DCHECK(result.second); |
| 21 } |
| 22 |
| 23 void ImageCursorsSet::DeleteImageCursors(ImageCursors* image_cursors) { |
| 24 auto it = |
| 25 std::find_if(image_cursors_set_.begin(), image_cursors_set_.end(), |
| 26 [image_cursors](const std::unique_ptr<ImageCursors>& elmt) { |
| 27 return elmt.get() == image_cursors; |
| 28 }); |
| 29 DCHECK(it != image_cursors_set_.end()); |
| 30 image_cursors_set_.erase(it); |
| 31 } |
| 32 |
| 33 base::WeakPtr<ImageCursorsSet> ImageCursorsSet::GetWeakPtr() { |
| 34 return weak_ptr_factory_.GetWeakPtr(); |
| 35 } |
| 36 |
| 37 } // namespace ui |
OLD | NEW |