Chromium Code Reviews| Index: chrome/browser/media/router/issue_manager.h |
| diff --git a/chrome/browser/media/router/issue_manager.h b/chrome/browser/media/router/issue_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a46d58fd1644a65e4eccbd4bb9202d8cb001ebb7 |
| --- /dev/null |
| +++ b/chrome/browser/media/router/issue_manager.h |
| @@ -0,0 +1,77 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_MEDIA_ROUTER_ISSUE_MANAGER_H_ |
| +#define CHROME_BROWSER_MEDIA_ROUTER_ISSUE_MANAGER_H_ |
| + |
| +#include <map> |
| + |
| +#include "base/containers/hash_tables.h" |
| +#include "base/observer_list.h" |
| +#include "base/threading/thread_checker.h" |
| +#include "chrome/browser/media/router/issue.h" |
| +#include "chrome/browser/media/router/issues_observer.h" |
| + |
| +namespace media_router { |
| + |
| +// IssueManager keeps track of current issues related to casting |
| +// connectivity and quality. |
| +// TODO(apacible): Determine what other issues will be handled here. |
| +class IssueManager { |
| + public: |
| + IssueManager(); |
| + ~IssueManager(); |
| + |
| + // Adds an issue. |
| + // |issue|: Issue to be added. Must have unique ID. |
| + void AddIssue(const Issue& issue); |
| + |
| + // Removes an issue when user has noted it is resolved. |
| + // |issue_id|: IssueId of the issue to be removed. |
| + void ClearIssue(const IssueId& issue_id); |
| + |
| + // Gets the number of unresolved issues. |
| + size_t GetIssueCount() const; |
| + |
| + // Removes all unresolved issues. |
| + void ClearAllIssues(); |
| + |
| + // Removes all unresolved global issues. |
| + void ClearGlobalIssues(); |
| + |
| + // Removes all unresolved issues with RouteId. |
| + // |route_id|: MediaRouteId of the issues to be removed. |
| + void ClearIssuesWithRouteId(const MediaRouteId& route_id); |
| + |
| + // Registers |observer| in |issues_observers_|. If there is already an |
| + // observer registered with this instance, do nothing. Does not take |
| + // ownership of |observer|. |
| + // |observer|: IssuesObserver to be registered. |
| + void RegisterObserver(IssuesObserver* observer); |
|
DaleCurtis
2015/04/30 18:18:15
Is it IssueObserver in that each observer will be
apacible
2015/04/30 19:02:06
All IssueObservers will be called for each issue t
Kevin M
2015/05/01 17:59:18
PTAL at the newest comments, hopefully it is clear
|
| + |
| + // Unregisters |observer| from |issues_observers_|. |
| + // |observer|: IssuesObserver to be unregistered. |
| + void UnregisterObserver(IssuesObserver* observer); |
| + |
| + private: |
| + // Checks if the current top issue has changed. Updates |top_issue_|. |
| + // If |top_issue_| has changed, issues in |issues_observers_| will be |
| + // notified of the new top issue. |
| + void MaybeUpdateTopIssue(); |
| + |
| + base::hash_map<IssueId, Issue> media_issue_map_; |
| + |
| + // Not owned by IssueManager. |
| + ObserverList<IssuesObserver> issues_observers_; |
| + |
| + Issue* top_issue_; |
| + |
| + base::ThreadChecker thread_checker_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(IssueManager); |
| +}; |
| + |
| +} // namespace media_router |
| + |
| +#endif // CHROME_BROWSER_MEDIA_ROUTER_ISSUE_MANAGER_H_ |