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

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

Issue 1987333003: [NTP Snippets] Persist snippets in a LevelDB instead of prefs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: prefs cleanup; fix internals Created 4 years, 6 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/feature_list.h" 7 #include "base/feature_list.h"
8 #include "base/files/file_path.h"
8 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
9 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
10 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.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_fetcher_impl.h"
13 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" 14 #include "chrome/browser/search/suggestions/suggestions_service_factory.h"
14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 15 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
15 #include "chrome/browser/signin/signin_manager_factory.h" 16 #include "chrome/browser/signin/signin_manager_factory.h"
16 #include "chrome/browser/sync/profile_sync_service_factory.h" 17 #include "chrome/browser/sync/profile_sync_service_factory.h"
17 #include "chrome/common/channel_info.h" 18 #include "chrome/common/channel_info.h"
18 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
19 #include "components/browser_sync/browser/profile_sync_service.h" 20 #include "components/browser_sync/browser/profile_sync_service.h"
20 #include "components/image_fetcher/image_fetcher.h" 21 #include "components/image_fetcher/image_fetcher.h"
21 #include "components/keyed_service/content/browser_context_dependency_manager.h" 22 #include "components/keyed_service/content/browser_context_dependency_manager.h"
23 #include "components/ntp_snippets/ntp_snippets_database.h"
22 #include "components/ntp_snippets/ntp_snippets_fetcher.h" 24 #include "components/ntp_snippets/ntp_snippets_fetcher.h"
23 #include "components/ntp_snippets/ntp_snippets_scheduler.h" 25 #include "components/ntp_snippets/ntp_snippets_scheduler.h"
24 #include "components/ntp_snippets/ntp_snippets_service.h" 26 #include "components/ntp_snippets/ntp_snippets_service.h"
25 #include "components/prefs/pref_service.h" 27 #include "components/prefs/pref_service.h"
26 #include "components/safe_json/safe_json_parser.h" 28 #include "components/safe_json/safe_json_parser.h"
27 #include "components/signin/core/browser/profile_oauth2_token_service.h" 29 #include "components/signin/core/browser/profile_oauth2_token_service.h"
28 #include "components/signin/core/browser/signin_manager.h" 30 #include "components/signin/core/browser/signin_manager.h"
29 #include "components/version_info/version_info.h" 31 #include "components/version_info/version_info.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"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 ProfileSyncService* sync_service = 91 ProfileSyncService* sync_service =
90 ProfileSyncServiceFactory::GetForProfile(profile); 92 ProfileSyncServiceFactory::GetForProfile(profile);
91 SuggestionsService* suggestions_service = 93 SuggestionsService* suggestions_service =
92 SuggestionsServiceFactory::GetForProfile(profile); 94 SuggestionsServiceFactory::GetForProfile(profile);
93 95
94 ntp_snippets::NTPSnippetsScheduler* scheduler = nullptr; 96 ntp_snippets::NTPSnippetsScheduler* scheduler = nullptr;
95 #if defined(OS_ANDROID) 97 #if defined(OS_ANDROID)
96 scheduler = NTPSnippetsLauncher::Get(); 98 scheduler = NTPSnippetsLauncher::Get();
97 #endif // OS_ANDROID 99 #endif // OS_ANDROID
98 100
101 base::FilePath database_dir(
102 profile->GetPath().Append(FILE_PATH_LITERAL("NTPSnippets")));
99 scoped_refptr<base::SequencedTaskRunner> task_runner = 103 scoped_refptr<base::SequencedTaskRunner> task_runner =
100 BrowserThread::GetBlockingPool() 104 BrowserThread::GetBlockingPool()
101 ->GetSequencedTaskRunnerWithShutdownBehavior( 105 ->GetSequencedTaskRunnerWithShutdownBehavior(
102 base::SequencedWorkerPool::GetSequenceToken(), 106 base::SequencedWorkerPool::GetSequenceToken(),
103 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); 107 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
104 108
105 return new ntp_snippets::NTPSnippetsService( 109 return new ntp_snippets::NTPSnippetsService(
106 enabled, profile->GetPrefs(), sync_service, suggestions_service, 110 enabled, profile->GetPrefs(), sync_service, suggestions_service,
107 task_runner, g_browser_process->GetApplicationLocale(), scheduler, 111 g_browser_process->GetApplicationLocale(), scheduler,
108 base::WrapUnique(new ntp_snippets::NTPSnippetsFetcher( 112 base::WrapUnique(new ntp_snippets::NTPSnippetsFetcher(
109 signin_manager, token_service, request_context, 113 signin_manager, token_service, request_context,
110 base::Bind(&safe_json::SafeJsonParser::Parse), 114 base::Bind(&safe_json::SafeJsonParser::Parse),
111 chrome::GetChannel() == version_info::Channel::STABLE)), 115 chrome::GetChannel() == version_info::Channel::STABLE)),
112 base::WrapUnique(new ImageFetcherImpl(request_context.get()))); 116 base::WrapUnique(new ImageFetcherImpl(request_context.get())),
117 base::WrapUnique(
118 new ntp_snippets::NTPSnippetsDatabase(database_dir, task_runner)));
113 } 119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698