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

Side by Side Diff: chrome/browser/media/router/issue_manager.h

Issue 2176613003: [Media Router] Clean up issues related code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: IssueObserver init behavior and use StructTraits Created 4 years, 2 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 CHROME_BROWSER_MEDIA_ROUTER_ISSUE_MANAGER_H_ 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_ISSUE_MANAGER_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_ISSUE_MANAGER_H_ 6 #define CHROME_BROWSER_MEDIA_ROUTER_ISSUE_MANAGER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/containers/hash_tables.h" 13 #include "base/containers/hash_tables.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/observer_list.h" 15 #include "base/observer_list.h"
15 #include "chrome/browser/media/router/issue.h" 16 #include "chrome/browser/media/router/issue.h"
16 #include "chrome/browser/media/router/issues_observer.h" 17 #include "chrome/browser/media/router/issues_observer.h"
17 18
18 namespace media_router { 19 namespace media_router {
19 20
20 // IssueManager keeps track of current issues related to casting 21 // IssueManager keeps track of current issues related to casting
21 // connectivity and quality. It lives on the UI thread. 22 // connectivity and quality. It lives on the UI thread.
22 // TODO(apacible): Determine what other issues will be handled here. 23 // TODO(apacible): Determine what other issues will be handled here.
23 class IssueManager { 24 class IssueManager {
24 public: 25 public:
25 IssueManager(); 26 IssueManager();
26 ~IssueManager(); 27 ~IssueManager();
27 28
28 // Adds an issue. 29 // Adds an issue.
29 // |issue|: Issue to be added. Must have unique ID. 30 // |issue_info|: Info of issue to be added.
30 void AddIssue(const Issue& issue); 31 void AddIssue(const IssueInfo& issue_info);
31 32
32 // Removes an issue when user has noted it is resolved. 33 // Removes an issue when user has noted it is resolved.
33 // |issue_id|: Issue::Id of the issue to be removed. 34 // |issue_id|: Issue::Id of the issue to be removed.
34 void ClearIssue(const Issue::Id& issue_id); 35 void ClearIssue(const Issue::Id& issue_id);
35 36
36 // Gets the number of unresolved issues.
37 size_t GetIssueCount() const;
38
39 // Removes all unresolved issues.
40 void ClearAllIssues();
41
42 // Removes all unresolved global issues.
43 void ClearGlobalIssues();
44
45 // Removes all unresolved issues with RouteId.
46 // |route_id|: ID of the media route whose issues are to be cleared.
47 void ClearIssuesWithRouteId(const MediaRoute::Id& route_id);
48
49 // Registers an issue observer |observer|. The observer will be triggered 37 // Registers an issue observer |observer|. The observer will be triggered
50 // when the highest priority issue changes. 38 // when the highest priority issue changes.
51 // If there is already an observer registered with this instance, do nothing. 39 // If there is already an observer registered with this instance, do nothing.
52 // Does not assume ownership of |observer|. 40 // Does not assume ownership of |observer|.
53 // |observer|: IssuesObserver to be registered. 41 // |observer|: IssuesObserver to be registered.
54 void RegisterObserver(IssuesObserver* observer); 42 void RegisterObserver(IssuesObserver* observer);
55 43
56 // Unregisters |observer| from |issues_observers_|. 44 // Unregisters |observer| from |issues_observers_|.
57 // |observer|: IssuesObserver to be unregistered. 45 // |observer|: IssuesObserver to be unregistered.
58 void UnregisterObserver(IssuesObserver* observer); 46 void UnregisterObserver(IssuesObserver* observer);
59 47
60 private: 48 private:
61 // Checks if the current top issue has changed. Updates |top_issue_|. 49 // Checks if the current top issue has changed. Updates |top_issue_|.
62 // If |top_issue_| has changed, issues in |issues_observers_| will be 50 // If |top_issue_| has changed, observers in |issues_observers_| will be
63 // notified of the new top issue. 51 // notified of the new top issue.
64 void MaybeUpdateTopIssue(); 52 void MaybeUpdateTopIssue();
65 53
66 std::vector<Issue> issues_; 54 std::vector<std::unique_ptr<Issue>> issues_;
mark a. foltz 2016/10/18 17:16:52 Consider making this a set<unique_ptr<Issue>> with
imcheng 2016/11/18 23:45:13 I am inclined to keep this a vector for now since
67 55
68 // IssueObserver insteances are not owned by the manager. 56 // IssueObserver insteances are not owned by the manager.
69 base::ObserverList<IssuesObserver> issues_observers_; 57 base::ObserverList<IssuesObserver> issues_observers_;
70 58
71 // The ID of the current top issue. 59 // The top Issue in |issues_|, or |nullptr| if there are none.
mark a. foltz 2016/10/18 17:16:52 nit: s/are/is/
imcheng 2016/11/18 23:45:13 Done.
72 Issue::Id top_issue_id_; 60 const Issue* top_issue_;
73 61
74 DISALLOW_COPY_AND_ASSIGN(IssueManager); 62 DISALLOW_COPY_AND_ASSIGN(IssueManager);
75 }; 63 };
76 64
77 } // namespace media_router 65 } // namespace media_router
78 66
79 #endif // CHROME_BROWSER_MEDIA_ROUTER_ISSUE_MANAGER_H_ 67 #endif // CHROME_BROWSER_MEDIA_ROUTER_ISSUE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698