OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This file declares a HttpTransactionFactory implementation that can be | 5 // This file declares a HttpTransactionFactory implementation that can be |
6 // layered on top of another HttpTransactionFactory to add HTTP caching. The | 6 // layered on top of another HttpTransactionFactory to add HTTP caching. The |
7 // caching logic follows RFC 7234 (any exceptions are called out in the code). | 7 // caching logic follows RFC 7234 (any exceptions are called out in the code). |
8 // | 8 // |
9 // The HttpCache takes a disk_cache::Backend as a parameter, and uses that for | 9 // The HttpCache takes a disk_cache::Backend as a parameter, and uses that for |
10 // the cache storage. | 10 // the cache storage. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 const base::FilePath path_; | 119 const base::FilePath path_; |
120 int max_bytes_; | 120 int max_bytes_; |
121 scoped_refptr<base::SingleThreadTaskRunner> thread_; | 121 scoped_refptr<base::SingleThreadTaskRunner> thread_; |
122 }; | 122 }; |
123 | 123 |
124 // The number of minutes after a resource is prefetched that it can be used | 124 // The number of minutes after a resource is prefetched that it can be used |
125 // again without validation. | 125 // again without validation. |
126 static const int kPrefetchReuseMins = 5; | 126 static const int kPrefetchReuseMins = 5; |
127 | 127 |
128 // The disk cache is initialized lazily (by CreateTransaction) in this case. | 128 // The disk cache is initialized lazily (by CreateTransaction) in this case. |
129 // The HttpCache takes ownership of the |backend_factory|. | |
130 HttpCache(const HttpNetworkSession::Params& params, | |
131 BackendFactory* backend_factory); | |
132 | |
133 // The disk cache is initialized lazily (by CreateTransaction) in this case. | |
134 // Provide an existing HttpNetworkSession, the cache can construct a | 129 // Provide an existing HttpNetworkSession, the cache can construct a |
135 // network layer with a shared HttpNetworkSession in order for multiple | 130 // network layer with a shared HttpNetworkSession in order for multiple |
136 // network layers to share information (e.g. authentication data). The | 131 // network layers to share information (e.g. authentication data). The |
137 // HttpCache takes ownership of the |backend_factory|. | 132 // HttpCache takes ownership of the |backend_factory|. |
138 HttpCache(HttpNetworkSession* session, BackendFactory* backend_factory); | 133 // |
134 // The HttpCache must be destroyed before the HttpNetworkSession. | |
135 // | |
136 // If |set_up_quic_server_info| is true, configures the cache to track | |
137 // information about which servers support SPDY. | |
pauljensen
2015/09/02 14:32:29
SPDY->QUIC
mmenke
2015/09/02 16:29:34
Done.
| |
138 HttpCache(HttpNetworkSession* session, | |
139 BackendFactory* backend_factory, | |
pauljensen
2015/09/02 14:32:29
should be a scoped_ptr...for another CL.
mmenke
2015/09/02 16:29:34
Almost did it in this CL, but just got too massive
| |
140 bool set_up_quic_server_info); | |
139 | 141 |
140 // Initialize the cache from its component parts. The lifetime of the | 142 // Initialize the cache from its component parts. The lifetime of the |
141 // |network_layer| and |backend_factory| are managed by the HttpCache and | 143 // |network_layer| and |backend_factory| are managed by the HttpCache and |
142 // will be destroyed using |delete| when the HttpCache is destroyed. | 144 // will be destroyed using |delete| when the HttpCache is destroyed. |
143 HttpCache(HttpTransactionFactory* network_layer, | 145 HttpCache(HttpTransactionFactory* network_layer, |
pauljensen
2015/09/02 14:32:29
ditto
mmenke
2015/09/02 16:29:34
Acknowledged.
| |
144 NetLog* net_log, | 146 NetLog* net_log, |
145 BackendFactory* backend_factory); | 147 BackendFactory* backend_factory, |
pauljensen
2015/09/02 14:32:29
ditto
mmenke
2015/09/02 16:29:33
Acknowledged.
| |
148 bool set_up_quic_server_info); | |
146 | 149 |
147 ~HttpCache() override; | 150 ~HttpCache() override; |
148 | 151 |
149 HttpTransactionFactory* network_layer() { return network_layer_.get(); } | 152 HttpTransactionFactory* network_layer() { return network_layer_.get(); } |
150 | 153 |
151 DiskBasedCertCache* cert_cache() const { return cert_cache_.get(); } | 154 DiskBasedCertCache* cert_cache() const { return cert_cache_.get(); } |
152 | 155 |
153 // Retrieves the cache backend for this HttpCache instance. If the backend | 156 // Retrieves the cache backend for this HttpCache instance. If the backend |
154 // is not initialized yet, this method will initialize it. The return value is | 157 // is not initialized yet, this method will initialize it. The return value is |
155 // a network error code, and it could be ERR_IO_PENDING, in which case the | 158 // a network error code, and it could be ERR_IO_PENDING, in which case the |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
441 scoped_ptr<base::Clock> clock_; | 444 scoped_ptr<base::Clock> clock_; |
442 | 445 |
443 base::WeakPtrFactory<HttpCache> weak_factory_; | 446 base::WeakPtrFactory<HttpCache> weak_factory_; |
444 | 447 |
445 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 448 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
446 }; | 449 }; |
447 | 450 |
448 } // namespace net | 451 } // namespace net |
449 | 452 |
450 #endif // NET_HTTP_HTTP_CACHE_H_ | 453 #endif // NET_HTTP_HTTP_CACHE_H_ |
OLD | NEW |