summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/cache_storage/cache_storage_blob_client_list.h
blob: 5d00e128e6ac6fe033ff998c252c7c48c0106265 (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
// Copyright 2019 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_MODULES_CACHE_STORAGE_CACHE_STORAGE_BLOB_CLIENT_LIST_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_CACHE_STORAGE_CACHE_STORAGE_BLOB_CLIENT_LIST_H_

#include "mojo/public/cpp/bindings/receiver.h"
#include "third_party/blink/public/mojom/blob/blob.mojom-blink.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/loader/fetch/data_pipe_bytes_consumer.h"

namespace blink {

// This class holds a list of BlobReaderClient implementations alive until
// they complete or the entire list is garbage collected.
class CacheStorageBlobClientList
    : public GarbageCollected<CacheStorageBlobClientList> {
 public:
  CacheStorageBlobClientList() = default;
  void AddClient(
      ExecutionContext* context,
      mojo::PendingReceiver<mojom::blink::BlobReaderClient>
          client_pending_receiver,
      DataPipeBytesConsumer::CompletionNotifier* completion_notifier);

  void Trace(Visitor* visitor);

 private:
  class Client;

  void RevokeClient(Client* client);

  HeapVector<Member<Client>> clients;
  DISALLOW_COPY_AND_ASSIGN(CacheStorageBlobClientList);
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_MODULES_CACHE_STORAGE_CACHE_STORAGE_BLOB_CLIENT_LIST_H_