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

Unified Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc

Issue 23708028: Reduce calling count of UpdateAppState() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 7 years, 3 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/ui/ash/launcher/chrome_launcher_controller.cc
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
index e53408fa6934b1748779d790bbe4a8075341cc08..a98120486efb22b13cd35556ba2f01c6521f4d57 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
@@ -390,9 +390,10 @@ void ChromeLauncherController::SetItemStatus(
ash::LauncherID id,
ash::LauncherItemStatus status) {
int index = model_->ItemIndexByID(id);
+ ash::LauncherItemStatus old_status = model_->items()[index].status;
// Since ordinary browser windows are not registered, we might get a negative
// index here.
- if (index >= 0) {
+ if (index >= 0 && old_status != status) {
ash::LauncherItem item = model_->items()[index];
item.status = status;
model_->Set(index, item);
@@ -834,6 +835,10 @@ void ChromeLauncherController::RemoveTabFromRunningApp(
WebContents* tab,
const std::string& app_id) {
web_contents_to_app_id_.erase(tab);
+ // For empty |app_id| tab, its state is udpated by UpdateBrowserItemState().
Mr4D (OOO till 08-26) 2013/10/01 03:20:33 What about: UpdateBrowserItemState will update th
simonhong_ 2013/10/01 05:10:43 Done.
+ if (app_id.empty())
+ return;
+
AppIDToWebContentsListMap::iterator i_app_id =
app_id_to_web_contents_list_.find(app_id);
if (i_app_id != app_id_to_web_contents_list_.end()) {
@@ -871,7 +876,7 @@ void ChromeLauncherController::UpdateAppState(content::WebContents* contents,
if (app_state == APP_STATE_REMOVED) {
// The tab has gone away.
RemoveTabFromRunningApp(contents, app_id);
- } else {
+ } else if (!app_id.empty()) {
WebContentsList& tab_list(app_id_to_web_contents_list_[app_id]);
if (app_state == APP_STATE_INACTIVE) {
@@ -879,6 +884,7 @@ void ChromeLauncherController::UpdateAppState(content::WebContents* contents,
std::find(tab_list.begin(), tab_list.end(), contents);
if (i_tab == tab_list.end())
tab_list.push_back(contents);
+ // TODO(simon.hong81): Does this below case exist?
if (i_tab != tab_list.begin()) {
// Going inactive, but wasn't the front tab, indicating that a new
// tab has already become active.

Powered by Google App Engine
This is Rietveld 408576698