chromium/third_party/blink/renderer/platform/loader/fetch/response_body_loader.h

// 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.

#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_LOADER_FETCH_RESPONSE_BODY_LOADER_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_LOADER_FETCH_RESPONSE_BODY_LOADER_H_

#include "base/containers/span.h"
#include "base/memory/scoped_refptr.h"
#include "mojo/public/cpp/system/data_pipe.h"
#include "third_party/blink/public/mojom/navigation/renderer_eviction_reason.mojom-blink-forward.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/member.h"
#include "third_party/blink/renderer/platform/loader/fetch/bytes_consumer.h"
#include "third_party/blink/renderer/platform/loader/fetch/loader_freeze_mode.h"
#include "third_party/blink/renderer/platform/loader/fetch/response_body_loader_client.h"
#include "third_party/blink/renderer/platform/platform_export.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"

namespace base {
class SingleThreadTaskRunner;
}  // namespace base

namespace blink {

class BackForwardCacheLoaderHelper;
class ResponseBodyLoader;

// See ResponseBodyLoader for details. This is a virtual interface to expose
// only Drain functions.
class PLATFORM_EXPORT ResponseBodyLoaderDrainableInterface
    : public GarbageCollected<ResponseBodyLoaderDrainableInterface> {};

// ResponseBodyLoader reads the response body and reports the contents to the
// associated client. There are two ways:
//  - By calling Start(), ResponseBodyLoader reads the response body. and
//    reports the contents to the client. Abort() aborts reading.
//  - By calling DrainAsDataPipe, a user can "drain" the contents from
//    ResponseBodyLoader. The caller is responsible for reading the body and
//    providing the information to the client this function provides.
//  - By calling DrainBytesConsumer, a user can "drain" the contents from
//    ResponseBodyLoader.
// A ResponseBodyLoader is bound to the thread on which it is created.
class PLATFORM_EXPORT ResponseBodyLoader final
    : public ResponseBodyLoaderDrainableInterface,
      private ResponseBodyLoaderClient,
      private BytesConsumer::Client {};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_LOADER_FETCH_RESPONSE_BODY_LOADER_H_