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

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

Issue 1864583006: Simplify BrowserContext by removing redundant methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ntp_snippets_service_factory.h" 5 #include "chrome/browser/ntp_snippets/ntp_snippets_service_factory.h"
6 6
7 #include "base/memory/singleton.h" 7 #include "base/memory/singleton.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" 10 #include "chrome/browser/search/suggestions/suggestions_service_factory.h"
11 #include "chrome/common/channel_info.h" 11 #include "chrome/common/channel_info.h"
12 #include "components/keyed_service/content/browser_context_dependency_manager.h" 12 #include "components/keyed_service/content/browser_context_dependency_manager.h"
13 #include "components/ntp_snippets/ntp_snippets_fetcher.h" 13 #include "components/ntp_snippets/ntp_snippets_fetcher.h"
14 #include "components/ntp_snippets/ntp_snippets_scheduler.h" 14 #include "components/ntp_snippets/ntp_snippets_scheduler.h"
15 #include "components/ntp_snippets/ntp_snippets_service.h" 15 #include "components/ntp_snippets/ntp_snippets_service.h"
16 #include "components/safe_json/safe_json_parser.h" 16 #include "components/safe_json/safe_json_parser.h"
17 #include "components/version_info/version_info.h" 17 #include "components/version_info/version_info.h"
18 #include "content/public/browser/browser_context.h" 18 #include "content/public/browser/browser_context.h"
19 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/storage_partition.h"
20 #include "net/url_request/url_request_context_getter.h" 21 #include "net/url_request/url_request_context_getter.h"
21 22
22 #if defined(OS_ANDROID) 23 #if defined(OS_ANDROID)
23 #include "chrome/browser/android/ntp/ntp_snippets_launcher.h" 24 #include "chrome/browser/android/ntp/ntp_snippets_launcher.h"
24 #endif // OS_ANDROID 25 #endif // OS_ANDROID
25 26
26 using content::BrowserThread; 27 using content::BrowserThread;
27 using suggestions::SuggestionsService; 28 using suggestions::SuggestionsService;
28 using suggestions::SuggestionsServiceFactory; 29 using suggestions::SuggestionsServiceFactory;
29 30
(...skipping 16 matching lines...) Expand all
46 BrowserContextDependencyManager::GetInstance()) { 47 BrowserContextDependencyManager::GetInstance()) {
47 DependsOn(SuggestionsServiceFactory::GetInstance()); 48 DependsOn(SuggestionsServiceFactory::GetInstance());
48 } 49 }
49 50
50 NTPSnippetsServiceFactory::~NTPSnippetsServiceFactory() {} 51 NTPSnippetsServiceFactory::~NTPSnippetsServiceFactory() {}
51 52
52 KeyedService* NTPSnippetsServiceFactory::BuildServiceInstanceFor( 53 KeyedService* NTPSnippetsServiceFactory::BuildServiceInstanceFor(
53 content::BrowserContext* context) const { 54 content::BrowserContext* context) const {
54 Profile* profile = Profile::FromBrowserContext(context); 55 Profile* profile = Profile::FromBrowserContext(context);
55 scoped_refptr<net::URLRequestContextGetter> request_context = 56 scoped_refptr<net::URLRequestContextGetter> request_context =
56 context->GetRequestContext(); 57 content::BrowserContext::GetDefaultStoragePartition(context)->
58 GetURLRequestContext();
57 SuggestionsService* suggestions_service = 59 SuggestionsService* suggestions_service =
58 SuggestionsServiceFactory::GetForProfile(profile); 60 SuggestionsServiceFactory::GetForProfile(profile);
59 61
60 ntp_snippets::NTPSnippetsScheduler* scheduler = nullptr; 62 ntp_snippets::NTPSnippetsScheduler* scheduler = nullptr;
61 #if defined(OS_ANDROID) 63 #if defined(OS_ANDROID)
62 scheduler = NTPSnippetsLauncher::Get(); 64 scheduler = NTPSnippetsLauncher::Get();
63 #endif // OS_ANDROID 65 #endif // OS_ANDROID
64 66
65 scoped_refptr<base::SequencedTaskRunner> task_runner = 67 scoped_refptr<base::SequencedTaskRunner> task_runner =
66 BrowserThread::GetBlockingPool() 68 BrowserThread::GetBlockingPool()
67 ->GetSequencedTaskRunnerWithShutdownBehavior( 69 ->GetSequencedTaskRunnerWithShutdownBehavior(
68 base::SequencedWorkerPool::GetSequenceToken(), 70 base::SequencedWorkerPool::GetSequenceToken(),
69 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); 71 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
70 72
71 return new ntp_snippets::NTPSnippetsService( 73 return new ntp_snippets::NTPSnippetsService(
72 profile->GetPrefs(), suggestions_service, task_runner, 74 profile->GetPrefs(), suggestions_service, task_runner,
73 g_browser_process->GetApplicationLocale(), scheduler, 75 g_browser_process->GetApplicationLocale(), scheduler,
74 make_scoped_ptr(new ntp_snippets::NTPSnippetsFetcher( 76 make_scoped_ptr(new ntp_snippets::NTPSnippetsFetcher(
75 task_runner, request_context, 77 task_runner, request_context,
76 chrome::GetChannel() == version_info::Channel::STABLE)), 78 chrome::GetChannel() == version_info::Channel::STABLE)),
77 base::Bind(&safe_json::SafeJsonParser::Parse)); 79 base::Bind(&safe_json::SafeJsonParser::Parse));
78 } 80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698