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

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

Issue 1556018: Add support for attaching custom parameters to NetLog events. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Address willchan's comments Created 10 years, 8 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/chrome_net_log.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')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 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 #ifndef CHROME_BROWSER_NET_PASSIVE_LOG_COLLECTOR_H_ 5 #ifndef CHROME_BROWSER_NET_PASSIVE_LOG_COLLECTOR_H_
6 #define CHROME_BROWSER_NET_PASSIVE_LOG_COLLECTOR_H_ 6 #define CHROME_BROWSER_NET_PASSIVE_LOG_COLLECTOR_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
11 #include "chrome/browser/net/chrome_net_log.h" 11 #include "chrome/browser/net/chrome_net_log.h"
12 #include "net/base/net_log.h" 12 #include "net/base/net_log.h"
13 13
14 class PassiveLogCollector : public ChromeNetLog::Observer { 14 class PassiveLogCollector : public ChromeNetLog::Observer {
15 public: 15 public:
16 struct RequestInfo { 16 struct RequestInfo {
17 RequestInfo() : num_entries_truncated(0) {} 17 RequestInfo() : num_entries_truncated(0) {}
18 std::string url; 18 std::string url;
19 std::vector<net::NetLog::Entry> entries; 19 net::CapturingNetLog::EntryList entries;
20 size_t num_entries_truncated; 20 size_t num_entries_truncated;
21 }; 21 };
22 22
23 typedef std::vector<RequestInfo> RequestInfoList; 23 typedef std::vector<RequestInfo> RequestInfoList;
24 24
25 // This class stores and manages the passively logged information for 25 // This class stores and manages the passively logged information for
26 // URLRequests/SocketStreams/ConnectJobs. 26 // URLRequests/SocketStreams/ConnectJobs.
27 class RequestTrackerBase { 27 class RequestTrackerBase {
28 public: 28 public:
29 explicit RequestTrackerBase(size_t max_graveyard_size); 29 explicit RequestTrackerBase(size_t max_graveyard_size);
30 30
31 void OnAddEntry(const net::NetLog::Entry& entry); 31 void OnAddEntry(const net::CapturingNetLog::Entry& entry);
32 32
33 RequestInfoList GetLiveRequests() const; 33 RequestInfoList GetLiveRequests() const;
34 void ClearRecentlyDeceased(); 34 void ClearRecentlyDeceased();
35 RequestInfoList GetRecentlyDeceased() const; 35 RequestInfoList GetRecentlyDeceased() const;
36 void SetUnbounded(bool unbounded); 36 void SetUnbounded(bool unbounded);
37 37
38 bool IsUnbounded() const { return is_unbounded_; } 38 bool IsUnbounded() const { return is_unbounded_; }
39 39
40 void Clear(); 40 void Clear();
41 41
42 const RequestInfo* GetRequestInfoFromGraveyard(int id) const; 42 const RequestInfo* GetRequestInfoFromGraveyard(int id) const;
43 43
44 protected: 44 protected:
45 enum Action { 45 enum Action {
46 ACTION_NONE, 46 ACTION_NONE,
47 ACTION_DELETE, 47 ACTION_DELETE,
48 ACTION_MOVE_TO_GRAVEYARD, 48 ACTION_MOVE_TO_GRAVEYARD,
49 }; 49 };
50 50
51 // Updates |out_info| with the information from |entry|. Returns an action 51 // Updates |out_info| with the information from |entry|. Returns an action
52 // to perform for this map entry on completion. 52 // to perform for this map entry on completion.
53 virtual Action DoAddEntry(const net::NetLog::Entry& entry, 53 virtual Action DoAddEntry(const net::CapturingNetLog::Entry& entry,
54 RequestInfo* out_info) = 0; 54 RequestInfo* out_info) = 0;
55 55
56 bool is_unbounded() const { return is_unbounded_; } 56 bool is_unbounded() const { return is_unbounded_; }
57 57
58 private: 58 private:
59 typedef base::hash_map<int, RequestInfo> SourceIDToInfoMap; 59 typedef base::hash_map<int, RequestInfo> SourceIDToInfoMap;
60 60
61 bool HandleNotificationOfConnectJobID(const net::NetLog::Entry& entry,
62 RequestInfo* live_entry);
63
64 void RemoveFromLiveRequests(int source_id); 61 void RemoveFromLiveRequests(int source_id);
65 void InsertIntoGraveyard(const RequestInfo& info); 62 void InsertIntoGraveyard(const RequestInfo& info);
66 63
67 SourceIDToInfoMap live_requests_; 64 SourceIDToInfoMap live_requests_;
68 size_t max_graveyard_size_; 65 size_t max_graveyard_size_;
69 size_t next_graveyard_index_; 66 size_t next_graveyard_index_;
70 RequestInfoList graveyard_; 67 RequestInfoList graveyard_;
71 bool is_unbounded_; 68 bool is_unbounded_;
72 69
73 DISALLOW_COPY_AND_ASSIGN(RequestTrackerBase); 70 DISALLOW_COPY_AND_ASSIGN(RequestTrackerBase);
74 }; 71 };
75 72
76 // Specialization of RequestTrackerBase for handling ConnectJobs. 73 // Specialization of RequestTrackerBase for handling ConnectJobs.
77 class ConnectJobTracker : public RequestTrackerBase { 74 class ConnectJobTracker : public RequestTrackerBase {
78 public: 75 public:
79 static const size_t kMaxGraveyardSize; 76 static const size_t kMaxGraveyardSize;
80 77
81 ConnectJobTracker(); 78 ConnectJobTracker();
82 79
83 protected: 80 protected:
84 virtual Action DoAddEntry(const net::NetLog::Entry& entry, 81 virtual Action DoAddEntry(const net::CapturingNetLog::Entry& entry,
85 RequestInfo* out_info); 82 RequestInfo* out_info);
86 private: 83 private:
87 DISALLOW_COPY_AND_ASSIGN(ConnectJobTracker); 84 DISALLOW_COPY_AND_ASSIGN(ConnectJobTracker);
88 }; 85 };
89 86
90 // Specialization of RequestTrackerBase for handling URLRequest/SocketStream. 87 // Specialization of RequestTrackerBase for handling URLRequest/SocketStream.
91 class RequestTracker : public RequestTrackerBase { 88 class RequestTracker : public RequestTrackerBase {
92 public: 89 public:
93 static const size_t kMaxGraveyardSize; 90 static const size_t kMaxGraveyardSize;
94 static const size_t kMaxGraveyardURLSize; 91 static const size_t kMaxGraveyardURLSize;
95 92
96 explicit RequestTracker(ConnectJobTracker* connect_job_tracker); 93 explicit RequestTracker(ConnectJobTracker* connect_job_tracker);
97 94
98 protected: 95 protected:
99 virtual Action DoAddEntry(const net::NetLog::Entry& entry, 96 virtual Action DoAddEntry(const net::CapturingNetLog::Entry& entry,
100 RequestInfo* out_info); 97 RequestInfo* out_info);
101 98
102 private: 99 private:
103 // Searches through |connect_job_tracker_| for information on the 100 // Searches through |connect_job_tracker_| for information on the
104 // ConnectJob specified in |entry|, and appends it to |live_entry|. 101 // ConnectJob specified in |entry|, and appends it to |live_entry|.
105 void AddConnectJobInfo(const net::NetLog::Entry& entry, 102 void AddConnectJobInfo(const net::CapturingNetLog::Entry& entry,
106 RequestInfo* live_entry); 103 RequestInfo* live_entry);
107 104
108 ConnectJobTracker* connect_job_tracker_; 105 ConnectJobTracker* connect_job_tracker_;
109 106
110 DISALLOW_COPY_AND_ASSIGN(RequestTracker); 107 DISALLOW_COPY_AND_ASSIGN(RequestTracker);
111 }; 108 };
112 109
113 // Tracks the log entries for the last seen SOURCE_INIT_PROXY_RESOLVER. 110 // Tracks the log entries for the last seen SOURCE_INIT_PROXY_RESOLVER.
114 class InitProxyResolverTracker { 111 class InitProxyResolverTracker {
115 public: 112 public:
116 InitProxyResolverTracker(); 113 InitProxyResolverTracker();
117 114
118 void OnAddEntry(const net::NetLog::Entry& entry); 115 void OnAddEntry(const net::CapturingNetLog::Entry& entry);
119 116
120 const std::vector<net::NetLog::Entry>& entries() const { 117 const net::CapturingNetLog::EntryList& entries() const {
121 return entries_; 118 return entries_;
122 } 119 }
123 120
124 private: 121 private:
125 std::vector<net::NetLog::Entry> entries_; 122 net::CapturingNetLog::EntryList entries_;
126 DISALLOW_COPY_AND_ASSIGN(InitProxyResolverTracker); 123 DISALLOW_COPY_AND_ASSIGN(InitProxyResolverTracker);
127 }; 124 };
128 125
129 PassiveLogCollector(); 126 PassiveLogCollector();
130 ~PassiveLogCollector(); 127 ~PassiveLogCollector();
131 128
132 // Observer implementation: 129 // Observer implementation:
133 virtual void OnAddEntry(const net::NetLog::Entry& entry); 130 virtual void OnAddEntry(net::NetLog::EventType type,
131 const base::TimeTicks& time,
132 const net::NetLog::Source& source,
133 net::NetLog::EventPhase phase,
134 net::NetLog::EventParameters* extra_parameters);
134 135
135 // Clears all of the passively logged data. 136 // Clears all of the passively logged data.
136 void Clear(); 137 void Clear();
137 138
138 RequestTracker* url_request_tracker() { 139 RequestTracker* url_request_tracker() {
139 return &url_request_tracker_; 140 return &url_request_tracker_;
140 } 141 }
141 142
142 RequestTracker* socket_stream_tracker() { 143 RequestTracker* socket_stream_tracker() {
143 return &socket_stream_tracker_; 144 return &socket_stream_tracker_;
144 } 145 }
145 146
146 InitProxyResolverTracker* init_proxy_resolver_tracker() { 147 InitProxyResolverTracker* init_proxy_resolver_tracker() {
147 return &init_proxy_resolver_tracker_; 148 return &init_proxy_resolver_tracker_;
148 } 149 }
149 150
150 private: 151 private:
151 ConnectJobTracker connect_job_tracker_; 152 ConnectJobTracker connect_job_tracker_;
152 RequestTracker url_request_tracker_; 153 RequestTracker url_request_tracker_;
153 RequestTracker socket_stream_tracker_; 154 RequestTracker socket_stream_tracker_;
154 InitProxyResolverTracker init_proxy_resolver_tracker_; 155 InitProxyResolverTracker init_proxy_resolver_tracker_;
155 156
156 DISALLOW_COPY_AND_ASSIGN(PassiveLogCollector); 157 DISALLOW_COPY_AND_ASSIGN(PassiveLogCollector);
157 }; 158 };
158 159
159 #endif // CHROME_BROWSER_NET_PASSIVE_LOG_COLLECTOR_H_ 160 #endif // CHROME_BROWSER_NET_PASSIVE_LOG_COLLECTOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_net_log.cc ('k') | chrome/browser/net/passive_log_collector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698