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.
5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_ISSUE_MANAGER_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_ISSUE_MANAGER_H_
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"
16 namespace media_router
{
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.
27 // |issue|: Issue to be added. Must have unique ID.
28 void AddIssue(const Issue
& issue
);
30 // Removes an issue when user has noted it is resolved.
31 // |issue_id|: Issue::Id of the issue to be removed.
32 void ClearIssue(const Issue::Id
& issue_id
);
34 // Gets the number of unresolved issues.
35 size_t GetIssueCount() const;
37 // Removes all unresolved issues.
38 void ClearAllIssues();
40 // Removes all unresolved global issues.
41 void ClearGlobalIssues();
43 // Removes all unresolved issues with RouteId.
44 // |route_id|: ID of the media route whose issues are to be cleared.
45 void ClearIssuesWithRouteId(const MediaRoute::Id
& route_id
);
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
);
54 // Unregisters |observer| from |issues_observers_|.
55 // |observer|: IssuesObserver to be unregistered.
56 void UnregisterObserver(IssuesObserver
* observer
);
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();
64 std::vector
<Issue
> issues_
;
66 // IssueObserver insteances are not owned by the manager.
67 base::ObserverList
<IssuesObserver
> issues_observers_
;
69 // The ID of the current top issue.
70 Issue::Id top_issue_id_
;
72 base::ThreadChecker thread_checker_
;
74 DISALLOW_COPY_AND_ASSIGN(IssueManager
);
77 } // namespace media_router
79 #endif // CHROME_BROWSER_MEDIA_ROUTER_ISSUE_MANAGER_H_