| OLD | NEW |
| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 // Called when a main frame navigation is started. | 80 // Called when a main frame navigation is started. |
| 81 void DidStartMainFrameNavigation(GURL gurl, | 81 void DidStartMainFrameNavigation(GURL gurl, |
| 82 int render_process_id, | 82 int render_process_id, |
| 83 int render_frame_id, | 83 int render_frame_id, |
| 84 void* navigation_handle); | 84 void* navigation_handle); |
| 85 | 85 |
| 86 // Called when a main frame navigation is ready to be committed in a | 86 // Called when a main frame navigation is ready to be committed in a |
| 87 // renderer. | 87 // renderer. |
| 88 void ReadyToCommitMainFrameNavigation( | 88 void ReadyToCommitMainFrameNavigation( |
| 89 GURL gurl, | |
| 90 content::GlobalRequestID global_request_id, | 89 content::GlobalRequestID global_request_id, |
| 91 int render_process_id, | 90 int render_process_id, |
| 92 int render_frame_id, | 91 int render_frame_id); |
| 93 bool is_same_page_navigation, | |
| 94 void* navigation_handle); | |
| 95 | 92 |
| 96 // Called every time the WebContents changes visibility. | 93 // Called every time the WebContents changes visibility. |
| 97 void WasShownOrHidden(int main_render_process_id, | 94 void WasShownOrHidden(int main_render_process_id, |
| 98 int main_render_frame_id, | 95 int main_render_frame_id, |
| 99 bool visible); | 96 bool visible); |
| 100 | 97 |
| 101 // Called whenever one of the render frames of a WebContents is swapped. | 98 // Called whenever one of the render frames of a WebContents is swapped. |
| 102 void RenderFrameHostChanged(int old_render_process_id, | 99 void RenderFrameHostChanged(int old_render_process_id, |
| 103 int old_render_frame_id, | 100 int old_render_frame_id, |
| 104 int new_render_process_id, | 101 int new_render_process_id, |
| 105 int new_render_frame_id); | 102 int new_render_frame_id); |
| 106 | 103 |
| 107 void DidFinishNavigation(int render_process_id, | 104 void DidFinishNavigation(int render_process_id, |
| 108 int render_frame_id, | 105 int render_frame_id, |
| 106 GURL gurl, |
| 107 bool is_same_page_navigation, |
| 109 uint32_t page_transition); | 108 uint32_t page_transition); |
| 110 | 109 |
| 111 private: | 110 private: |
| 112 friend class ChromeDataUseAscriberTest; | 111 friend class ChromeDataUseAscriberTest; |
| 113 | 112 |
| 114 // Entry in the |data_use_recorders_| list which owns all instances of | 113 // Entry in the |data_use_recorders_| list which owns all instances of |
| 115 // DataUseRecorder. | 114 // DataUseRecorder. |
| 116 typedef std::list<ChromeDataUseRecorder> DataUseRecorderList; | 115 typedef std::list<ChromeDataUseRecorder> DataUseRecorderList; |
| 117 typedef DataUseRecorderList::iterator DataUseRecorderEntry; | 116 typedef DataUseRecorderList::iterator DataUseRecorderEntry; |
| 118 | 117 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 147 bool IsRecorderInPendingNavigationMap(net::URLRequest* request); | 146 bool IsRecorderInPendingNavigationMap(net::URLRequest* request); |
| 148 | 147 |
| 149 bool IsRecorderInRenderFrameMap(net::URLRequest* request); | 148 bool IsRecorderInRenderFrameMap(net::URLRequest* request); |
| 150 | 149 |
| 151 // Owner for all instances of DataUseRecorder. An instance is kept in this | 150 // Owner for all instances of DataUseRecorder. An instance is kept in this |
| 152 // list if any entity (render frame hosts, URLRequests, pending navigations) | 151 // list if any entity (render frame hosts, URLRequests, pending navigations) |
| 153 // that ascribe data use to the instance exists, and deleted when all | 152 // that ascribe data use to the instance exists, and deleted when all |
| 154 // ascribing entities go away. | 153 // ascribing entities go away. |
| 155 DataUseRecorderList data_use_recorders_; | 154 DataUseRecorderList data_use_recorders_; |
| 156 | 155 |
| 157 // Map from RenderFrameHost to the DataUseRecorderEntry in | 156 // TODO(rajendrant): Combine the multiple hash_maps keyed by |
| 157 // RenderFrameHostID. Map from RenderFrameHost to the DataUseRecorderEntry in |
| 158 // |data_use_recorders_| that the main frame ascribes data use to. | 158 // |data_use_recorders_| that the main frame ascribes data use to. |
| 159 base::hash_map<RenderFrameHostID, DataUseRecorderEntry> | 159 base::hash_map<RenderFrameHostID, DataUseRecorderEntry> |
| 160 main_render_frame_data_use_map_; | 160 main_render_frame_data_use_map_; |
| 161 | 161 |
| 162 // Maps subframe IDs to the mainframe ID, so the mainframe lifetime can have | 162 // Maps subframe IDs to the mainframe ID, so the mainframe lifetime can have |
| 163 // ownership over the lifetime of entries in |data_use_recorders_|. Mainframes | 163 // ownership over the lifetime of entries in |data_use_recorders_|. Mainframes |
| 164 // are mapped to themselves. | 164 // are mapped to themselves. |
| 165 base::hash_map<RenderFrameHostID, RenderFrameHostID> | 165 base::hash_map<RenderFrameHostID, RenderFrameHostID> |
| 166 subframe_to_mainframe_map_; | 166 subframe_to_mainframe_map_; |
| 167 | 167 |
| 168 // Map from pending navigations to the DataUseRecorderEntry in | 168 // Map from pending navigations to the DataUseRecorderEntry in |
| 169 // |data_use_recorders_| that the navigation ascribes data use to. | 169 // |data_use_recorders_| that the navigation ascribes data use to. |
| 170 std::unordered_map<content::GlobalRequestID, | 170 std::unordered_map<content::GlobalRequestID, |
| 171 DataUseRecorderEntry, | 171 DataUseRecorderEntry, |
| 172 GlobalRequestIDHash> | 172 GlobalRequestIDHash> |
| 173 pending_navigation_data_use_map_; | 173 pending_navigation_data_use_map_; |
| 174 | 174 |
| 175 // Contains the global requestid of pending navigations in the mainframe. This |
| 176 // is needed to support navigations that transfer from one mainframe to |
| 177 // another. |
| 178 base::hash_map<RenderFrameHostID, content::GlobalRequestID> |
| 179 pending_navigation_global_request_id_; |
| 180 |
| 175 // Contains the mainframe IDs that are currently visible. | 181 // Contains the mainframe IDs that are currently visible. |
| 176 base::hash_set<RenderFrameHostID> visible_main_render_frames_; | 182 base::hash_set<RenderFrameHostID> visible_main_render_frames_; |
| 177 | 183 |
| 178 DISALLOW_COPY_AND_ASSIGN(ChromeDataUseAscriber); | 184 DISALLOW_COPY_AND_ASSIGN(ChromeDataUseAscriber); |
| 179 }; | 185 }; |
| 180 | 186 |
| 181 } // namespace data_use_measurement | 187 } // namespace data_use_measurement |
| 182 | 188 |
| 183 #endif // CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_H_ | 189 #endif // CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_H_ |
| OLD | NEW |