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

Side by Side Diff: ios/chrome/browser/suggestions/suggestions_service_factory.mm

Issue 2697043005: Use component ImageFetcher instead of iOS one. (Closed)
Patch Set: Created 3 years, 10 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 "ios/chrome/browser/suggestions/suggestions_service_factory.h" 5 #include "ios/chrome/browser/suggestions/suggestions_service_factory.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/memory/singleton.h" 11 #include "base/memory/singleton.h"
12 #include "base/sequenced_task_runner.h" 12 #include "base/sequenced_task_runner.h"
13 #include "base/threading/sequenced_worker_pool.h" 13 #include "base/threading/sequenced_worker_pool.h"
14 #include "components/browser_sync/profile_sync_service.h" 14 #include "components/browser_sync/profile_sync_service.h"
15 #include "components/image_fetcher/image_fetcher.h" 15 #include "components/image_fetcher/image_fetcher.h"
16 #include "components/image_fetcher/image_fetcher_impl.h"
16 #include "components/keyed_service/ios/browser_state_dependency_manager.h" 17 #include "components/keyed_service/ios/browser_state_dependency_manager.h"
17 #include "components/leveldb_proto/proto_database_impl.h" 18 #include "components/leveldb_proto/proto_database_impl.h"
18 #include "components/signin/core/browser/profile_oauth2_token_service.h" 19 #include "components/signin/core/browser/profile_oauth2_token_service.h"
19 #include "components/signin/core/browser/signin_manager.h" 20 #include "components/signin/core/browser/signin_manager.h"
20 #include "components/suggestions/blacklist_store.h" 21 #include "components/suggestions/blacklist_store.h"
21 #include "components/suggestions/image_manager.h" 22 #include "components/suggestions/image_manager.h"
22 #include "components/suggestions/suggestions_service_impl.h" 23 #include "components/suggestions/suggestions_service_impl.h"
23 #include "components/suggestions/suggestions_store.h" 24 #include "components/suggestions/suggestions_store.h"
24 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 25 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
25 #include "ios/chrome/browser/signin/oauth2_token_service_factory.h" 26 #include "ios/chrome/browser/signin/oauth2_token_service_factory.h"
26 #include "ios/chrome/browser/signin/signin_manager_factory.h" 27 #include "ios/chrome/browser/signin/signin_manager_factory.h"
27 #include "ios/chrome/browser/suggestions/image_fetcher_impl.h" 28 #include "ios/chrome/browser/suggestions/ios_image_decoder_impl.h"
28 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h" 29 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
29 #include "ios/web/public/browser_state.h" 30 #include "ios/web/public/browser_state.h"
30 #include "ios/web/public/web_thread.h" 31 #include "ios/web/public/web_thread.h"
31 32
32 #if !defined(__has_feature) || !__has_feature(objc_arc) 33 #if !defined(__has_feature) || !__has_feature(objc_arc)
33 #error "This file requires ARC support." 34 #error "This file requires ARC support."
34 #endif 35 #endif
35 36
36 namespace suggestions { 37 namespace suggestions {
37 namespace { 38 namespace {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 ios::ChromeBrowserState* browser_state = 76 ios::ChromeBrowserState* browser_state =
76 ios::ChromeBrowserState::FromBrowserState(context); 77 ios::ChromeBrowserState::FromBrowserState(context);
77 SigninManager* signin_manager = 78 SigninManager* signin_manager =
78 ios::SigninManagerFactory::GetForBrowserState(browser_state); 79 ios::SigninManagerFactory::GetForBrowserState(browser_state);
79 ProfileOAuth2TokenService* token_service = 80 ProfileOAuth2TokenService* token_service =
80 OAuth2TokenServiceFactory::GetForBrowserState(browser_state); 81 OAuth2TokenServiceFactory::GetForBrowserState(browser_state);
81 browser_sync::ProfileSyncService* sync_service = 82 browser_sync::ProfileSyncService* sync_service =
82 IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state); 83 IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state);
83 base::FilePath database_dir( 84 base::FilePath database_dir(
84 browser_state->GetStatePath().Append(kThumbnailDirectory)); 85 browser_state->GetStatePath().Append(kThumbnailDirectory));
86
85 std::unique_ptr<SuggestionsStore> suggestions_store( 87 std::unique_ptr<SuggestionsStore> suggestions_store(
86 new SuggestionsStore(browser_state->GetPrefs())); 88 new SuggestionsStore(browser_state->GetPrefs()));
87 std::unique_ptr<BlacklistStore> blacklist_store( 89 std::unique_ptr<BlacklistStore> blacklist_store(
88 new BlacklistStore(browser_state->GetPrefs())); 90 new BlacklistStore(browser_state->GetPrefs()));
89 std::unique_ptr<leveldb_proto::ProtoDatabaseImpl<ImageData>> db( 91 std::unique_ptr<leveldb_proto::ProtoDatabaseImpl<ImageData>> db(
90 new leveldb_proto::ProtoDatabaseImpl<ImageData>(background_task_runner)); 92 new leveldb_proto::ProtoDatabaseImpl<ImageData>(background_task_runner));
91 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher( 93
92 new ImageFetcherImpl(browser_state->GetRequestContext(), 94 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher =
93 sequenced_worker_pool)); 95 base::MakeUnique<image_fetcher::ImageFetcherImpl>(
96 CreateIOSImageDecoder(sequenced_worker_pool),
97 browser_state->GetRequestContext());
98
94 std::unique_ptr<ImageManager> thumbnail_manager(new ImageManager( 99 std::unique_ptr<ImageManager> thumbnail_manager(new ImageManager(
95 std::move(image_fetcher), std::move(db), database_dir, 100 std::move(image_fetcher), std::move(db), database_dir,
96 web::WebThread::GetTaskRunnerForThread(web::WebThread::DB))); 101 web::WebThread::GetTaskRunnerForThread(web::WebThread::DB)));
102
justincohen 2017/02/17 14:24:31 nit remove new spaces
gambard 2017/02/17 14:26:00 I find it way more readable with the new line (add
97 return base::MakeUnique<SuggestionsServiceImpl>( 103 return base::MakeUnique<SuggestionsServiceImpl>(
98 signin_manager, token_service, sync_service, 104 signin_manager, token_service, sync_service,
99 browser_state->GetRequestContext(), std::move(suggestions_store), 105 browser_state->GetRequestContext(), std::move(suggestions_store),
100 std::move(thumbnail_manager), std::move(blacklist_store)); 106 std::move(thumbnail_manager), std::move(blacklist_store));
101 } 107 }
102 108
103 void SuggestionsServiceFactory::RegisterBrowserStatePrefs( 109 void SuggestionsServiceFactory::RegisterBrowserStatePrefs(
104 user_prefs::PrefRegistrySyncable* registry) { 110 user_prefs::PrefRegistrySyncable* registry) {
105 SuggestionsServiceImpl::RegisterProfilePrefs(registry); 111 SuggestionsServiceImpl::RegisterProfilePrefs(registry);
106 } 112 }
107 113
108 } // namespace suggestions 114 } // namespace suggestions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698