Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: chrome/browser/download/download_query.h

Issue 7192016: chrome.experimental.downloads (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: DownloadQuery, single DownloadMap Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/download/download_prefs.cc ('k') | chrome/browser/download/download_query.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_QUERY_H_
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_QUERY_H_
7 #pragma once
8
9 #include <string>
10 #include <vector>
11
12 #include "base/callback.h"
13 #include "chrome/browser/download/download_item.h"
14
15 class DictionaryValue;
16 class ListValue;
17
18 namespace download_util {
19 // Used to search for DownloadItems.
20 //
21 // std::vector<DownloadItem*> results;
22 // std::string error_msg;
23 // scoped_ptr<ListValue> json_results(new ListValue());
24 // bool FilterOutOddDownloads(DownloadItem* item) {
25 // CHECK(item);
26 // return 0 == (item->id() % 2);
27 // }
28 // download_manager->Search(DownloadQuery().
29 // filter_func(base::Bind(&FilterOutOddDownloads))->
30 // filenameRegex(".*foo.*")->
31 // urlRegex(".*foo.*"),
32 // &results, &error_msg, json_results.get());
33 class DownloadQuery {
34 public:
35 typedef base::Callback<bool(DownloadItem*)> FilterType;
36
37 DownloadQuery();
38
39 explicit DownloadQuery(const DictionaryValue& json);
40
41 ~DownloadQuery() {}
42
43 // Modify items in-place to sort, filter, and limit.
44 // If results is non-NULL, convert the results to json in it.
45 // Return true iff the query is well-formed. Return false and set error_msg if
46 // query is malformed.
47 bool Search(std::vector<DownloadItem*>* items,
48 std::string* error_msg = NULL,
49 ListValue* results = NULL) const;
50
51 // Chainable settors set a field to a value and return |this|.
52 DownloadQuery* filter_func(FilterType func);
53 DownloadQuery* state_enum(DownloadItem::DownloadState dstate);
54 DownloadQuery* danger_enum(DownloadItem::DangerType danger_type);
55 #define Boolean bool
56 #define Integer int
57 #define String std::string
58 #define FIELD(name, type) \
59 protected: bool has_ ## name ## _; \
60 protected: type name ## _; \
61 public: DownloadQuery* name(type value) { \
62 name ## _ = value; \
63 has_ ## name ## _ = true; \
64 return this; \
65 }
66 #include "chrome/browser/download/download_query_fields.h"
67 #undef FIELD
68 #undef Boolean
69 #undef Integer
70 #undef String
71
72 protected:
73 FilterType filter_func_;
74 bool has_state_enum_;
75 DownloadItem::DownloadState state_enum_;
76 bool has_danger_enum_;
77 DownloadItem::DangerType danger_enum_;
78 // Allow copy and assign.
79 };
80 } // namespace download_util
81
82 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_QUERY_H_
OLDNEW
« no previous file with comments | « chrome/browser/download/download_prefs.cc ('k') | chrome/browser/download/download_query.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698