Commit 21e565f2 authored by Jon Mann's avatar Jon Mann Committed by Commit Bot

Only create one WifiConfigurationSyncService instance for a session.

Previously there were three services running at the same time,
including unnecessary instances for the default and signin profiles.

Bug: 966270
Change-Id: I6e1a4338c6d9c6619febb5305671ce2da14769ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2110214Reviewed-by: default avatarJames Vecore <vecore@google.com>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Jon Mann <jonmann@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753382}
parent 9730b949
......@@ -491,7 +491,8 @@ ChromeSyncClient::CreateDataTypeControllers(syncer::SyncService* sync_service) {
profile_->GetPrefs(), sync_service));
}
if (!disabled_types.Has(syncer::WIFI_CONFIGURATIONS) &&
base::FeatureList::IsEnabled(switches::kSyncWifiConfigurations)) {
base::FeatureList::IsEnabled(switches::kSyncWifiConfigurations) &&
WifiConfigurationSyncServiceFactory::ShouldRunInProfile(profile_)) {
// Use the same delegate in full-sync and transport-only modes.
syncer::ModelTypeControllerDelegate* delegate =
GetControllerDelegateForModelType(syncer::WIFI_CONFIGURATIONS).get();
......
......@@ -5,6 +5,7 @@
#include "chrome/browser/sync/wifi_configuration_sync_service_factory.h"
#include "base/memory/singleton.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/model_type_store_service_factory.h"
#include "chrome/common/channel_info.h"
......@@ -17,6 +18,10 @@
// static
chromeos::sync_wifi::WifiConfigurationSyncService*
WifiConfigurationSyncServiceFactory::GetForProfile(Profile* profile) {
if (!ShouldRunInProfile(profile)) {
return nullptr;
}
return static_cast<chromeos::sync_wifi::WifiConfigurationSyncService*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
......@@ -27,6 +32,14 @@ WifiConfigurationSyncServiceFactory::GetInstance() {
return base::Singleton<WifiConfigurationSyncServiceFactory>::get();
}
// static
bool WifiConfigurationSyncServiceFactory::ShouldRunInProfile(
const Profile* profile) {
return profile && !chromeos::ProfileHelper::IsSigninProfile(profile) &&
!chromeos::ProfileHelper::IsLockScreenAppProfile(profile) &&
!profile->IsOffTheRecord();
}
WifiConfigurationSyncServiceFactory::WifiConfigurationSyncServiceFactory()
: BrowserContextKeyedServiceFactory(
"WifiConfigurationSyncService",
......
......@@ -29,6 +29,7 @@ class WifiConfigurationSyncServiceFactory
static chromeos::sync_wifi::WifiConfigurationSyncService* GetForProfile(
Profile* profile);
static WifiConfigurationSyncServiceFactory* GetInstance();
static bool ShouldRunInProfile(const Profile* profile);
private:
friend struct base::DefaultSingletonTraits<
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment