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

Unified Diff: chrome/browser/media/router/issue_manager.h

Issue 1103273013: Upstream the Media Router's Issue class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed feedback, switched manager to std::list, explicitly invalidated top_issue on clear Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
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..132dd33d316efa9958bc7e4017ecf18542a13cdc
--- /dev/null
+++ b/chrome/browser/media/router/issue_manager.h
@@ -0,0 +1,79 @@
+// 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 <list>
+
+#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|: Issue::IssueId of the issue to be removed.
+ void ClearIssue(const Issue::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 an issue observer |observer|. The observer will be triggered
+ // when the highest priority issue changes.
+ // If there is already an observer registered with this instance, do nothing.
+ // Does not assume ownership of |observer|.
+ // |observer|: IssuesObserver to be registered.
+ void RegisterObserver(IssuesObserver* observer);
+
+ // 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();
+
+ std::list<Issue> issues_;
+
+ // Not owned by IssueManager.
+ ObserverList<IssuesObserver> issues_observers_;
+
+ // A pointer to the previously selected "top issue".
+ const Issue* top_issue_;
+
+ base::ThreadChecker thread_checker_;
+
+ DISALLOW_COPY_AND_ASSIGN(IssueManager);
+};
+
+} // namespace media_router
+
+#endif // CHROME_BROWSER_MEDIA_ROUTER_ISSUE_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698