| 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 #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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 base::Bind( | 156 base::Bind( |
| 157 &ChromeDataUseAscriber::ReadyToCommitMainFrameNavigation, | 157 &ChromeDataUseAscriber::ReadyToCommitMainFrameNavigation, |
| 158 base::Unretained(ascriber_), navigation_handle->GetURL(), | 158 base::Unretained(ascriber_), navigation_handle->GetURL(), |
| 159 navigation_handle->GetGlobalRequestID(), | 159 navigation_handle->GetGlobalRequestID(), |
| 160 web_contents->GetRenderProcessHost()->GetID(), | 160 web_contents->GetRenderProcessHost()->GetID(), |
| 161 web_contents->GetMainFrame()->GetRoutingID(), | 161 web_contents->GetMainFrame()->GetRoutingID(), |
| 162 !navigation_handle->HasCommitted() || navigation_handle->IsSamePage(), | 162 !navigation_handle->HasCommitted() || navigation_handle->IsSamePage(), |
| 163 navigation_handle)); | 163 navigation_handle)); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void ChromeDataUseAscriberService::DidFinishNavigation( |
| 167 content::NavigationHandle* navigation_handle) { |
| 168 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 169 |
| 170 if (!navigation_handle->IsInMainFrame() || |
| 171 !navigation_handle->HasCommitted() || navigation_handle->IsSamePage()) |
| 172 return; |
| 173 |
| 174 if (!ascriber_) |
| 175 return; |
| 176 |
| 177 content::WebContents* web_contents = navigation_handle->GetWebContents(); |
| 178 content::BrowserThread::PostTask( |
| 179 content::BrowserThread::IO, FROM_HERE, |
| 180 base::Bind(&ChromeDataUseAscriber::DidFinishNavigation, |
| 181 base::Unretained(ascriber_), |
| 182 web_contents->GetRenderProcessHost()->GetID(), |
| 183 web_contents->GetMainFrame()->GetRoutingID(), |
| 184 navigation_handle->GetPageTransition())); |
| 185 } |
| 186 |
| 166 void ChromeDataUseAscriberService::SetDataUseAscriber( | 187 void ChromeDataUseAscriberService::SetDataUseAscriber( |
| 167 ChromeDataUseAscriber* ascriber) { | 188 ChromeDataUseAscriber* ascriber) { |
| 168 DCHECK(!is_initialized_); | 189 DCHECK(!is_initialized_); |
| 169 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 190 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 170 | 191 |
| 171 ascriber_ = ascriber; | 192 ascriber_ = ascriber; |
| 172 is_initialized_ = true; | 193 is_initialized_ = true; |
| 173 | 194 |
| 174 for (auto& it : pending_frames_queue_) { | 195 for (auto& it : pending_frames_queue_) { |
| 175 RenderFrameCreated(it); | 196 RenderFrameCreated(it); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 content::BrowserThread::PostTask( | 234 content::BrowserThread::PostTask( |
| 214 content::BrowserThread::IO, FROM_HERE, | 235 content::BrowserThread::IO, FROM_HERE, |
| 215 base::Bind(&ChromeDataUseAscriber::RenderFrameHostChanged, | 236 base::Bind(&ChromeDataUseAscriber::RenderFrameHostChanged, |
| 216 base::Unretained(ascriber_), old_host->GetProcess()->GetID(), | 237 base::Unretained(ascriber_), old_host->GetProcess()->GetID(), |
| 217 old_host->GetRoutingID(), new_host->GetProcess()->GetID(), | 238 old_host->GetRoutingID(), new_host->GetProcess()->GetID(), |
| 218 new_host->GetRoutingID())); | 239 new_host->GetRoutingID())); |
| 219 } | 240 } |
| 220 } | 241 } |
| 221 | 242 |
| 222 } // namespace data_use_measurement | 243 } // namespace data_use_measurement |
| OLD | NEW |