OLD | NEW |
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 #include "chrome/browser/media/router/issue_manager.h" | 5 #include "chrome/browser/media/router/issue_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 | 10 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 void IssueManager::UnregisterObserver(IssuesObserver* observer) { | 89 void IssueManager::UnregisterObserver(IssuesObserver* observer) { |
90 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 90 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
91 issues_observers_.RemoveObserver(observer); | 91 issues_observers_.RemoveObserver(observer); |
92 } | 92 } |
93 | 93 |
94 void IssueManager::MaybeUpdateTopIssue() { | 94 void IssueManager::MaybeUpdateTopIssue() { |
95 const Issue* new_top_issue = nullptr; | 95 const Issue* new_top_issue = nullptr; |
96 | 96 |
97 if (issues_.empty()) { | 97 if (issues_.empty()) { |
98 FOR_EACH_OBSERVER(IssuesObserver, issues_observers_, | 98 for (auto& observer : issues_observers_) |
99 OnIssueUpdated(new_top_issue)); | 99 observer.OnIssueUpdated(new_top_issue); |
100 return; | 100 return; |
101 } | 101 } |
102 | 102 |
103 // Select the first blocking issue in the list of issues. | 103 // Select the first blocking issue in the list of issues. |
104 // If there are none, simply select the first issue in the list. | 104 // If there are none, simply select the first issue in the list. |
105 new_top_issue = &(issues_.front()); | 105 new_top_issue = &(issues_.front()); |
106 for (const auto& issue : issues_) { | 106 for (const auto& issue : issues_) { |
107 // The first blocking issue is of higher priority than the first issue. | 107 // The first blocking issue is of higher priority than the first issue. |
108 if (issue.is_blocking()) { | 108 if (issue.is_blocking()) { |
109 new_top_issue = &issue; | 109 new_top_issue = &issue; |
110 break; | 110 break; |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 // If we've found a new top issue, then report it via the observer. | 114 // If we've found a new top issue, then report it via the observer. |
115 if (new_top_issue->id() != top_issue_id_) { | 115 if (new_top_issue->id() != top_issue_id_) { |
116 top_issue_id_ = new_top_issue->id(); | 116 top_issue_id_ = new_top_issue->id(); |
117 FOR_EACH_OBSERVER(IssuesObserver, issues_observers_, | 117 for (auto& observer : issues_observers_) |
118 OnIssueUpdated(new_top_issue)); | 118 observer.OnIssueUpdated(new_top_issue); |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 } // namespace media_router | 122 } // namespace media_router |
OLD | NEW |