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

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

Issue 2661333002: Track SimpleCache memory usage in net/ MemoryDumpProvider (Closed)
Patch Set: address comments Created 3 years, 10 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
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 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
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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 base::WeakPtr<HttpCache> GetWeakPtr() { return weak_factory_.GetWeakPtr(); } 211 base::WeakPtr<HttpCache> GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
209 212
210 // Resets the network layer to allow for tests that probe 213 // Resets the network layer to allow for tests that probe
211 // network changes (e.g. host unreachable). The old network layer is 214 // network changes (e.g. host unreachable). The old network layer is
212 // returned to allow for filter patterns that only intercept 215 // returned to allow for filter patterns that only intercept
213 // some creation requests. Note ownership exchange. 216 // some creation requests. Note ownership exchange.
214 std::unique_ptr<HttpTransactionFactory> 217 std::unique_ptr<HttpTransactionFactory>
215 SetHttpNetworkTransactionFactoryForTesting( 218 SetHttpNetworkTransactionFactoryForTesting(
216 std::unique_ptr<HttpTransactionFactory> new_network_layer); 219 std::unique_ptr<HttpTransactionFactory> new_network_layer);
217 220
221 // Dumps memory allocation stats. |parent_dump_absolute_name| is the name
222 // used by the parent MemoryAllocatorDump in the memory dump hierarchy.
223 void DumpMemoryStats(base::trace_event::ProcessMemoryDump* pmd,
224 const std::string& parent_absolute_name) const;
225
218 private: 226 private:
219 // Types -------------------------------------------------------------------- 227 // Types --------------------------------------------------------------------
220 228
221 // Disk cache entry data indices. 229 // Disk cache entry data indices.
222 enum { 230 enum {
223 kResponseInfoIndex = 0, 231 kResponseInfoIndex = 0,
224 kResponseContentIndex, 232 kResponseContentIndex,
225 kMetadataIndex, 233 kMetadataIndex,
226 234
227 // Must remain at the end of the enum. 235 // Must remain at the end of the enum.
228 kNumCacheEntryDataIndices 236 kNumCacheEntryDataIndices
229 }; 237 };
230 238
231 class MetadataWriter; 239 class MetadataWriter;
232 class QuicServerInfoFactoryAdaptor; 240 class QuicServerInfoFactoryAdaptor;
233 class Transaction; 241 class Transaction;
234 class WorkItem; 242 class WorkItem;
235 friend class Transaction; 243 friend class Transaction;
236 friend class ViewCacheHelper; 244 friend class ViewCacheHelper;
237 struct PendingOp; // Info for an entry under construction. 245 struct PendingOp; // Info for an entry under construction.
238 246
239 typedef std::list<Transaction*> TransactionList; 247 typedef std::list<Transaction*> TransactionList;
240 typedef std::list<std::unique_ptr<WorkItem>> WorkItemList; 248 typedef std::list<std::unique_ptr<WorkItem>> WorkItemList;
241 249
242 struct ActiveEntry { 250 struct ActiveEntry {
243 explicit ActiveEntry(disk_cache::Entry* entry); 251 explicit ActiveEntry(disk_cache::Entry* entry);
244 ~ActiveEntry(); 252 ~ActiveEntry();
253 size_t EstimateMemoryUsage() const;
245 254
246 disk_cache::Entry* disk_entry; 255 disk_cache::Entry* disk_entry;
247 Transaction* writer; 256 Transaction* writer;
248 TransactionList readers; 257 TransactionList readers;
249 TransactionList pending_queue; 258 TransactionList pending_queue;
250 bool will_process_pending_queue; 259 bool will_process_pending_queue;
251 bool doomed; 260 bool doomed;
252 }; 261 };
253 262
254 using ActiveEntriesMap = 263 using ActiveEntriesMap =
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 std::unique_ptr<base::Clock> clock_; 431 std::unique_ptr<base::Clock> clock_;
423 432
424 base::WeakPtrFactory<HttpCache> weak_factory_; 433 base::WeakPtrFactory<HttpCache> weak_factory_;
425 434
426 DISALLOW_COPY_AND_ASSIGN(HttpCache); 435 DISALLOW_COPY_AND_ASSIGN(HttpCache);
427 }; 436 };
428 437
429 } // namespace net 438 } // namespace net
430 439
431 #endif // NET_HTTP_HTTP_CACHE_H_ 440 #endif // NET_HTTP_HTTP_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698