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

Side by Side Diff: components/history/core/browser/visit_tracker.cc

Issue 2231753002: components: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: One more call site Created 4 years, 4 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "components/history/core/browser/visit_tracker.h" 5 #include "components/history/core/browser/visit_tracker.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 10
11 namespace history { 11 namespace history {
12 12
13 // When the list gets longer than 'MaxItems', CleanupTransitionList will resize 13 // When the list gets longer than 'MaxItems', CleanupTransitionList will resize
14 // the list down to 'ResizeTo' size. This is so we only do few block moves of 14 // the list down to 'ResizeTo' size. This is so we only do few block moves of
15 // the data rather than constantly shuffle stuff around in the vector. 15 // the data rather than constantly shuffle stuff around in the vector.
16 static const size_t kMaxItemsInTransitionList = 96; 16 static const size_t kMaxItemsInTransitionList = 96;
17 static const size_t kResizeBigTransitionListTo = 64; 17 static const size_t kResizeBigTransitionListTo = 64;
18 static_assert(kResizeBigTransitionListTo < kMaxItemsInTransitionList, 18 static_assert(kResizeBigTransitionListTo < kMaxItemsInTransitionList,
19 "maxium number of items must be larger than we are resizing to"); 19 "maxium number of items must be larger than we are resizing to");
20 20
21 VisitTracker::VisitTracker() { 21 VisitTracker::VisitTracker() {
22 } 22 }
23 23
24 VisitTracker::~VisitTracker() { 24 VisitTracker::~VisitTracker() {
25 STLDeleteContainerPairSecondPointers(contexts_.begin(), contexts_.end()); 25 base::STLDeleteContainerPairSecondPointers(contexts_.begin(),
26 contexts_.end());
26 } 27 }
27 28
28 // This function is potentially slow because it may do up to two brute-force 29 // This function is potentially slow because it may do up to two brute-force
29 // searches of the transitions list. This transitions list is kept to a 30 // searches of the transitions list. This transitions list is kept to a
30 // relatively small number by CleanupTransitionList so it shouldn't be a big 31 // relatively small number by CleanupTransitionList so it shouldn't be a big
31 // deal. However, if this ends up being noticable for performance, we may want 32 // deal. However, if this ends up being noticable for performance, we may want
32 // to optimize lookup. 33 // to optimize lookup.
33 VisitID VisitTracker::GetLastVisit(ContextID context_id, 34 VisitID VisitTracker::GetLastVisit(ContextID context_id,
34 int nav_entry_id, 35 int nav_entry_id,
35 const GURL& referrer) { 36 const GURL& referrer) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 102
102 void VisitTracker::CleanupTransitionList(TransitionList* transitions) { 103 void VisitTracker::CleanupTransitionList(TransitionList* transitions) {
103 if (transitions->size() <= kMaxItemsInTransitionList) 104 if (transitions->size() <= kMaxItemsInTransitionList)
104 return; // Nothing to do. 105 return; // Nothing to do.
105 106
106 transitions->erase(transitions->begin(), 107 transitions->erase(transitions->begin(),
107 transitions->begin() + kResizeBigTransitionListTo); 108 transitions->begin() + kResizeBigTransitionListTo);
108 } 109 }
109 110
110 } // namespace history 111 } // namespace history
OLDNEW
« no previous file with comments | « components/history/core/browser/history_backend.cc ('k') | components/history/core/browser/web_history_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698