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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/user_event_service_factory.cc
diff --git a/chrome/browser/sync/user_event_service_factory.cc b/chrome/browser/sync/user_event_service_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..de359567b8bb9d3bd7ff437c875ee788802deb9f
--- /dev/null
+++ b/chrome/browser/sync/user_event_service_factory.cc
@@ -0,0 +1,58 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/sync/user_event_service_factory.h"
+
+#include <memory>
+#include <utility>
+
+#include "base/memory/ptr_util.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
+#include "chrome/common/channel_info.h"
+#include "components/browser_sync/profile_sync_service.h"
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
+#include "components/sync/base/model_type.h"
+#include "components/sync/base/report_unrecoverable_error.h"
+#include "components/sync/user_events/user_event_service.h"
+#include "components/sync/user_events/user_event_sync_bridge.h"
+
+namespace browser_sync {
+
+// static
+UserEventServiceFactory* UserEventServiceFactory::GetInstance() {
+ return base::Singleton<UserEventServiceFactory>::get();
+}
+
+// static
+syncer::UserEventService* UserEventServiceFactory::GetForProfile(
+ Profile* profile) {
+ return static_cast<syncer::UserEventService*>(
+ GetInstance()->GetServiceForBrowserContext(profile, true));
+}
+
+UserEventServiceFactory::UserEventServiceFactory()
+ : BrowserContextKeyedServiceFactory(
+ "UserEventService",
+ BrowserContextDependencyManager::GetInstance()) {}
+
+UserEventServiceFactory::~UserEventServiceFactory() {}
+
+KeyedService* UserEventServiceFactory::BuildServiceInstanceFor(
+ content::BrowserContext* context) const {
+ Profile* profile = Profile::FromBrowserContext(context);
+ syncer::ModelTypeStoreFactory store_factory =
+ browser_sync::ProfileSyncService::GetModelTypeStoreFactory(
+ syncer::USER_EVENTS, profile->GetPath());
+ syncer::ModelTypeSyncBridge::ChangeProcessorFactory processor_factory =
+ base::BindRepeating(&syncer::ModelTypeChangeProcessor::Create,
+ base::BindRepeating(&syncer::ReportUnrecoverableError,
+ chrome::GetChannel()));
+ auto bridge = base::MakeUnique<syncer::UserEventSyncBridge>(
+ std::move(store_factory), std::move(processor_factory));
+ return new syncer::UserEventService(
+ ProfileSyncServiceFactory::GetForProfile(profile), std::move(bridge));
+}
+
+} // namespace browser_sync
« 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