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

Unified 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 side-by-side diff with in-line comments
Download patch
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..9ef533309401e4dd71ed8e52947280bd12866652
--- /dev/null
+++ b/chrome/browser/sync/user_event_service_factory.cc
@@ -0,0 +1,59 @@
+// 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"
+#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
+
+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

Powered by Google App Engine
This is Rietveld 408576698