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 <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 12 matching lines...) Expand all Loading... |
23 // Filter and sort a vector of DownloadItem*s. | 23 // Filter and sort a vector of DownloadItem*s. |
24 // | 24 // |
25 // The following example copies from |all_items| to |results| those | 25 // The following example copies from |all_items| to |results| those |
26 // DownloadItem*s whose start time is 0 and whose id is odd, sorts primarily by | 26 // DownloadItem*s whose start time is 0 and whose id is odd, sorts primarily by |
27 // bytes received ascending and secondarily by url descending, and limits the | 27 // bytes received ascending and secondarily by url descending, and limits the |
28 // results to 20 items. Any number of filters or sorters is allowed. If all | 28 // results to 20 items. Any number of filters or sorters is allowed. If all |
29 // sorters compare two DownloadItems equivalently, then they are sorted by their | 29 // sorters compare two DownloadItems equivalently, then they are sorted by their |
30 // id ascending. | 30 // id ascending. |
31 // | 31 // |
32 // DownloadQuery query; | 32 // DownloadQuery query; |
33 // base::FundamentalValue start_time(0); | 33 // base::Value start_time(0); |
34 // CHECK(query.AddFilter(FILTER_START_TIME, start_time)); | 34 // CHECK(query.AddFilter(FILTER_START_TIME, start_time)); |
35 // bool FilterOutOddDownloads(const DownloadItem& item) { | 35 // bool FilterOutOddDownloads(const DownloadItem& item) { |
36 // return 0 == (item.GetId() % 2); | 36 // return 0 == (item.GetId() % 2); |
37 // } | 37 // } |
38 // CHECK(query.AddFilter(base::Bind(&FilterOutOddDownloads))); | 38 // CHECK(query.AddFilter(base::Bind(&FilterOutOddDownloads))); |
39 // query.AddSorter(SORT_BYTES_RECEIVED, ASCENDING); | 39 // query.AddSorter(SORT_BYTES_RECEIVED, ASCENDING); |
40 // query.AddSorter(SORT_URL, DESCENDING); | 40 // query.AddSorter(SORT_URL, DESCENDING); |
41 // query.Limit(20); | 41 // query.Limit(20); |
42 // DownloadVector all_items, results; | 42 // DownloadVector all_items, results; |
43 // query.Search(all_items.begin(), all_items.end(), &results); | 43 // query.Search(all_items.begin(), all_items.end(), &results); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 void FinishSearch(DownloadVector* results) const; | 155 void FinishSearch(DownloadVector* results) const; |
156 | 156 |
157 FilterCallbackVector filters_; | 157 FilterCallbackVector filters_; |
158 SorterVector sorters_; | 158 SorterVector sorters_; |
159 size_t limit_; | 159 size_t limit_; |
160 | 160 |
161 DISALLOW_COPY_AND_ASSIGN(DownloadQuery); | 161 DISALLOW_COPY_AND_ASSIGN(DownloadQuery); |
162 }; | 162 }; |
163 | 163 |
164 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_QUERY_H_ | 164 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_QUERY_H_ |
OLD | NEW |