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
44
45
46
47
48
49
50
51
52
53
54
55
56
content / browser / shared_storage / shared_storage_code_cache_host_proxy.h [blame]
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_SHARED_STORAGE_SHARED_STORAGE_CODE_CACHE_HOST_PROXY_H_
#define CONTENT_BROWSER_SHARED_STORAGE_SHARED_STORAGE_CODE_CACHE_HOST_PROXY_H_
#include "content/common/content_export.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "third_party/blink/public/mojom/loader/code_cache.mojom.h"
#include "url/gurl.h"
namespace content {
// Proxy CodeCacheHost, to limit the requests that a shared storage worklet can
// make. It also implicitly adds a scope -- requests are only allowed during the
// lifetime of `SharedStorageCodeCacheHostProxy`.
class CONTENT_EXPORT SharedStorageCodeCacheHostProxy
: public blink::mojom::CodeCacheHost {
public:
explicit SharedStorageCodeCacheHostProxy(
mojo::PendingRemote<blink::mojom::CodeCacheHost> actual_code_cache_host,
mojo::PendingReceiver<blink::mojom::CodeCacheHost> receiver,
const GURL& script_url);
~SharedStorageCodeCacheHostProxy() override;
void DidGenerateCacheableMetadata(blink::mojom::CodeCacheType cache_type,
const GURL& url,
base::Time expected_response_time,
mojo_base::BigBuffer data) override;
void FetchCachedCode(blink::mojom::CodeCacheType cache_type,
const GURL& url,
FetchCachedCodeCallback callback) override;
void ClearCodeCacheEntry(blink::mojom::CodeCacheType cache_type,
const GURL& url) override;
void DidGenerateCacheableMetadataInCacheStorage(
const GURL& url,
base::Time expected_response_time,
mojo_base::BigBuffer data,
const std::string& cache_storage_cache_name) override;
private:
mojo::Remote<blink::mojom::CodeCacheHost> actual_code_cache_host_;
mojo::Receiver<blink::mojom::CodeCacheHost> receiver_;
const GURL script_url_;
};
} // namespace content
#endif // CONTENT_BROWSER_SHARED_STORAGE_SHARED_STORAGE_CODE_CACHE_HOST_PROXY_H_