| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 2616 (any exceptions are called out in the code). | 7 // caching logic follows RFC 2616 (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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 // Get/Set the cache's mode. | 173 // Get/Set the cache's mode. |
| 174 void set_mode(Mode value) { mode_ = value; } | 174 void set_mode(Mode value) { mode_ = value; } |
| 175 Mode mode() { return mode_; } | 175 Mode mode() { return mode_; } |
| 176 | 176 |
| 177 // Close currently active sockets so that fresh page loads will not use any | 177 // Close currently active sockets so that fresh page loads will not use any |
| 178 // recycled connections. For sockets currently in use, they may not close | 178 // recycled connections. For sockets currently in use, they may not close |
| 179 // immediately, but they will not be reusable. This is for debugging. | 179 // immediately, but they will not be reusable. This is for debugging. |
| 180 void CloseAllConnections(); | 180 void CloseAllConnections(); |
| 181 | 181 |
| 182 // Called whenever an external cache in the system reuses the resource |
| 183 // referred to by |url| and |http_method|. |
| 184 void OnExternalCacheHit(const GURL& url, const std::string& http_method); |
| 185 |
| 182 // HttpTransactionFactory implementation: | 186 // HttpTransactionFactory implementation: |
| 183 virtual int CreateTransaction(scoped_ptr<HttpTransaction>* trans); | 187 virtual int CreateTransaction(scoped_ptr<HttpTransaction>* trans); |
| 184 virtual HttpCache* GetCache(); | 188 virtual HttpCache* GetCache(); |
| 185 virtual HttpNetworkSession* GetSession(); | 189 virtual HttpNetworkSession* GetSession(); |
| 186 | 190 |
| 187 protected: | 191 protected: |
| 188 // Disk cache entry data indices. | 192 // Disk cache entry data indices. |
| 189 enum { | 193 enum { |
| 190 kResponseInfoIndex = 0, | 194 kResponseInfoIndex = 0, |
| 191 kResponseContentIndex, | 195 kResponseContentIndex, |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 void OnProcessPendingQueue(ActiveEntry* entry); | 342 void OnProcessPendingQueue(ActiveEntry* entry); |
| 339 | 343 |
| 340 // Callbacks ---------------------------------------------------------------- | 344 // Callbacks ---------------------------------------------------------------- |
| 341 | 345 |
| 342 // Processes BackendCallback notifications. | 346 // Processes BackendCallback notifications. |
| 343 void OnIOComplete(int result, PendingOp* entry); | 347 void OnIOComplete(int result, PendingOp* entry); |
| 344 | 348 |
| 345 // Processes the backend creation notification. | 349 // Processes the backend creation notification. |
| 346 void OnBackendCreated(int result, PendingOp* pending_op); | 350 void OnBackendCreated(int result, PendingOp* pending_op); |
| 347 | 351 |
| 348 | |
| 349 // Variables ---------------------------------------------------------------- | 352 // Variables ---------------------------------------------------------------- |
| 350 | 353 |
| 351 NetLog* net_log_; | 354 NetLog* net_log_; |
| 352 | 355 |
| 353 // Used when lazily constructing the disk_cache_. | 356 // Used when lazily constructing the disk_cache_. |
| 354 scoped_ptr<BackendFactory> backend_factory_; | 357 scoped_ptr<BackendFactory> backend_factory_; |
| 355 bool building_backend_; | 358 bool building_backend_; |
| 356 | 359 |
| 357 Mode mode_; | 360 Mode mode_; |
| 358 | 361 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 373 ScopedRunnableMethodFactory<HttpCache> task_factory_; | 376 ScopedRunnableMethodFactory<HttpCache> task_factory_; |
| 374 | 377 |
| 375 scoped_ptr<PlaybackCacheMap> playback_cache_map_; | 378 scoped_ptr<PlaybackCacheMap> playback_cache_map_; |
| 376 | 379 |
| 377 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 380 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
| 378 }; | 381 }; |
| 379 | 382 |
| 380 } // namespace net | 383 } // namespace net |
| 381 | 384 |
| 382 #endif // NET_HTTP_HTTP_CACHE_H_ | 385 #endif // NET_HTTP_HTTP_CACHE_H_ |
| OLD | NEW |