Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bookmarks/bookmark_index.h" | 5 #include "chrome/browser/bookmarks/bookmark_index.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <list> | 9 #include <list> |
| 10 | 10 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 // will run backwards to assure higher relevance will be attributed to the | 105 // will run backwards to assure higher relevance will be attributed to the |
| 106 // best matches. | 106 // best matches. |
| 107 for (NodeTypedCountPairs::const_iterator i = node_typed_counts.begin(); | 107 for (NodeTypedCountPairs::const_iterator i = node_typed_counts.begin(); |
| 108 i != node_typed_counts.end() && results->size() < max_count; ++i) | 108 i != node_typed_counts.end() && results->size() < max_count; ++i) |
| 109 AddMatchToResults(i->first, &parser, query_nodes.get(), results); | 109 AddMatchToResults(i->first, &parser, query_nodes.get(), results); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void BookmarkIndex::SortMatches(const Matches& matches, | 112 void BookmarkIndex::SortMatches(const Matches& matches, |
| 113 NodeTypedCountPairs* node_typed_counts) const { | 113 NodeTypedCountPairs* node_typed_counts) const { |
| 114 HistoryService* const history_service = profile_ ? | 114 HistoryService* const history_service = profile_ ? |
| 115 HistoryServiceFactory::GetForProfile(profile_, | 115 HistoryServiceFactory::GetForProfileIfExists( |
|
sky
2012/06/21 17:14:31
Keep this as it was.
| |
| 116 Profile::EXPLICIT_ACCESS) : NULL; | 116 profile_, Profile::EXPLICIT_ACCESS) : NULL; |
| 117 | 117 |
| 118 history::URLDatabase* url_db = history_service ? | 118 history::URLDatabase* url_db = history_service ? |
| 119 history_service->InMemoryDatabase() : NULL; | 119 history_service->InMemoryDatabase() : NULL; |
| 120 | 120 |
| 121 for (Matches::const_iterator i = matches.begin(); i != matches.end(); ++i) | 121 for (Matches::const_iterator i = matches.begin(); i != matches.end(); ++i) |
| 122 ExtractBookmarkNodePairs(url_db, *i, node_typed_counts); | 122 ExtractBookmarkNodePairs(url_db, *i, node_typed_counts); |
| 123 | 123 |
| 124 std::sort(node_typed_counts->begin(), node_typed_counts->end(), | 124 std::sort(node_typed_counts->begin(), node_typed_counts->end(), |
| 125 &NodeTypedCountPairSortFunc); | 125 &NodeTypedCountPairSortFunc); |
| 126 } | 126 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 Index::iterator i = index_.find(term); | 266 Index::iterator i = index_.find(term); |
| 267 if (i == index_.end()) { | 267 if (i == index_.end()) { |
| 268 // We can get here if the node has the same term more than once. For | 268 // We can get here if the node has the same term more than once. For |
| 269 // example, a bookmark with the title 'foo foo' would end up here. | 269 // example, a bookmark with the title 'foo foo' would end up here. |
| 270 return; | 270 return; |
| 271 } | 271 } |
| 272 i->second.erase(node); | 272 i->second.erase(node); |
| 273 if (i->second.empty()) | 273 if (i->second.empty()) |
| 274 index_.erase(i); | 274 index_.erase(i); |
| 275 } | 275 } |
| OLD | NEW |