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

Side by Side Diff: chrome/browser/win/jumplist.cc

Issue 2954173002: Remove redundant JumpListUpdater::IsEnabled calls (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/win/jumplist.h" 5 #include "chrome/browser/win/jumplist.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); 259 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
260 Terminate(); 260 Terminate();
261 } 261 }
262 262
263 void JumpList::TopSitesLoaded(history::TopSites* top_sites) {} 263 void JumpList::TopSitesLoaded(history::TopSites* top_sites) {}
264 264
265 void JumpList::TopSitesChanged(history::TopSites* top_sites, 265 void JumpList::TopSitesChanged(history::TopSites* top_sites,
266 ChangeReason change_reason) { 266 ChangeReason change_reason) {
267 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); 267 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
268 268
269 if (!JumpListUpdater::IsEnabled())
grt (UTC plus 2) 2017/06/24 20:42:44 BrowserView::InitViews only constructs a JumpList
chengx 2017/06/29 19:14:37 That should be enough.
270 return;
271
269 top_sites_has_pending_notification_ = true; 272 top_sites_has_pending_notification_ = true;
270 273
271 // Postpone handling this notification until a pending update completes. 274 // Postpone handling this notification until a pending update completes.
272 if (update_in_progress_) 275 if (update_in_progress_)
273 return; 276 return;
274 277
275 // If we have a pending favicon request, cancel it here as it's out of date. 278 // If we have a pending favicon request, cancel it here as it's out of date.
276 CancelPendingUpdate(); 279 CancelPendingUpdate();
277 280
278 // Initialize the one-shot timer to update the JumpList in a while. 281 // Initialize the one-shot timer to update the JumpList in a while.
279 InitializeTimerForUpdate(); 282 InitializeTimerForUpdate();
280 } 283 }
281 284
282 void JumpList::TabRestoreServiceChanged(sessions::TabRestoreService* service) { 285 void JumpList::TabRestoreServiceChanged(sessions::TabRestoreService* service) {
283 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); 286 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
284 287
288 if (!JumpListUpdater::IsEnabled())
289 return;
290
285 tab_restore_has_pending_notification_ = true; 291 tab_restore_has_pending_notification_ = true;
286 292
287 // Postpone handling this notification until a pending update completes. 293 // Postpone handling this notification until a pending update completes.
288 if (update_in_progress_) 294 if (update_in_progress_)
289 return; 295 return;
290 296
291 // if we have a pending favicon request, cancel it here as it's out of date. 297 // if we have a pending favicon request, cancel it here as it's out of date.
292 CancelPendingUpdate(); 298 CancelPendingUpdate();
293 299
294 // Initialize the one-shot timer to update the JumpList in a while. 300 // Initialize the one-shot timer to update the JumpList in a while.
295 InitializeTimerForUpdate(); 301 InitializeTimerForUpdate();
296 } 302 }
297 303
298 void JumpList::TabRestoreServiceDestroyed( 304 void JumpList::TabRestoreServiceDestroyed(
299 sessions::TabRestoreService* service) {} 305 sessions::TabRestoreService* service) {}
300 306
301 void JumpList::OnIncognitoAvailabilityChanged() { 307 void JumpList::OnIncognitoAvailabilityChanged() {
302 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); 308 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
303 309
310 if (!JumpListUpdater::IsEnabled())
311 return;
312
304 if (icon_urls_.empty()) 313 if (icon_urls_.empty())
305 PostRunUpdate(); 314 PostRunUpdate();
306 } 315 }
307 316
308 void JumpList::InitializeTimerForUpdate() { 317 void JumpList::InitializeTimerForUpdate() {
309 if (timer_.IsRunning()) { 318 if (timer_.IsRunning()) {
310 timer_.Reset(); 319 timer_.Reset();
311 } else { 320 } else {
312 // base::Unretained is safe since |this| is guaranteed to outlive timer_. 321 // base::Unretained is safe since |this| is guaranteed to outlive timer_.
313 timer_.Start(FROM_HERE, kDelayForJumplistUpdate, 322 timer_.Start(FROM_HERE, kDelayForJumplistUpdate,
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 // static 666 // static
658 void JumpList::RunUpdateJumpList( 667 void JumpList::RunUpdateJumpList(
659 const base::string16& app_id, 668 const base::string16& app_id,
660 const base::FilePath& profile_dir, 669 const base::FilePath& profile_dir,
661 const ShellLinkItemList& most_visited_pages, 670 const ShellLinkItemList& most_visited_pages,
662 const ShellLinkItemList& recently_closed_pages, 671 const ShellLinkItemList& recently_closed_pages,
663 bool most_visited_should_update, 672 bool most_visited_should_update,
664 bool recently_closed_should_update, 673 bool recently_closed_should_update,
665 IncognitoModePrefs::Availability incognito_availability, 674 IncognitoModePrefs::Availability incognito_availability,
666 UpdateResults* update_results) { 675 UpdateResults* update_results) {
667 if (!JumpListUpdater::IsEnabled())
668 return;
669
670 DCHECK(update_results); 676 DCHECK(update_results);
671 677
672 JumpListUpdater jumplist_updater(app_id); 678 JumpListUpdater jumplist_updater(app_id);
673 679
674 base::ElapsedTimer begin_update_timer; 680 base::ElapsedTimer begin_update_timer;
675 681
676 if (!jumplist_updater.BeginUpdate()) 682 if (!jumplist_updater.BeginUpdate())
677 return; 683 return;
678 684
679 // Discard this JumpList update if JumpListUpdater::BeginUpdate takes longer 685 // Discard this JumpList update if JumpListUpdater::BeginUpdate takes longer
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 URLIconCache* icon_cache) { 828 URLIconCache* icon_cache) {
823 // Put all cached icon file paths into a set. 829 // Put all cached icon file paths into a set.
824 base::flat_set<base::FilePath> cached_files; 830 base::flat_set<base::FilePath> cached_files;
825 cached_files.reserve(icon_cache->size()); 831 cached_files.reserve(icon_cache->size());
826 832
827 for (const auto& url_path_pair : *icon_cache) 833 for (const auto& url_path_pair : *icon_cache)
828 cached_files.insert(url_path_pair.second); 834 cached_files.insert(url_path_pair.second);
829 835
830 DeleteNonCachedFiles(icon_dir, cached_files); 836 DeleteNonCachedFiles(icon_dir, cached_files);
831 } 837 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698