OLD | NEW |
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 Loading... |
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 |
OLD | NEW |