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

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

Issue 2728123003: Skip page refresh navigation in navigation observer (Closed)
Patch Set: skip page refresh navigation Created 3 years, 9 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 | « no previous file | 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698