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 if data is loaded from disk cache and ready (WaitForDataReady | |
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 void SetConfigData(std::string* server_config, |
wtc
2014/02/19 02:24:11
This function name is confusing.
| |
61 std::vector<std::string> data; | 65 std::string* source_address_token, |
66 std::vector<std::string>* certs, | |
67 std::string* server_config_sig); | |
68 | |
69 // This class matches QuicClientCryptoConfig::CachedState. | |
70 std::string* server_config; // A serialized handshake message. | |
71 std::string* source_address_token; // An opaque proof of IP ownership. | |
72 std::vector<std::string>* certs; // A list of certificates in leaf-first | |
73 // order. | |
74 std::string* server_config_sig; // A signature of |server_config_|. | |
62 | 75 |
63 private: | 76 private: |
64 DISALLOW_COPY_AND_ASSIGN(State); | 77 DISALLOW_COPY_AND_ASSIGN(State); |
65 }; | 78 }; |
66 | 79 |
67 // Once the data is ready, it can be read using the following members. These | 80 // Once the data is ready, it can be read using the following members. These |
68 // members can then be updated before calling |Persist|. | 81 // members can then be updated before calling |Persist|. |
69 const State& state() const; | 82 const State& state() const; |
70 State* mutable_state(); | 83 State* mutable_state(); |
71 | 84 |
72 protected: | 85 protected: |
73 // Parse parses an opaque blob of data and fills out the public member fields | 86 // 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 | 87 // object. It returns true iff the parse was successful. The public member |
75 // member fields will be set to something sane in any case. | 88 // fields will be set to something sane in any case. |
76 bool Parse(const std::string& data); | 89 bool Parse(const std::string& data); |
77 std::string Serialize() const; | 90 std::string Serialize() const; |
78 State state_; | 91 State state_; |
79 | 92 |
80 private: | 93 private: |
81 // ParseInner is a helper function for Parse. | 94 // ParseInner is a helper function for Parse. |
82 bool ParseInner(const std::string& data); | 95 bool ParseInner(const std::string& data); |
83 | 96 |
84 // This is the QUIC server hostname for which we restore the crypto_config. | 97 // This is the QUIC server hostname for which we restore the crypto_config. |
85 const std::string hostname_; | 98 const std::string hostname_; |
86 base::WeakPtrFactory<QuicServerInfo> weak_factory_; | |
87 }; | 99 }; |
88 | 100 |
89 class QuicServerInfoFactory { | 101 class QuicServerInfoFactory { |
90 public: | 102 public: |
91 virtual ~QuicServerInfoFactory(); | 103 virtual ~QuicServerInfoFactory(); |
92 | 104 |
93 // GetForHost returns a fresh, allocated QuicServerInfo for the given | 105 // GetForHost returns a fresh, allocated QuicServerInfo for the given |
94 // hostname or NULL on failure. | 106 // hostname or NULL on failure. |
95 virtual QuicServerInfo* GetForHost(const std::string& hostname) = 0; | 107 virtual QuicServerInfo* GetForHost(const std::string& hostname) = 0; |
96 }; | 108 }; |
97 | 109 |
98 } // namespace net | 110 } // namespace net |
99 | 111 |
100 #endif // NET_QUIC_CRYPTO_QUIC_SERVER_INFO_H_ | 112 #endif // NET_QUIC_CRYPTO_QUIC_SERVER_INFO_H_ |
OLD | NEW |