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

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

Issue 667923003: Standardize usage of virtual/override/final in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « net/http/http_basic_stream.h ('k') | net/http/http_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 class NET_EXPORT DefaultBackend : public BackendFactory { 101 class NET_EXPORT DefaultBackend : public BackendFactory {
102 public: 102 public:
103 // |path| is the destination for any files used by the backend, and 103 // |path| is the destination for any files used by the backend, and
104 // |thread| is the thread where disk operations should take place. If 104 // |thread| is the thread where disk operations should take place. If
105 // |max_bytes| is zero, a default value will be calculated automatically. 105 // |max_bytes| is zero, a default value will be calculated automatically.
106 DefaultBackend(CacheType type, 106 DefaultBackend(CacheType type,
107 BackendType backend_type, 107 BackendType backend_type,
108 const base::FilePath& path, 108 const base::FilePath& path,
109 int max_bytes, 109 int max_bytes,
110 const scoped_refptr<base::SingleThreadTaskRunner>& thread); 110 const scoped_refptr<base::SingleThreadTaskRunner>& thread);
111 virtual ~DefaultBackend(); 111 ~DefaultBackend() override;
112 112
113 // Returns a factory for an in-memory cache. 113 // Returns a factory for an in-memory cache.
114 static BackendFactory* InMemory(int max_bytes); 114 static BackendFactory* InMemory(int max_bytes);
115 115
116 // BackendFactory implementation. 116 // BackendFactory implementation.
117 virtual int CreateBackend(NetLog* net_log, 117 int CreateBackend(NetLog* net_log,
118 scoped_ptr<disk_cache::Backend>* backend, 118 scoped_ptr<disk_cache::Backend>* backend,
119 const CompletionCallback& callback) override; 119 const CompletionCallback& callback) override;
120 120
121 private: 121 private:
122 CacheType type_; 122 CacheType type_;
123 BackendType backend_type_; 123 BackendType backend_type_;
124 const base::FilePath path_; 124 const base::FilePath path_;
125 int max_bytes_; 125 int max_bytes_;
126 scoped_refptr<base::SingleThreadTaskRunner> thread_; 126 scoped_refptr<base::SingleThreadTaskRunner> thread_;
127 }; 127 };
128 128
129 // The disk cache is initialized lazily (by CreateTransaction) in this case. 129 // The disk cache is initialized lazily (by CreateTransaction) in this case.
130 // The HttpCache takes ownership of the |backend_factory|. 130 // The HttpCache takes ownership of the |backend_factory|.
131 HttpCache(const net::HttpNetworkSession::Params& params, 131 HttpCache(const net::HttpNetworkSession::Params& params,
132 BackendFactory* backend_factory); 132 BackendFactory* backend_factory);
133 133
134 // The disk cache is initialized lazily (by CreateTransaction) in this case. 134 // The disk cache is initialized lazily (by CreateTransaction) in this case.
135 // Provide an existing HttpNetworkSession, the cache can construct a 135 // Provide an existing HttpNetworkSession, the cache can construct a
136 // network layer with a shared HttpNetworkSession in order for multiple 136 // network layer with a shared HttpNetworkSession in order for multiple
137 // network layers to share information (e.g. authentication data). The 137 // network layers to share information (e.g. authentication data). The
138 // HttpCache takes ownership of the |backend_factory|. 138 // HttpCache takes ownership of the |backend_factory|.
139 HttpCache(HttpNetworkSession* session, BackendFactory* backend_factory); 139 HttpCache(HttpNetworkSession* session, BackendFactory* backend_factory);
140 140
141 // Initialize the cache from its component parts. The lifetime of the 141 // Initialize the cache from its component parts. The lifetime of the
142 // |network_layer| and |backend_factory| are managed by the HttpCache and 142 // |network_layer| and |backend_factory| are managed by the HttpCache and
143 // will be destroyed using |delete| when the HttpCache is destroyed. 143 // will be destroyed using |delete| when the HttpCache is destroyed.
144 HttpCache(HttpTransactionFactory* network_layer, 144 HttpCache(HttpTransactionFactory* network_layer,
145 NetLog* net_log, 145 NetLog* net_log,
146 BackendFactory* backend_factory); 146 BackendFactory* backend_factory);
147 147
148 virtual ~HttpCache(); 148 ~HttpCache() override;
149 149
150 HttpTransactionFactory* network_layer() { return network_layer_.get(); } 150 HttpTransactionFactory* network_layer() { return network_layer_.get(); }
151 151
152 DiskBasedCertCache* cert_cache() const { return cert_cache_.get(); } 152 DiskBasedCertCache* cert_cache() const { return cert_cache_.get(); }
153 153
154 // Retrieves the cache backend for this HttpCache instance. If the backend 154 // Retrieves the cache backend for this HttpCache instance. If the backend
155 // is not initialized yet, this method will initialize it. The return value is 155 // is not initialized yet, this method will initialize it. The return value is
156 // a network error code, and it could be ERR_IO_PENDING, in which case the 156 // a network error code, and it could be ERR_IO_PENDING, in which case the
157 // |callback| will be notified when the operation completes. The pointer that 157 // |callback| will be notified when the operation completes. The pointer that
158 // receives the |backend| must remain valid until the operation completes. 158 // receives the |backend| must remain valid until the operation completes.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 return use_stale_while_revalidate_; 206 return use_stale_while_revalidate_;
207 } 207 }
208 208
209 // Enable stale_while_revalidate functionality for testing purposes. 209 // Enable stale_while_revalidate functionality for testing purposes.
210 void set_use_stale_while_revalidate_for_testing( 210 void set_use_stale_while_revalidate_for_testing(
211 bool use_stale_while_revalidate) { 211 bool use_stale_while_revalidate) {
212 use_stale_while_revalidate_ = use_stale_while_revalidate; 212 use_stale_while_revalidate_ = use_stale_while_revalidate;
213 } 213 }
214 214
215 // HttpTransactionFactory implementation: 215 // HttpTransactionFactory implementation:
216 virtual int CreateTransaction(RequestPriority priority, 216 int CreateTransaction(RequestPriority priority,
217 scoped_ptr<HttpTransaction>* trans) override; 217 scoped_ptr<HttpTransaction>* trans) override;
218 virtual HttpCache* GetCache() override; 218 HttpCache* GetCache() override;
219 virtual HttpNetworkSession* GetSession() override; 219 HttpNetworkSession* GetSession() override;
220 220
221 base::WeakPtr<HttpCache> GetWeakPtr() { return weak_factory_.GetWeakPtr(); } 221 base::WeakPtr<HttpCache> GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
222 222
223 // Resets the network layer to allow for tests that probe 223 // Resets the network layer to allow for tests that probe
224 // network changes (e.g. host unreachable). The old network layer is 224 // network changes (e.g. host unreachable). The old network layer is
225 // returned to allow for filter patterns that only intercept 225 // returned to allow for filter patterns that only intercept
226 // some creation requests. Note ownership exchange. 226 // some creation requests. Note ownership exchange.
227 scoped_ptr<HttpTransactionFactory> 227 scoped_ptr<HttpTransactionFactory>
228 SetHttpNetworkTransactionFactoryForTesting( 228 SetHttpNetworkTransactionFactoryForTesting(
229 scoped_ptr<HttpTransactionFactory> new_network_layer); 229 scoped_ptr<HttpTransactionFactory> new_network_layer);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 AsyncValidationMap async_validations_; 456 AsyncValidationMap async_validations_;
457 457
458 base::WeakPtrFactory<HttpCache> weak_factory_; 458 base::WeakPtrFactory<HttpCache> weak_factory_;
459 459
460 DISALLOW_COPY_AND_ASSIGN(HttpCache); 460 DISALLOW_COPY_AND_ASSIGN(HttpCache);
461 }; 461 };
462 462
463 } // namespace net 463 } // namespace net
464 464
465 #endif // NET_HTTP_HTTP_CACHE_H_ 465 #endif // NET_HTTP_HTTP_CACHE_H_
OLDNEW
« no previous file with comments | « net/http/http_basic_stream.h ('k') | net/http/http_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698