chromium/third_party/blink/renderer/platform/exported/resource_load_info_notifier_wrapper.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 "third_party/blink/public/platform/resource_load_info_notifier_wrapper.h"

#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "net/base/ip_endpoint.h"
#include "net/url_request/redirect_info.h"
#include "services/network/public/cpp/url_loader_completion_status.h"
#include "services/network/public/mojom/fetch_api.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "third_party/blink/public/common/loader/network_utils.h"
#include "third_party/blink/public/common/loader/record_load_histograms.h"
#include "third_party/blink/public/common/loader/resource_type_util.h"
#include "third_party/blink/public/mojom/loader/resource_load_info_notifier.mojom.h"
#include "third_party/blink/public/platform/weak_wrapper_resource_load_info_notifier.h"

namespace blink {

ResourceLoadInfoNotifierWrapper::ResourceLoadInfoNotifierWrapper(
    base::WeakPtr<WeakWrapperResourceLoadInfoNotifier>
        weak_wrapper_resource_load_info_notifier)
    :{}

ResourceLoadInfoNotifierWrapper::ResourceLoadInfoNotifierWrapper(
    base::WeakPtr<WeakWrapperResourceLoadInfoNotifier>
        weak_wrapper_resource_load_info_notifier,
    scoped_refptr<base::SingleThreadTaskRunner> task_runner)
    :{}

ResourceLoadInfoNotifierWrapper::~ResourceLoadInfoNotifierWrapper() = default;

#if BUILDFLAG(IS_ANDROID)
void ResourceLoadInfoNotifierWrapper::NotifyUpdateUserGestureCarryoverInfo() {
  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
  if (task_runner_->BelongsToCurrentThread()) {
    if (weak_wrapper_resource_load_info_notifier_) {
      weak_wrapper_resource_load_info_notifier_
          ->NotifyUpdateUserGestureCarryoverInfo();
    }
    return;
  }
  task_runner_->PostTask(
      FROM_HERE, base::BindOnce(&mojom::ResourceLoadInfoNotifier::
                                    NotifyUpdateUserGestureCarryoverInfo,
                                weak_wrapper_resource_load_info_notifier_));
}
#endif

void ResourceLoadInfoNotifierWrapper::NotifyResourceLoadInitiated(
    int64_t request_id,
    const GURL& request_url,
    const std::string& http_method,
    const GURL& referrer,
    network::mojom::RequestDestination request_destination,
    net::RequestPriority request_priority,
    bool is_ad_resource) {}

void ResourceLoadInfoNotifierWrapper::NotifyResourceRedirectReceived(
    const net::RedirectInfo& redirect_info,
    network::mojom::URLResponseHeadPtr redirect_response) {}

void ResourceLoadInfoNotifierWrapper::NotifyResourceResponseReceived(
    network::mojom::URLResponseHeadPtr response_head) {}

void ResourceLoadInfoNotifierWrapper::NotifyResourceTransferSizeUpdated(
    int32_t transfer_size_diff) {}

void ResourceLoadInfoNotifierWrapper::NotifyResourceLoadCompleted(
    const network::URLLoaderCompletionStatus& status) {}

void ResourceLoadInfoNotifierWrapper::NotifyResourceLoadCanceled(
    int net_error) {}

}  // namespace blink