Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: net/quic/crypto/quic_server_info.h

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/crypto/quic_random_test.cc ('k') | net/quic/crypto/quic_server_info.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NET_QUIC_CRYPTO_QUIC_SERVER_INFO_H_
6 #define NET_QUIC_CRYPTO_QUIC_SERVER_INFO_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/time/time.h"
14 #include "net/base/completion_callback.h"
15 #include "net/base/net_export.h"
16 #include "net/quic/quic_server_id.h"
17
18 namespace net {
19
20 class X509Certificate;
21
22 // QuicServerInfo is an interface for fetching information about a QUIC server.
23 // This information may be stored on disk so does not include keys or other
24 // sensitive information. Primarily it's intended for caching the QUIC server's
25 // crypto config.
26 class NET_EXPORT_PRIVATE QuicServerInfo {
27 public:
28 QuicServerInfo(const QuicServerId& server_id);
29 virtual ~QuicServerInfo();
30
31 // Start will commence the lookup. This must be called before any other
32 // methods. By opportunistically calling this early, it may be possible to
33 // overlap this object's lookup and reduce latency.
34 virtual void Start() = 0;
35
36 // WaitForDataReady returns OK if the fetch of the requested data has
37 // completed. Otherwise it returns ERR_IO_PENDING and will call |callback| on
38 // the current thread when ready.
39 //
40 // Only a single callback can be outstanding at a given time and, in the
41 // event that WaitForDataReady returns OK, it's the caller's responsibility
42 // to delete |callback|.
43 //
44 // |callback| may be NULL, in which case ERR_IO_PENDING may still be returned
45 // but, obviously, a callback will never be made.
46 virtual int WaitForDataReady(const CompletionCallback& callback) = 0;
47
48 // Reset's WaitForDataReady callback. This method shouldn't have any side
49 // effects (could be called even if HttpCache doesn't exist).
50 virtual void ResetWaitForDataReadyCallback() = 0;
51
52 // Cancel's WaitForDataReady callback. |callback| passed in WaitForDataReady
53 // will not be called.
54 virtual void CancelWaitForDataReadyCallback() = 0;
55
56 // Returns true if data is loaded from disk cache and ready (WaitForDataReady
57 // doesn't have a pending callback).
58 virtual bool IsDataReady() = 0;
59
60 // Returns true if the object is ready to persist data, in other words, if
61 // data is loaded from disk cache and ready and there are no pending writes.
62 virtual bool IsReadyToPersist() = 0;
63
64 // Persist allows for the server information to be updated for future users.
65 // This is a fire and forget operation: the caller may drop its reference
66 // from this object and the store operation will still complete. This can
67 // only be called once WaitForDataReady has returned OK or called its
68 // callback.
69 virtual void Persist() = 0;
70
71 // Called whenever an external cache reuses quic server config.
72 virtual void OnExternalCacheHit() = 0;
73
74 struct State {
75 State();
76 ~State();
77
78 void Clear();
79
80 // This class matches QuicClientCryptoConfig::CachedState.
81 std::string server_config; // A serialized handshake message.
82 std::string source_address_token; // An opaque proof of IP ownership.
83 std::vector<std::string> certs; // A list of certificates in leaf-first
84 // order.
85 std::string server_config_sig; // A signature of |server_config_|.
86
87 private:
88 DISALLOW_COPY_AND_ASSIGN(State);
89 };
90
91 // Once the data is ready, it can be read using the following members. These
92 // members can then be updated before calling |Persist|.
93 const State& state() const;
94 State* mutable_state();
95
96 base::TimeTicks wait_for_data_start_time() const {
97 return wait_for_data_start_time_;
98 }
99
100 base::TimeTicks wait_for_data_end_time() const {
101 return wait_for_data_end_time_;
102 }
103
104 protected:
105 // Parse parses pickled data and fills out the public member fields of this
106 // object. It returns true iff the parse was successful. The public member
107 // fields will be set to something sane in any case.
108 bool Parse(const std::string& data);
109 std::string Serialize();
110 State state_;
111
112 // Time when WaitForDataReady was called and when it has finished.
113 base::TimeTicks wait_for_data_start_time_;
114 base::TimeTicks wait_for_data_end_time_;
115
116 private:
117 // ParseInner is a helper function for Parse.
118 bool ParseInner(const std::string& data);
119
120 // SerializeInner is a helper function for Serialize.
121 std::string SerializeInner() const;
122
123 // This is the QUIC server (hostname, port, is_https, privacy_mode) tuple for
124 // which we restore the crypto_config.
125 const QuicServerId server_id_;
126
127 DISALLOW_COPY_AND_ASSIGN(QuicServerInfo);
128 };
129
130 class NET_EXPORT_PRIVATE QuicServerInfoFactory {
131 public:
132 QuicServerInfoFactory() {}
133 virtual ~QuicServerInfoFactory();
134
135 // GetForServer returns a fresh, allocated QuicServerInfo for the given
136 // |server_id| or NULL on failure.
137 virtual QuicServerInfo* GetForServer(const QuicServerId& server_id) = 0;
138
139 DISALLOW_COPY_AND_ASSIGN(QuicServerInfoFactory);
140 };
141
142 } // namespace net
143
144 #endif // NET_QUIC_CRYPTO_QUIC_SERVER_INFO_H_
OLDNEW
« no previous file with comments | « net/quic/crypto/quic_random_test.cc ('k') | net/quic/crypto/quic_server_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698