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

Side by Side Diff: components/mus/ws/user_id_tracker.h

Issue 2119963002: Move mus to //services/ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « components/mus/ws/user_id.h ('k') | components/mus/ws/user_id_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_MUS_WS_USER_ID_TRACKER_H_
6 #define COMPONENTS_MUS_WS_USER_ID_TRACKER_H_
7
8 #include <stdint.h>
9
10 #include <set>
11
12 #include "base/macros.h"
13 #include "base/observer_list.h"
14 #include "components/mus/public/interfaces/user_access_manager.mojom.h"
15 #include "components/mus/ws/user_id.h"
16 #include "mojo/public/cpp/bindings/binding_set.h"
17
18 namespace mus {
19 namespace ws {
20
21 class UserIdTrackerObserver;
22
23 // Tracks the set of known/valid user ids.
24 class UserIdTracker : public mojom::UserAccessManager {
25 public:
26 UserIdTracker();
27 ~UserIdTracker() override;
28
29 bool IsValidUserId(const UserId& id) const;
30
31 const UserId& active_id() const { return active_id_; }
32
33 // Adds a new known user. Does nothing if |id| is not known.
34 void SetActiveUserId(const UserId& id);
35 void AddUserId(const UserId& id);
36 void RemoveUserId(const UserId& id);
37
38 void AddObserver(UserIdTrackerObserver* observer);
39 void RemoveObserver(UserIdTrackerObserver* observer);
40
41 void Bind(mojom::UserAccessManagerRequest request);
42
43 private:
44 using UserIdSet = std::set<UserId>;
45
46 // mojom::UserAccessManager:
47 void SetActiveUser(const mojo::String& user_id) override;
48
49 base::ObserverList<UserIdTrackerObserver> observers_;
50
51 UserIdSet ids_;
52 UserId active_id_;
53
54 mojo::BindingSet<mojom::UserAccessManager> bindings_;
55
56 DISALLOW_COPY_AND_ASSIGN(UserIdTracker);
57 };
58
59 } // namespace ws
60 } // namespace mus
61
62 #endif // COMPONENTS_MUS_WS_USER_ID_TRACKER_H_
OLDNEW
« no previous file with comments | « components/mus/ws/user_id.h ('k') | components/mus/ws/user_id_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698