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

Side by Side Diff: chrome/browser/data_use_measurement/chrome_data_use_ascriber_service.cc

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
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 #include "chrome/browser/data_use_measurement/chrome_data_use_ascriber_service.h " 5 #include "chrome/browser/data_use_measurement/chrome_data_use_ascriber_service.h "
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/data_use_measurement/chrome_data_use_ascriber.h" 10 #include "chrome/browser/data_use_measurement/chrome_data_use_ascriber.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 parent_render_frame_id)); 112 parent_render_frame_id));
113 } 113 }
114 114
115 void ChromeDataUseAscriberService::DidStartNavigation( 115 void ChromeDataUseAscriberService::DidStartNavigation(
116 content::NavigationHandle* navigation_handle) { 116 content::NavigationHandle* navigation_handle) {
117 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 117 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
118 118
119 if (!navigation_handle->IsInMainFrame()) 119 if (!navigation_handle->IsInMainFrame())
120 return; 120 return;
121 121
122 if (!is_initialized_) {
123 pending_navigations_queue_.push_back(navigation_handle);
124 return;
125 }
126
122 if (!ascriber_) 127 if (!ascriber_)
123 return; 128 return;
124 129
125 content::WebContents* web_contents = navigation_handle->GetWebContents(); 130 content::WebContents* web_contents = navigation_handle->GetWebContents();
126 content::BrowserThread::PostTask( 131 content::BrowserThread::PostTask(
127 content::BrowserThread::IO, FROM_HERE, 132 content::BrowserThread::IO, FROM_HERE,
128 base::Bind(&ChromeDataUseAscriber::DidStartMainFrameNavigation, 133 base::Bind(&ChromeDataUseAscriber::DidStartMainFrameNavigation,
129 base::Unretained(ascriber_), navigation_handle->GetURL(), 134 base::Unretained(ascriber_), navigation_handle->GetURL(),
130 web_contents->GetRenderProcessHost()->GetID(), 135 web_contents->GetRenderProcessHost()->GetID(),
131 web_contents->GetMainFrame()->GetRoutingID(), 136 web_contents->GetMainFrame()->GetRoutingID(),
132 navigation_handle)); 137 navigation_handle));
133 } 138 }
134 139
135 void ChromeDataUseAscriberService::ReadyToCommitNavigation( 140 void ChromeDataUseAscriberService::DidFinishNavigation(
136 content::NavigationHandle* navigation_handle) { 141 content::NavigationHandle* navigation_handle) {
137 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 142 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
138 143
139 if (!navigation_handle->IsInMainFrame()) 144 if (!navigation_handle->IsInMainFrame())
140 return; 145 return;
141 146
147 if (!is_initialized_) {
148 // While remove() is a O(n) operation, the pending queue is not expected
149 // to have a significant number of elements.
150 DCHECK_GE(50u, pending_navigations_queue_.size());
151 pending_navigations_queue_.remove(navigation_handle);
152 return;
153 }
154
142 if (!ascriber_) 155 if (!ascriber_)
143 return; 156 return;
144 157
145 content::WebContents* web_contents = navigation_handle->GetWebContents(); 158 content::WebContents* web_contents = navigation_handle->GetWebContents();
146 content::BrowserThread::PostTask( 159 content::BrowserThread::PostTask(
147 content::BrowserThread::IO, FROM_HERE, 160 content::BrowserThread::IO, FROM_HERE,
148 base::Bind( 161 base::Bind(
149 &ChromeDataUseAscriber::ReadyToCommitMainFrameNavigation, 162 &ChromeDataUseAscriber::DidFinishMainFrameNavigation,
150 base::Unretained(ascriber_), navigation_handle->GetURL(), 163 base::Unretained(ascriber_), navigation_handle->GetURL(),
151 navigation_handle->GetGlobalRequestID(),
152 web_contents->GetRenderProcessHost()->GetID(), 164 web_contents->GetRenderProcessHost()->GetID(),
153 web_contents->GetMainFrame()->GetRoutingID(), 165 web_contents->GetMainFrame()->GetRoutingID(),
154 !navigation_handle->HasCommitted() || navigation_handle->IsSamePage(), 166 !navigation_handle->HasCommitted() || navigation_handle->IsSamePage(),
155 navigation_handle)); 167 navigation_handle));
156 } 168 }
157 169
158 void ChromeDataUseAscriberService::DidRedirectNavigation( 170 void ChromeDataUseAscriberService::DidRedirectNavigation(
159 content::NavigationHandle* navigation_handle) { 171 content::NavigationHandle* navigation_handle) {
160 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 172 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
161 173
(...skipping 18 matching lines...) Expand all
180 DCHECK(!is_initialized_); 192 DCHECK(!is_initialized_);
181 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 193 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
182 194
183 ascriber_ = ascriber; 195 ascriber_ = ascriber;
184 is_initialized_ = true; 196 is_initialized_ = true;
185 197
186 for (auto& it : pending_frames_queue_) { 198 for (auto& it : pending_frames_queue_) {
187 RenderFrameCreated(it); 199 RenderFrameCreated(it);
188 } 200 }
189 pending_frames_queue_.clear(); 201 pending_frames_queue_.clear();
202
203 for (auto& it : pending_navigations_queue_) {
204 DidStartNavigation(it);
205 }
206 pending_navigations_queue_.clear();
190 } 207 }
191 208
192 } // namespace data_use_measurement 209 } // namespace data_use_measurement
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698