summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/platform/loader/fetch/back_forward_cache_loader_helper.h
blob: ea87bb15a53df23d01b6e5bc90766209c287b575 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2021 The Chromium Authors. All rights reserved.
// 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_BACK_FORWARD_CACHE_LOADER_HELPER_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_LOADER_FETCH_BACK_FORWARD_CACHE_LOADER_HELPER_H_

#include "third_party/blink/public/mojom/frame/back_forward_cache_controller.mojom-forward.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/heap/member.h"
#include "third_party/blink/renderer/platform/platform_export.h"

namespace blink {

// Helper class for in-flight network request support for back-forward cache.
class PLATFORM_EXPORT BackForwardCacheLoaderHelper
    : public GarbageCollected<BackForwardCacheLoaderHelper> {
 public:
  // Evict the page from BackForwardCache. Should be called when handling an
  // event which can't proceed if the page is in BackForwardCache and can't be
  // easily deferred to handle later, for example network redirect handling.
  virtual void EvictFromBackForwardCache(mojom::RendererEvictionReason reason) {
  }

  // Called when a network request buffered an additional `num_bytes` while the
  // in back-forward cache. May be called multiple times.
  virtual void DidBufferLoadWhileInBackForwardCache(size_t num_bytes) {}

  // Returns true if we can still continue buffering data from in-flight network
  // requests while in back-forward cache.
  virtual bool CanContinueBufferingWhileInBackForwardCache() const {
    return false;
  }

  virtual void Detach() {}

  virtual void Trace(Visitor*) const {}
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_PLATFORM_LOADER_FETCH_BACK_FORWARD_CACHE_LOADER_HELPER_H_