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

Side by Side Diff: chrome/browser/search/suggestions/suggestions_service_factory.cc

Issue 1770843002: SuggestionsService: implement SyncServiceObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: iOS Created 4 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/search/suggestions/suggestions_service_factory.h" 5 #include "chrome/browser/search/suggestions/suggestions_service_factory.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/profiles/incognito_helpers.h" 10 #include "chrome/browser/profiles/incognito_helpers.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/search/suggestions/image_fetcher_impl.h" 12 #include "chrome/browser/search/suggestions/image_fetcher_impl.h"
13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
14 #include "chrome/browser/signin/signin_manager_factory.h" 14 #include "chrome/browser/signin/signin_manager_factory.h"
15 #include "chrome/browser/sync/profile_sync_service_factory.h"
16 #include "components/browser_sync/browser/profile_sync_service.h"
15 #include "components/keyed_service/content/browser_context_dependency_manager.h" 17 #include "components/keyed_service/content/browser_context_dependency_manager.h"
16 #include "components/leveldb_proto/proto_database.h" 18 #include "components/leveldb_proto/proto_database.h"
17 #include "components/leveldb_proto/proto_database_impl.h" 19 #include "components/leveldb_proto/proto_database_impl.h"
18 #include "components/pref_registry/pref_registry_syncable.h" 20 #include "components/pref_registry/pref_registry_syncable.h"
19 #include "components/prefs/pref_service.h" 21 #include "components/prefs/pref_service.h"
20 #include "components/signin/core/browser/profile_oauth2_token_service.h" 22 #include "components/signin/core/browser/profile_oauth2_token_service.h"
21 #include "components/signin/core/browser/signin_manager.h" 23 #include "components/signin/core/browser/signin_manager.h"
22 #include "components/suggestions/blacklist_store.h" 24 #include "components/suggestions/blacklist_store.h"
23 #include "components/suggestions/image_fetcher.h" 25 #include "components/suggestions/image_fetcher.h"
24 #include "components/suggestions/image_manager.h" 26 #include "components/suggestions/image_manager.h"
(...skipping 17 matching lines...) Expand all
42 SuggestionsServiceFactory* SuggestionsServiceFactory::GetInstance() { 44 SuggestionsServiceFactory* SuggestionsServiceFactory::GetInstance() {
43 return base::Singleton<SuggestionsServiceFactory>::get(); 45 return base::Singleton<SuggestionsServiceFactory>::get();
44 } 46 }
45 47
46 SuggestionsServiceFactory::SuggestionsServiceFactory() 48 SuggestionsServiceFactory::SuggestionsServiceFactory()
47 : BrowserContextKeyedServiceFactory( 49 : BrowserContextKeyedServiceFactory(
48 "SuggestionsService", 50 "SuggestionsService",
49 BrowserContextDependencyManager::GetInstance()) { 51 BrowserContextDependencyManager::GetInstance()) {
50 DependsOn(SigninManagerFactory::GetInstance()); 52 DependsOn(SigninManagerFactory::GetInstance());
51 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); 53 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
54 DependsOn(ProfileSyncServiceFactory::GetInstance());
52 } 55 }
53 56
54 SuggestionsServiceFactory::~SuggestionsServiceFactory() {} 57 SuggestionsServiceFactory::~SuggestionsServiceFactory() {}
55 58
56 KeyedService* SuggestionsServiceFactory::BuildServiceInstanceFor( 59 KeyedService* SuggestionsServiceFactory::BuildServiceInstanceFor(
57 content::BrowserContext* profile) const { 60 content::BrowserContext* context) const {
58 scoped_refptr<base::SequencedTaskRunner> background_task_runner = 61 scoped_refptr<base::SequencedTaskRunner> background_task_runner =
59 BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( 62 BrowserThread::GetBlockingPool()->GetSequencedTaskRunner(
60 base::SequencedWorkerPool::GetSequenceToken()); 63 base::SequencedWorkerPool::GetSequenceToken());
61 64
62 Profile* the_profile = static_cast<Profile*>(profile); 65 Profile* profile = static_cast<Profile*>(context);
63 66
64 SigninManagerBase* signin_manager = 67 SigninManagerBase* signin_manager =
65 SigninManagerFactory::GetForProfile(the_profile); 68 SigninManagerFactory::GetForProfile(profile);
66 ProfileOAuth2TokenService* token_service = 69 ProfileOAuth2TokenService* token_service =
67 ProfileOAuth2TokenServiceFactory::GetForProfile(the_profile); 70 ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
71 ProfileSyncService* sync_service =
72 ProfileSyncServiceFactory::GetForProfile(profile);
68 73
69 scoped_ptr<SuggestionsStore> suggestions_store( 74 scoped_ptr<SuggestionsStore> suggestions_store(
70 new SuggestionsStore(the_profile->GetPrefs())); 75 new SuggestionsStore(profile->GetPrefs()));
71 scoped_ptr<BlacklistStore> blacklist_store( 76 scoped_ptr<BlacklistStore> blacklist_store(
72 new BlacklistStore(the_profile->GetPrefs())); 77 new BlacklistStore(profile->GetPrefs()));
73 78
74 scoped_ptr<leveldb_proto::ProtoDatabaseImpl<ImageData> > db( 79 scoped_ptr<leveldb_proto::ProtoDatabaseImpl<ImageData> > db(
75 new leveldb_proto::ProtoDatabaseImpl<ImageData>(background_task_runner)); 80 new leveldb_proto::ProtoDatabaseImpl<ImageData>(background_task_runner));
76 81
77 base::FilePath database_dir( 82 base::FilePath database_dir(
78 the_profile->GetPath().Append(FILE_PATH_LITERAL("Thumbnails"))); 83 profile->GetPath().Append(FILE_PATH_LITERAL("Thumbnails")));
79 84
80 scoped_ptr<ImageFetcherImpl> image_fetcher( 85 scoped_ptr<ImageFetcherImpl> image_fetcher(
81 new ImageFetcherImpl(the_profile->GetRequestContext())); 86 new ImageFetcherImpl(profile->GetRequestContext()));
82 scoped_ptr<ImageManager> thumbnail_manager( 87 scoped_ptr<ImageManager> thumbnail_manager(
83 new ImageManager( 88 new ImageManager(
84 std::move(image_fetcher), std::move(db), database_dir, 89 std::move(image_fetcher), std::move(db), database_dir,
85 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB))); 90 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)));
86 return new SuggestionsService( 91 return new SuggestionsService(
87 signin_manager, token_service, the_profile->GetRequestContext(), 92 signin_manager, token_service, sync_service, profile->GetRequestContext(),
88 std::move(suggestions_store), std::move(thumbnail_manager), 93 std::move(suggestions_store), std::move(thumbnail_manager),
89 std::move(blacklist_store)); 94 std::move(blacklist_store));
90 } 95 }
91 96
92 void SuggestionsServiceFactory::RegisterProfilePrefs( 97 void SuggestionsServiceFactory::RegisterProfilePrefs(
93 user_prefs::PrefRegistrySyncable* registry) { 98 user_prefs::PrefRegistrySyncable* registry) {
94 SuggestionsService::RegisterProfilePrefs(registry); 99 SuggestionsService::RegisterProfilePrefs(registry);
95 } 100 }
96 101
97 } // namespace suggestions 102 } // namespace suggestions
OLDNEW
« no previous file with comments | « chrome/browser/search/instant_service_factory.cc ('k') | chrome/browser/search/suggestions/suggestions_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698