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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.cc

Issue 2681783003: Since SafeBrowsingNavigationObserverManager cleans up navigation events every two minutes, if downl… (Closed)
Patch Set: Created 3 years, 10 months 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
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/safe_browsing/safe_browsing_navigation_observer_manager .h" 5 #include "chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager .h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 // The expiration period of a user gesture. Any user gesture that happened 1.0 69 // The expiration period of a user gesture. Any user gesture that happened 1.0
70 // second ago is considered as expired and not relevant to upcoming navigation 70 // second ago is considered as expired and not relevant to upcoming navigation
71 // events. 71 // events.
72 static const double kUserGestureTTLInSecond = 1.0; 72 static const double kUserGestureTTLInSecond = 1.0;
73 // The expiration period of navigation events and resolved IP addresses. Any 73 // The expiration period of navigation events and resolved IP addresses. Any
74 // navigation related records that happened 2 minutes ago are considered as 74 // navigation related records that happened 2 minutes ago are considered as
75 // expired. So we clean up these navigation footprints every 2 minutes. 75 // expired. So we clean up these navigation footprints every 2 minutes.
76 static const double kNavigationFootprintTTLInSecond = 120.0; 76 static const double kNavigationFootprintTTLInSecond = 120.0;
77 77
78 ReferrerChainData::ReferrerChainData(
79 std::unique_ptr<ReferrerChain> referrer_chain)
80 : referrer_chain_(std::move(referrer_chain)) {}
81
82 ReferrerChainData::~ReferrerChainData() {}
83
84 ReferrerChain* ReferrerChainData::GetReferrerChain() {
85 return referrer_chain_.get();
86 }
87
78 // static 88 // static
79 const base::Feature 89 const base::Feature
80 SafeBrowsingNavigationObserverManager::kDownloadAttribution { 90 SafeBrowsingNavigationObserverManager::kDownloadAttribution {
81 "DownloadAttribution", base::FEATURE_DISABLED_BY_DEFAULT 91 "DownloadAttribution", base::FEATURE_DISABLED_BY_DEFAULT
82 }; 92 };
83 // static 93 // static
84 bool SafeBrowsingNavigationObserverManager::IsUserGestureExpired( 94 bool SafeBrowsingNavigationObserverManager::IsUserGestureExpired(
85 const base::Time& timestamp) { 95 const base::Time& timestamp) {
86 return IsEventExpired(timestamp, kUserGestureTTLInSecond); 96 return IsEventExpired(timestamp, kUserGestureTTLInSecond);
87 } 97 }
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 } 436 }
427 } 437 }
428 } 438 }
429 return nullptr; 439 return nullptr;
430 } 440 }
431 441
432 void SafeBrowsingNavigationObserverManager::AddToReferrerChain( 442 void SafeBrowsingNavigationObserverManager::AddToReferrerChain(
433 ReferrerChain* referrer_chain, 443 ReferrerChain* referrer_chain,
434 NavigationEvent* nav_event, 444 NavigationEvent* nav_event,
435 ReferrerChainEntry::URLType type) { 445 ReferrerChainEntry::URLType type) {
436 std::unique_ptr<ReferrerChainEntry> referrer_chain_entry = 446 ReferrerChainEntry referrer_chain_entry;
437 base::MakeUnique<ReferrerChainEntry>(); 447 referrer_chain_entry.set_url(nav_event->destination_url.spec());
438 referrer_chain_entry->set_url(nav_event->destination_url.spec()); 448 referrer_chain_entry.set_type(type);
439 referrer_chain_entry->set_type(type);
440 auto ip_it = host_to_ip_map_.find(nav_event->destination_url.host()); 449 auto ip_it = host_to_ip_map_.find(nav_event->destination_url.host());
441 if (ip_it != host_to_ip_map_.end()) { 450 if (ip_it != host_to_ip_map_.end()) {
442 for (ResolvedIPAddress entry : ip_it->second) { 451 for (ResolvedIPAddress entry : ip_it->second) {
443 referrer_chain_entry->add_ip_addresses(entry.ip); 452 referrer_chain_entry.add_ip_addresses(entry.ip);
444 } 453 }
445 } 454 }
446 // Since we only track navigation to landing referrer, we will not log the 455 // Since we only track navigation to landing referrer, we will not log the
447 // referrer of the landing referrer page. 456 // referrer of the landing referrer page.
448 if (type != ReferrerChainEntry::LANDING_REFERRER) { 457 if (type != ReferrerChainEntry::LANDING_REFERRER) {
449 referrer_chain_entry->set_referrer_url(nav_event->source_url.spec()); 458 referrer_chain_entry.set_referrer_url(nav_event->source_url.spec());
450 referrer_chain_entry->set_referrer_main_frame_url( 459 referrer_chain_entry.set_referrer_main_frame_url(
451 nav_event->source_main_frame_url.spec()); 460 nav_event->source_main_frame_url.spec());
452 } 461 }
453 referrer_chain_entry->set_is_retargeting(nav_event->source_tab_id != 462 referrer_chain_entry.set_is_retargeting(nav_event->source_tab_id !=
454 nav_event->target_tab_id); 463 nav_event->target_tab_id);
455 referrer_chain_entry->set_navigation_time_msec( 464 referrer_chain_entry.set_navigation_time_msec(
456 nav_event->last_updated.ToJavaTime()); 465 nav_event->last_updated.ToJavaTime());
457 referrer_chain->push_back(std::move(referrer_chain_entry)); 466 referrer_chain->Add()->Swap(&referrer_chain_entry);
458 } 467 }
459 468
460 void SafeBrowsingNavigationObserverManager::GetRemainingReferrerChain( 469 void SafeBrowsingNavigationObserverManager::GetRemainingReferrerChain(
461 NavigationEvent* last_nav_event_traced, 470 NavigationEvent* last_nav_event_traced,
462 int current_user_gesture_count, 471 int current_user_gesture_count,
463 int user_gesture_count_limit, 472 int user_gesture_count_limit,
464 ReferrerChain* out_referrer_chain, 473 ReferrerChain* out_referrer_chain,
465 SafeBrowsingNavigationObserverManager::AttributionResult* out_result) { 474 SafeBrowsingNavigationObserverManager::AttributionResult* out_result) {
466 475
467 while (current_user_gesture_count < user_gesture_count_limit) { 476 while (current_user_gesture_count < user_gesture_count_limit) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 510
502 AddToReferrerChain(out_referrer_chain, last_nav_event_traced, 511 AddToReferrerChain(out_referrer_chain, last_nav_event_traced,
503 GetURLTypeAndAdjustAttributionResult( 512 GetURLTypeAndAdjustAttributionResult(
504 current_user_gesture_count == 513 current_user_gesture_count ==
505 user_gesture_count_limit, 514 user_gesture_count_limit,
506 out_result)); 515 out_result));
507 } 516 }
508 } 517 }
509 518
510 } // namespace safe_browsing 519 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_navigation_observer_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698