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

Side by Side Diff: chrome/browser/sync/glue/session_model_associator.cc

Issue 10873022: Revert 152904 - Moving FaviconService to a ProfileKeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
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/sync/glue/session_model_associator.h" 5 #include "chrome/browser/sync/glue/session_model_associator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/threading/sequenced_worker_pool.h" 15 #include "base/threading/sequenced_worker_pool.h"
16 #include "chrome/browser/favicon/favicon_service_factory.h"
17 #include "chrome/browser/history/history.h" 16 #include "chrome/browser/history/history.h"
18 #include "chrome/browser/prefs/pref_service.h" 17 #include "chrome/browser/prefs/pref_service.h"
19 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/sessions/session_id.h" 19 #include "chrome/browser/sessions/session_id.h"
21 #include "chrome/browser/sync/glue/synced_session.h" 20 #include "chrome/browser/sync/glue/synced_session.h"
22 #include "chrome/browser/sync/glue/synced_tab_delegate.h" 21 #include "chrome/browser/sync/glue/synced_tab_delegate.h"
23 #include "chrome/browser/sync/glue/synced_window_delegate.h" 22 #include "chrome/browser/sync/glue/synced_window_delegate.h"
24 #include "chrome/browser/sync/profile_sync_service.h" 23 #include "chrome/browser/sync/profile_sync_service.h"
25 #include "chrome/common/chrome_notification_types.h" 24 #include "chrome/common/chrome_notification_types.h"
26 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 PopulateSessionTabFromSpecifics(*sync_tab, 534 PopulateSessionTabFromSpecifics(*sync_tab,
536 base::Time::Now(), 535 base::Time::Now(),
537 prev_tab); 536 prev_tab);
538 } 537 }
539 538
540 void SessionModelAssociator::LoadFaviconForTab(TabLink* tab_link) { 539 void SessionModelAssociator::LoadFaviconForTab(TabLink* tab_link) {
541 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 540 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
542 if (!command_line.HasSwitch(switches::kSyncTabFavicons)) 541 if (!command_line.HasSwitch(switches::kSyncTabFavicons))
543 return; 542 return;
544 FaviconService* favicon_service = 543 FaviconService* favicon_service =
545 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 544 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
546 if (!favicon_service) 545 if (!favicon_service)
547 return; 546 return;
548 SessionID::id_type tab_id = tab_link->tab()->GetSessionId(); 547 SessionID::id_type tab_id = tab_link->tab()->GetSessionId();
549 if (tab_link->favicon_load_handle()) { 548 if (tab_link->favicon_load_handle()) {
550 // We have an outstanding favicon load for this tab. Cancel it. 549 // We have an outstanding favicon load for this tab. Cancel it.
551 load_consumer_.CancelAllRequestsForClientData(tab_id); 550 load_consumer_.CancelAllRequestsForClientData(tab_id);
552 } 551 }
553 DVLOG(1) << "Triggering favicon load for url " << tab_link->url().spec(); 552 DVLOG(1) << "Triggering favicon load for url " << tab_link->url().spec();
554 FaviconService::Handle handle = favicon_service->GetFaviconForURL( 553 FaviconService::Handle handle = favicon_service->GetFaviconForURL(
555 profile_, tab_link->url(), history::FAVICON, &load_consumer_, 554 tab_link->url(), history::FAVICON, &load_consumer_,
556 base::Bind(&SessionModelAssociator::OnFaviconDataAvailable, 555 base::Bind(&SessionModelAssociator::OnFaviconDataAvailable,
557 AsWeakPtr())); 556 AsWeakPtr()));
558 load_consumer_.SetClientData(favicon_service, handle, tab_id); 557 load_consumer_.SetClientData(favicon_service, handle, tab_id);
559 tab_link->set_favicon_load_handle(handle); 558 tab_link->set_favicon_load_handle(handle);
560 } 559 }
561 560
562 void SessionModelAssociator::OnFaviconDataAvailable( 561 void SessionModelAssociator::OnFaviconDataAvailable(
563 FaviconService::Handle handle, 562 FaviconService::Handle handle,
564 history::FaviconData favicon) { 563 history::FaviconData favicon) {
565 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 564 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
566 if (!command_line.HasSwitch(switches::kSyncTabFavicons)) 565 if (!command_line.HasSwitch(switches::kSyncTabFavicons))
567 return; 566 return;
568 SessionID::id_type tab_id = 567 SessionID::id_type tab_id =
569 load_consumer_.GetClientData( 568 load_consumer_.GetClientData(
570 FaviconServiceFactory::GetForProfile( 569 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), handle);
571 profile_, Profile::EXPLICIT_ACCESS), handle);
572 TabLinksMap::iterator iter = tab_map_.find(tab_id); 570 TabLinksMap::iterator iter = tab_map_.find(tab_id);
573 if (iter == tab_map_.end()) { 571 if (iter == tab_map_.end()) {
574 DVLOG(1) << "Ignoring favicon for closed tab " << tab_id; 572 DVLOG(1) << "Ignoring favicon for closed tab " << tab_id;
575 return; 573 return;
576 } 574 }
577 TabLink* tab_link = iter->second.get(); 575 TabLink* tab_link = iter->second.get();
578 DCHECK(tab_link); 576 DCHECK(tab_link);
579 DCHECK(tab_link->url().is_valid()); 577 DCHECK(tab_link->url().is_valid());
580 // The tab_link holds the current url. Because this load request would have 578 // The tab_link holds the current url. Because this load request would have
581 // been canceled if the url had changed, we know the url must still be 579 // been canceled if the url had changed, we know the url must still be
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 bool SessionModelAssociator::CryptoReadyIfNecessary() { 1593 bool SessionModelAssociator::CryptoReadyIfNecessary() {
1596 // We only access the cryptographer while holding a transaction. 1594 // We only access the cryptographer while holding a transaction.
1597 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); 1595 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare());
1598 const syncer::ModelTypeSet encrypted_types = 1596 const syncer::ModelTypeSet encrypted_types =
1599 syncer::GetEncryptedTypes(&trans); 1597 syncer::GetEncryptedTypes(&trans);
1600 return !encrypted_types.Has(SESSIONS) || 1598 return !encrypted_types.Has(SESSIONS) ||
1601 sync_service_->IsCryptographerReady(&trans); 1599 sync_service_->IsCryptographerReady(&trans);
1602 } 1600 }
1603 1601
1604 } // namespace browser_sync 1602 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/bookmark_change_processor.cc ('k') | chrome/browser/ui/cocoa/history_menu_bridge.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698