| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_MUS_WS_USER_ID_TRACKER_H_ | 5 #ifndef COMPONENTS_MUS_WS_USER_ID_TRACKER_H_ |
| 6 #define COMPONENTS_MUS_WS_USER_ID_TRACKER_H_ | 6 #define COMPONENTS_MUS_WS_USER_ID_TRACKER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "components/mus/ws/user_id.h" | 14 #include "components/mus/ws/user_id.h" |
| 15 | 15 |
| 16 namespace mus { | 16 namespace mus { |
| 17 namespace ws { | 17 namespace ws { |
| 18 | 18 |
| 19 class UserIdTrackerObserver; | 19 class UserIdTrackerObserver; |
| 20 | 20 |
| 21 // Tracks the set of known/valid user ids. | 21 // Tracks the set of known/valid user ids. |
| 22 class UserIdTracker { | 22 class UserIdTracker { |
| 23 public: | 23 public: |
| 24 UserIdTracker(); | 24 UserIdTracker(); |
| 25 ~UserIdTracker(); | 25 ~UserIdTracker(); |
| 26 | 26 |
| 27 bool IsValidUserId(const UserId& id) const; | 27 bool IsValidUserId(const UserId& id) const; |
| 28 | 28 |
| 29 const UserId& active_id() const { return active_id_; } |
| 30 |
| 29 void SetActiveUserId(const UserId& id); | 31 void SetActiveUserId(const UserId& id); |
| 30 void AddUserId(const UserId& id); | 32 void AddUserId(const UserId& id); |
| 31 void RemoveUserId(const UserId& id); | 33 void RemoveUserId(const UserId& id); |
| 32 | 34 |
| 33 void AddObserver(UserIdTrackerObserver* observer); | 35 void AddObserver(UserIdTrackerObserver* observer); |
| 34 void RemoveObserver(UserIdTrackerObserver* observer); | 36 void RemoveObserver(UserIdTrackerObserver* observer); |
| 35 | 37 |
| 36 private: | 38 private: |
| 37 using UserIdSet = std::set<UserId>; | 39 using UserIdSet = std::set<UserId>; |
| 38 | 40 |
| 39 base::ObserverList<UserIdTrackerObserver> observers_; | 41 base::ObserverList<UserIdTrackerObserver> observers_; |
| 40 UserIdSet ids_; | 42 UserIdSet ids_; |
| 41 UserId active_id_; | 43 UserId active_id_; |
| 42 | 44 |
| 43 DISALLOW_COPY_AND_ASSIGN(UserIdTracker); | 45 DISALLOW_COPY_AND_ASSIGN(UserIdTracker); |
| 44 }; | 46 }; |
| 45 | 47 |
| 46 } // namespace ws | 48 } // namespace ws |
| 47 } // namespace mus | 49 } // namespace mus |
| 48 | 50 |
| 49 #endif // COMPONENTS_MUS_WS_USER_ID_TRACKER_H_ | 51 #endif // COMPONENTS_MUS_WS_USER_ID_TRACKER_H_ |
| OLD | NEW |