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

Side by Side Diff: chrome/browser/ntp_snippets/content_suggestions_service_factory.cc

Issue 2671453003: [NTP::Cleanup] Avoid nested complex function calls (Closed)
Patch Set: tschumann@ & treib@ comments. 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
« no previous file with comments | « no previous file | ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ntp_snippets/content_suggestions_service_factory.h" 5 #include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/feature_list.h" 9 #include "base/feature_list.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 content::BrowserContext::GetDefaultStoragePartition(profile) 162 content::BrowserContext::GetDefaultStoragePartition(profile)
163 ->GetURLRequestContext(); 163 ->GetURLRequestContext();
164 164
165 base::FilePath database_dir( 165 base::FilePath database_dir(
166 profile->GetPath().Append(ntp_snippets::kDatabaseFolder)); 166 profile->GetPath().Append(ntp_snippets::kDatabaseFolder));
167 scoped_refptr<base::SequencedTaskRunner> task_runner = 167 scoped_refptr<base::SequencedTaskRunner> task_runner =
168 BrowserThread::GetBlockingPool() 168 BrowserThread::GetBlockingPool()
169 ->GetSequencedTaskRunnerWithShutdownBehavior( 169 ->GetSequencedTaskRunnerWithShutdownBehavior(
170 base::SequencedWorkerPool::GetSequenceToken(), 170 base::SequencedWorkerPool::GetSequenceToken(),
171 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); 171 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
172 bool is_stable_channel = 172
173 chrome::GetChannel() == version_info::Channel::STABLE; 173 std::unique_ptr<RemoteSuggestionsProviderImpl> provider;
174 auto provider = base::MakeUnique<RemoteSuggestionsProviderImpl>( 174 {
tschumann 2017/02/01 15:07:59 sorry for the late response. I'm not a fan of such
175 service, pref_service, g_browser_process->GetApplicationLocale(), 175 bool is_stable_channel =
176 service->category_ranker(), 176 chrome::GetChannel() == version_info::Channel::STABLE;
177 base::MakeUnique<RemoteSuggestionsFetcher>( 177 auto suggestions_fetcher = base::MakeUnique<RemoteSuggestionsFetcher>(
178 signin_manager, token_service, request_context, pref_service, 178 signin_manager, token_service, request_context, pref_service,
179 language_model, base::Bind(&safe_json::SafeJsonParser::Parse), 179 language_model, base::Bind(&safe_json::SafeJsonParser::Parse),
180 is_stable_channel ? google_apis::GetAPIKey() 180 is_stable_channel ? google_apis::GetAPIKey()
181 : google_apis::GetNonStableAPIKey(), 181 : google_apis::GetNonStableAPIKey(),
182 service->user_classifier()), 182 service->user_classifier());
183 base::MakeUnique<ImageFetcherImpl>(base::MakeUnique<ImageDecoderImpl>(), 183 auto image_fetcher = base::MakeUnique<ImageFetcherImpl>(
184 request_context.get()), 184 base::MakeUnique<ImageDecoderImpl>(), request_context.get());
185 base::MakeUnique<ImageDecoderImpl>(), 185 auto database =
186 base::MakeUnique<RemoteSuggestionsDatabase>(database_dir, task_runner), 186 base::MakeUnique<RemoteSuggestionsDatabase>(database_dir, task_runner);
187 base::MakeUnique<RemoteSuggestionsStatusService>(signin_manager, 187 auto status_service = base::MakeUnique<RemoteSuggestionsStatusService>(
188 pref_service)); 188 signin_manager, pref_service);
189 provider = base::MakeUnique<RemoteSuggestionsProviderImpl>(
190 service, pref_service, g_browser_process->GetApplicationLocale(),
191 service->category_ranker(), std::move(suggestions_fetcher),
192 std::move(image_fetcher), base::MakeUnique<ImageDecoderImpl>(),
193 std::move(database), std::move(status_service));
194 }
189 195
190 PersistentScheduler* scheduler = nullptr; 196 PersistentScheduler* scheduler = nullptr;
191 #if defined(OS_ANDROID) 197 #if defined(OS_ANDROID)
192 scheduler = NTPSnippetsLauncher::Get(); 198 scheduler = NTPSnippetsLauncher::Get();
193 #endif // OS_ANDROID 199 #endif // OS_ANDROID
194 200
195 auto scheduling_provider = 201 auto scheduling_provider =
196 base::MakeUnique<SchedulingRemoteSuggestionsProvider>( 202 base::MakeUnique<SchedulingRemoteSuggestionsProvider>(
197 service, std::move(provider), scheduler, service->user_classifier(), 203 service, std::move(provider), scheduler, service->user_classifier(),
198 pref_service, base::MakeUnique<base::DefaultClock>()); 204 pref_service, base::MakeUnique<base::DefaultClock>());
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 language_model, pref_service, profile); 329 language_model, pref_service, profile);
324 } 330 }
325 331
326 if (base::FeatureList::IsEnabled( 332 if (base::FeatureList::IsEnabled(
327 ntp_snippets::kForeignSessionsSuggestionsFeature)) { 333 ntp_snippets::kForeignSessionsSuggestionsFeature)) {
328 RegisterForeignSessionsProvider(sync_service, service, pref_service); 334 RegisterForeignSessionsProvider(sync_service, service, pref_service);
329 } 335 }
330 336
331 return service; 337 return service;
332 } 338 }
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/ntp_snippets/ios_chrome_content_suggestions_service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698