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

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

Issue 8794003: base::Bind: Convert disk_cache_based_ssl_host_info. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Test fix. Created 9 years 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) 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 virtual ~HttpCache(); 151 virtual ~HttpCache();
152 152
153 HttpTransactionFactory* network_layer() { return network_layer_.get(); } 153 HttpTransactionFactory* network_layer() { return network_layer_.get(); }
154 154
155 // Retrieves the cache backend for this HttpCache instance. If the backend 155 // Retrieves the cache backend for this HttpCache instance. If the backend
156 // is not initialized yet, this method will initialize it. The return value is 156 // is not initialized yet, this method will initialize it. The return value is
157 // a network error code, and it could be ERR_IO_PENDING, in which case the 157 // a network error code, and it could be ERR_IO_PENDING, in which case the
158 // |callback| will be notified when the operation completes. The pointer that 158 // |callback| will be notified when the operation completes. The pointer that
159 // receives the |backend| must remain valid until the operation completes. 159 // receives the |backend| must remain valid until the operation completes.
160 int GetBackend(disk_cache::Backend** backend, OldCompletionCallback* callback) ; 160 int GetBackend(disk_cache::Backend** backend,
161 const CompletionCallback& callback);
161 162
162 // Returns the current backend (can be NULL). 163 // Returns the current backend (can be NULL).
163 disk_cache::Backend* GetCurrentBackend() const; 164 disk_cache::Backend* GetCurrentBackend() const;
164 165
165 // Given a header data blob, convert it to a response info object. 166 // Given a header data blob, convert it to a response info object.
166 static bool ParseResponseInfo(const char* data, int len, 167 static bool ParseResponseInfo(const char* data, int len,
167 HttpResponseInfo* response_info, 168 HttpResponseInfo* response_info,
168 bool* response_truncated); 169 bool* response_truncated);
169 170
170 // Writes |buf_len| bytes of metadata stored in |buf| to the cache entry 171 // Writes |buf_len| bytes of metadata stored in |buf| to the cache entry
(...skipping 12 matching lines...) Expand all
183 // immediately, but they will not be reusable. This is for debugging. 184 // immediately, but they will not be reusable. This is for debugging.
184 void CloseAllConnections(); 185 void CloseAllConnections();
185 186
186 // Close all idle connections. Will close all sockets not in active use. 187 // Close all idle connections. Will close all sockets not in active use.
187 void CloseIdleConnections(); 188 void CloseIdleConnections();
188 189
189 // Called whenever an external cache in the system reuses the resource 190 // Called whenever an external cache in the system reuses the resource
190 // referred to by |url| and |http_method|. 191 // referred to by |url| and |http_method|.
191 void OnExternalCacheHit(const GURL& url, const std::string& http_method); 192 void OnExternalCacheHit(const GURL& url, const std::string& http_method);
192 193
193 // HttpTransactionFactory implementation: 194 // HttpTransactionFactory implementation.
194 virtual int CreateTransaction(scoped_ptr<HttpTransaction>* trans) OVERRIDE; 195 virtual int CreateTransaction(scoped_ptr<HttpTransaction>* trans) OVERRIDE;
195 virtual HttpCache* GetCache() OVERRIDE; 196 virtual HttpCache* GetCache() OVERRIDE;
196 virtual HttpNetworkSession* GetSession() OVERRIDE; 197 virtual HttpNetworkSession* GetSession() OVERRIDE;
197 198
198 protected: 199 protected:
199 // Disk cache entry data indices. 200 // Disk cache entry data indices.
200 enum { 201 enum {
201 kResponseInfoIndex = 0, 202 kResponseInfoIndex = 0,
202 kResponseContentIndex, 203 kResponseContentIndex,
203 kMetadataIndex, 204 kMetadataIndex,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 typedef base::hash_map<std::string, ActiveEntry*> ActiveEntriesMap; 237 typedef base::hash_map<std::string, ActiveEntry*> ActiveEntriesMap;
237 typedef base::hash_map<std::string, PendingOp*> PendingOpsMap; 238 typedef base::hash_map<std::string, PendingOp*> PendingOpsMap;
238 typedef std::set<ActiveEntry*> ActiveEntriesSet; 239 typedef std::set<ActiveEntry*> ActiveEntriesSet;
239 typedef base::hash_map<std::string, int> PlaybackCacheMap; 240 typedef base::hash_map<std::string, int> PlaybackCacheMap;
240 241
241 // Methods ------------------------------------------------------------------ 242 // Methods ------------------------------------------------------------------
242 243
243 // Creates the |backend| object and notifies the |callback| when the operation 244 // Creates the |backend| object and notifies the |callback| when the operation
244 // completes. Returns an error code. 245 // completes. Returns an error code.
245 int CreateBackend(disk_cache::Backend** backend, 246 int CreateBackend(disk_cache::Backend** backend,
246 OldCompletionCallback* callback); 247 const CompletionCallback& callback);
247 248
248 // Makes sure that the backend creation is complete before allowing the 249 // Makes sure that the backend creation is complete before allowing the
249 // provided transaction to use the object. Returns an error code. |trans| 250 // provided transaction to use the object. Returns an error code. |trans|
250 // will be notified via its IO callback if this method returns ERR_IO_PENDING. 251 // will be notified via its IO callback if this method returns ERR_IO_PENDING.
251 // The transaction is free to use the backend directly at any time after 252 // The transaction is free to use the backend directly at any time after
252 // receiving the notification. 253 // receiving the notification.
253 int GetBackendForTransaction(Transaction* trans); 254 int GetBackendForTransaction(Transaction* trans);
254 255
255 // Generates the cache key for this request. 256 // Generates the cache key for this request.
256 std::string GenerateCacheKey(const HttpRequestInfo*); 257 std::string GenerateCacheKey(const HttpRequestInfo*);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 PendingOpsMap pending_ops_; 382 PendingOpsMap pending_ops_;
382 383
383 scoped_ptr<PlaybackCacheMap> playback_cache_map_; 384 scoped_ptr<PlaybackCacheMap> playback_cache_map_;
384 385
385 DISALLOW_COPY_AND_ASSIGN(HttpCache); 386 DISALLOW_COPY_AND_ASSIGN(HttpCache);
386 }; 387 };
387 388
388 } // namespace net 389 } // namespace net
389 390
390 #endif // NET_HTTP_HTTP_CACHE_H_ 391 #endif // NET_HTTP_HTTP_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698