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

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

Issue 2507813003: Periodically remove old pending navigation entries.
Patch Set: Sync Created 4 years, 1 month 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 <unordered_map> 10 #include <unordered_map>
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 bool is_same_page_navigation, 92 bool is_same_page_navigation,
93 void* navigation_handle); 93 void* navigation_handle);
94 94
95 // Called when a main frame navigation is redirected. 95 // Called when a main frame navigation is redirected.
96 void DidRedirectMainFrameNavigation(GURL gurl, 96 void DidRedirectMainFrameNavigation(GURL gurl,
97 int render_process_id, 97 int render_process_id,
98 int render_frame_id, 98 int render_frame_id,
99 void* navigation_handle); 99 void* navigation_handle);
100 100
101 private: 101 private:
102 friend class ChromeDataUseAscriberTest;
103
102 // Use as a key in the render frame map. Corresponds to a unique 104 // Use as a key in the render frame map. Corresponds to a unique
103 // RenderFrameHost. 105 // RenderFrameHost.
104 typedef std::pair<int, int> RenderFrameHostID; 106 typedef std::pair<int, int> RenderFrameHostID;
105 107
106 // Entry in the |data_use_recorders_| list which owns all instances of 108 // Entry in the |data_use_recorders_| list which owns all instances of
107 // DataUseRecorder. 109 // DataUseRecorder.
108 typedef std::list<std::unique_ptr<data_use_measurement::DataUseRecorder>>:: 110 typedef std::list<std::unique_ptr<data_use_measurement::DataUseRecorder>>::
109 iterator DataUseRecorderEntry; 111 iterator DataUseRecorderEntry;
110 112
111 struct GlobalRequestIDHash { 113 struct GlobalRequestIDHash {
(...skipping 12 matching lines...) Expand all
124 DataUseRecorderEntry recorder_entry() { return entry_; } 126 DataUseRecorderEntry recorder_entry() { return entry_; }
125 127
126 static const void* kUserDataKey; 128 static const void* kUserDataKey;
127 129
128 private: 130 private:
129 DataUseRecorderEntry entry_; 131 DataUseRecorderEntry entry_;
130 }; 132 };
131 133
132 void DeletePendingNavigationEntry(content::GlobalRequestID global_request_id); 134 void DeletePendingNavigationEntry(content::GlobalRequestID global_request_id);
133 135
136 // The ReadyToCommitNavigation() callback is used to remove entries from
137 // |pending_navigation_data_use_map_|. However, there are a number of race
138 // conditions which make this callback unreliable until PlzNavigate is used.
139 // Until then, this method periodically deletes old navigation entries
140 // that have finished data use.
141 void DeleteOldPendingNavigationEntries(base::Time now);
142
134 // Owner for all instances of DataUseRecorder. An instance is kept in this 143 // Owner for all instances of DataUseRecorder. An instance is kept in this
135 // list if any entity (render frame hosts, URLRequests, pending navigations) 144 // list if any entity (render frame hosts, URLRequests, pending navigations)
136 // that ascribe data use to the instance exists, and deleted when all 145 // that ascribe data use to the instance exists, and deleted when all
137 // ascribing entities go away. 146 // ascribing entities go away.
138 std::list<std::unique_ptr<DataUseRecorder>> data_use_recorders_; 147 std::list<std::unique_ptr<DataUseRecorder>> data_use_recorders_;
139 148
140 // Map from RenderFrameHost to the DataUseRecorderEntry in 149 // Map from RenderFrameHost to the DataUseRecorderEntry in
141 // |data_use_recorders_| that the frame ascribe data use to. 150 // |data_use_recorders_| that the frame ascribe data use to.
142 base::hash_map<RenderFrameHostID, DataUseRecorderEntry> 151 base::hash_map<RenderFrameHostID, DataUseRecorderEntry>
143 render_frame_data_use_map_; 152 render_frame_data_use_map_;
144 153
145 // Map from pending navigations to the DataUseRecorderEntry in 154 // Map from pending navigations to the DataUseRecorderEntry in
146 // |data_use_recorders_| that the navigation ascribes data use to. 155 // |data_use_recorders_| that the navigation ascribes data use to.
147 std::unordered_map<content::GlobalRequestID, 156 std::unordered_map<content::GlobalRequestID,
148 DataUseRecorderEntry, 157 DataUseRecorderEntry,
149 GlobalRequestIDHash> 158 GlobalRequestIDHash>
150 pending_navigation_data_use_map_; 159 pending_navigation_data_use_map_;
151 160
161 base::Time last_pending_navigations_discard_time_;
162
152 DISALLOW_COPY_AND_ASSIGN(ChromeDataUseAscriber); 163 DISALLOW_COPY_AND_ASSIGN(ChromeDataUseAscriber);
153 }; 164 };
154 165
155 } // namespace data_use_measurement 166 } // namespace data_use_measurement
156 167
157 #endif // CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_H_ 168 #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