| 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/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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 nav_event->target_tab_id == target_tab_id && | 168 nav_event->target_tab_id == target_tab_id && |
| 169 nav_event->source_tab_id != nav_event->target_tab_id) { | 169 nav_event->source_tab_id != nav_event->target_tab_id) { |
| 170 return nav_event; | 170 return nav_event; |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 return nullptr; | 173 return nullptr; |
| 174 } | 174 } |
| 175 | 175 |
| 176 void NavigationEventList::RecordNavigationEvent( | 176 void NavigationEventList::RecordNavigationEvent( |
| 177 std::unique_ptr<NavigationEvent> nav_event) { | 177 std::unique_ptr<NavigationEvent> nav_event) { |
| 178 // Skip page refresh. |
| 179 if (nav_event->source_url == nav_event->GetDestinationUrl() && |
| 180 nav_event->source_tab_id == nav_event->target_tab_id) |
| 181 return; |
| 182 |
| 178 if (navigation_events_.size() == size_limit_) | 183 if (navigation_events_.size() == size_limit_) |
| 179 navigation_events_.pop_front(); | 184 navigation_events_.pop_front(); |
| 180 navigation_events_.push_back(std::move(nav_event)); | 185 navigation_events_.push_back(std::move(nav_event)); |
| 181 } | 186 } |
| 182 | 187 |
| 183 std::size_t NavigationEventList::CleanUpNavigationEvents() { | 188 std::size_t NavigationEventList::CleanUpNavigationEvents() { |
| 184 // Remove any stale NavigationEnvent, if it is older than | 189 // Remove any stale NavigationEnvent, if it is older than |
| 185 // kNavigationFootprintTTLInSecond. | 190 // kNavigationFootprintTTLInSecond. |
| 186 std::size_t removal_count = 0; | 191 std::size_t removal_count = 0; |
| 187 while (navigation_events_.size() > 0 && | 192 while (navigation_events_.size() > 0 && |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 out_result)); | 609 out_result)); |
| 605 // Stop searching if the size of out_referrer_chain already reached its | 610 // Stop searching if the size of out_referrer_chain already reached its |
| 606 // limit. | 611 // limit. |
| 607 if (out_referrer_chain->size() == kReferrerChainMaxLength) | 612 if (out_referrer_chain->size() == kReferrerChainMaxLength) |
| 608 return; | 613 return; |
| 609 last_main_frame_url_traced = last_nav_event_traced->source_main_frame_url; | 614 last_main_frame_url_traced = last_nav_event_traced->source_main_frame_url; |
| 610 } | 615 } |
| 611 } | 616 } |
| 612 | 617 |
| 613 } // namespace safe_browsing | 618 } // namespace safe_browsing |
| OLD | NEW |