File: wifi_configuration_sync_service.cc

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (71 lines) | stat: -rw-r--r-- 3,358 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chromeos/ash/components/sync_wifi/wifi_configuration_sync_service.h"

#include <utility>

#include "ash/public/cpp/network_config_service.h"
#include "base/functional/callback_helpers.h"
#include "base/time/default_clock.h"
#include "chromeos/ash/components/network/network_handler.h"
#include "chromeos/ash/components/network/network_metadata_store.h"
#include "chromeos/ash/components/sync_wifi/local_network_collector_impl.h"
#include "chromeos/ash/components/sync_wifi/pending_network_configuration_tracker_impl.h"
#include "chromeos/ash/components/sync_wifi/synced_network_metrics_logger.h"
#include "chromeos/ash/components/sync_wifi/synced_network_updater_impl.h"
#include "chromeos/ash/components/sync_wifi/wifi_configuration_bridge.h"
#include "chromeos/ash/components/timer_factory/timer_factory_impl.h"
#include "chromeos/services/network_config/public/mojom/cros_network_config.mojom.h"
#include "components/sync/base/report_unrecoverable_error.h"
#include "components/sync/model/client_tag_based_data_type_processor.h"
#include "components/sync/model/data_type_store.h"

namespace ash::sync_wifi {

WifiConfigurationSyncService::WifiConfigurationSyncService(
    version_info::Channel channel,
    PrefService* pref_service,
    syncer::OnceDataTypeStoreFactory create_store_callback) {
  NetworkHandler* network_handler = NetworkHandler::Get();
  ash::GetNetworkConfigService(
      remote_cros_network_config_.BindNewPipeAndPassReceiver());
  metrics_logger_ = std::make_unique<SyncedNetworkMetricsLogger>(
      network_handler->network_state_handler(),
      network_handler->network_connection_handler());
  timer_factory_ = ash::timer_factory::TimerFactoryImpl::Factory::Create();
  updater_ = std::make_unique<SyncedNetworkUpdaterImpl>(
      std::make_unique<PendingNetworkConfigurationTrackerImpl>(pref_service),
      remote_cros_network_config_.get(), timer_factory_.get(),
      metrics_logger_.get());
  collector_ = std::make_unique<LocalNetworkCollectorImpl>(
      remote_cros_network_config_.get(), metrics_logger_.get());
  bridge_ = std::make_unique<sync_wifi::WifiConfigurationBridge>(
      updater_.get(), collector_.get(),
      network_handler->network_configuration_handler(), metrics_logger_.get(),
      timer_factory_.get(), pref_service,
      std::make_unique<syncer::ClientTagBasedDataTypeProcessor>(
          syncer::WIFI_CONFIGURATIONS,
          base::BindRepeating(&syncer::ReportUnrecoverableError, channel)),
      std::move(create_store_callback));
  NetworkMetadataStore* metadata_store =
      network_handler->network_metadata_store();
  if (metadata_store)
    SetNetworkMetadataStore(metadata_store->GetWeakPtr());
}

WifiConfigurationSyncService::~WifiConfigurationSyncService() = default;

base::WeakPtr<syncer::DataTypeControllerDelegate>
WifiConfigurationSyncService::GetControllerDelegate() {
  return bridge_->change_processor()->GetControllerDelegate();
}

void WifiConfigurationSyncService::SetNetworkMetadataStore(
    base::WeakPtr<NetworkMetadataStore> network_metadata_store) {
  bridge_->SetNetworkMetadataStore(network_metadata_store);
  collector_->SetNetworkMetadataStore(network_metadata_store);
}

}  // namespace ash::sync_wifi