| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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. |
| 11 // | 11 // |
| 12 // See HttpTransactionFactory and HttpTransaction for more details. | 12 // See HttpTransactionFactory and HttpTransaction for more details. |
| 13 | 13 |
| 14 #ifndef NET_HTTP_HTTP_CACHE_H_ | 14 #ifndef NET_HTTP_HTTP_CACHE_H_ |
| 15 #define NET_HTTP_HTTP_CACHE_H_ | 15 #define NET_HTTP_HTTP_CACHE_H_ |
| 16 | 16 |
| 17 #include <list> | 17 #include <list> |
| 18 #include <set> | 18 #include <set> |
| 19 #include <string> |
| 19 | 20 |
| 20 #include "base/basictypes.h" | 21 #include "base/basictypes.h" |
| 21 #include "base/file_path.h" | 22 #include "base/file_path.h" |
| 22 #include "base/hash_tables.h" | 23 #include "base/hash_tables.h" |
| 23 #include "base/message_loop_proxy.h" | 24 #include "base/message_loop_proxy.h" |
| 24 #include "base/scoped_ptr.h" | 25 #include "base/scoped_ptr.h" |
| 25 #include "base/task.h" | 26 #include "base/task.h" |
| 26 #include "base/weak_ptr.h" | 27 #include "base/weak_ptr.h" |
| 27 #include "net/base/cache_type.h" | 28 #include "net/base/cache_type.h" |
| 28 #include "net/base/completion_callback.h" | 29 #include "net/base/completion_callback.h" |
| 29 #include "net/http/http_transaction_factory.h" | 30 #include "net/http/http_transaction_factory.h" |
| 30 | 31 |
| 31 class GURL; | 32 class GURL; |
| 32 | 33 |
| 33 namespace disk_cache { | 34 namespace disk_cache { |
| 34 class Backend; | 35 class Backend; |
| 35 class Entry; | 36 class Entry; |
| 36 } | 37 } |
| 37 | 38 |
| 38 namespace net { | 39 namespace net { |
| 39 | 40 |
| 40 class HostResolver; | 41 class HostResolver; |
| 41 class HttpAuthHandlerFactory; | 42 class HttpAuthHandlerFactory; |
| 42 class HttpNetworkSession; | 43 class HttpNetworkSession; |
| 43 struct HttpRequestInfo; | 44 struct HttpRequestInfo; |
| 44 class HttpResponseInfo; | 45 class HttpResponseInfo; |
| 45 class IOBuffer; | 46 class IOBuffer; |
| 47 class NetLog; |
| 46 class NetworkChangeNotifier; | 48 class NetworkChangeNotifier; |
| 47 class ProxyService; | 49 class ProxyService; |
| 48 class SSLConfigService; | 50 class SSLConfigService; |
| 49 class ViewCacheHelper; | 51 class ViewCacheHelper; |
| 50 | 52 |
| 51 class HttpCache : public HttpTransactionFactory, | 53 class HttpCache : public HttpTransactionFactory, |
| 52 public base::SupportsWeakPtr<HttpCache> { | 54 public base::SupportsWeakPtr<HttpCache> { |
| 53 public: | 55 public: |
| 54 ~HttpCache(); | 56 ~HttpCache(); |
| 55 | 57 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 int max_bytes_; | 109 int max_bytes_; |
| 108 scoped_refptr<base::MessageLoopProxy> thread_; | 110 scoped_refptr<base::MessageLoopProxy> thread_; |
| 109 }; | 111 }; |
| 110 | 112 |
| 111 // The disk cache is initialized lazily (by CreateTransaction) in this case. | 113 // The disk cache is initialized lazily (by CreateTransaction) in this case. |
| 112 // The HttpCache takes ownership of the |backend_factory|. | 114 // The HttpCache takes ownership of the |backend_factory|. |
| 113 HttpCache(NetworkChangeNotifier* network_change_notifier, | 115 HttpCache(NetworkChangeNotifier* network_change_notifier, |
| 114 HostResolver* host_resolver, ProxyService* proxy_service, | 116 HostResolver* host_resolver, ProxyService* proxy_service, |
| 115 SSLConfigService* ssl_config_service, | 117 SSLConfigService* ssl_config_service, |
| 116 HttpAuthHandlerFactory* http_auth_handler_factory, | 118 HttpAuthHandlerFactory* http_auth_handler_factory, |
| 119 NetLog* net_log, |
| 117 BackendFactory* backend_factory); | 120 BackendFactory* backend_factory); |
| 118 | 121 |
| 119 // The disk cache is initialized lazily (by CreateTransaction) in this case. | 122 // The disk cache is initialized lazily (by CreateTransaction) in this case. |
| 120 // Provide an existing HttpNetworkSession, the cache can construct a | 123 // Provide an existing HttpNetworkSession, the cache can construct a |
| 121 // network layer with a shared HttpNetworkSession in order for multiple | 124 // network layer with a shared HttpNetworkSession in order for multiple |
| 122 // network layers to share information (e.g. authenication data). The | 125 // network layers to share information (e.g. authenication data). The |
| 123 // HttpCache takes ownership of the |backend_factory|. | 126 // HttpCache takes ownership of the |backend_factory|. |
| 124 HttpCache(HttpNetworkSession* session, BackendFactory* backend_factory); | 127 HttpCache(HttpNetworkSession* session, BackendFactory* backend_factory); |
| 125 | 128 |
| 126 // Initialize the cache from its component parts, which is useful for | 129 // Initialize the cache from its component parts, which is useful for |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 | 383 |
| 381 typedef base::hash_map<std::string, int> PlaybackCacheMap; | 384 typedef base::hash_map<std::string, int> PlaybackCacheMap; |
| 382 scoped_ptr<PlaybackCacheMap> playback_cache_map_; | 385 scoped_ptr<PlaybackCacheMap> playback_cache_map_; |
| 383 | 386 |
| 384 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 387 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
| 385 }; | 388 }; |
| 386 | 389 |
| 387 } // namespace net | 390 } // namespace net |
| 388 | 391 |
| 389 #endif // NET_HTTP_HTTP_CACHE_H_ | 392 #endif // NET_HTTP_HTTP_CACHE_H_ |
| OLD | NEW |