#include "chrome/browser/policy/messaging_layer/util/reporting_server_connector.h"
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#include "base/check_is_test.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/singleton.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/strcat.h"
#include "base/task/bind_post_task.h"
#include "base/time/time.h"
#include "base/types/expected.h"
#include "base/types/expected_macros.h"
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/enterprise/browser_management/management_service_factory.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/browser/policy/messaging_layer/upload/encrypted_reporting_client.h"
#include "chrome/browser/policy/messaging_layer/util/upload_declarations.h"
#include "chrome/browser/policy/messaging_layer/util/upload_response_parser.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/reporting_util.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "components/embedder_support/user_agent_utils.h"
#include "components/policy/core/common/cloud/cloud_policy_client.h"
#include "components/policy/core/common/cloud/cloud_policy_client_registration_helper.h"
#include "components/policy/core/common/cloud/cloud_policy_core.h"
#include "components/policy/core/common/cloud/cloud_policy_manager.h"
#include "components/policy/core/common/cloud/device_management_service.h"
#include "components/policy/core/common/cloud/machine_level_user_cloud_policy_manager.h"
#include "components/policy/core/common/cloud/user_cloud_policy_manager.h"
#include "components/reporting/proto/synced/record.pb.h"
#include "components/reporting/proto/synced/record_constants.pb.h"
#include "components/reporting/resources/resource_manager.h"
#include "components/reporting/util/encrypted_reporting_json_keys.h"
#include "components/reporting/util/reporting_errors.h"
#include "components/reporting/util/status.h"
#include "components/reporting/util/status_macros.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/policy/core/browser_policy_connector_ash.h"
#include "chromeos/ash/components/install_attributes/install_attributes.h"
#endif
CloudPolicyClient;
CloudPolicyCore;
namespace reporting {
namespace {
bool DeviceInfoRequiredForUpload() { … }
}
BASE_FEATURE(…);
ReportingServerConnector::ReportingServerConnector()
: … { … }
ReportingServerConnector::~ReportingServerConnector() { … }
ReportingServerConnector* ReportingServerConnector::GetInstance() { … }
void ReportingServerConnector::OnCoreConnected(CloudPolicyCore* core) { … }
void ReportingServerConnector::OnRefreshSchedulerStarted(
CloudPolicyCore* core) { … }
void ReportingServerConnector::OnCoreDisconnecting(CloudPolicyCore* core) { … }
void ReportingServerConnector::OnCoreDestruction(CloudPolicyCore* core) { … }
void ReportingServerConnector::UploadEncryptedReport(
bool need_encryption_key,
int config_file_version,
std::vector<EncryptedRecord> records,
ScopedReservation scoped_reservation,
UploadEnqueuedCallback enqueued_cb,
ResponseCallback callback) { … }
void ReportingServerConnector::UploadEncryptedReportInternal(
bool need_encryption_key,
int config_file_version,
std::vector<EncryptedRecord> records,
ScopedReservation scoped_reservation,
UploadEnqueuedCallback enqueued_cb,
ResponseCallback callback) { … }
StatusOr<::policy::CloudPolicyManager*>
ReportingServerConnector::GetUserCloudPolicyManager() { … }
Status ReportingServerConnector::EnsureUsableCore() { … }
Status ReportingServerConnector::EnsureUsableClient() { … }
void ReportingServerConnector::AddObserver(Observer* observer) { … }
void ReportingServerConnector::RemoveObserver(Observer* observer) { … }
}