• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2024 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 #ifndef NET_DEVICE_BOUND_SESSIONS_REGISTRATION_REQUEST_PARAM_H_
6 #define NET_DEVICE_BOUND_SESSIONS_REGISTRATION_REQUEST_PARAM_H_
7 
8 #include <optional>
9 #include <string>
10 #include <utility>
11 
12 #include "net/base/net_export.h"
13 #include "url/gurl.h"
14 
15 namespace net::device_bound_sessions {
16 
17 class RegistrationFetcherParam;
18 class Session;
19 
20 class NET_EXPORT RegistrationRequestParam {
21  public:
22   RegistrationRequestParam(const RegistrationRequestParam& other);
23   RegistrationRequestParam& operator=(const RegistrationRequestParam& other);
24 
25   RegistrationRequestParam(RegistrationRequestParam&& other) noexcept;
26   RegistrationRequestParam& operator=(
27       RegistrationRequestParam&& other) noexcept;
28 
29   ~RegistrationRequestParam();
30 
31   static RegistrationRequestParam Create(
32       RegistrationFetcherParam&& fetcher_param);
33   static RegistrationRequestParam Create(const Session& session);
34 
registration_endpoint()35   const GURL& registration_endpoint() const { return registration_endpoint_; }
session_identifier()36   const std::optional<std::string>& session_identifier() const {
37     return session_identifier_;
38   }
challenge()39   const std::optional<std::string>& challenge() const { return challenge_; }
authorization()40   const std::optional<std::string>& authorization() const {
41     return authorization_;
42   }
43 
TakeRegistrationEndpoint()44   GURL TakeRegistrationEndpoint() { return std::move(registration_endpoint_); }
TakeSessionIdentifier()45   std::optional<std::string> TakeSessionIdentifier() {
46     return std::move(session_identifier_);
47   }
TakeChallenge()48   std::optional<std::string> TakeChallenge() { return std::move(challenge_); }
TakeAuthorization()49   std::optional<std::string> TakeAuthorization() {
50     return std::move(authorization_);
51   }
52 
53   static RegistrationRequestParam CreateForTesting(
54       const GURL& registration_endpoint,
55       std::string session_identifier,
56       std::optional<std::string> challenge);
57 
58  private:
59   RegistrationRequestParam(const GURL& registration_endpoint,
60                            std::optional<std::string> session_identifier,
61                            std::optional<std::string> challenge,
62                            std::optional<std::string> authorization);
63 
64   GURL registration_endpoint_;
65   std::optional<std::string> session_identifier_;
66   std::optional<std::string> challenge_;
67   std::optional<std::string> authorization_;
68 };
69 
70 }  // namespace net::device_bound_sessions
71 
72 #endif  // NET_DEVICE_BOUND_SESSIONS_REGISTRATION_REQUEST_PARAM_H_
73