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

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

Issue 2498433002: Revert of Expose GlobalRequestID in NavigationHandle and ResourceRequestInfo. (Closed)
Patch Set: 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>
9 #include <memory>
10 #include <unordered_map>
11 #include <utility>
12
13 #include "base/containers/hash_tables.h"
14 #include "base/hash.h"
15 #include "base/macros.h" 8 #include "base/macros.h"
16 #include "base/supports_user_data.h"
17 #include "components/data_use_measurement/core/data_use_ascriber.h" 9 #include "components/data_use_measurement/core/data_use_ascriber.h"
18 #include "content/public/browser/global_request_id.h"
19 #include "url/gurl.h" 10 #include "url/gurl.h"
20 11
21 namespace content { 12 namespace content {
22 class NavigationHandle; 13 class NavigationHandle;
23 class RenderFrameHost; 14 class RenderFrameHost;
24 } 15 }
25 16
26 namespace data_use_measurement { 17 namespace data_use_measurement {
27 18
28 // Browser implementation of DataUseAscriber. Maintains a list of 19 // Browser implementation of DataUseAscriber. Maintains a list of
(...skipping 14 matching lines...) Expand all
43 // the DataUseRecorder instance for page load. 34 // the DataUseRecorder instance for page load.
44 // 35 //
45 // This class lives entirely on the IO thread. It maintains a copy of frame and 36 // This class lives entirely on the IO thread. It maintains a copy of frame and
46 // navigation information on the IO thread. 37 // navigation information on the IO thread.
47 class ChromeDataUseAscriber : public DataUseAscriber { 38 class ChromeDataUseAscriber : public DataUseAscriber {
48 public: 39 public:
49 ChromeDataUseAscriber(); 40 ChromeDataUseAscriber();
50 41
51 ~ChromeDataUseAscriber() override; 42 ~ChromeDataUseAscriber() override;
52 43
53 // DataUseAscriber implementation: 44 // DataUseAscriber:
54 DataUseRecorder* GetDataUseRecorder(net::URLRequest* request) override; 45 DataUseRecorder* GetDataUseRecorder(net::URLRequest* request) override;
55 46
56 // Called before a request is sent.
57 void OnBeforeUrlRequest(net::URLRequest* request) override;
58
59 // Called when a URLRequest completes.
60 void OnUrlRequestCompleted(net::URLRequest* request, bool started) override;
61
62 // Called when a render frame host is created. 47 // Called when a render frame host is created.
63 void RenderFrameCreated(int render_process_id, 48 void RenderFrameCreated(int render_process_id,
64 int render_frame_id, 49 int render_frame_id,
65 int parent_render_process_id, 50 int parent_render_process_id,
66 int parent_render_frame_id); 51 int parent_render_frame_id);
67 52
68 // Called when a render frame host is deleted. 53 // Called when a render frame host is deleted.
69 void RenderFrameDeleted(int render_process_id, 54 void RenderFrameDeleted(int render_process_id,
70 int render_frame_id, 55 int render_frame_id,
71 int parent_render_process_id, 56 int parent_render_process_id,
72 int parent_render_frame_id); 57 int parent_render_frame_id);
73 58
74 // Called when a main frame navigation is started. 59 // Called when a main frame navigation is started.
75 void DidStartMainFrameNavigation(GURL gurl, 60 void DidStartMainFrameNavigation(GURL gurl,
76 int render_process_id, 61 int render_process_id,
77 int render_frame_id, 62 int render_frame_id,
78 void* navigation_handle); 63 void* navigation_handle);
79 64
80 // Called when a main frame navigation is ready to be committed in a 65 // Called when a main frame navigation is completed.
81 // renderer. 66 void DidFinishMainFrameNavigation(GURL gurl,
82 void ReadyToCommitMainFrameNavigation( 67 int render_process_id,
83 GURL gurl, 68 int render_frame_id,
84 content::GlobalRequestID global_request_id, 69 bool is_same_page_navigation,
85 int render_process_id, 70 void* navigation_handle);
86 int render_frame_id,
87 bool is_same_page_navigation,
88 void* navigation_handle);
89 71
90 // Called when a main frame navigation is redirected. 72 // Called when a main frame navigation is redirected.
91 void DidRedirectMainFrameNavigation(GURL gurl, 73 void DidRedirectMainFrameNavigation(GURL gurl,
92 int render_process_id, 74 int render_process_id,
93 int render_frame_id, 75 int render_frame_id,
94 void* navigation_handle); 76 void* navigation_handle);
95 77
96 private: 78 private:
97 // Use as a key in the render frame map. Corresponds to a unique
98 // RenderFrameHost.
99 typedef std::pair<int, int> RenderFrameHostID;
100
101 // Entry in the |data_use_recorders_| list which owns all instances of
102 // DataUseRecorder.
103 typedef std::list<std::unique_ptr<data_use_measurement::DataUseRecorder>>::
104 iterator DataUseRecorderEntry;
105
106 struct GlobalRequestIDHash {
107 public:
108 std::size_t operator()(const content::GlobalRequestID& x) const {
109 return base::HashInts(x.child_id, x.request_id);
110 }
111 };
112
113 class DataUseRecorderEntryAsUserData : public base::SupportsUserData::Data {
114 public:
115 explicit DataUseRecorderEntryAsUserData(DataUseRecorderEntry entry);
116
117 ~DataUseRecorderEntryAsUserData() override;
118
119 DataUseRecorderEntry recorder_entry() { return entry_; }
120
121 static const void* kUserDataKey;
122
123 private:
124 DataUseRecorderEntry entry_;
125 };
126
127 void DeletePendingNavigationEntry(content::GlobalRequestID global_request_id);
128
129 // Owner for all instances of DataUseRecorder. An instance is kept in this
130 // list if any entity (render frame hosts, URLRequests, pending navigations)
131 // that ascribe data use to the instance exists, and deleted when all
132 // ascribing entities go away.
133 std::list<std::unique_ptr<DataUseRecorder>> data_use_recorders_;
134
135 // Map from RenderFrameHost to the DataUseRecorderEntry in
136 // |data_use_recorders_| that the frame ascribe data use to.
137 base::hash_map<RenderFrameHostID, DataUseRecorderEntry>
138 render_frame_data_use_map_;
139
140 // Map from pending navigations to the DataUseRecorderEntry in
141 // |data_use_recorders_| that the navigation ascribes data use to.
142 std::unordered_map<content::GlobalRequestID,
143 DataUseRecorderEntry,
144 GlobalRequestIDHash>
145 pending_navigation_data_use_map_;
146
147 DISALLOW_COPY_AND_ASSIGN(ChromeDataUseAscriber); 79 DISALLOW_COPY_AND_ASSIGN(ChromeDataUseAscriber);
148 }; 80 };
149 81
150 } // namespace data_use_measurement 82 } // namespace data_use_measurement
151 83
152 #endif // CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_H_ 84 #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