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

Side by Side Diff: chrome/browser/data_use_measurement/chrome_data_use_ascriber.h

Issue 2875263003: Support for transfer navigations in data use ascriber (Closed)
Patch Set: rebased Created 3 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
« no previous file with comments | « no previous file | chrome/browser/data_use_measurement/chrome_data_use_ascriber.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_H_ 5 #ifndef CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_H_
6 #define CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_H_ 6 #define CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 // Called when a main frame navigation is started. 82 // Called when a main frame navigation is started.
83 void DidStartMainFrameNavigation(GURL gurl, 83 void DidStartMainFrameNavigation(GURL gurl,
84 int render_process_id, 84 int render_process_id,
85 int render_frame_id, 85 int render_frame_id,
86 void* navigation_handle); 86 void* navigation_handle);
87 87
88 // Called when a main frame navigation is ready to be committed in a 88 // Called when a main frame navigation is ready to be committed in a
89 // renderer. 89 // renderer.
90 void ReadyToCommitMainFrameNavigation( 90 void ReadyToCommitMainFrameNavigation(
91 GURL gurl,
92 content::GlobalRequestID global_request_id, 91 content::GlobalRequestID global_request_id,
93 int render_process_id, 92 int render_process_id,
94 int render_frame_id, 93 int render_frame_id);
95 bool is_same_page_navigation,
96 void* navigation_handle);
97 94
98 // Called every time the WebContents changes visibility. 95 // Called every time the WebContents changes visibility.
99 void WasShownOrHidden(int main_render_process_id, 96 void WasShownOrHidden(int main_render_process_id,
100 int main_render_frame_id, 97 int main_render_frame_id,
101 bool visible); 98 bool visible);
102 99
103 // Called whenever one of the render frames of a WebContents is swapped. 100 // Called whenever one of the render frames of a WebContents is swapped.
104 void RenderFrameHostChanged(int old_render_process_id, 101 void RenderFrameHostChanged(int old_render_process_id,
105 int old_render_frame_id, 102 int old_render_frame_id,
106 int new_render_process_id, 103 int new_render_process_id,
107 int new_render_frame_id); 104 int new_render_frame_id);
108 105
109 void DidFinishNavigation(int render_process_id, 106 void DidFinishNavigation(int render_process_id,
110 int render_frame_id, 107 int render_frame_id,
108 GURL gurl,
109 bool is_same_page_navigation,
111 uint32_t page_transition); 110 uint32_t page_transition);
112 111
113 private: 112 private:
114 friend class ChromeDataUseAscriberTest; 113 friend class ChromeDataUseAscriberTest;
115 114
116 // Entry in the |data_use_recorders_| list which owns all instances of 115 // Entry in the |data_use_recorders_| list which owns all instances of
117 // DataUseRecorder. 116 // DataUseRecorder.
118 typedef std::list<ChromeDataUseRecorder> DataUseRecorderList; 117 typedef std::list<ChromeDataUseRecorder> DataUseRecorderList;
119 typedef DataUseRecorderList::iterator DataUseRecorderEntry; 118 typedef DataUseRecorderList::iterator DataUseRecorderEntry;
120 119
(...skipping 14 matching lines...) Expand all
135 134
136 static const void* kUserDataKey; 135 static const void* kUserDataKey;
137 136
138 private: 137 private:
139 DataUseRecorderEntry entry_; 138 DataUseRecorderEntry entry_;
140 }; 139 };
141 140
142 DataUseRecorderEntry GetOrCreateDataUseRecorderEntry( 141 DataUseRecorderEntry GetOrCreateDataUseRecorderEntry(
143 net::URLRequest* request); 142 net::URLRequest* request);
144 143
144 void NotifyPageLoadCommit(DataUseRecorderEntry entry);
145 void NotifyDataUseCompleted(DataUseRecorderEntry entry); 145 void NotifyDataUseCompleted(DataUseRecorderEntry entry);
146 146
147 DataUseRecorderEntry CreateNewDataUseRecorder( 147 DataUseRecorderEntry CreateNewDataUseRecorder(
148 net::URLRequest* request, 148 net::URLRequest* request,
149 DataUse::TrafficType traffic_type); 149 DataUse::TrafficType traffic_type);
150 150
151 bool IsRecorderInPendingNavigationMap(net::URLRequest* request); 151 bool IsRecorderInPendingNavigationMap(net::URLRequest* request);
152 152
153 bool IsRecorderInRenderFrameMap(net::URLRequest* request); 153 bool IsRecorderInRenderFrameMap(net::URLRequest* request);
154 154
155 // Owner for all instances of DataUseRecorder. An instance is kept in this 155 // Owner for all instances of DataUseRecorder. An instance is kept in this
156 // list if any entity (render frame hosts, URLRequests, pending navigations) 156 // list if any entity (render frame hosts, URLRequests, pending navigations)
157 // that ascribe data use to the instance exists, and deleted when all 157 // that ascribe data use to the instance exists, and deleted when all
158 // ascribing entities go away. 158 // ascribing entities go away.
159 DataUseRecorderList data_use_recorders_; 159 DataUseRecorderList data_use_recorders_;
160 160
161 // Map from RenderFrameHost to the DataUseRecorderEntry in 161 // TODO(rajendrant): Combine the multiple hash_maps keyed by
162 // RenderFrameHostID. Map from RenderFrameHost to the DataUseRecorderEntry in
162 // |data_use_recorders_| that the main frame ascribes data use to. 163 // |data_use_recorders_| that the main frame ascribes data use to.
163 base::hash_map<RenderFrameHostID, DataUseRecorderEntry> 164 base::hash_map<RenderFrameHostID, DataUseRecorderEntry>
164 main_render_frame_data_use_map_; 165 main_render_frame_data_use_map_;
165 166
166 // Maps subframe IDs to the mainframe ID, so the mainframe lifetime can have 167 // Maps subframe IDs to the mainframe ID, so the mainframe lifetime can have
167 // ownership over the lifetime of entries in |data_use_recorders_|. Mainframes 168 // ownership over the lifetime of entries in |data_use_recorders_|. Mainframes
168 // are mapped to themselves. 169 // are mapped to themselves.
169 base::hash_map<RenderFrameHostID, RenderFrameHostID> 170 base::hash_map<RenderFrameHostID, RenderFrameHostID>
170 subframe_to_mainframe_map_; 171 subframe_to_mainframe_map_;
171 172
172 // Map from pending navigations to the DataUseRecorderEntry in 173 // Map from pending navigations to the DataUseRecorderEntry in
173 // |data_use_recorders_| that the navigation ascribes data use to. 174 // |data_use_recorders_| that the navigation ascribes data use to.
174 std::unordered_map<content::GlobalRequestID, 175 std::unordered_map<content::GlobalRequestID,
175 DataUseRecorderEntry, 176 DataUseRecorderEntry,
176 GlobalRequestIDHash> 177 GlobalRequestIDHash>
177 pending_navigation_data_use_map_; 178 pending_navigation_data_use_map_;
178 179
180 // Contains the global requestid of pending navigations in the mainframe. This
181 // is needed to support navigations that transfer from one mainframe to
182 // another.
183 base::hash_map<RenderFrameHostID, content::GlobalRequestID>
184 pending_navigation_global_request_id_;
185
179 // Contains the mainframe IDs that are currently visible. 186 // Contains the mainframe IDs that are currently visible.
180 base::hash_set<RenderFrameHostID> visible_main_render_frames_; 187 base::hash_set<RenderFrameHostID> visible_main_render_frames_;
181 188
182 DISALLOW_COPY_AND_ASSIGN(ChromeDataUseAscriber); 189 DISALLOW_COPY_AND_ASSIGN(ChromeDataUseAscriber);
183 }; 190 };
184 191
185 } // namespace data_use_measurement 192 } // namespace data_use_measurement
186 193
187 #endif // CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_H_ 194 #endif // CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/data_use_measurement/chrome_data_use_ascriber.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698