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

Unified Diff: chrome/browser/sync/user_event_service_factory.cc

Issue 2909283003: [Sync] Split UserEventService into interface and impl, add fake impl, add unit tests. (Closed)
Patch Set: Added a NoOp service to handle OffTheRecord. 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
index de359567b8bb9d3bd7ff437c875ee788802deb9f..bcf784e084d58cb2842f7c602a3c3811e6a5642e 100644
--- a/chrome/browser/sync/user_event_service_factory.cc
+++ b/chrome/browser/sync/user_event_service_factory.cc
@@ -8,6 +8,7 @@
#include <utility>
#include "base/memory/ptr_util.h"
+#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/common/channel_info.h"
@@ -15,7 +16,8 @@
#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/no_op_user_event_service.h"
+#include "components/sync/user_events/user_event_service_impl.h"
#include "components/sync/user_events/user_event_sync_bridge.h"
namespace browser_sync {
@@ -41,6 +43,10 @@ UserEventServiceFactory::~UserEventServiceFactory() {}
KeyedService* UserEventServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
+ if (context->IsOffTheRecord()) {
+ return new syncer::NoOpUserEventService();
+ }
+
Profile* profile = Profile::FromBrowserContext(context);
syncer::ModelTypeStoreFactory store_factory =
browser_sync::ProfileSyncService::GetModelTypeStoreFactory(
@@ -51,8 +57,13 @@ KeyedService* UserEventServiceFactory::BuildServiceInstanceFor(
chrome::GetChannel()));
auto bridge = base::MakeUnique<syncer::UserEventSyncBridge>(
std::move(store_factory), std::move(processor_factory));
- return new syncer::UserEventService(
+ return new syncer::UserEventServiceImpl(
ProfileSyncServiceFactory::GetForProfile(profile), std::move(bridge));
}
+content::BrowserContext* UserEventServiceFactory::GetBrowserContextToUse(
+ content::BrowserContext* context) const {
+ return chrome::GetBrowserContextOwnInstanceInIncognito(context);
+}
+
} // namespace browser_sync
« no previous file with comments | « chrome/browser/sync/user_event_service_factory.h ('k') | chrome/browser/ui/webui/sync_internals_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698