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

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

Issue 2413663003: Expose GlobalRequestID in NavigationHandle and ResourceRequestInfo. (Closed)
Patch Set: Use OnURLRequestDestroyed 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
127 if (!ascriber_) 122 if (!ascriber_)
128 return; 123 return;
129 124
130 content::WebContents* web_contents = navigation_handle->GetWebContents(); 125 content::WebContents* web_contents = navigation_handle->GetWebContents();
131 content::BrowserThread::PostTask( 126 content::BrowserThread::PostTask(
132 content::BrowserThread::IO, FROM_HERE, 127 content::BrowserThread::IO, FROM_HERE,
133 base::Bind(&ChromeDataUseAscriber::DidStartMainFrameNavigation, 128 base::Bind(&ChromeDataUseAscriber::DidStartMainFrameNavigation,
134 base::Unretained(ascriber_), navigation_handle->GetURL(), 129 base::Unretained(ascriber_), navigation_handle->GetURL(),
135 web_contents->GetRenderProcessHost()->GetID(), 130 web_contents->GetRenderProcessHost()->GetID(),
136 web_contents->GetMainFrame()->GetRoutingID(), 131 web_contents->GetMainFrame()->GetRoutingID(),
137 navigation_handle)); 132 navigation_handle));
138 } 133 }
139 134
140 void ChromeDataUseAscriberService::DidFinishNavigation( 135 void ChromeDataUseAscriberService::ReadyToCommitNavigation(
141 content::NavigationHandle* navigation_handle) { 136 content::NavigationHandle* navigation_handle) {
142 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 137 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
143 138
144 if (!navigation_handle->IsInMainFrame()) 139 if (!navigation_handle->IsInMainFrame())
145 return; 140 return;
146 141
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
155 if (!ascriber_) 142 if (!ascriber_)
156 return; 143 return;
157 144
158 content::WebContents* web_contents = navigation_handle->GetWebContents(); 145 content::WebContents* web_contents = navigation_handle->GetWebContents();
159 content::BrowserThread::PostTask( 146 content::BrowserThread::PostTask(
160 content::BrowserThread::IO, FROM_HERE, 147 content::BrowserThread::IO, FROM_HERE,
161 base::Bind( 148 base::Bind(
162 &ChromeDataUseAscriber::DidFinishMainFrameNavigation, 149 &ChromeDataUseAscriber::ReadyToCommitMainFrameNavigation,
163 base::Unretained(ascriber_), navigation_handle->GetURL(), 150 base::Unretained(ascriber_), navigation_handle->GetURL(),
151 navigation_handle->GetGlobalRequestID(),
164 web_contents->GetRenderProcessHost()->GetID(), 152 web_contents->GetRenderProcessHost()->GetID(),
165 web_contents->GetMainFrame()->GetRoutingID(), 153 web_contents->GetMainFrame()->GetRoutingID(),
166 !navigation_handle->HasCommitted() || navigation_handle->IsSamePage(), 154 !navigation_handle->HasCommitted() || navigation_handle->IsSamePage(),
167 navigation_handle)); 155 navigation_handle));
168 } 156 }
169 157
170 void ChromeDataUseAscriberService::DidRedirectNavigation( 158 void ChromeDataUseAscriberService::DidRedirectNavigation(
171 content::NavigationHandle* navigation_handle) { 159 content::NavigationHandle* navigation_handle) {
172 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 160 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
173 161
(...skipping 18 matching lines...) Expand all
192 DCHECK(!is_initialized_); 180 DCHECK(!is_initialized_);
193 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 181 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
194 182
195 ascriber_ = ascriber; 183 ascriber_ = ascriber;
196 is_initialized_ = true; 184 is_initialized_ = true;
197 185
198 for (auto& it : pending_frames_queue_) { 186 for (auto& it : pending_frames_queue_) {
199 RenderFrameCreated(it); 187 RenderFrameCreated(it);
200 } 188 }
201 pending_frames_queue_.clear(); 189 pending_frames_queue_.clear();
202
203 for (auto& it : pending_navigations_queue_) {
204 DidStartNavigation(it);
205 }
206 pending_navigations_queue_.clear();
207 } 190 }
208 191
209 } // namespace data_use_measurement 192 } // namespace data_use_measurement
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698