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

Side by Side Diff: chrome/browser/jumplist_win.cc

Issue 965503002: Filter out redundant jumplist updates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix some accumulated glitches Created 5 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 | « chrome/browser/jumplist_win.h ('k') | 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/jumplist_win.h" 5 #include "chrome/browser/jumplist_win.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 28 matching lines...) Expand all
39 #include "ui/gfx/codec/png_codec.h" 39 #include "ui/gfx/codec/png_codec.h"
40 #include "ui/gfx/favicon_size.h" 40 #include "ui/gfx/favicon_size.h"
41 #include "ui/gfx/icon_util.h" 41 #include "ui/gfx/icon_util.h"
42 #include "ui/gfx/image/image_family.h" 42 #include "ui/gfx/image/image_family.h"
43 #include "url/gurl.h" 43 #include "url/gurl.h"
44 44
45 using content::BrowserThread; 45 using content::BrowserThread;
46 46
47 namespace { 47 namespace {
48 48
49 // Delay jumplist update tasks to allow collapsing of redundant
50 // update requests.
gab 2015/06/03 19:03:50 Looks like "update" fits on previous line.
brucedawson 2015/06/04 17:11:59 Done.
51 const int kDelayForJumplistUpdateInMS = 3500;
52
49 // Append the common switches to each shell link. 53 // Append the common switches to each shell link.
50 void AppendCommonSwitches(ShellLinkItem* shell_link) { 54 void AppendCommonSwitches(ShellLinkItem* shell_link) {
51 const char* kSwitchNames[] = { switches::kUserDataDir }; 55 const char* kSwitchNames[] = { switches::kUserDataDir };
52 const base::CommandLine& command_line = 56 const base::CommandLine& command_line =
53 *base::CommandLine::ForCurrentProcess(); 57 *base::CommandLine::ForCurrentProcess();
54 shell_link->GetCommandLine()->CopySwitchesFrom(command_line, 58 shell_link->GetCommandLine()->CopySwitchesFrom(command_line,
55 kSwitchNames, 59 kSwitchNames,
56 arraysize(kSwitchNames)); 60 arraysize(kSwitchNames));
57 } 61 }
58 62
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 base::AutoLock auto_lock(list_lock_); 437 base::AutoLock auto_lock(list_lock_);
434 waiting_for_icons = !icon_urls_.empty(); 438 waiting_for_icons = !icon_urls_.empty();
435 } 439 }
436 if (!waiting_for_icons) 440 if (!waiting_for_icons)
437 PostRunUpdate(); 441 PostRunUpdate();
438 // If |icon_urls_| isn't empty then OnFaviconDataAvailable will eventually 442 // If |icon_urls_| isn't empty then OnFaviconDataAvailable will eventually
439 // call PostRunUpdate(). 443 // call PostRunUpdate().
440 } 444 }
441 445
442 void JumpList::PostRunUpdate() { 446 void JumpList::PostRunUpdate() {
447
gab 2015/06/03 19:03:50 No empty line.
brucedawson 2015/06/04 17:11:59 Done.
448 // Initialize the one-shot timer to update the jumplists in a while.
449 // If there is already a request queued then cancel it and post the new
450 // request. This ensures that JumpListUpdates won't happen until there has
451 // been a brief quiet period, thus avoiding update storms.
452 if (timer_.IsRunning())
gab 2015/06/03 19:03:50 {}s everywhere since the else's body is multiline.
brucedawson 2015/06/04 17:11:59 Done.
453 timer_.Reset();
454 else
455 timer_.Start(FROM_HERE,
456 base::TimeDelta::FromMilliseconds(kDelayForJumplistUpdateInMS),
457 this,
458 &JumpList::DeferredRunUpdate);
459 }
460
461 void JumpList::DeferredRunUpdate() {
443 // Check if incognito windows (or normal windows) are disabled by policy. 462 // Check if incognito windows (or normal windows) are disabled by policy.
444 IncognitoModePrefs::Availability incognito_availability = 463 IncognitoModePrefs::Availability incognito_availability =
445 profile_ ? IncognitoModePrefs::GetAvailability(profile_->GetPrefs()) 464 profile_ ? IncognitoModePrefs::GetAvailability(profile_->GetPrefs())
446 : IncognitoModePrefs::ENABLED; 465 : IncognitoModePrefs::ENABLED;
447 466
448 BrowserThread::PostTask( 467 BrowserThread::PostTask(
449 BrowserThread::FILE, FROM_HERE, 468 BrowserThread::FILE, FROM_HERE,
450 base::Bind(&JumpList::RunUpdateOnFileThread, 469 base::Bind(&JumpList::RunUpdateOnFileThread,
451 this, 470 this,
452 incognito_availability)); 471 incognito_availability));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 524
506 void JumpList::TopSitesLoaded(history::TopSites* top_sites) { 525 void JumpList::TopSitesLoaded(history::TopSites* top_sites) {
507 } 526 }
508 527
509 void JumpList::TopSitesChanged(history::TopSites* top_sites) { 528 void JumpList::TopSitesChanged(history::TopSites* top_sites) {
510 top_sites->GetMostVisitedURLs( 529 top_sites->GetMostVisitedURLs(
511 base::Bind(&JumpList::OnMostVisitedURLsAvailable, 530 base::Bind(&JumpList::OnMostVisitedURLsAvailable,
512 weak_ptr_factory_.GetWeakPtr()), 531 weak_ptr_factory_.GetWeakPtr()),
513 false); 532 false);
514 } 533 }
OLDNEW
« no previous file with comments | « chrome/browser/jumplist_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698