chromium/chrome/browser/safe_browsing/extension_telemetry/extension_telemetry_uploader.cc

// Copyright 2021 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/browser/safe_browsing/extension_telemetry/extension_telemetry_uploader.h"

#include <memory>
#include <utility>

#include "base/functional/bind.h"
#include "base/metrics/histogram_functions.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "components/safe_browsing/core/browser/sync/safe_browsing_primary_account_token_fetcher.h"
#include "components/safe_browsing/core/common/utils.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/load_flags.h"
#include "net/http/http_status_code.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/mojom/url_response_head.mojom.h"

namespace safe_browsing {

namespace {

constexpr const char kUploadUrl[] =;

constexpr net::NetworkTrafficAnnotationTag
    kSafeBrowsingExtensionTelemetryTrafficAnnotation =;
// Constants associated with exponential backoff. On each failure, we will
// increase the backoff by |kBackoffFactor|, starting from
// |kInitialBackoffSeconds|. If we fail after |kMaxRetryAttempts| retries, the
// upload fails.
const int kInitialBackoffSeconds =;
const int kBackoffFactor =;
const int kMaxRetryAttempts =;

void RecordUploadSize(size_t size) {}

void RecordUploadSuccess(bool success) {}

void RecordUploadRetries(int num_retries) {}

void RecordNetworkResponseCodeOrError(int code_or_error) {}

void RecordUploadDuration(bool success, base::TimeDelta delta) {}

}  // namespace

ExtensionTelemetryUploader::~ExtensionTelemetryUploader() = default;

ExtensionTelemetryUploader::ExtensionTelemetryUploader(
    OnUploadCallback callback,
    const scoped_refptr<network::SharedURLLoaderFactory>& url_loader_factory,
    std::unique_ptr<std::string> upload_data,
    std::unique_ptr<SafeBrowsingTokenFetcher> token_fetcher)
    :{}

void ExtensionTelemetryUploader::Start() {}

// static
std::string ExtensionTelemetryUploader::GetUploadURLForTest() {}

void ExtensionTelemetryUploader::MaybeSendRequestWithAccessToken() {}

void ExtensionTelemetryUploader::SendRequest(const std::string& access_token) {}

void ExtensionTelemetryUploader::OnURLLoaderComplete(
    std::unique_ptr<std::string> response_body) {}

void ExtensionTelemetryUploader::RetryOrFinish(
    int net_error,
    int response_code,
    const std::string& response_data) {}

}  // namespace safe_browsing