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

Unified Diff: chrome/browser/ntp_snippets/ntp_snippets_service_factory.cc

Issue 1677073002: Fetch snippets from ChromeReader and show them on the NTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments Created 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ntp_snippets/ntp_snippets_service_factory.cc
diff --git a/chrome/browser/ntp_snippets/ntp_snippets_service_factory.cc b/chrome/browser/ntp_snippets/ntp_snippets_service_factory.cc
index 5730e2f68d6fbf5adf3eed3aafa47eda1201ae88..69f772a731a95ea19bb2197b066c2c251bf43b49 100644
--- a/chrome/browser/ntp_snippets/ntp_snippets_service_factory.cc
+++ b/chrome/browser/ntp_snippets/ntp_snippets_service_factory.cc
@@ -8,9 +8,17 @@
#include "base/memory/singleton.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/signin/signin_manager_factory.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
+#include "components/ntp_snippets/ntp_snippets_fetcher.h"
#include "components/ntp_snippets/ntp_snippets_service.h"
+#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "content/public/browser/browser_context.h"
+#include "content/public/browser/browser_thread.h"
+#include "net/url_request/url_request_context_getter.h"
+
+using content::BrowserThread;
// static
NTPSnippetsServiceFactory* NTPSnippetsServiceFactory::GetInstance() {
@@ -34,6 +42,23 @@ NTPSnippetsServiceFactory::~NTPSnippetsServiceFactory() {}
KeyedService* NTPSnippetsServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
+ Profile* profile = Profile::FromBrowserContext(context);
+ SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile);
+ OAuth2TokenService* token_service =
+ ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
+ scoped_refptr<net::URLRequestContextGetter> request_context =
+ context->GetRequestContext();
+
return new ntp_snippets::NTPSnippetsService(
- g_browser_process->GetApplicationLocale());
+ BrowserThread::GetBlockingPool()
+ ->GetSequencedTaskRunnerWithShutdownBehavior(
Bernhard Bauer 2016/02/10 10:48:44 Actually, extract this SequencedTaskRunner into a
May 2016/02/10 18:16:47 Whoops, right. My bad.
+ base::SequencedWorkerPool::GetSequenceToken(),
+ base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN),
+ g_browser_process->GetApplicationLocale(),
+ new ntp_snippets::NTPSnippetsFetcher(
+ BrowserThread::GetBlockingPool()
+ ->GetSequencedTaskRunnerWithShutdownBehavior(
+ base::SequencedWorkerPool::GetSequenceToken(),
+ base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN),
+ signin_manager, token_service, request_context.get()));
}

Powered by Google App Engine
This is Rietveld 408576698