OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/history/in_memory_url_index.h" | 5 #include "chrome/browser/history/in_memory_url_index.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <iterator> | 9 #include <iterator> |
10 #include <limits> | 10 #include <limits> |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 InMemoryURLIndex::HistoryItemFactorGreater::HistoryItemFactorGreater( | 405 InMemoryURLIndex::HistoryItemFactorGreater::HistoryItemFactorGreater( |
406 const HistoryInfoMap& history_info_map) | 406 const HistoryInfoMap& history_info_map) |
407 : history_info_map_(history_info_map) { | 407 : history_info_map_(history_info_map) { |
408 } | 408 } |
409 | 409 |
410 InMemoryURLIndex::HistoryItemFactorGreater::~HistoryItemFactorGreater() {} | 410 InMemoryURLIndex::HistoryItemFactorGreater::~HistoryItemFactorGreater() {} |
411 | 411 |
412 bool InMemoryURLIndex::HistoryItemFactorGreater::operator()( | 412 bool InMemoryURLIndex::HistoryItemFactorGreater::operator()( |
413 const HistoryID h1, | 413 const HistoryID h1, |
414 const HistoryID h2) { | 414 const HistoryID h2) { |
415 const URLRow& r1(history_info_map_.find(h1)->second); | 415 HistoryInfoMap::const_iterator entry1(history_info_map_.find(h1)); |
416 const URLRow& r2(history_info_map_.find(h2)->second); | 416 if (entry1 == history_info_map_.end()) |
| 417 return false; |
| 418 HistoryInfoMap::const_iterator entry2(history_info_map_.find(h2)); |
| 419 if (entry2 == history_info_map_.end()) |
| 420 return true; |
| 421 const URLRow& r1(entry1->second); |
| 422 const URLRow& r2(entry2->second); |
417 // First cut: typed count, visit count, recency. | 423 // First cut: typed count, visit count, recency. |
418 // TODO(mrossetti): This is too simplistic. Consider an approach which ranks | 424 // TODO(mrossetti): This is too simplistic. Consider an approach which ranks |
419 // recently visited (within the last 12/24 hours) as highly important. Get | 425 // recently visited (within the last 12/24 hours) as highly important. Get |
420 // input from mpearson. | 426 // input from mpearson. |
421 if (r1.typed_count() != r2.typed_count()) | 427 if (r1.typed_count() != r2.typed_count()) |
422 return (r1.typed_count() > r2.typed_count()); | 428 return (r1.typed_count() > r2.typed_count()); |
423 if (r1.visit_count() != r2.visit_count()) | 429 if (r1.visit_count() != r2.visit_count()) |
424 return (r1.visit_count() > r2.visit_count()); | 430 return (r1.visit_count() > r2.visit_count()); |
425 return (r1.last_visit() > r2.last_visit()); | 431 return (r1.last_visit() > r2.last_visit()); |
426 } | 432 } |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1128 if (iter->has_title()) { | 1134 if (iter->has_title()) { |
1129 string16 title(UTF8ToUTF16(iter->title())); | 1135 string16 title(UTF8ToUTF16(iter->title())); |
1130 url_row.set_title(title); | 1136 url_row.set_title(title); |
1131 } | 1137 } |
1132 private_data_->history_info_map_[history_id] = url_row; | 1138 private_data_->history_info_map_[history_id] = url_row; |
1133 } | 1139 } |
1134 return true; | 1140 return true; |
1135 } | 1141 } |
1136 | 1142 |
1137 } // namespace history | 1143 } // namespace history |
OLD | NEW |