OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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 CHROME_BROWSER_MEDIA_ROUTER_ISSUE_MANAGER_H_ | |
6 #define CHROME_BROWSER_MEDIA_ROUTER_ISSUE_MANAGER_H_ | |
7 | |
8 #include <list> | |
9 | |
10 #include "base/containers/hash_tables.h" | |
11 #include "base/observer_list.h" | |
12 #include "base/threading/thread_checker.h" | |
13 #include "chrome/browser/media/router/issue.h" | |
14 #include "chrome/browser/media/router/issues_observer.h" | |
15 | |
16 namespace media_router { | |
17 | |
18 // IssueManager keeps track of current issues related to casting | |
19 // connectivity and quality. | |
20 // TODO(apacible): Determine what other issues will be handled here. | |
21 class IssueManager { | |
22 public: | |
23 IssueManager(); | |
24 ~IssueManager(); | |
25 | |
26 // Adds an issue. | |
27 // |issue|: Issue to be added. Must have unique ID. | |
28 void AddIssue(const Issue& issue); | |
29 | |
30 // Removes an issue when user has noted it is resolved. | |
31 // |issue_id|: Issue::IssueId of the issue to be removed. | |
32 void ClearIssue(const Issue::IssueId& issue_id); | |
33 | |
34 // Gets the number of unresolved issues. | |
35 size_t GetIssueCount() const; | |
36 | |
37 // Removes all unresolved issues. | |
38 void ClearAllIssues(); | |
39 | |
40 // Removes all unresolved global issues. | |
41 void ClearGlobalIssues(); | |
42 | |
43 // Removes all unresolved issues with RouteId. | |
44 // |route_id|: MediaRouteId of the issues to be removed. | |
45 void ClearIssuesWithRouteId(const MediaRouteId& route_id); | |
46 | |
47 // Registers an issue observer |observer|. The observer will be triggered | |
48 // when the highest priority issue changes. | |
49 // If there is already an observer registered with this instance, do nothing. | |
50 // Does not assume ownership of |observer|. | |
51 // |observer|: IssuesObserver to be registered. | |
52 void RegisterObserver(IssuesObserver* observer); | |
53 | |
54 // Unregisters |observer| from |issues_observers_|. | |
55 // |observer|: IssuesObserver to be unregistered. | |
56 void UnregisterObserver(IssuesObserver* observer); | |
57 | |
58 private: | |
59 // Checks if the current top issue has changed. Updates |top_issue_|. | |
60 // If |top_issue_| has changed, issues in |issues_observers_| will be | |
61 // notified of the new top issue. | |
62 void MaybeUpdateTopIssue(); | |
63 | |
64 std::list<Issue> issues_; | |
DaleCurtis
2015/05/02 18:13:32
If you only have 10 elements, using a deque / vect
Kevin M
2015/05/04 18:45:48
OK. I switched top_issue_ from an Issue* to an Iss
| |
65 | |
66 // Not owned by IssueManager. | |
67 ObserverList<IssuesObserver> issues_observers_; | |
68 | |
69 // A pointer to the previously selected "top issue". | |
70 const Issue* top_issue_; | |
71 | |
72 base::ThreadChecker thread_checker_; | |
73 | |
74 DISALLOW_COPY_AND_ASSIGN(IssueManager); | |
75 }; | |
76 | |
77 } // namespace media_router | |
78 | |
79 #endif // CHROME_BROWSER_MEDIA_ROUTER_ISSUE_MANAGER_H_ | |
OLD | NEW |