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_HISTORY_ANDROID_ANDROID_HISTORY_PROVIDER_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_ANDROID_ANDROID_HISTORY_PROVIDER_SERVICE_H_ |
6 #define CHROME_BROWSER_HISTORY_ANDROID_ANDROID_HISTORY_PROVIDER_SERVICE_H_ | 6 #define CHROME_BROWSER_HISTORY_ANDROID_ANDROID_HISTORY_PROVIDER_SERVICE_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/task/cancelable_task_tracker.h" | 10 #include "base/task/cancelable_task_tracker.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 typedef base::Callback<void(history::AndroidStatement*)> QueryCallback; | 30 typedef base::Callback<void(history::AndroidStatement*)> QueryCallback; |
31 | 31 |
32 // Callback invoked when a method updating rows in the database complete. | 32 // Callback invoked when a method updating rows in the database complete. |
33 // The parameter is the number of rows updated or 0 if the update failed. | 33 // The parameter is the number of rows updated or 0 if the update failed. |
34 typedef base::Callback<void(int)> UpdateCallback; | 34 typedef base::Callback<void(int)> UpdateCallback; |
35 | 35 |
36 // Callback invoked when a method inserting rows in the database complete. | 36 // Callback invoked when a method inserting rows in the database complete. |
37 // The value is the new row id or 0 if the insertion failed. | 37 // The value is the new row id or 0 if the insertion failed. |
38 typedef base::Callback<void(int64)> InsertCallback; | 38 typedef base::Callback<void(int64)> InsertCallback; |
39 | 39 |
40 typedef base::Callback<void( | 40 // Callback invoked when a method deleting rows in the database complete. |
41 Handle, // handle | 41 // The value is the number of rows deleted or 0 if the deletion failed. |
42 bool, // true if the deletion succeeded. | 42 typedef base::Callback<void(int)> DeleteCallback; |
43 int)> // the number of row deleted. | |
44 DeleteCallback; | |
45 typedef CancelableRequest<DeleteCallback> DeleteRequest; | |
46 | 43 |
47 // Callback invoked when a method moving an |AndroidStatement| is complete. | 44 // Callback invoked when a method moving an |AndroidStatement| is complete. |
48 // The value passed to the callback is the new position, or in case of | 45 // The value passed to the callback is the new position, or in case of |
49 // failure, the old position. | 46 // failure, the old position. |
50 typedef base::Callback<void(int)> MoveStatementCallback; | 47 typedef base::Callback<void(int)> MoveStatementCallback; |
51 | 48 |
52 // History and Bookmarks ---------------------------------------------------- | 49 // History and Bookmarks ---------------------------------------------------- |
53 // | 50 // |
54 // Runs the given query on history backend, and invokes the |callback| to | 51 // Runs the given query on history backend, and invokes the |callback| to |
55 // return the result. | 52 // return the result. |
(...skipping 22 matching lines...) Expand all Loading... |
78 const std::vector<base::string16>& selection_args, | 75 const std::vector<base::string16>& selection_args, |
79 const UpdateCallback& callback, | 76 const UpdateCallback& callback, |
80 base::CancelableTaskTracker* tracker); | 77 base::CancelableTaskTracker* tracker); |
81 | 78 |
82 // Deletes the specified rows and invokes the |callback| to return the number | 79 // Deletes the specified rows and invokes the |callback| to return the number |
83 // of row deleted on success. | 80 // of row deleted on success. |
84 // | 81 // |
85 // |selection| is the SQL WHERE clause without 'WHERE'. | 82 // |selection| is the SQL WHERE clause without 'WHERE'. |
86 // |selection_args| is the arguments for the WHERE clause. | 83 // |selection_args| is the arguments for the WHERE clause. |
87 // | 84 // |
88 // if |selection| is empty all history and bookmarks are deleted. | 85 // If |selection| is empty all history and bookmarks are deleted. |
89 Handle DeleteHistoryAndBookmarks( | 86 base::CancelableTaskTracker::TaskId DeleteHistoryAndBookmarks( |
90 const std::string& selection, | 87 const std::string& selection, |
91 const std::vector<base::string16>& selection_args, | 88 const std::vector<base::string16>& selection_args, |
92 CancelableRequestConsumerBase* consumer, | 89 const DeleteCallback& callback, |
93 const DeleteCallback& callback); | 90 base::CancelableTaskTracker* tracker); |
94 | 91 |
95 // Inserts the given values into history backend, and invokes the |callback| | 92 // Inserts the given values into history backend, and invokes the |callback| |
96 // to return the result. | 93 // to return the result. |
97 base::CancelableTaskTracker::TaskId InsertHistoryAndBookmark( | 94 base::CancelableTaskTracker::TaskId InsertHistoryAndBookmark( |
98 const history::HistoryAndBookmarkRow& values, | 95 const history::HistoryAndBookmarkRow& values, |
99 const InsertCallback& callback, | 96 const InsertCallback& callback, |
100 base::CancelableTaskTracker* tracker); | 97 base::CancelableTaskTracker* tracker); |
101 | 98 |
102 // Deletes the matched history and invokes |callback| to return the number of | 99 // Deletes the matched history and invokes |callback| to return the number of |
103 // the row deleted from the |callback|. | 100 // rows deleted. |
104 Handle DeleteHistory(const std::string& selection, | 101 base::CancelableTaskTracker::TaskId DeleteHistory( |
105 const std::vector<base::string16>& selection_args, | 102 const std::string& selection, |
106 CancelableRequestConsumerBase* consumer, | 103 const std::vector<base::string16>& selection_args, |
107 const DeleteCallback& callback); | 104 const DeleteCallback& callback, |
| 105 base::CancelableTaskTracker* tracker); |
108 | 106 |
109 // Statement ---------------------------------------------------------------- | 107 // Statement ---------------------------------------------------------------- |
110 // Moves the statement's current row from |current_pos| to |destination| in DB | 108 // Moves the statement's current row from |current_pos| to |destination| in DB |
111 // thread. The new position is returned to the callback. The result supplied | 109 // thread. The new position is returned to the callback. The result supplied |
112 // the callback is constrained by the number of rows might. | 110 // the callback is constrained by the number of rows might. |
113 base::CancelableTaskTracker::TaskId MoveStatement( | 111 base::CancelableTaskTracker::TaskId MoveStatement( |
114 history::AndroidStatement* statement, | 112 history::AndroidStatement* statement, |
115 int current_pos, | 113 int current_pos, |
116 int destination, | 114 int destination, |
117 const MoveStatementCallback& callback, | 115 const MoveStatementCallback& callback, |
(...skipping 23 matching lines...) Expand all Loading... |
141 const std::vector<base::string16>& selection_args, | 139 const std::vector<base::string16>& selection_args, |
142 const UpdateCallback& callback, | 140 const UpdateCallback& callback, |
143 base::CancelableTaskTracker* tracker); | 141 base::CancelableTaskTracker* tracker); |
144 | 142 |
145 // Deletes the matched rows and the number of deleted rows is returned to | 143 // Deletes the matched rows and the number of deleted rows is returned to |
146 // the |callback| on success. | 144 // the |callback| on success. |
147 // | 145 // |
148 // |selection| is the SQL WHERE clause without 'WHERE'. | 146 // |selection| is the SQL WHERE clause without 'WHERE'. |
149 // |selection_args| is the arguments for WHERE clause. | 147 // |selection_args| is the arguments for WHERE clause. |
150 // | 148 // |
151 // if |selection| is empty all search be deleted. | 149 // If |selection| is empty all search terms will be deleted. |
152 Handle DeleteSearchTerms(const std::string& selection, | 150 base::CancelableTaskTracker::TaskId DeleteSearchTerms( |
153 const std::vector<base::string16>& selection_args, | 151 const std::string& selection, |
154 CancelableRequestConsumerBase* consumer, | 152 const std::vector<base::string16>& selection_args, |
155 const DeleteCallback& callback); | 153 const DeleteCallback& callback, |
| 154 base::CancelableTaskTracker* tracker); |
156 | 155 |
157 // Runs the query and invokes the |callback| to return the result. | 156 // Runs the query and invokes the |callback| to return the result. |
158 // | 157 // |
159 // |projections| specifies the result columns, can not be empty, otherwise | 158 // |projections| specifies the result columns, can not be empty, otherwise |
160 // NULL is returned. | 159 // NULL is returned. |
161 // |selection| is the SQL WHERE clause without 'WHERE'. | 160 // |selection| is the SQL WHERE clause without 'WHERE'. |
162 // |selection_args| is the arguments for WHERE clause. | 161 // |selection_args| is the arguments for WHERE clause. |
163 // |sort_order| the SQL ORDER clause. | 162 // |sort_order| the SQL ORDER clause. |
164 base::CancelableTaskTracker::TaskId QuerySearchTerms( | 163 base::CancelableTaskTracker::TaskId QuerySearchTerms( |
165 const std::vector<history::SearchRow::ColumnID>& projections, | 164 const std::vector<history::SearchRow::ColumnID>& projections, |
166 const std::string& selection, | 165 const std::string& selection, |
167 const std::vector<base::string16>& selection_args, | 166 const std::vector<base::string16>& selection_args, |
168 const std::string& sort_order, | 167 const std::string& sort_order, |
169 const QueryCallback& callback, | 168 const QueryCallback& callback, |
170 base::CancelableTaskTracker* tracker); | 169 base::CancelableTaskTracker* tracker); |
171 | 170 |
172 private: | 171 private: |
173 Profile* profile_; | 172 Profile* profile_; |
174 | 173 |
175 DISALLOW_COPY_AND_ASSIGN(AndroidHistoryProviderService); | 174 DISALLOW_COPY_AND_ASSIGN(AndroidHistoryProviderService); |
176 }; | 175 }; |
177 | 176 |
178 #endif // CHROME_BROWSER_HISTORY_ANDROID_ANDROID_HISTORY_PROVIDER_SERVICE_H_ | 177 #endif // CHROME_BROWSER_HISTORY_ANDROID_ANDROID_HISTORY_PROVIDER_SERVICE_H_ |
OLD | NEW |