xref: /aosp_15_r20/external/cronet/net/extras/shared_dictionary/shared_dictionary_info.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
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,const std::string & match_dest_string,const std::string & id,base::Time last_used_time,size_t size,const net::SHA256HashValue & hash,const base::UnguessableToken & disk_cache_key_token,const std::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     const std::string& match_dest_string,
15     const std::string& id,
16     base::Time last_used_time,
17     size_t size,
18     const net::SHA256HashValue& hash,
19     const base::UnguessableToken& disk_cache_key_token,
20     const std::optional<int64_t>& primary_key_in_database)
21     : url_(url),
22       response_time_(response_time),
23       expiration_(expiration),
24       match_(match),
25       match_dest_string_(match_dest_string),
26       id_(id),
27       last_used_time_(last_used_time),
28       size_(size),
29       hash_(hash),
30       disk_cache_key_token_(disk_cache_key_token),
31       primary_key_in_database_(primary_key_in_database) {}
32 
33 SharedDictionaryInfo::SharedDictionaryInfo(const SharedDictionaryInfo&) =
34     default;
35 SharedDictionaryInfo& SharedDictionaryInfo::operator=(
36     const SharedDictionaryInfo&) = default;
37 
38 SharedDictionaryInfo::SharedDictionaryInfo(SharedDictionaryInfo&&) = default;
39 SharedDictionaryInfo& SharedDictionaryInfo::operator=(SharedDictionaryInfo&&) =
40     default;
41 
42 SharedDictionaryInfo::~SharedDictionaryInfo() = default;
43 
operator ==(const SharedDictionaryInfo & other) const44 bool SharedDictionaryInfo::operator==(const SharedDictionaryInfo& other) const {
45   return url_ == other.url_ && response_time_ == other.response_time_ &&
46          expiration_ == other.expiration_ && match_ == other.match_ &&
47          last_used_time_ == other.last_used_time_ && size_ == other.size_ &&
48          hash_ == other.hash_ &&
49          disk_cache_key_token_ == other.disk_cache_key_token_ &&
50          primary_key_in_database_ == other.primary_key_in_database_;
51 }
52 
GetExpirationTime() const53 base::Time SharedDictionaryInfo::GetExpirationTime() const {
54   return response_time_ + expiration_;
55 }
56 
57 }  // namespace net
58