OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_QUIC_CRYPTO_QUIC_SERVER_INFO_H_ | 5 #ifndef NET_QUIC_CRYPTO_QUIC_SERVER_INFO_H_ |
6 #define NET_QUIC_CRYPTO_QUIC_SERVER_INFO_H_ | 6 #define NET_QUIC_CRYPTO_QUIC_SERVER_INFO_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... | |
37 // the current thread when ready. | 37 // the current thread when ready. |
38 // | 38 // |
39 // Only a single callback can be outstanding at a given time and, in the | 39 // Only a single callback can be outstanding at a given time and, in the |
40 // event that WaitForDataReady returns OK, it's the caller's responsibility | 40 // event that WaitForDataReady returns OK, it's the caller's responsibility |
41 // to delete |callback|. | 41 // to delete |callback|. |
42 // | 42 // |
43 // |callback| may be NULL, in which case ERR_IO_PENDING may still be returned | 43 // |callback| may be NULL, in which case ERR_IO_PENDING may still be returned |
44 // but, obviously, a callback will never be made. | 44 // but, obviously, a callback will never be made. |
45 virtual int WaitForDataReady(const CompletionCallback& callback) = 0; | 45 virtual int WaitForDataReady(const CompletionCallback& callback) = 0; |
46 | 46 |
47 // Returns true is data is loaded from disk cache and ready (WaitForDataReady | |
wtc
2014/02/11 01:01:45
Typo: is data is => if data is
ramant (doing other things)
2014/02/11 07:57:55
Done.
| |
48 // doesn't have a pending callback). | |
49 virtual bool IsDataReady() = 0; | |
50 | |
47 // Persist allows for the server information to be updated for future users. | 51 // Persist allows for the server information to be updated for future users. |
48 // This is a fire and forget operation: the caller may drop its reference | 52 // This is a fire and forget operation: the caller may drop its reference |
49 // from this object and the store operation will still complete. This can | 53 // from this object and the store operation will still complete. This can |
50 // only be called once WaitForDataReady has returned OK or called its | 54 // only be called once WaitForDataReady has returned OK or called its |
51 // callback. | 55 // callback. |
52 virtual void Persist() = 0; | 56 virtual void Persist() = 0; |
53 | 57 |
54 struct State { | 58 struct State { |
55 State(); | 59 State(); |
56 ~State(); | 60 ~State(); |
57 | 61 |
58 void Clear(); | 62 void Clear(); |
59 | 63 |
60 // TODO(rtenneti): figure out what are the data members. | 64 // This class matches QuicClientCryptoConfig::CachedState. |
61 std::vector<std::string> data; | 65 std::string server_config_; // A serialized handshake message. |
66 std::string source_address_token_; // An opaque proof of IP ownership. | |
67 std::vector<std::string> certs_; // A list of certificates in leaf-first | |
68 // order. | |
69 std::string server_config_sig_; // A signature of |server_config_|. | |
wtc
2014/02/11 01:01:45
These members should follow the naming convention
ramant (doing other things)
2014/02/11 07:57:55
Done.
| |
62 | 70 |
63 private: | 71 private: |
64 DISALLOW_COPY_AND_ASSIGN(State); | 72 DISALLOW_COPY_AND_ASSIGN(State); |
65 }; | 73 }; |
66 | 74 |
67 // Once the data is ready, it can be read using the following members. These | 75 // Once the data is ready, it can be read using the following members. These |
68 // members can then be updated before calling |Persist|. | 76 // members can then be updated before calling |Persist|. |
69 const State& state() const; | 77 const State& state() const; |
70 State* mutable_state(); | 78 State* mutable_state(); |
71 | 79 |
72 protected: | 80 protected: |
73 // Parse parses an opaque blob of data and fills out the public member fields | 81 // Parse parses pickled data and fills out the public member fields of this |
74 // of this object. It returns true iff the parse was successful. The public | 82 // object. It returns true iff the parse was successful. The public member |
75 // member fields will be set to something sane in any case. | 83 // fields will be set to something sane in any case. |
76 bool Parse(const std::string& data); | 84 bool Parse(const std::string& data); |
77 std::string Serialize() const; | 85 std::string Serialize() const; |
78 State state_; | 86 State state_; |
79 | 87 |
80 private: | 88 private: |
81 // ParseInner is a helper function for Parse. | 89 // ParseInner is a helper function for Parse. |
82 bool ParseInner(const std::string& data); | 90 bool ParseInner(const std::string& data); |
83 | 91 |
84 // This is the QUIC server hostname for which we restore the crypto_config. | 92 // This is the QUIC server hostname for which we restore the crypto_config. |
85 const std::string hostname_; | 93 const std::string hostname_; |
86 base::WeakPtrFactory<QuicServerInfo> weak_factory_; | |
87 }; | 94 }; |
88 | 95 |
89 class QuicServerInfoFactory { | 96 class QuicServerInfoFactory { |
90 public: | 97 public: |
91 virtual ~QuicServerInfoFactory(); | 98 virtual ~QuicServerInfoFactory(); |
92 | 99 |
93 // GetForHost returns a fresh, allocated QuicServerInfo for the given | 100 // GetForHost returns a fresh, allocated QuicServerInfo for the given |
94 // hostname or NULL on failure. | 101 // hostname or NULL on failure. |
95 virtual QuicServerInfo* GetForHost(const std::string& hostname) = 0; | 102 virtual QuicServerInfo* GetForHost(const std::string& hostname) = 0; |
96 }; | 103 }; |
97 | 104 |
98 } // namespace net | 105 } // namespace net |
99 | 106 |
100 #endif // NET_QUIC_CRYPTO_QUIC_SERVER_INFO_H_ | 107 #endif // NET_QUIC_CRYPTO_QUIC_SERVER_INFO_H_ |
OLD | NEW |