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

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: fix test memleaks 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
« no previous file with comments | « no previous file | chrome/browser/resources/snippets_internals.js » ('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 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_constants.h"
24 #include "components/ntp_snippets/ntp_snippets_database.h"
22 #include "components/ntp_snippets/ntp_snippets_fetcher.h" 25 #include "components/ntp_snippets/ntp_snippets_fetcher.h"
23 #include "components/ntp_snippets/ntp_snippets_scheduler.h" 26 #include "components/ntp_snippets/ntp_snippets_scheduler.h"
24 #include "components/ntp_snippets/ntp_snippets_service.h" 27 #include "components/ntp_snippets/ntp_snippets_service.h"
25 #include "components/prefs/pref_service.h" 28 #include "components/prefs/pref_service.h"
26 #include "components/safe_json/safe_json_parser.h" 29 #include "components/safe_json/safe_json_parser.h"
27 #include "components/signin/core/browser/profile_oauth2_token_service.h" 30 #include "components/signin/core/browser/profile_oauth2_token_service.h"
28 #include "components/signin/core/browser/signin_manager.h" 31 #include "components/signin/core/browser/signin_manager.h"
29 #include "components/version_info/version_info.h" 32 #include "components/version_info/version_info.h"
30 #include "content/public/browser/browser_context.h" 33 #include "content/public/browser/browser_context.h"
31 #include "content/public/browser/browser_thread.h" 34 #include "content/public/browser/browser_thread.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 ProfileSyncService* sync_service = 92 ProfileSyncService* sync_service =
90 ProfileSyncServiceFactory::GetForProfile(profile); 93 ProfileSyncServiceFactory::GetForProfile(profile);
91 SuggestionsService* suggestions_service = 94 SuggestionsService* suggestions_service =
92 SuggestionsServiceFactory::GetForProfile(profile); 95 SuggestionsServiceFactory::GetForProfile(profile);
93 96
94 ntp_snippets::NTPSnippetsScheduler* scheduler = nullptr; 97 ntp_snippets::NTPSnippetsScheduler* scheduler = nullptr;
95 #if defined(OS_ANDROID) 98 #if defined(OS_ANDROID)
96 scheduler = NTPSnippetsLauncher::Get(); 99 scheduler = NTPSnippetsLauncher::Get();
97 #endif // OS_ANDROID 100 #endif // OS_ANDROID
98 101
102 base::FilePath database_dir(
103 profile->GetPath().Append(ntp_snippets::kDatabaseFolder));
99 scoped_refptr<base::SequencedTaskRunner> task_runner = 104 scoped_refptr<base::SequencedTaskRunner> task_runner =
100 BrowserThread::GetBlockingPool() 105 BrowserThread::GetBlockingPool()
101 ->GetSequencedTaskRunnerWithShutdownBehavior( 106 ->GetSequencedTaskRunnerWithShutdownBehavior(
102 base::SequencedWorkerPool::GetSequenceToken(), 107 base::SequencedWorkerPool::GetSequenceToken(),
103 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); 108 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
104 109
105 return new ntp_snippets::NTPSnippetsService( 110 return new ntp_snippets::NTPSnippetsService(
106 enabled, profile->GetPrefs(), sync_service, suggestions_service, 111 enabled, profile->GetPrefs(), sync_service, suggestions_service,
107 task_runner, g_browser_process->GetApplicationLocale(), scheduler, 112 g_browser_process->GetApplicationLocale(), scheduler,
108 base::WrapUnique(new ntp_snippets::NTPSnippetsFetcher( 113 base::WrapUnique(new ntp_snippets::NTPSnippetsFetcher(
109 signin_manager, token_service, request_context, 114 signin_manager, token_service, request_context,
110 base::Bind(&safe_json::SafeJsonParser::Parse), 115 base::Bind(&safe_json::SafeJsonParser::Parse),
111 chrome::GetChannel() == version_info::Channel::STABLE)), 116 chrome::GetChannel() == version_info::Channel::STABLE)),
112 base::WrapUnique(new ImageFetcherImpl(request_context.get()))); 117 base::WrapUnique(new ImageFetcherImpl(request_context.get())),
118 base::WrapUnique(
119 new ntp_snippets::NTPSnippetsDatabase(database_dir, task_runner)));
113 } 120 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/snippets_internals.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698