| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 |
| 11 #include "app/l10n_util.h" | 11 #include "app/l10n_util.h" |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_model.h" | 13 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 14 #include "chrome/browser/bookmarks/bookmark_utils.h" | 14 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 15 #include "chrome/browser/history/history_database.h" | 15 #include "chrome/browser/history/history_database.h" |
| 16 #include "chrome/browser/history/query_parser.h" | 16 #include "chrome/browser/history/query_parser.h" |
| 17 #include "chrome/browser/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 | 18 |
| 19 // Used when finding the set of bookmarks that match a query. Each match | 19 // Used when finding the set of bookmarks that match a query. Each match |
| 20 // represents a set of terms (as an interator into the Index) matching the | 20 // represents a set of terms (as an interator into the Index) matching the |
| 21 // query as well as the set of nodes that contain those terms in their titles. | 21 // query as well as the set of nodes that contain those terms in their titles. |
| 22 struct BookmarkIndex::Match { | 22 struct BookmarkIndex::Match { |
| 23 // List of terms matching the query. | 23 // List of terms matching the query. |
| 24 std::list<Index::const_iterator> terms; | 24 std::list<Index::const_iterator> terms; |
| 25 | 25 |
| 26 // The set of nodes matching the terms. As an optimization this is empty | 26 // The set of nodes matching the terms. As an optimization this is empty |
| 27 // when we match only one term, and is filled in when we get more than one | 27 // when we match only one term, and is filled in when we get more than one |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 Index::iterator i = index_.find(term); | 262 Index::iterator i = index_.find(term); |
| 263 if (i == index_.end()) { | 263 if (i == index_.end()) { |
| 264 // We can get here if the node has the same term more than once. For | 264 // We can get here if the node has the same term more than once. For |
| 265 // example, a bookmark with the title 'foo foo' would end up here. | 265 // example, a bookmark with the title 'foo foo' would end up here. |
| 266 return; | 266 return; |
| 267 } | 267 } |
| 268 i->second.erase(node); | 268 i->second.erase(node); |
| 269 if (i->second.empty()) | 269 if (i->second.empty()) |
| 270 index_.erase(i); | 270 index_.erase(i); |
| 271 } | 271 } |
| OLD | NEW |