1 // Copyright 2023 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/extras/shared_dictionary/shared_dictionary_info.h"
6
7 namespace net {
8
SharedDictionaryInfo(const GURL & url,base::Time response_time,base::TimeDelta expiration,const std::string & match,base::Time last_used_time,size_t size,const net::SHA256HashValue & hash,const base::UnguessableToken & disk_cache_key_token,const absl::optional<int64_t> & primary_key_in_database)9 SharedDictionaryInfo::SharedDictionaryInfo(
10 const GURL& url,
11 base::Time response_time,
12 base::TimeDelta expiration,
13 const std::string& match,
14 base::Time last_used_time,
15 size_t size,
16 const net::SHA256HashValue& hash,
17 const base::UnguessableToken& disk_cache_key_token,
18 const absl::optional<int64_t>& primary_key_in_database)
19 : url_(url),
20 response_time_(response_time),
21 expiration_(expiration),
22 match_(match),
23 last_used_time_(last_used_time),
24 size_(size),
25 hash_(hash),
26 disk_cache_key_token_(disk_cache_key_token),
27 primary_key_in_database_(primary_key_in_database) {}
28
29 SharedDictionaryInfo::SharedDictionaryInfo(const SharedDictionaryInfo&) =
30 default;
31 SharedDictionaryInfo& SharedDictionaryInfo::operator=(
32 const SharedDictionaryInfo&) = default;
33
34 SharedDictionaryInfo::SharedDictionaryInfo(SharedDictionaryInfo&&) = default;
35 SharedDictionaryInfo& SharedDictionaryInfo::operator=(SharedDictionaryInfo&&) =
36 default;
37
38 SharedDictionaryInfo::~SharedDictionaryInfo() = default;
39
operator ==(const SharedDictionaryInfo & other) const40 bool SharedDictionaryInfo::operator==(const SharedDictionaryInfo& other) const {
41 return url_ == other.url_ && response_time_ == other.response_time_ &&
42 expiration_ == other.expiration_ && match_ == other.match_ &&
43 last_used_time_ == other.last_used_time_ && size_ == other.size_ &&
44 hash_ == other.hash_ &&
45 disk_cache_key_token_ == other.disk_cache_key_token_ &&
46 primary_key_in_database_ == other.primary_key_in_database_;
47 }
48
GetExpirationTime() const49 base::Time SharedDictionaryInfo::GetExpirationTime() const {
50 return response_time_ + expiration_;
51 }
52
53 } // namespace net
54