| OLD | NEW |
| 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 7234 (any exceptions are called out in the code). | 7 // caching logic follows RFC 7234 (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 20 matching lines...) Expand all Loading... |
| 31 #include "net/base/load_states.h" | 31 #include "net/base/load_states.h" |
| 32 #include "net/base/net_export.h" | 32 #include "net/base/net_export.h" |
| 33 #include "net/base/request_priority.h" | 33 #include "net/base/request_priority.h" |
| 34 #include "net/http/http_network_session.h" | 34 #include "net/http/http_network_session.h" |
| 35 #include "net/http/http_transaction_factory.h" | 35 #include "net/http/http_transaction_factory.h" |
| 36 | 36 |
| 37 class GURL; | 37 class GURL; |
| 38 | 38 |
| 39 namespace base { | 39 namespace base { |
| 40 class SingleThreadTaskRunner; | 40 class SingleThreadTaskRunner; |
| 41 namespace trace_event { |
| 42 class ProcessMemoryDump; |
| 43 } |
| 41 } // namespace base | 44 } // namespace base |
| 42 | 45 |
| 43 namespace disk_cache { | 46 namespace disk_cache { |
| 44 class Backend; | 47 class Backend; |
| 45 class Entry; | 48 class Entry; |
| 46 } // namespace disk_cache | 49 } // namespace disk_cache |
| 47 | 50 |
| 48 namespace net { | 51 namespace net { |
| 49 | 52 |
| 50 class HttpNetworkSession; | 53 class HttpNetworkSession; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 base::WeakPtr<HttpCache> GetWeakPtr() { return weak_factory_.GetWeakPtr(); } | 212 base::WeakPtr<HttpCache> GetWeakPtr() { return weak_factory_.GetWeakPtr(); } |
| 210 | 213 |
| 211 // Resets the network layer to allow for tests that probe | 214 // Resets the network layer to allow for tests that probe |
| 212 // network changes (e.g. host unreachable). The old network layer is | 215 // network changes (e.g. host unreachable). The old network layer is |
| 213 // returned to allow for filter patterns that only intercept | 216 // returned to allow for filter patterns that only intercept |
| 214 // some creation requests. Note ownership exchange. | 217 // some creation requests. Note ownership exchange. |
| 215 std::unique_ptr<HttpTransactionFactory> | 218 std::unique_ptr<HttpTransactionFactory> |
| 216 SetHttpNetworkTransactionFactoryForTesting( | 219 SetHttpNetworkTransactionFactoryForTesting( |
| 217 std::unique_ptr<HttpTransactionFactory> new_network_layer); | 220 std::unique_ptr<HttpTransactionFactory> new_network_layer); |
| 218 | 221 |
| 222 // Dumps memory allocation stats. |parent_dump_absolute_name| is the name |
| 223 // used by the parent MemoryAllocatorDump in the memory dump hierarchy. |
| 224 void DumpMemoryStats(base::trace_event::ProcessMemoryDump* pmd, |
| 225 const std::string& parent_absolute_name) const; |
| 226 |
| 219 private: | 227 private: |
| 220 // Types -------------------------------------------------------------------- | 228 // Types -------------------------------------------------------------------- |
| 221 | 229 |
| 222 // Disk cache entry data indices. | 230 // Disk cache entry data indices. |
| 223 enum { | 231 enum { |
| 224 kResponseInfoIndex = 0, | 232 kResponseInfoIndex = 0, |
| 225 kResponseContentIndex, | 233 kResponseContentIndex, |
| 226 kMetadataIndex, | 234 kMetadataIndex, |
| 227 | 235 |
| 228 // Must remain at the end of the enum. | 236 // Must remain at the end of the enum. |
| 229 kNumCacheEntryDataIndices | 237 kNumCacheEntryDataIndices |
| 230 }; | 238 }; |
| 231 | 239 |
| 232 class MetadataWriter; | 240 class MetadataWriter; |
| 233 class QuicServerInfoFactoryAdaptor; | 241 class QuicServerInfoFactoryAdaptor; |
| 234 class Transaction; | 242 class Transaction; |
| 235 class WorkItem; | 243 class WorkItem; |
| 236 friend class Transaction; | 244 friend class Transaction; |
| 237 friend class ViewCacheHelper; | 245 friend class ViewCacheHelper; |
| 238 struct PendingOp; // Info for an entry under construction. | 246 struct PendingOp; // Info for an entry under construction. |
| 239 | 247 |
| 240 typedef std::list<Transaction*> TransactionList; | 248 typedef std::list<Transaction*> TransactionList; |
| 241 typedef std::list<std::unique_ptr<WorkItem>> WorkItemList; | 249 typedef std::list<std::unique_ptr<WorkItem>> WorkItemList; |
| 242 | 250 |
| 243 struct ActiveEntry { | 251 struct ActiveEntry { |
| 244 explicit ActiveEntry(disk_cache::Entry* entry); | 252 explicit ActiveEntry(disk_cache::Entry* entry); |
| 245 ~ActiveEntry(); | 253 ~ActiveEntry(); |
| 254 // Returns the estimate of dynamically allocated memory in bytes. |
| 255 size_t EstimateMemoryUsage() const; |
| 246 | 256 |
| 247 disk_cache::Entry* disk_entry; | 257 disk_cache::Entry* disk_entry; |
| 248 Transaction* writer; | 258 Transaction* writer; |
| 249 TransactionList readers; | 259 TransactionList readers; |
| 250 TransactionList pending_queue; | 260 TransactionList pending_queue; |
| 251 bool will_process_pending_queue; | 261 bool will_process_pending_queue; |
| 252 bool doomed; | 262 bool doomed; |
| 253 }; | 263 }; |
| 254 | 264 |
| 255 using ActiveEntriesMap = | 265 using ActiveEntriesMap = |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 std::unique_ptr<base::Clock> clock_; | 433 std::unique_ptr<base::Clock> clock_; |
| 424 | 434 |
| 425 base::WeakPtrFactory<HttpCache> weak_factory_; | 435 base::WeakPtrFactory<HttpCache> weak_factory_; |
| 426 | 436 |
| 427 DISALLOW_COPY_AND_ASSIGN(HttpCache); | 437 DISALLOW_COPY_AND_ASSIGN(HttpCache); |
| 428 }; | 438 }; |
| 429 | 439 |
| 430 } // namespace net | 440 } // namespace net |
| 431 | 441 |
| 432 #endif // NET_HTTP_HTTP_CACHE_H_ | 442 #endif // NET_HTTP_HTTP_CACHE_H_ |
| OLD | NEW |