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

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

Issue 2074153002: Pass the ImageDecoder to the ImageFetcher at creation time. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments round2 treib@ & added missing imports *sigh* Created 4 years, 5 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 <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/ptr_util.h"
10 #include "chrome/browser/profiles/incognito_helpers.h" 11 #include "chrome/browser/profiles/incognito_helpers.h"
11 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/search/suggestions/image_fetcher_impl.h" 13 #include "chrome/browser/search/suggestions/image_decoder_impl.h"
13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
14 #include "chrome/browser/signin/signin_manager_factory.h" 15 #include "chrome/browser/signin/signin_manager_factory.h"
15 #include "chrome/browser/sync/profile_sync_service_factory.h" 16 #include "chrome/browser/sync/profile_sync_service_factory.h"
16 #include "components/browser_sync/browser/profile_sync_service.h" 17 #include "components/browser_sync/browser/profile_sync_service.h"
17 #include "components/image_fetcher/image_fetcher.h" 18 #include "components/image_fetcher/image_fetcher.h"
19 #include "components/image_fetcher/image_fetcher_impl.h"
18 #include "components/keyed_service/content/browser_context_dependency_manager.h" 20 #include "components/keyed_service/content/browser_context_dependency_manager.h"
19 #include "components/leveldb_proto/proto_database.h" 21 #include "components/leveldb_proto/proto_database.h"
20 #include "components/leveldb_proto/proto_database_impl.h" 22 #include "components/leveldb_proto/proto_database_impl.h"
21 #include "components/pref_registry/pref_registry_syncable.h" 23 #include "components/pref_registry/pref_registry_syncable.h"
22 #include "components/prefs/pref_service.h" 24 #include "components/prefs/pref_service.h"
23 #include "components/signin/core/browser/profile_oauth2_token_service.h" 25 #include "components/signin/core/browser/profile_oauth2_token_service.h"
24 #include "components/signin/core/browser/signin_manager.h" 26 #include "components/signin/core/browser/signin_manager.h"
25 #include "components/suggestions/blacklist_store.h" 27 #include "components/suggestions/blacklist_store.h"
26 #include "components/suggestions/image_manager.h" 28 #include "components/suggestions/image_manager.h"
27 #include "components/suggestions/proto/suggestions.pb.h" 29 #include "components/suggestions/proto/suggestions.pb.h"
28 #include "components/suggestions/suggestions_service.h" 30 #include "components/suggestions/suggestions_service.h"
29 #include "components/suggestions/suggestions_store.h" 31 #include "components/suggestions/suggestions_store.h"
30 #include "content/public/browser/browser_context.h" 32 #include "content/public/browser/browser_context.h"
31 #include "content/public/browser/browser_thread.h" 33 #include "content/public/browser/browser_thread.h"
32 34
33 using content::BrowserThread; 35 using content::BrowserThread;
36 using image_fetcher::ImageFetcherImpl;
34 37
35 namespace suggestions { 38 namespace suggestions {
36 39
37 // static 40 // static
38 SuggestionsService* SuggestionsServiceFactory::GetForProfile(Profile* profile) { 41 SuggestionsService* SuggestionsServiceFactory::GetForProfile(Profile* profile) {
39 return static_cast<SuggestionsService*>( 42 return static_cast<SuggestionsService*>(
40 GetInstance()->GetServiceForBrowserContext(profile, true)); 43 GetInstance()->GetServiceForBrowserContext(profile, true));
41 } 44 }
42 45
43 // static 46 // static
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 std::unique_ptr<BlacklistStore> blacklist_store( 79 std::unique_ptr<BlacklistStore> blacklist_store(
77 new BlacklistStore(profile->GetPrefs())); 80 new BlacklistStore(profile->GetPrefs()));
78 81
79 std::unique_ptr<leveldb_proto::ProtoDatabaseImpl<ImageData>> db( 82 std::unique_ptr<leveldb_proto::ProtoDatabaseImpl<ImageData>> db(
80 new leveldb_proto::ProtoDatabaseImpl<ImageData>(background_task_runner)); 83 new leveldb_proto::ProtoDatabaseImpl<ImageData>(background_task_runner));
81 84
82 base::FilePath database_dir( 85 base::FilePath database_dir(
83 profile->GetPath().Append(FILE_PATH_LITERAL("Thumbnails"))); 86 profile->GetPath().Append(FILE_PATH_LITERAL("Thumbnails")));
84 87
85 std::unique_ptr<ImageFetcherImpl> image_fetcher( 88 std::unique_ptr<ImageFetcherImpl> image_fetcher(
86 new ImageFetcherImpl(profile->GetRequestContext())); 89 new ImageFetcherImpl(
90 base::MakeUnique<suggestions::ImageDecoderImpl>(),
91 profile->GetRequestContext()));
87 std::unique_ptr<ImageManager> thumbnail_manager(new ImageManager( 92 std::unique_ptr<ImageManager> thumbnail_manager(new ImageManager(
88 std::move(image_fetcher), std::move(db), database_dir, 93 std::move(image_fetcher), std::move(db), database_dir,
89 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB))); 94 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)));
90 return new SuggestionsService( 95 return new SuggestionsService(
91 signin_manager, token_service, sync_service, profile->GetRequestContext(), 96 signin_manager, token_service, sync_service, profile->GetRequestContext(),
92 std::move(suggestions_store), std::move(thumbnail_manager), 97 std::move(suggestions_store), std::move(thumbnail_manager),
93 std::move(blacklist_store)); 98 std::move(blacklist_store));
94 } 99 }
95 100
96 void SuggestionsServiceFactory::RegisterProfilePrefs( 101 void SuggestionsServiceFactory::RegisterProfilePrefs(
97 user_prefs::PrefRegistrySyncable* registry) { 102 user_prefs::PrefRegistrySyncable* registry) {
98 SuggestionsService::RegisterProfilePrefs(registry); 103 SuggestionsService::RegisterProfilePrefs(registry);
99 } 104 }
100 105
101 } // namespace suggestions 106 } // namespace suggestions
OLDNEW
« no previous file with comments | « chrome/browser/search/suggestions/image_fetcher_impl_browsertest.cc ('k') | chrome/browser/search/thumbnail_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698