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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 static const int kPrefetchReuseMins = 5; | 116 static const int kPrefetchReuseMins = 5; |
117 | 117 |
118 // The disk cache is initialized lazily (by CreateTransaction) in this case. | 118 // The disk cache is initialized lazily (by CreateTransaction) in this case. |
119 // Provide an existing HttpNetworkSession, the cache can construct a | 119 // Provide an existing HttpNetworkSession, the cache can construct a |
120 // network layer with a shared HttpNetworkSession in order for multiple | 120 // network layer with a shared HttpNetworkSession in order for multiple |
121 // network layers to share information (e.g. authentication data). The | 121 // network layers to share information (e.g. authentication data). The |
122 // HttpCache takes ownership of the |backend_factory|. | 122 // HttpCache takes ownership of the |backend_factory|. |
123 // | 123 // |
124 // The HttpCache must be destroyed before the HttpNetworkSession. | 124 // The HttpCache must be destroyed before the HttpNetworkSession. |
125 // | 125 // |
126 // If |set_up_quic_server_info| is true, configures the cache to track | 126 // If |is_main_cache| is true, configures the cache to track |
127 // information about servers supporting QUIC. | 127 // information about servers supporting QUIC. |
| 128 // TODO(zhongyi): remove |is_main_cache| when we get rid of cache split. |
128 HttpCache(HttpNetworkSession* session, | 129 HttpCache(HttpNetworkSession* session, |
129 std::unique_ptr<BackendFactory> backend_factory, | 130 std::unique_ptr<BackendFactory> backend_factory, |
130 bool set_up_quic_server_info); | 131 bool is_main_cache); |
131 | 132 |
132 // Initialize the cache from its component parts. |network_layer| and | 133 // Initialize the cache from its component parts. |network_layer| and |
133 // |backend_factory| will be destroyed when the HttpCache is. | 134 // |backend_factory| will be destroyed when the HttpCache is. |
134 HttpCache(std::unique_ptr<HttpTransactionFactory> network_layer, | 135 HttpCache(std::unique_ptr<HttpTransactionFactory> network_layer, |
135 std::unique_ptr<BackendFactory> backend_factory, | 136 std::unique_ptr<BackendFactory> backend_factory, |
136 bool set_up_quic_server_info); | 137 bool is_main_cache); |
137 | 138 |
138 ~HttpCache() override; | 139 ~HttpCache() override; |
139 | 140 |
140 HttpTransactionFactory* network_layer() { return network_layer_.get(); } | 141 HttpTransactionFactory* network_layer() { return network_layer_.get(); } |
141 | 142 |
142 // Retrieves the cache backend for this HttpCache instance. If the backend | 143 // Retrieves the cache backend for this HttpCache instance. If the backend |
143 // is not initialized yet, this method will initialize it. The return value is | 144 // is not initialized yet, this method will initialize it. The return value is |
144 // a network error code, and it could be ERR_IO_PENDING, in which case the | 145 // a network error code, and it could be ERR_IO_PENDING, in which case the |
145 // |callback| will be notified when the operation completes. The pointer that | 146 // |callback| will be notified when the operation completes. The pointer that |
146 // receives the |backend| must remain valid until the operation completes. | 147 // receives the |backend| must remain valid until the operation completes. |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 std::unique_ptr<base::Clock> clock_; | 424 std::unique_ptr<base::Clock> clock_; |
424 | 425 |
425 base::WeakPtrFactory<HttpCache> weak_factory_; | 426 base::WeakPtrFactory<HttpCache> weak_factory_; |
426 | 427 |
427 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 428 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
428 }; | 429 }; |
429 | 430 |
430 } // namespace net | 431 } // namespace net |
431 | 432 |
432 #endif // NET_HTTP_HTTP_CACHE_H_ | 433 #endif // NET_HTTP_HTTP_CACHE_H_ |
OLD | NEW |