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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 DCHECK(!is_initialized_); | 168 DCHECK(!is_initialized_); |
169 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 169 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
170 | 170 |
171 ascriber_ = ascriber; | 171 ascriber_ = ascriber; |
172 is_initialized_ = true; | 172 is_initialized_ = true; |
173 | 173 |
174 for (auto& it : pending_frames_queue_) { | 174 for (auto& it : pending_frames_queue_) { |
175 RenderFrameCreated(it); | 175 RenderFrameCreated(it); |
176 } | 176 } |
177 pending_frames_queue_.clear(); | 177 pending_frames_queue_.clear(); |
178 | |
179 for (const auto& it : pending_visible_main_frames_) { | |
180 WasShownOrHidden(it, true); | |
RyanSturm
2016/12/13 22:04:19
Is it possible a frame is created, shown, and dele
Raj
2016/12/14 23:00:50
Done.
| |
181 } | |
182 pending_visible_main_frames_.clear(); | |
183 } | |
184 | |
185 void ChromeDataUseAscriberService::WasShownOrHidden( | |
186 content::RenderFrameHost* main_render_frame_host, | |
187 bool visible) { | |
188 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
189 | |
190 if (!ascriber_) { | |
191 if (visible) | |
192 pending_visible_main_frames_.insert(main_render_frame_host); | |
193 else | |
194 pending_visible_main_frames_.erase(main_render_frame_host); | |
195 return; | |
196 } | |
197 | |
198 content::BrowserThread::PostTask( | |
199 content::BrowserThread::IO, FROM_HERE, | |
200 base::Bind(&ChromeDataUseAscriber::WasShownOrHidden, | |
201 base::Unretained(ascriber_), | |
202 main_render_frame_host->GetProcess()->GetID(), | |
203 main_render_frame_host->GetRoutingID(), visible)); | |
204 } | |
205 | |
206 void ChromeDataUseAscriberService::RenderFrameHostChanged( | |
207 content::RenderFrameHost* old_host, | |
208 content::RenderFrameHost* new_host) { | |
209 if (!ascriber_) | |
210 return; | |
211 | |
212 if (old_host) { | |
213 content::BrowserThread::PostTask( | |
214 content::BrowserThread::IO, FROM_HERE, | |
215 base::Bind(&ChromeDataUseAscriber::RenderFrameHostChanged, | |
216 base::Unretained(ascriber_), old_host->GetProcess()->GetID(), | |
217 old_host->GetRoutingID(), new_host->GetProcess()->GetID(), | |
218 new_host->GetRoutingID())); | |
219 } | |
178 } | 220 } |
179 | 221 |
180 } // namespace data_use_measurement | 222 } // namespace data_use_measurement |
OLD | NEW |