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