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.h" | 5 #include "chrome/browser/data_use_measurement/chrome_data_use_ascriber.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 data_use_recorders_.erase(entry); | 372 data_use_recorders_.erase(entry); |
373 } | 373 } |
374 return; | 374 return; |
375 } | 375 } |
376 DataUseRecorderEntry old_frame_entry = | 376 DataUseRecorderEntry old_frame_entry = |
377 main_frame_it->second.data_use_recorder; | 377 main_frame_it->second.data_use_recorder; |
378 old_frame_entry->set_page_transition(page_transition); | 378 old_frame_entry->set_page_transition(page_transition); |
379 NotifyPageLoadCommit(old_frame_entry); | 379 NotifyPageLoadCommit(old_frame_entry); |
380 | 380 |
381 if (is_same_page_navigation) { | 381 if (is_same_page_navigation) { |
382 old_frame_entry->MergeFrom(&(*entry)); | 382 for (auto& request : entry->pending_url_requests()) { |
383 | 383 AscribeRecorderWithRequest(request.first, old_frame_entry); |
384 for (auto* request : entry->pending_url_requests()) | 384 old_frame_entry->MovePendingURLRequest(&(*entry), request.first); |
385 AscribeRecorderWithRequest(request, old_frame_entry); | 385 } |
386 | |
387 entry->RemoveAllPendingURLRequests(); | |
388 data_use_recorders_.erase(entry); | 386 data_use_recorders_.erase(entry); |
389 } else { | 387 } else { |
390 if (old_frame_entry->IsDataUseComplete()) { | 388 if (old_frame_entry->IsDataUseComplete()) { |
391 NotifyDataUseCompleted(old_frame_entry); | 389 NotifyDataUseCompleted(old_frame_entry); |
392 data_use_recorders_.erase(old_frame_entry); | 390 data_use_recorders_.erase(old_frame_entry); |
393 } | 391 } |
394 | 392 |
395 DataUse& data_use = entry->data_use(); | 393 DataUse& data_use = entry->data_use(); |
396 DCHECK(!data_use.url().is_valid() || data_use.url() == gurl) | 394 DCHECK(!data_use.url().is_valid() || data_use.url() == gurl) |
397 << "is valid: " << data_use.url().is_valid() | 395 << "is valid: " << data_use.url().is_valid() |
(...skipping 29 matching lines...) Expand all Loading... |
427 DataUse::TrafficType traffic_type) { | 425 DataUse::TrafficType traffic_type) { |
428 DataUseRecorderEntry entry = | 426 DataUseRecorderEntry entry = |
429 data_use_recorders_.emplace(data_use_recorders_.end(), traffic_type); | 427 data_use_recorders_.emplace(data_use_recorders_.end(), traffic_type); |
430 if (request) | 428 if (request) |
431 AscribeRecorderWithRequest(request, entry); | 429 AscribeRecorderWithRequest(request, entry); |
432 return entry; | 430 return entry; |
433 } | 431 } |
434 | 432 |
435 void ChromeDataUseAscriber::AscribeRecorderWithRequest( | 433 void ChromeDataUseAscriber::AscribeRecorderWithRequest( |
436 net::URLRequest* request, | 434 net::URLRequest* request, |
437 DataUseRecorderEntry recorder) { | 435 DataUseRecorderEntry entry) { |
438 recorder->AddPendingURLRequest(request); | 436 entry->AddPendingURLRequest(request); |
439 request->SetUserData( | 437 request->SetUserData(DataUseRecorderEntryAsUserData::kUserDataKey, |
440 DataUseRecorderEntryAsUserData::kUserDataKey, | 438 base::MakeUnique<DataUseRecorderEntryAsUserData>(entry)); |
441 base::MakeUnique<DataUseRecorderEntryAsUserData>(recorder)); | |
442 } | 439 } |
443 | 440 |
444 void ChromeDataUseAscriber::WasShownOrHidden(int main_render_process_id, | 441 void ChromeDataUseAscriber::WasShownOrHidden(int main_render_process_id, |
445 int main_render_frame_id, | 442 int main_render_frame_id, |
446 bool visible) { | 443 bool visible) { |
447 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 444 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
448 | 445 |
449 auto main_frame_it = main_render_frame_entry_map_.find( | 446 auto main_frame_it = main_render_frame_entry_map_.find( |
450 RenderFrameHostID(main_render_process_id, main_render_frame_id)); | 447 RenderFrameHostID(main_render_process_id, main_render_frame_id)); |
451 if (main_frame_it != main_render_frame_entry_map_.end()) { | 448 if (main_frame_it != main_render_frame_entry_map_.end()) { |
(...skipping 22 matching lines...) Expand all Loading... |
474 .find(RenderFrameHostID(new_render_process_id, new_render_frame_id)) | 471 .find(RenderFrameHostID(new_render_process_id, new_render_frame_id)) |
475 ->second.pending_navigation_global_request_id = | 472 ->second.pending_navigation_global_request_id = |
476 old_frame_iter->second.pending_navigation_global_request_id; | 473 old_frame_iter->second.pending_navigation_global_request_id; |
477 old_frame_iter->second.pending_navigation_global_request_id = | 474 old_frame_iter->second.pending_navigation_global_request_id = |
478 content::GlobalRequestID(); | 475 content::GlobalRequestID(); |
479 } | 476 } |
480 } | 477 } |
481 } | 478 } |
482 | 479 |
483 } // namespace data_use_measurement | 480 } // namespace data_use_measurement |
OLD | NEW |