chromium/chrome/updater/device_management/dm_client.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/updater/device_management/dm_client.h"

#include <cstdint>
#include <memory>
#include <optional>
#include <ostream>
#include <string>
#include <utility>

#include "base/containers/flat_map.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_refptr.h"
#include "base/sequence_checker.h"
#include "base/strings/strcat.h"
#include "base/strings/stringprintf.h"
#include "base/system/sys_info.h"
#include "base/task/sequenced_task_runner.h"
#include "build/build_config.h"
#include "chrome/enterprise_companion/device_management_storage/dm_storage.h"
#include "chrome/updater/device_management/dm_message.h"
#include "chrome/updater/device_management/dm_response_validator.h"
#include "chrome/updater/net/network.h"
#include "chrome/updater/policy/service.h"
#include "chrome/updater/updater_branding.h"
#include "chrome/updater/updater_version.h"
#include "chrome/updater/util/util.h"
#include "components/update_client/network.h"
#include "url/gurl.h"

namespace updater {
namespace {

// Content-type of DM requests.
constexpr char kDMContentType[] =;

// String constants for the device and app type we report to the server.
constexpr char kParamAgent[] =;
constexpr char kParamRequest[] =;
constexpr char kParamPlatform[] =;
constexpr char kParamDeviceID[] =;
constexpr char kParamAppType[] =;
constexpr char kValueAppType[] =;

constexpr char kAuthorizationHeader[] =;

// Constants for device management enrollment requests.
constexpr char kRegistrationRequestType[] =;
constexpr char kRegistrationTokenType[] =;

// Constants for policy fetch requests.
constexpr char kPolicyFetchRequestType[] =;
constexpr char kDMTokenType[] =;
constexpr char kGoogleUpdateMachineLevelApps[] =;

// Constants for policy validation report requests.
constexpr char kValidationReportRequestType[] =;

constexpr int kHTTPStatusOK =;
constexpr int kHTTPStatusGone =;

class DefaultConfigurator : public DMClient::Configurator {};

// Builds a DM request and sends it via the wrapped network fetcher. Raw fetch
// result will be translated into DM request result for external callback.
// Do not reuse this class for multiple requests, as the class maintains the
// intermediate state of the wrapped network request.
class DMFetch : public base::RefCountedThreadSafe<DMFetch> {};

DMFetch::DMFetch(std::unique_ptr<DMClient::Configurator> config,
                 scoped_refptr<device_management_storage::DMStorage> storage)
    :{}

DMFetch::~DMFetch() {}

GURL DMFetch::BuildURL(const std::string& request_type) const {}

std::string DMFetch::BuildTokenString(TokenType type) const {}

void DMFetch::PostRequest(const std::string& request_type,
                          TokenType token_type,
                          const std::string& request_data,
                          Callback callback) {}

void DMFetch::OnRequestStarted(int response_code, int64_t content_length) {}

void DMFetch::OnRequestProgress(int64_t current) {}

void DMFetch::OnRequestComplete(std::unique_ptr<std::string> response_body,
                                int net_error,
                                const std::string& header_etag,
                                const std::string& header_x_cup_server_proof,
                                int64_t xheader_retry_after_sec) {}

void OnDMRegisterRequestComplete(scoped_refptr<DMFetch> dm_fetch,
                                 DMClient::RegisterCallback callback,
                                 DMClient::RequestResult result,
                                 std::unique_ptr<std::string> response_body) {}

void OnDMPolicyFetchRequestComplete(
    scoped_refptr<DMFetch> dm_fetch,
    DMClient::PolicyFetchCallback callback,
    std::unique_ptr<device_management_storage::CachedPolicyInfo> cached_info,
    DMClient::RequestResult result,
    std::unique_ptr<std::string> response_body) {}

void OnDMPolicyValidationReportRequestComplete(
    scoped_refptr<DMFetch> dm_fetch,
    DMClient::PolicyValidationReportCallback callback,
    DMClient::RequestResult result,
    std::unique_ptr<std::string> response_body) {}

}  // namespace

void DMClient::RegisterDevice(
    std::unique_ptr<Configurator> config,
    scoped_refptr<device_management_storage::DMStorage> storage,
    RegisterCallback callback) {}

void DMClient::FetchPolicy(
    std::unique_ptr<Configurator> config,
    scoped_refptr<device_management_storage::DMStorage> storage,
    PolicyFetchCallback callback) {}

void DMClient::ReportPolicyValidationErrors(
    std::unique_ptr<Configurator> config,
    scoped_refptr<device_management_storage::DMStorage> storage,
    const PolicyValidationResult& validation_result,
    PolicyValidationReportCallback callback) {}

std::unique_ptr<DMClient::Configurator> DMClient::CreateDefaultConfigurator(
    const GURL& server_url,
    std::optional<PolicyServiceProxyConfiguration>
        policy_service_proxy_configuration) {}

std::ostream& operator<<(std::ostream& os,
                         const DMClient::RequestResult& result) {}

}  // namespace updater