File: prefetched_signed_exchange_cache_entry.cc

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (88 lines) | stat: -rw-r--r-- 3,257 bytes parent folder | download | duplicates (8)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/browser/web_package/prefetched_signed_exchange_cache_entry.h"

#include "net/base/hash_value.h"
#include "storage/browser/blob/blob_data_handle.h"

namespace content {

PrefetchedSignedExchangeCacheEntry::PrefetchedSignedExchangeCacheEntry() =
    default;
PrefetchedSignedExchangeCacheEntry::~PrefetchedSignedExchangeCacheEntry() =
    default;

void PrefetchedSignedExchangeCacheEntry::SetOuterUrl(const GURL& outer_url) {
  outer_url_ = outer_url;
}
void PrefetchedSignedExchangeCacheEntry::SetOuterResponse(
    network::mojom::URLResponseHeadPtr outer_response) {
  outer_response_ = std::move(outer_response);
}
void PrefetchedSignedExchangeCacheEntry::SetHeaderIntegrity(
    std::unique_ptr<const net::SHA256HashValue> header_integrity) {
  header_integrity_ = std::move(header_integrity);
}
void PrefetchedSignedExchangeCacheEntry::SetInnerUrl(const GURL& inner_url) {
  inner_url_ = inner_url;
}
void PrefetchedSignedExchangeCacheEntry::SetInnerResponse(
    network::mojom::URLResponseHeadPtr inner_response) {
  inner_response_ = std::move(inner_response);
}
void PrefetchedSignedExchangeCacheEntry::SetCompletionStatus(
    std::unique_ptr<const network::URLLoaderCompletionStatus>
        completion_status) {
  completion_status_ = std::move(completion_status);
}
void PrefetchedSignedExchangeCacheEntry::SetBlobDataHandle(
    std::unique_ptr<const storage::BlobDataHandle> blob_data_handle) {
  blob_data_handle_ = std::move(blob_data_handle);
}
void PrefetchedSignedExchangeCacheEntry::SetSignatureExpireTime(
    const base::Time& signature_expire_time) {
  signature_expire_time_ = signature_expire_time;
}
void PrefetchedSignedExchangeCacheEntry::SetCertUrl(const GURL& cert_url) {
  cert_url_ = cert_url;
}
void PrefetchedSignedExchangeCacheEntry::SetCertServerIPAddress(
    const net::IPAddress& cert_server_ip_address) {
  cert_server_ip_address_ = cert_server_ip_address;
}

std::unique_ptr<const PrefetchedSignedExchangeCacheEntry>
PrefetchedSignedExchangeCacheEntry::Clone() const {
  DCHECK(outer_url().is_valid());
  DCHECK(outer_response());
  DCHECK(header_integrity());
  DCHECK(inner_url().is_valid());
  DCHECK(inner_response());
  DCHECK(completion_status());
  DCHECK(blob_data_handle());
  DCHECK(!signature_expire_time().is_null());

  std::unique_ptr<PrefetchedSignedExchangeCacheEntry> clone =
      std::make_unique<PrefetchedSignedExchangeCacheEntry>();
  clone->SetOuterUrl(outer_url_);
  clone->SetOuterResponse(outer_response_.Clone());
  clone->SetHeaderIntegrity(
      std::make_unique<const net::SHA256HashValue>(*header_integrity_));
  clone->SetInnerUrl(inner_url_);
  clone->SetInnerResponse(inner_response_.Clone());
  clone->SetCompletionStatus(
      std::make_unique<const network::URLLoaderCompletionStatus>(
          *completion_status_));
  clone->SetBlobDataHandle(
      std::make_unique<const storage::BlobDataHandle>(*blob_data_handle_));
  clone->SetSignatureExpireTime(signature_expire_time_);

  clone->SetCertUrl(cert_url_);
  clone->SetCertServerIPAddress(cert_server_ip_address_);

  return clone;
}

}  // namespace content