OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/bookmarks/browser/bookmark_index.h" | 5 #include "components/bookmarks/browser/bookmark_index.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <functional> | 10 #include <functional> |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // This should not happen. Log the error and fall back. | 49 // This should not happen. Log the error and fall back. |
50 LOG(ERROR) << "normalization failed: " << u_errorName(status); | 50 LOG(ERROR) << "normalization failed: " << u_errorName(status); |
51 return text; | 51 return text; |
52 } | 52 } |
53 return base::string16(unicode_normalized_text.getBuffer(), | 53 return base::string16(unicode_normalized_text.getBuffer(), |
54 unicode_normalized_text.length()); | 54 unicode_normalized_text.length()); |
55 } | 55 } |
56 | 56 |
57 // Sort functor for NodeTypedCountPairs. We sort in decreasing order of typed | 57 // Sort functor for NodeTypedCountPairs. We sort in decreasing order of typed |
58 // count so that the best matches will always be added to the results. | 58 // count so that the best matches will always be added to the results. |
59 struct NodeTypedCountPairSortFunctor | 59 struct NodeTypedCountPairSortFunctor { |
60 : std::binary_function<NodeTypedCountPair, NodeTypedCountPair, bool> { | |
61 bool operator()(const NodeTypedCountPair& a, | 60 bool operator()(const NodeTypedCountPair& a, |
62 const NodeTypedCountPair& b) const { | 61 const NodeTypedCountPair& b) const { |
63 return a.second > b.second; | 62 return a.second > b.second; |
64 } | 63 } |
65 }; | 64 }; |
66 | 65 |
67 // Extract the const Node* stored in a BookmarkClient::NodeTypedCountPair. | 66 // Extract the const Node* stored in a BookmarkClient::NodeTypedCountPair. |
68 struct NodeTypedCountPairExtractNodeFunctor | 67 struct NodeTypedCountPairExtractNodeFunctor { |
69 : std::unary_function<NodeTypedCountPair, const BookmarkNode*> { | |
70 const BookmarkNode* operator()(const NodeTypedCountPair& pair) const { | 68 const BookmarkNode* operator()(const NodeTypedCountPair& pair) const { |
71 return pair.first; | 69 return pair.first; |
72 } | 70 } |
73 }; | 71 }; |
74 | 72 |
75 } // namespace | 73 } // namespace |
76 | 74 |
77 BookmarkIndex::BookmarkIndex(BookmarkClient* client, | 75 BookmarkIndex::BookmarkIndex(BookmarkClient* client, |
78 const std::string& languages) | 76 const std::string& languages) |
79 : client_(client), | 77 : client_(client), |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 // We can get here if the node has the same term more than once. For | 286 // We can get here if the node has the same term more than once. For |
289 // example, a bookmark with the title 'foo foo' would end up here. | 287 // example, a bookmark with the title 'foo foo' would end up here. |
290 return; | 288 return; |
291 } | 289 } |
292 i->second.erase(node); | 290 i->second.erase(node); |
293 if (i->second.empty()) | 291 if (i->second.empty()) |
294 index_.erase(i); | 292 index_.erase(i); |
295 } | 293 } |
296 | 294 |
297 } // namespace bookmarks | 295 } // namespace bookmarks |
OLD | NEW |