Commit 520ff042 authored by calamity's avatar calamity Committed by Commit Bot

Revert "Inject NetworkMetadataStore in wifi sync classes which depend on it."

This reverts commit 3014d931.

Reason for revert: Failing on Linux Chromium OS Asan
https://ci.chromium.org/p/chromium/builders/ci/Linux%20Chromium%20OS%20ASan%20LSan%20Tests%20%281%29/37195

Original change's description:
> Inject NetworkMetadataStore in wifi sync classes which depend on it.
> 
> The instance of NetworkMetadataStore for a user profile is created
> after the sync service is already initialized.  This change does
> the necessary plumbing to get the metadata store instance to
> the wifi sync classes.
> 
> Bug: 966270
> Change-Id: Icd235cd780df97a367f09f281f3e957893baa93b
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2110079
> Commit-Queue: Jon Mann <jonmann@chromium.org>
> Reviewed-by: Marc Treib <treib@chromium.org>
> Reviewed-by: James Vecore <vecore@google.com>
> Reviewed-by: Steven Bennetts <stevenjb@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#752273}

TBR=stevenjb@chromium.org,treib@chromium.org,jonmann@chromium.org,vecore@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 966270
Change-Id: If4cc3b26c510b86ed0abe2fc3a95b1a1358405a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2113400Reviewed-by: default avatarcalamity <calamity@chromium.org>
Commit-Queue: calamity <calamity@chromium.org>
Cr-Commit-Position: refs/heads/master@{#752357}
parent b9e86a94
......@@ -111,7 +111,6 @@ source_set("chromeos") {
"//chromeos/components/quick_answers/public/cpp:prefs",
"//chromeos/components/smbfs",
"//chromeos/components/smbfs/mojom",
"//chromeos/components/sync_wifi",
"//chromeos/components/tether",
"//chromeos/constants",
"//chromeos/cryptohome",
......
......@@ -8,8 +8,6 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/wifi_configuration_sync_service_factory.h"
#include "chromeos/components/sync_wifi/wifi_configuration_sync_service.h"
#include "chromeos/network/network_handler.h"
#include "content/public/browser/notification_service.h"
......@@ -42,14 +40,6 @@ void NetworkPrefStateObserver::Observe(
if (ProfileHelper::IsPrimaryProfile(profile)) {
InitializeNetworkPrefServices(profile);
notification_registrar_.RemoveAll();
auto* wifi_sync_service =
WifiConfigurationSyncServiceFactory::GetForProfile(profile,
/*create=*/false);
if (wifi_sync_service) {
wifi_sync_service->SetNetworkMetadataStore(
NetworkHandler::Get()->network_metadata_store());
}
}
}
......
......@@ -613,8 +613,7 @@ ChromeSyncClient::GetControllerDelegateForModelType(syncer::ModelType type) {
->change_processor()
->GetControllerDelegate();
case syncer::WIFI_CONFIGURATIONS:
return WifiConfigurationSyncServiceFactory::GetForProfile(profile_,
/*create=*/true)
return WifiConfigurationSyncServiceFactory::GetForProfile(profile_)
->GetControllerDelegate();
#endif // defined(OS_CHROMEOS)
case syncer::SHARING_MESSAGE:
......
......@@ -16,10 +16,9 @@
// static
chromeos::sync_wifi::WifiConfigurationSyncService*
WifiConfigurationSyncServiceFactory::GetForProfile(Profile* profile,
bool create) {
WifiConfigurationSyncServiceFactory::GetForProfile(Profile* profile) {
return static_cast<chromeos::sync_wifi::WifiConfigurationSyncService*>(
GetInstance()->GetServiceForBrowserContext(profile, create));
GetInstance()->GetServiceForBrowserContext(profile, true));
}
// static
......
......@@ -27,8 +27,7 @@ class WifiConfigurationSyncServiceFactory
: public BrowserContextKeyedServiceFactory {
public:
static chromeos::sync_wifi::WifiConfigurationSyncService* GetForProfile(
Profile* profile,
bool create);
Profile* profile);
static WifiConfigurationSyncServiceFactory* GetInstance();
private:
......
......@@ -40,9 +40,6 @@ void FakeLocalNetworkCollector::ClearNetworks() {
networks_.clear();
}
void FakeLocalNetworkCollector::SetNetworkMetadataStore(
NetworkMetadataStore* network_metadata_store) {}
} // namespace sync_wifi
} // namespace chromeos
\ No newline at end of file
......@@ -29,8 +29,6 @@ class FakeLocalNetworkCollector : public LocalNetworkCollector {
void AddNetwork(sync_pb::WifiConfigurationSpecifics proto);
void ClearNetworks();
void SetNetworkMetadataStore(
NetworkMetadataStore* network_metadata_store) override;
private:
std::vector<sync_pb::WifiConfigurationSpecifics> networks_;
......
......@@ -19,8 +19,6 @@ class WifiConfigurationSpecifics;
namespace chromeos {
class NetworkMetadataStore;
namespace sync_wifi {
class NetworkIdentifier;
......@@ -50,10 +48,6 @@ class LocalNetworkCollector {
// exist or isn't syncable it will provide base::nullopt to the callback.
virtual void GetSyncableNetwork(const NetworkIdentifier& id,
ProtoCallback callback) = 0;
// Provides the metadata store which gets constructed later.
virtual void SetNetworkMetadataStore(
NetworkMetadataStore* network_metadata_store) = 0;
};
} // namespace sync_wifi
......
......@@ -36,8 +36,10 @@ dbus::ObjectPath GetServicePathForGuid(const std::string& guid) {
} // namespace
LocalNetworkCollectorImpl::LocalNetworkCollectorImpl(
network_config::mojom::CrosNetworkConfig* cros_network_config)
: cros_network_config_(cros_network_config) {
network_config::mojom::CrosNetworkConfig* cros_network_config,
NetworkMetadataStore* network_metadata_store)
: cros_network_config_(cros_network_config),
network_metadata_store_(network_metadata_store) {
cros_network_config_->AddObserver(
cros_network_config_observer_receiver_.BindNewPipeAndPassRemote());
......@@ -95,11 +97,6 @@ void LocalNetworkCollectorImpl::GetSyncableNetwork(const NetworkIdentifier& id,
StartGetNetworkDetails(network, request_guid);
}
void LocalNetworkCollectorImpl::SetNetworkMetadataStore(
NetworkMetadataStore* network_metadata_store) {
network_metadata_store_ = network_metadata_store;
}
std::string LocalNetworkCollectorImpl::InitializeRequest() {
std::string request_guid = base::GenerateGUID();
request_guid_to_complete_protos_[request_guid] =
......
......@@ -38,8 +38,9 @@ class LocalNetworkCollectorImpl
// LocalNetworkCollector:
// |cros_network_config| and |network_metadata_store| must outlive this class.
explicit LocalNetworkCollectorImpl(
network_config::mojom::CrosNetworkConfig* cros_network_config);
LocalNetworkCollectorImpl(
network_config::mojom::CrosNetworkConfig* cros_network_config,
NetworkMetadataStore* network_metadata_store);
~LocalNetworkCollectorImpl() override;
// Can only execute one request at a time.
......@@ -49,9 +50,6 @@ class LocalNetworkCollectorImpl
void GetSyncableNetwork(const NetworkIdentifier& id,
ProtoCallback callback) override;
void SetNetworkMetadataStore(
NetworkMetadataStore* network_metadata_store) override;
// CrosNetworkConfigObserver:
void OnNetworkStateListChanged() override;
void OnActiveNetworksChanged(
......
......@@ -58,8 +58,7 @@ class LocalNetworkCollectorImplTest : public testing::Test {
testing::Test::SetUp();
helper()->SetUp();
local_network_collector_ = std::make_unique<LocalNetworkCollectorImpl>(
remote_cros_network_config_.get());
local_network_collector_->SetNetworkMetadataStore(
remote_cros_network_config_.get(),
NetworkHandler::Get()->network_metadata_store());
}
......
......@@ -15,7 +15,6 @@
#include "base/time/time.h"
#include "chromeos/components/sync_wifi/network_identifier.h"
#include "chromeos/components/sync_wifi/synced_network_updater.h"
#include "chromeos/network/network_metadata_store.h"
#include "components/device_event_log/device_event_log.h"
#include "components/sync/model/entity_change.h"
#include "components/sync/model/metadata_batch.h"
......@@ -46,19 +45,14 @@ WifiConfigurationBridge::WifiConfigurationBridge(
syncer::OnceModelTypeStoreFactory create_store_callback)
: ModelTypeSyncBridge(std::move(change_processor)),
synced_network_updater_(synced_network_updater),
local_network_collector_(local_network_collector),
network_metadata_store_(nullptr) {
local_network_collector_(local_network_collector) {
std::move(create_store_callback)
.Run(syncer::WIFI_CONFIGURATIONS,
base::BindOnce(&WifiConfigurationBridge::OnStoreCreated,
weak_ptr_factory_.GetWeakPtr()));
}
WifiConfigurationBridge::~WifiConfigurationBridge() {
if (network_metadata_store_) {
network_metadata_store_->RemoveObserver(this);
}
}
WifiConfigurationBridge::~WifiConfigurationBridge() {}
std::unique_ptr<syncer::MetadataChangeList>
WifiConfigurationBridge::CreateMetadataChangeList() {
......@@ -300,20 +294,6 @@ std::vector<NetworkIdentifier> WifiConfigurationBridge::GetAllIdsForTesting() {
return ids;
}
void WifiConfigurationBridge::OnFirstConnectionToNetwork(
const std::string& guid) {
// TODO(jonmann): Add network to sync.
}
void WifiConfigurationBridge::SetNetworkMetadataStore(
NetworkMetadataStore* network_metadata_store) {
if (network_metadata_store_) {
network_metadata_store->RemoveObserver(this);
}
network_metadata_store_ = network_metadata_store;
network_metadata_store->AddObserver(this);
}
} // namespace sync_wifi
} // namespace chromeos
......@@ -16,7 +16,6 @@
#include "base/time/time.h"
#include "chromeos/components/sync_wifi/local_network_collector.h"
#include "chromeos/components/sync_wifi/synced_network_updater.h"
#include "chromeos/network/network_metadata_observer.h"
#include "components/sync/base/model_type.h"
#include "components/sync/model/model_type_store.h"
#include "components/sync/model/model_type_sync_bridge.h"
......@@ -27,14 +26,11 @@ class ModelTypeChangeProcessor;
namespace chromeos {
class NetworkMetadataStore;
namespace sync_wifi {
// Receives updates to network configurations from the Chrome sync back end and
// from the system network stack and keeps both lists in sync.
class WifiConfigurationBridge : public syncer::ModelTypeSyncBridge,
public NetworkMetadataObserver {
class WifiConfigurationBridge : public syncer::ModelTypeSyncBridge {
public:
WifiConfigurationBridge(
SyncedNetworkUpdater* synced_network_updater,
......@@ -57,14 +53,9 @@ class WifiConfigurationBridge : public syncer::ModelTypeSyncBridge,
std::string GetClientTag(const syncer::EntityData& entity_data) override;
std::string GetStorageKey(const syncer::EntityData& entity_data) override;
// NetworkMetadataObserver:
void OnFirstConnectionToNetwork(const std::string& guid) override;
// Comes from |entries_| the in-memory map.
std::vector<NetworkIdentifier> GetAllIdsForTesting();
void SetNetworkMetadataStore(NetworkMetadataStore* network_metadata_store);
private:
void Commit(std::unique_ptr<syncer::ModelTypeStore::WriteBatch> batch);
......@@ -95,8 +86,8 @@ class WifiConfigurationBridge : public syncer::ModelTypeSyncBridge,
std::unique_ptr<syncer::ModelTypeStore> store_;
SyncedNetworkUpdater* synced_network_updater_;
LocalNetworkCollector* local_network_collector_;
NetworkMetadataStore* network_metadata_store_;
base::WeakPtrFactory<WifiConfigurationBridge> weak_ptr_factory_{this};
......
......@@ -34,7 +34,8 @@ WifiConfigurationSyncService::WifiConfigurationSyncService(
std::make_unique<PendingNetworkConfigurationTrackerImpl>(pref_service),
remote_cros_network_config_.get(), std::make_unique<TimerFactory>());
collector_ = std::make_unique<LocalNetworkCollectorImpl>(
remote_cros_network_config_.get());
remote_cros_network_config_.get(),
NetworkHandler::Get()->network_metadata_store());
bridge_ = std::make_unique<sync_wifi::WifiConfigurationBridge>(
updater_.get(), collector_.get(),
std::make_unique<syncer::ClientTagBasedModelTypeProcessor>(
......@@ -50,12 +51,6 @@ WifiConfigurationSyncService::GetControllerDelegate() {
return bridge_->change_processor()->GetControllerDelegate();
}
void WifiConfigurationSyncService::SetNetworkMetadataStore(
NetworkMetadataStore* network_metadata_store) {
bridge_->SetNetworkMetadataStore(network_metadata_store);
collector_->SetNetworkMetadataStore(network_metadata_store);
}
} // namespace sync_wifi
} // namespace chromeos
......@@ -23,8 +23,6 @@ class ModelTypeControllerDelegate;
namespace chromeos {
class NetworkMetadataStore;
namespace sync_wifi {
class LocalNetworkCollectorImpl;
......@@ -42,7 +40,6 @@ class WifiConfigurationSyncService : public KeyedService {
~WifiConfigurationSyncService() override;
base::WeakPtr<syncer::ModelTypeControllerDelegate> GetControllerDelegate();
void SetNetworkMetadataStore(NetworkMetadataStore* network_metadata_store);
private:
std::unique_ptr<WifiConfigurationBridge> bridge_;
......
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