| 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 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_QUERY_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_QUERY_H_ |
| 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_QUERY_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_QUERY_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "base/strings/string16.h" |
| 13 #include "content/public/browser/download_item.h" | 14 #include "content/public/browser/download_item.h" |
| 14 | 15 |
| 15 namespace base { | 16 namespace base { |
| 16 class Value; | 17 class Value; |
| 17 } | 18 } |
| 18 | 19 |
| 19 // Filter and sort a vector of DownloadItem*s. | 20 // Filter and sort a vector of DownloadItem*s. |
| 20 // | 21 // |
| 21 // The following example copies from |all_items| to |results| those | 22 // The following example copies from |all_items| to |results| those |
| 22 // DownloadItem*s whose start time is 0 and whose id is odd, sorts primarily by | 23 // DownloadItem*s whose start time is 0 and whose id is odd, sorts primarily by |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 SORT_STATE, | 84 SORT_STATE, |
| 84 SORT_TOTAL_BYTES, | 85 SORT_TOTAL_BYTES, |
| 85 SORT_URL, | 86 SORT_URL, |
| 86 }; | 87 }; |
| 87 | 88 |
| 88 enum SortDirection { | 89 enum SortDirection { |
| 89 ASCENDING, | 90 ASCENDING, |
| 90 DESCENDING, | 91 DESCENDING, |
| 91 }; | 92 }; |
| 92 | 93 |
| 94 static bool MatchesQuery(const std::vector<base::string16>& query_terms, |
| 95 const content::DownloadItem& item); |
| 96 |
| 93 DownloadQuery(); | 97 DownloadQuery(); |
| 94 ~DownloadQuery(); | 98 ~DownloadQuery(); |
| 95 | 99 |
| 96 // Adds a new filter of type |type| with value |value| and returns true if | 100 // Adds a new filter of type |type| with value |value| and returns true if |
| 97 // |type| is valid and |value| is the correct Value-type and well-formed. | 101 // |type| is valid and |value| is the correct Value-type and well-formed. |
| 98 // Returns false if |type| is invalid or |value| is the incorrect Value-type | 102 // Returns false if |type| is invalid or |value| is the incorrect Value-type |
| 99 // or malformed. Search() will filter out all DownloadItem*s that do not | 103 // or malformed. Search() will filter out all DownloadItem*s that do not |
| 100 // match all filters. Multiple instances of the same FilterType are allowed, | 104 // match all filters. Multiple instances of the same FilterType are allowed, |
| 101 // so you can pass two regexes to AddFilter(URL_REGEX,...) in order to | 105 // so you can pass two regexes to AddFilter(URL_REGEX,...) in order to |
| 102 // Search() for items whose url matches both regexes. You can also pass two | 106 // Search() for items whose url matches both regexes. You can also pass two |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 156 |
| 153 FilterCallbackVector filters_; | 157 FilterCallbackVector filters_; |
| 154 SorterVector sorters_; | 158 SorterVector sorters_; |
| 155 size_t limit_; | 159 size_t limit_; |
| 156 size_t skip_; | 160 size_t skip_; |
| 157 | 161 |
| 158 DISALLOW_COPY_AND_ASSIGN(DownloadQuery); | 162 DISALLOW_COPY_AND_ASSIGN(DownloadQuery); |
| 159 }; | 163 }; |
| 160 | 164 |
| 161 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_QUERY_H_ | 165 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_QUERY_H_ |
| OLD | NEW |