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

Side by Side Diff: chrome/browser/sync/user_event_service_factory.cc

Issue 2864973002: [Sync] Create UserEventService. (Closed)
Patch Set: Updates for Patrick. Created 3 years, 7 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 | « chrome/browser/sync/user_event_service_factory.h ('k') | components/sync/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sync/user_event_service_factory.h"
6
7 #include <memory>
8 #include <utility>
9
10 #include "base/memory/ptr_util.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/sync/profile_sync_service_factory.h"
13 #include "chrome/common/channel_info.h"
14 #include "components/browser_sync/profile_sync_service.h"
15 #include "components/keyed_service/content/browser_context_dependency_manager.h"
16 #include "components/sync/base/model_type.h"
17 #include "components/sync/base/report_unrecoverable_error.h"
18 #include "components/sync/user_events/user_event_service.h"
19 #include "components/sync/user_events/user_event_sync_bridge.h"
20
21 namespace browser_sync {
22
23 // static
24 UserEventServiceFactory* UserEventServiceFactory::GetInstance() {
25 return base::Singleton<UserEventServiceFactory>::get();
26 }
27
28 // static
29 syncer::UserEventService* UserEventServiceFactory::GetForProfile(
30 Profile* profile) {
31 return static_cast<syncer::UserEventService*>(
32 GetInstance()->GetServiceForBrowserContext(profile, true));
33 }
34
35 UserEventServiceFactory::UserEventServiceFactory()
36 : BrowserContextKeyedServiceFactory(
37 "UserEventService",
38 BrowserContextDependencyManager::GetInstance()) {}
39
40 UserEventServiceFactory::~UserEventServiceFactory() {}
41
42 KeyedService* UserEventServiceFactory::BuildServiceInstanceFor(
43 content::BrowserContext* context) const {
44 Profile* profile = Profile::FromBrowserContext(context);
45 syncer::ModelTypeStoreFactory store_factory =
46 browser_sync::ProfileSyncService::GetModelTypeStoreFactory(
47 syncer::USER_EVENTS, profile->GetPath());
48 syncer::ModelTypeSyncBridge::ChangeProcessorFactory processor_factory =
49 base::BindRepeating(&syncer::ModelTypeChangeProcessor::Create,
50 base::BindRepeating(&syncer::ReportUnrecoverableError,
51 chrome::GetChannel()));
52 auto bridge = base::MakeUnique<syncer::UserEventSyncBridge>(
53 std::move(store_factory), std::move(processor_factory));
54 return new syncer::UserEventService(
55 ProfileSyncServiceFactory::GetForProfile(profile), std::move(bridge));
56 }
57
58 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/user_event_service_factory.h ('k') | components/sync/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698