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

Side by Side Diff: ios/chrome/browser/sync/ios_user_event_service_factory.cc

Issue 2916873003: [Sync] Create iOS factory for UserEventService. (Closed)
Patch Set: Remove an accidental ios_chrome_profile_sync_service_factory.h Created 3 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 | « ios/chrome/browser/sync/ios_user_event_service_factory.h ('k') | no next file » | 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 "ios/chrome/browser/sync/ios_user_event_service_factory.h"
6
7 #include <memory>
8 #include <utility>
9
10 #include "base/memory/ptr_util.h"
11 #include "base/memory/singleton.h"
12 #include "components/browser_sync/profile_sync_service.h"
13 #include "components/keyed_service/ios/browser_state_dependency_manager.h"
14 #include "components/sync/base/model_type.h"
15 #include "components/sync/base/report_unrecoverable_error.h"
16 #include "components/sync/user_events/no_op_user_event_service.h"
17 #include "components/sync/user_events/user_event_service_impl.h"
18 #include "components/sync/user_events/user_event_sync_bridge.h"
19 #include "ios/chrome/browser/browser_state/browser_state_otr_helper.h"
20 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
21 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
22 #include "ios/chrome/common/channel_info.h"
23 #include "ios/web/public/browser_state.h"
24
25 // static
26 syncer::UserEventService* IOSUserEventServiceFactory::GetForBrowserState(
27 ios::ChromeBrowserState* browser_state) {
28 return static_cast<syncer::UserEventService*>(
29 GetInstance()->GetServiceForBrowserState(browser_state, true));
30 }
31
32 // static
33 IOSUserEventServiceFactory* IOSUserEventServiceFactory::GetInstance() {
34 return base::Singleton<IOSUserEventServiceFactory>::get();
35 }
36
37 IOSUserEventServiceFactory::IOSUserEventServiceFactory()
38 : BrowserStateKeyedServiceFactory(
39 "UserEventService",
40 BrowserStateDependencyManager::GetInstance()) {}
41
42 IOSUserEventServiceFactory::~IOSUserEventServiceFactory() {}
43
44 std::unique_ptr<KeyedService>
45 IOSUserEventServiceFactory::BuildServiceInstanceFor(
46 web::BrowserState* browser_state) const {
47 if (browser_state->IsOffTheRecord()) {
48 return base::MakeUnique<syncer::NoOpUserEventService>();
49 }
50
51 syncer::ModelTypeStoreFactory store_factory =
52 browser_sync::ProfileSyncService::GetModelTypeStoreFactory(
53 syncer::USER_EVENTS, browser_state->GetStatePath());
54 syncer::ModelTypeSyncBridge::ChangeProcessorFactory processor_factory =
55 base::BindRepeating(&syncer::ModelTypeChangeProcessor::Create,
56 base::BindRepeating(&syncer::ReportUnrecoverableError,
57 ::GetChannel()));
58 auto bridge = base::MakeUnique<syncer::UserEventSyncBridge>(
59 std::move(store_factory), std::move(processor_factory));
60 return base::MakeUnique<syncer::UserEventServiceImpl>(
61 IOSChromeProfileSyncServiceFactory::GetForBrowserState(
62 ios::ChromeBrowserState::FromBrowserState(browser_state)),
63 std::move(bridge));
64 }
65
66 web::BrowserState* IOSUserEventServiceFactory::GetBrowserStateToUse(
67 web::BrowserState* context) const {
68 return GetBrowserStateOwnInstanceInIncognito(context);
69 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/sync/ios_user_event_service_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698