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

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

Issue 182993003: Add the ability for DevTools to wrap network transactions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 6 years, 7 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) 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // Provide an existing HttpNetworkSession, the cache can construct a 129 // Provide an existing HttpNetworkSession, the cache can construct a
130 // network layer with a shared HttpNetworkSession in order for multiple 130 // network layer with a shared HttpNetworkSession in order for multiple
131 // network layers to share information (e.g. authentication data). The 131 // network layers to share information (e.g. authentication data). The
132 // HttpCache takes ownership of the |backend_factory|. 132 // HttpCache takes ownership of the |backend_factory|.
133 HttpCache(HttpNetworkSession* session, BackendFactory* backend_factory); 133 HttpCache(HttpNetworkSession* session, BackendFactory* backend_factory);
134 134
135 // Initialize the cache from its component parts, which is useful for 135 // Initialize the cache from its component parts, which is useful for
136 // testing. The lifetime of the network_layer and backend_factory are managed 136 // testing. The lifetime of the network_layer and backend_factory are managed
137 // by the HttpCache and will be destroyed using |delete| when the HttpCache is 137 // by the HttpCache and will be destroyed using |delete| when the HttpCache is
138 // destroyed. 138 // destroyed.
139 HttpCache(HttpTransactionFactory* network_layer, 139 HttpCache(HttpTransactionFactory* network_layer,
rvargas (doing something else) 2014/04/29 23:40:45 This constructor is intended for unit tests but it
eustas 2014/05/07 13:47:17 It is possible to remove constructor that takes pa
rvargas (doing something else) 2014/05/07 20:22:57 I don't have an issue with tests using the same co
140 NetLog* net_log, 140 NetLog* net_log,
141 BackendFactory* backend_factory); 141 BackendFactory* backend_factory,
142 bool setup_network_session);
rvargas (doing something else) 2014/04/29 23:40:45 It is not clear how a caller should know what to p
eustas 2014/05/07 13:47:17 Reverted.
142 143
143 virtual ~HttpCache(); 144 virtual ~HttpCache();
144 145
145 HttpTransactionFactory* network_layer() { return network_layer_.get(); } 146 HttpTransactionFactory* network_layer() { return network_layer_.get(); }
146 147
147 // Retrieves the cache backend for this HttpCache instance. If the backend 148 // Retrieves the cache backend for this HttpCache instance. If the backend
148 // is not initialized yet, this method will initialize it. The return value is 149 // is not initialized yet, this method will initialize it. The return value is
149 // a network error code, and it could be ERR_IO_PENDING, in which case the 150 // a network error code, and it could be ERR_IO_PENDING, in which case the
150 // |callback| will be notified when the operation completes. The pointer that 151 // |callback| will be notified when the operation completes. The pointer that
151 // receives the |backend| must remain valid until the operation completes. 152 // receives the |backend| must remain valid until the operation completes.
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 void RemovePendingTransaction(Transaction* trans); 348 void RemovePendingTransaction(Transaction* trans);
348 349
349 // Removes the transaction |trans|, from the pending list of |entry|. 350 // Removes the transaction |trans|, from the pending list of |entry|.
350 bool RemovePendingTransactionFromEntry(ActiveEntry* entry, 351 bool RemovePendingTransactionFromEntry(ActiveEntry* entry,
351 Transaction* trans); 352 Transaction* trans);
352 353
353 // Removes the transaction |trans|, from the pending list of |pending_op|. 354 // Removes the transaction |trans|, from the pending list of |pending_op|.
354 bool RemovePendingTransactionFromPendingOp(PendingOp* pending_op, 355 bool RemovePendingTransactionFromPendingOp(PendingOp* pending_op,
355 Transaction* trans); 356 Transaction* trans);
356 357
358 // Instantiates and sets QUIC server info factory. Should be invoked only
359 // once for every network session.
360 void SetupNetworkSession(HttpNetworkSession* session);
rvargas (doing something else) 2014/04/29 23:40:45 If what this does is to configure quick server inf
eustas 2014/05/07 13:47:17 Done.
361
357 // Resumes processing the pending list of |entry|. 362 // Resumes processing the pending list of |entry|.
358 void ProcessPendingQueue(ActiveEntry* entry); 363 void ProcessPendingQueue(ActiveEntry* entry);
359 364
360 // Events (called via PostTask) --------------------------------------------- 365 // Events (called via PostTask) ---------------------------------------------
361 366
362 void OnProcessPendingQueue(ActiveEntry* entry); 367 void OnProcessPendingQueue(ActiveEntry* entry);
363 368
364 // Callbacks ---------------------------------------------------------------- 369 // Callbacks ----------------------------------------------------------------
365 370
366 // Processes BackendCallback notifications. 371 // Processes BackendCallback notifications.
(...skipping 15 matching lines...) Expand all
382 // Variables ---------------------------------------------------------------- 387 // Variables ----------------------------------------------------------------
383 388
384 NetLog* net_log_; 389 NetLog* net_log_;
385 390
386 // Used when lazily constructing the disk_cache_. 391 // Used when lazily constructing the disk_cache_.
387 scoped_ptr<BackendFactory> backend_factory_; 392 scoped_ptr<BackendFactory> backend_factory_;
388 bool building_backend_; 393 bool building_backend_;
389 394
390 Mode mode_; 395 Mode mode_;
391 396
392 const scoped_ptr<QuicServerInfoFactoryAdaptor> quic_server_info_factory_; 397 scoped_ptr<QuicServerInfoFactoryAdaptor> quic_server_info_factory_;
393 398
394 scoped_ptr<HttpTransactionFactory> network_layer_; 399 scoped_ptr<HttpTransactionFactory> network_layer_;
395 400
396 scoped_ptr<disk_cache::Backend> disk_cache_; 401 scoped_ptr<disk_cache::Backend> disk_cache_;
397 402
398 // The set of active entries indexed by cache key. 403 // The set of active entries indexed by cache key.
399 ActiveEntriesMap active_entries_; 404 ActiveEntriesMap active_entries_;
400 405
401 // The set of doomed entries. 406 // The set of doomed entries.
402 ActiveEntriesSet doomed_entries_; 407 ActiveEntriesSet doomed_entries_;
403 408
404 // The set of entries "under construction". 409 // The set of entries "under construction".
405 PendingOpsMap pending_ops_; 410 PendingOpsMap pending_ops_;
406 411
407 scoped_ptr<PlaybackCacheMap> playback_cache_map_; 412 scoped_ptr<PlaybackCacheMap> playback_cache_map_;
408 413
409 DISALLOW_COPY_AND_ASSIGN(HttpCache); 414 DISALLOW_COPY_AND_ASSIGN(HttpCache);
410 }; 415 };
411 416
412 } // namespace net 417 } // namespace net
413 418
414 #endif // NET_HTTP_HTTP_CACHE_H_ 419 #endif // NET_HTTP_HTTP_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698