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

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: 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 d579d9bc40113cbb9d96676915b5895e0a0eda74..974654b7dffe835c0d4ff3c416abd0f27844d881 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.cc
@@ -345,9 +345,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);
@@ -786,6 +787,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().
+ 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()) {
@@ -823,7 +828,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) {
@@ -831,6 +836,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