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

Side by Side Diff: chrome/browser/net/passive_log_collector.h

Issue 848006: Generalize the net module's LoadLog facility from a passive container, to an event stream (NetLog). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Split up RequestTracker into ConnectJobTracker+RequestTracker+RequestTrackerBase, address comments Created 10 years, 9 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
« no previous file with comments | « chrome/browser/net/dns_master.cc ('k') | chrome/browser/net/passive_log_collector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_NET_PASSIVE_LOG_COLLECTOR_H_
6 #define CHROME_BROWSER_NET_PASSIVE_LOG_COLLECTOR_H_
7
8 #include <vector>
9
10 #include "base/hash_tables.h"
11 #include "chrome/browser/net/chrome_net_log.h"
12 #include "net/base/net_log.h"
13
14 class PassiveLogCollector : public ChromeNetLog::Observer {
15 public:
16 struct RequestInfo {
17 RequestInfo() : num_entries_truncated(0) {}
18 std::string url;
19 std::vector<net::NetLog::Entry> entries;
20 size_t num_entries_truncated;
21 };
22
23 typedef std::vector<RequestInfo> RequestInfoList;
24
25 // This class stores and manages the passively logged information for
26 // URLRequests/SocketStreams/ConnectJobs.
27 class RequestTrackerBase {
28 public:
29 explicit RequestTrackerBase(size_t max_graveyard_size);
30
31 void OnAddEntry(const net::NetLog::Entry& entry);
32
33 RequestInfoList GetLiveRequests() const;
34 void ClearRecentlyDeceased();
35 RequestInfoList GetRecentlyDeceased() const;
36 void SetUnbounded(bool unbounded);
37
38 bool IsUnbounded() const { return is_unbounded_; }
39
40 void Clear();
41
42 const RequestInfo* GetRequestInfoFromGraveyard(int id) const;
43
44 protected:
45 enum Action {
46 ACTION_NONE,
47 ACTION_DELETE,
48 ACTION_MOVE_TO_GRAVEYARD,
49 };
50
51 // Updates |out_info| with the information from |entry|. Returns an action
52 // to perform for this map entry on completion.
53 virtual Action DoAddEntry(const net::NetLog::Entry& entry,
54 RequestInfo* out_info) = 0;
55
56 bool is_unbounded() const { return is_unbounded_; }
57
58 private:
59 typedef base::hash_map<int, RequestInfo> SourceIDToInfoMap;
60
61 bool HandleNotificationOfConnectJobID(const net::NetLog::Entry& entry,
62 RequestInfo* live_entry);
63
64 void RemoveFromLiveRequests(const RequestInfo& info);
65 void InsertIntoGraveyard(const RequestInfo& info);
66
67 SourceIDToInfoMap live_requests_;
68 size_t max_graveyard_size_;
69 size_t next_graveyard_index_;
70 RequestInfoList graveyard_;
71 bool is_unbounded_;
72
73 DISALLOW_COPY_AND_ASSIGN(RequestTrackerBase);
74 };
75
76 // Specialization of RequestTrackerBase for handling ConnectJobs.
77 class ConnectJobTracker : public RequestTrackerBase {
78 public:
79 static const size_t kMaxGraveyardSize;
80
81 ConnectJobTracker();
82
83 protected:
84 virtual Action DoAddEntry(const net::NetLog::Entry& entry,
85 RequestInfo* out_info);
86 private:
87 DISALLOW_COPY_AND_ASSIGN(ConnectJobTracker);
88 };
89
90 // Specialization of RequestTrackerBase for handling URLRequest/SocketStream.
91 class RequestTracker : public RequestTrackerBase {
92 public:
93 static const size_t kMaxGraveyardSize;
94 static const size_t kMaxGraveyardURLSize;
95
96 explicit RequestTracker(ConnectJobTracker* connect_job_tracker);
97
98 protected:
99 virtual Action DoAddEntry(const net::NetLog::Entry& entry,
100 RequestInfo* out_info);
101
102 private:
103 // Searches through |connect_job_tracker_| for information on the
104 // ConnectJob specified in |entry|, and appends it to |live_entry|.
105 void AddConnectJobInfo(const net::NetLog::Entry& entry,
106 RequestInfo* live_entry);
107
108 ConnectJobTracker* connect_job_tracker_;
109
110 DISALLOW_COPY_AND_ASSIGN(RequestTracker);
111 };
112
113 PassiveLogCollector();
114 ~PassiveLogCollector();
115
116 // Observer implementation:
117 virtual void OnAddEntry(const net::NetLog::Entry& entry);
118
119 // Clears all of the passively logged data.
120 void Clear();
121
122 RequestTracker* url_request_tracker() {
123 return &url_request_tracker_;
124 }
125
126 RequestTracker* socket_stream_tracker() {
127 return &socket_stream_tracker_;
128 }
129
130 private:
131 ConnectJobTracker connect_job_tracker_;
132 RequestTracker url_request_tracker_;
133 RequestTracker socket_stream_tracker_;
134
135 DISALLOW_COPY_AND_ASSIGN(PassiveLogCollector);
136 };
137
138 #endif // CHROME_BROWSER_NET_PASSIVE_LOG_COLLECTOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/net/dns_master.cc ('k') | chrome/browser/net/passive_log_collector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698