1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_CACHE_STORAGE_CACHE_STORAGE_BLOB_CLIENT_LIST_H_
6 #define THIRD_PARTY_BLINK_RENDERER_MODULES_CACHE_STORAGE_CACHE_STORAGE_BLOB_CLIENT_LIST_H_
7 
8 #include "mojo/public/cpp/bindings/receiver.h"
9 #include "third_party/blink/public/mojom/blob/blob.mojom-blink.h"
10 #include "third_party/blink/renderer/platform/heap/heap.h"
11 #include "third_party/blink/renderer/platform/loader/fetch/data_pipe_bytes_consumer.h"
12 
13 namespace blink {
14 
15 // This class holds a list of BlobReaderClient implementations alive until
16 // they complete or the entire list is garbage collected.
17 class CacheStorageBlobClientList
18     : public GarbageCollected<CacheStorageBlobClientList> {
19  public:
20   CacheStorageBlobClientList() = default;
21   void AddClient(
22       mojo::PendingReceiver<mojom::blink::BlobReaderClient>
23           client_pending_receiver,
24       DataPipeBytesConsumer::CompletionNotifier* completion_notifier);
25 
26   void Trace(Visitor* visitor);
27 
28  private:
29   class Client;
30 
31   void RevokeClient(Client* client);
32 
33   HeapVector<Member<Client>> clients;
34   DISALLOW_COPY_AND_ASSIGN(CacheStorageBlobClientList);
35 };
36 
37 }  // namespace blink
38 
39 #endif  // THIRD_PARTY_BLINK_RENDERER_MODULES_CACHE_STORAGE_CACHE_STORAGE_BLOB_CLIENT_LIST_H_
40