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

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

Issue 11515005: Delay updating jumplist to avoid blocking the file thread at start-up (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up a couple nits Created 8 years 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 | Annotate | Revision Log
« chrome/browser/jumplist_win.h ('K') | « 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <windows.h> 7 #include <windows.h>
8 #include <shobjidl.h> 8 #include <shobjidl.h>
9 #include <propkey.h> 9 #include <propkey.h>
10 #include <propvarutil.h> 10 #include <propvarutil.h>
(...skipping 19 matching lines...) Expand all
30 #include "chrome/browser/profiles/profile.h" 30 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/browser/sessions/session_types.h" 31 #include "chrome/browser/sessions/session_types.h"
32 #include "chrome/browser/sessions/tab_restore_service.h" 32 #include "chrome/browser/sessions/tab_restore_service.h"
33 #include "chrome/browser/sessions/tab_restore_service_factory.h" 33 #include "chrome/browser/sessions/tab_restore_service_factory.h"
34 #include "chrome/browser/shell_integration.h" 34 #include "chrome/browser/shell_integration.h"
35 #include "chrome/common/chrome_constants.h" 35 #include "chrome/common/chrome_constants.h"
36 #include "chrome/common/chrome_notification_types.h" 36 #include "chrome/common/chrome_notification_types.h"
37 #include "chrome/common/chrome_switches.h" 37 #include "chrome/common/chrome_switches.h"
38 #include "chrome/common/url_constants.h" 38 #include "chrome/common/url_constants.h"
39 #include "content/public/browser/browser_thread.h" 39 #include "content/public/browser/browser_thread.h"
40 #include "content/public/browser/notification_service.h"
40 #include "content/public/browser/notification_source.h" 41 #include "content/public/browser/notification_source.h"
42 #include "content/public/browser/notification_types.h"
41 #include "googleurl/src/gurl.h" 43 #include "googleurl/src/gurl.h"
42 #include "grit/chromium_strings.h" 44 #include "grit/chromium_strings.h"
43 #include "grit/generated_resources.h" 45 #include "grit/generated_resources.h"
44 #include "third_party/skia/include/core/SkBitmap.h" 46 #include "third_party/skia/include/core/SkBitmap.h"
45 #include "ui/base/l10n/l10n_util.h" 47 #include "ui/base/l10n/l10n_util.h"
46 #include "ui/gfx/codec/png_codec.h" 48 #include "ui/gfx/codec/png_codec.h"
47 #include "ui/gfx/favicon_size.h" 49 #include "ui/gfx/favicon_size.h"
48 #include "ui/gfx/icon_util.h" 50 #include "ui/gfx/icon_util.h"
49 51
50 using content::BrowserThread; 52 using content::BrowserThread;
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 return false; 483 return false;
482 484
483 return true; 485 return true;
484 } 486 }
485 487
486 } // namespace 488 } // namespace
487 489
488 JumpList::JumpList() 490 JumpList::JumpList()
489 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), 491 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)),
490 profile_(NULL), 492 profile_(NULL),
491 task_id_(CancelableTaskTracker::kBadTaskId) { 493 task_id_(CancelableTaskTracker::kBadTaskId),
494 first_page_load_(true),
495 update_pending_(false) {
492 } 496 }
493 497
494 JumpList::~JumpList() { 498 JumpList::~JumpList() {
495 Terminate(); 499 Terminate();
496 } 500 }
497 501
498 // static 502 // static
499 bool JumpList::Enabled() { 503 bool JumpList::Enabled() {
500 return (base::win::GetVersion() >= base::win::VERSION_WIN7 && 504 return (base::win::GetVersion() >= base::win::VERSION_WIN7 &&
501 !CommandLine::ForCurrentProcess()->HasSwitch( 505 !CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 25 matching lines...) Expand all
527 top_sites->SyncWithHistory(); 531 top_sites->SyncWithHistory();
528 registrar_.reset(new content::NotificationRegistrar); 532 registrar_.reset(new content::NotificationRegistrar);
529 // Register for notification when TopSites changes so that we can update 533 // Register for notification when TopSites changes so that we can update
530 // ourself. 534 // ourself.
531 registrar_->Add(this, chrome::NOTIFICATION_TOP_SITES_CHANGED, 535 registrar_->Add(this, chrome::NOTIFICATION_TOP_SITES_CHANGED,
532 content::Source<history::TopSites>(top_sites)); 536 content::Source<history::TopSites>(top_sites));
533 // Register for notification when profile is destroyed to ensure that all 537 // Register for notification when profile is destroyed to ensure that all
534 // observers are detatched at that time. 538 // observers are detatched at that time.
535 registrar_->Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, 539 registrar_->Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
536 content::Source<Profile>(profile_)); 540 content::Source<Profile>(profile_));
541 // Register for notification of when
542 registrar_->Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
543 content::NotificationService::AllSources());
jeremy 2012/12/12 08:16:09 I think 'content::' should be aligned under 'this'
Cait (Slow) 2012/12/12 17:09:17 Done.
537 } 544 }
538 tab_restore_service->AddObserver(this); 545 tab_restore_service->AddObserver(this);
539 return true; 546 return true;
540 } 547 }
541 548
542 void JumpList::Observe(int type, 549 void JumpList::Observe(int type,
543 const content::NotificationSource& source, 550 const content::NotificationSource& source,
544 const content::NotificationDetails& details) { 551 const content::NotificationDetails& details) {
545 switch (type) { 552 switch (type) {
546 case chrome::NOTIFICATION_TOP_SITES_CHANGED: { 553 case chrome::NOTIFICATION_TOP_SITES_CHANGED: {
547 // Most visited urls changed, query again. 554 // Most visited urls changed, query again.
548 history::TopSites* top_sites = profile_->GetTopSites(); 555 history::TopSites* top_sites = profile_->GetTopSites();
549 if (top_sites) { 556 if (top_sites) {
550 top_sites->GetMostVisitedURLs( 557 top_sites->GetMostVisitedURLs(
551 base::Bind(&JumpList::OnMostVisitedURLsAvailable, 558 base::Bind(&JumpList::OnMostVisitedURLsAvailable,
552 weak_ptr_factory_.GetWeakPtr())); 559 weak_ptr_factory_.GetWeakPtr()));
553 } 560 }
554 break; 561 break;
555 } 562 }
556 case chrome::NOTIFICATION_PROFILE_DESTROYED: { 563 case chrome::NOTIFICATION_PROFILE_DESTROYED: {
557 // Profile was destroyed, do clean-up. 564 // Profile was destroyed, do clean-up.
558 Terminate(); 565 Terminate();
559 break; 566 break;
560 } 567 }
568 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: {
569 if (first_page_load_) {
570 first_page_load_ = false;
571 if (update_pending_) {
572 update_pending_ = false;
573 BrowserThread::PostTask(
574 BrowserThread::FILE, FROM_HERE,
575 base::Bind(&JumpList::RunUpdate, this));
576 }
577 }
578 }
jeremy 2012/12/12 08:16:09 break ?
Cait (Slow) 2012/12/12 17:09:17 Done.
561 default: 579 default:
562 NOTREACHED() << "Unexpected notification type."; 580 NOTREACHED() << "Unexpected notification type.";
563 } 581 }
564 } 582 }
565 583
566 void JumpList::RemoveObserver() { 584 void JumpList::RemoveObserver() {
567 if (profile_) { 585 if (profile_) {
568 TabRestoreService* tab_restore_service = 586 TabRestoreService* tab_restore_service =
569 TabRestoreServiceFactory::GetForProfile(profile_); 587 TabRestoreServiceFactory::GetForProfile(profile_);
570 if (tab_restore_service) 588 if (tab_restore_service)
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 } 706 }
689 } 707 }
690 708
691 void JumpList::StartLoadingFavicon() { 709 void JumpList::StartLoadingFavicon() {
692 GURL url; 710 GURL url;
693 { 711 {
694 base::AutoLock auto_lock(list_lock_); 712 base::AutoLock auto_lock(list_lock_);
695 if (icon_urls_.empty()) { 713 if (icon_urls_.empty()) {
696 // No more favicons are needed by the application JumpList. Schedule a 714 // No more favicons are needed by the application JumpList. Schedule a
697 // RunUpdate call. 715 // RunUpdate call.
698 BrowserThread::PostTask( 716 if (first_page_load_) {
699 BrowserThread::FILE, FROM_HERE, 717 update_pending_ = true;
700 base::Bind(&JumpList::RunUpdate, this)); 718 } else {
719 BrowserThread::PostTask(
720 BrowserThread::FILE, FROM_HERE,
721 base::Bind(&JumpList::RunUpdate, this));
722 }
701 return; 723 return;
702 } 724 }
703 // Ask FaviconService if it has a favicon of a URL. 725 // Ask FaviconService if it has a favicon of a URL.
704 // When FaviconService has one, it will call OnFaviconDataAvailable(). 726 // When FaviconService has one, it will call OnFaviconDataAvailable().
705 url = GURL(icon_urls_.front().first); 727 url = GURL(icon_urls_.front().first);
706 } 728 }
707 FaviconService* favicon_service = 729 FaviconService* favicon_service =
708 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 730 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
709 task_id_ = favicon_service->GetFaviconImageForURL( 731 task_id_ = favicon_service->GetFaviconImageForURL(
710 FaviconService::FaviconForURLParams(profile_, 732 FaviconService::FaviconForURLParams(profile_,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 } 800 }
779 801
780 void JumpList::CreateIconFiles(const ShellLinkItemList& item_list) { 802 void JumpList::CreateIconFiles(const ShellLinkItemList& item_list) {
781 for (ShellLinkItemList::const_iterator item = item_list.begin(); 803 for (ShellLinkItemList::const_iterator item = item_list.begin();
782 item != item_list.end(); ++item) { 804 item != item_list.end(); ++item) {
783 FilePath icon_path; 805 FilePath icon_path;
784 if (CreateIconFile((*item)->data(), icon_dir_, &icon_path)) 806 if (CreateIconFile((*item)->data(), icon_dir_, &icon_path))
785 (*item)->SetIcon(icon_path.value(), 0, true); 807 (*item)->SetIcon(icon_path.value(), 0, true);
786 } 808 }
787 } 809 }
OLDNEW
« chrome/browser/jumplist_win.h ('K') | « chrome/browser/jumplist_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698