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

Side by Side Diff: net/http/http_cache.h

Issue 118100: Avoid doing concurrent DNS resolves of the same hostname (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Get compiling on mac Created 11 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 13 matching lines...) Expand all
24 #include "net/base/cache_type.h" 24 #include "net/base/cache_type.h"
25 #include "net/http/http_transaction_factory.h" 25 #include "net/http/http_transaction_factory.h"
26 26
27 namespace disk_cache { 27 namespace disk_cache {
28 class Backend; 28 class Backend;
29 class Entry; 29 class Entry;
30 } 30 }
31 31
32 namespace net { 32 namespace net {
33 33
34 class HostResolver;
34 class HttpNetworkSession; 35 class HttpNetworkSession;
35 class HttpRequestInfo; 36 class HttpRequestInfo;
36 class HttpResponseInfo; 37 class HttpResponseInfo;
37 class ProxyService; 38 class ProxyService;
38 39
39 class HttpCache : public HttpTransactionFactory { 40 class HttpCache : public HttpTransactionFactory {
40 public: 41 public:
41 ~HttpCache(); 42 ~HttpCache();
42 43
43 // The cache mode of operation. 44 // The cache mode of operation.
44 enum Mode { 45 enum Mode {
45 // Normal mode just behaves like a standard web cache. 46 // Normal mode just behaves like a standard web cache.
46 NORMAL = 0, 47 NORMAL = 0,
47 // Record mode caches everything for purposes of offline playback. 48 // Record mode caches everything for purposes of offline playback.
48 RECORD, 49 RECORD,
49 // Playback mode replays from a cache without considering any 50 // Playback mode replays from a cache without considering any
50 // standard invalidations. 51 // standard invalidations.
51 PLAYBACK, 52 PLAYBACK,
52 // Disables reads and writes from the cache. 53 // Disables reads and writes from the cache.
53 // Equivalent to setting LOAD_DISABLE_CACHE on every request. 54 // Equivalent to setting LOAD_DISABLE_CACHE on every request.
54 DISABLE 55 DISABLE
55 }; 56 };
56 57
57 // Initialize the cache from the directory where its data is stored. The 58 // Initialize the cache from the directory where its data is stored. The
58 // disk cache is initialized lazily (by CreateTransaction) in this case. If 59 // disk cache is initialized lazily (by CreateTransaction) in this case. If
59 // |cache_size| is zero, a default value will be calculated automatically. 60 // |cache_size| is zero, a default value will be calculated automatically.
60 HttpCache(ProxyService* proxy_service, 61 HttpCache(HostResolver* host_resolver,
62 ProxyService* proxy_service,
61 const std::wstring& cache_dir, 63 const std::wstring& cache_dir,
62 int cache_size); 64 int cache_size);
63 65
64 // Initialize the cache from the directory where its data is stored. The 66 // Initialize the cache from the directory where its data is stored. The
65 // disk cache is initialized lazily (by CreateTransaction) in this case. If 67 // disk cache is initialized lazily (by CreateTransaction) in this case. If
66 // |cache_size| is zero, a default value will be calculated automatically. 68 // |cache_size| is zero, a default value will be calculated automatically.
67 // Provide an existing HttpNetworkSession, the cache can construct a 69 // Provide an existing HttpNetworkSession, the cache can construct a
68 // network layer with a shared HttpNetworkSession in order for multiple 70 // network layer with a shared HttpNetworkSession in order for multiple
69 // network layers to share information (e.g. authenication data). 71 // network layers to share information (e.g. authenication data).
70 HttpCache(HttpNetworkSession* session, const std::wstring& cache_dir, 72 HttpCache(HttpNetworkSession* session, const std::wstring& cache_dir,
71 int cache_size); 73 int cache_size);
72 74
73 // Initialize using an in-memory cache. The cache is initialized lazily 75 // Initialize using an in-memory cache. The cache is initialized lazily
74 // (by CreateTransaction) in this case. If |cache_size| is zero, a default 76 // (by CreateTransaction) in this case. If |cache_size| is zero, a default
75 // value will be calculated automatically. 77 // value will be calculated automatically.
76 HttpCache(ProxyService* proxy_service, int cache_size); 78 HttpCache(HostResolver* host_resolver,
79 ProxyService* proxy_service,
80 int cache_size);
77 81
78 // Initialize the cache from its component parts, which is useful for 82 // Initialize the cache from its component parts, which is useful for
79 // testing. The lifetime of the network_layer and disk_cache are managed by 83 // testing. The lifetime of the network_layer and disk_cache are managed by
80 // the HttpCache and will be destroyed using |delete| when the HttpCache is 84 // the HttpCache and will be destroyed using |delete| when the HttpCache is
81 // destroyed. 85 // destroyed.
82 HttpCache(HttpTransactionFactory* network_layer, 86 HttpCache(HttpTransactionFactory* network_layer,
83 disk_cache::Backend* disk_cache); 87 disk_cache::Backend* disk_cache);
84 88
85 HttpTransactionFactory* network_layer() { return network_layer_.get(); } 89 HttpTransactionFactory* network_layer() { return network_layer_.get(); }
86 disk_cache::Backend* disk_cache() { return disk_cache_.get(); } 90 disk_cache::Backend* disk_cache() { return disk_cache_.get(); }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 scoped_ptr<PlaybackCacheMap> playback_cache_map_; 189 scoped_ptr<PlaybackCacheMap> playback_cache_map_;
186 190
187 RevocableStore transactions_; 191 RevocableStore transactions_;
188 192
189 DISALLOW_COPY_AND_ASSIGN(HttpCache); 193 DISALLOW_COPY_AND_ASSIGN(HttpCache);
190 }; 194 };
191 195
192 } // namespace net 196 } // namespace net
193 197
194 #endif // NET_HTTP_HTTP_CACHE_H_ 198 #endif // NET_HTTP_HTTP_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698