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

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

Issue 2864973002: [Sync] Create UserEventService. (Closed)
Patch Set: Added keyed service dep to Build file. 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
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 #include "content/public/browser/browser_thread.h"
Patrick Noland 2017/05/08 22:42:37 What is this include for? I don't see any obvious
skym 2017/05/08 23:35:27 Good catch, this was to call content::BrowserThrea
21
22 namespace browser_sync {
23
24 // static
25 UserEventServiceFactory* UserEventServiceFactory::GetInstance() {
26 return base::Singleton<UserEventServiceFactory>::get();
27 }
28
29 // static
30 syncer::UserEventService* UserEventServiceFactory::GetForProfile(
31 Profile* profile) {
32 return static_cast<syncer::UserEventService*>(
33 GetInstance()->GetServiceForBrowserContext(profile, true));
34 }
35
36 UserEventServiceFactory::UserEventServiceFactory()
37 : BrowserContextKeyedServiceFactory(
38 "UserEventService",
39 BrowserContextDependencyManager::GetInstance()) {}
40
41 UserEventServiceFactory::~UserEventServiceFactory() {}
42
43 KeyedService* UserEventServiceFactory::BuildServiceInstanceFor(
44 content::BrowserContext* context) const {
45 Profile* profile = Profile::FromBrowserContext(context);
46 syncer::ModelTypeStoreFactory store_factory =
47 browser_sync::ProfileSyncService::GetModelTypeStoreFactory(
48 syncer::USER_EVENTS, profile->GetPath());
49 syncer::ModelTypeSyncBridge::ChangeProcessorFactory processor_factory =
50 base::BindRepeating(&syncer::ModelTypeChangeProcessor::Create,
51 base::BindRepeating(&syncer::ReportUnrecoverableError,
52 chrome::GetChannel()));
53 auto bridge = base::MakeUnique<syncer::UserEventSyncBridge>(
54 std::move(store_factory), std::move(processor_factory));
55 return new syncer::UserEventService(
56 ProfileSyncServiceFactory::GetForProfile(profile), std::move(bridge));
57 }
58
59 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698