| 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 18 matching lines...) Expand all Loading... |
| 29 // complete. The pointer is NULL if the creation failed. | 29 // complete. The pointer is NULL if the creation failed. |
| 30 typedef base::Callback<void(history::AndroidStatement*)> QueryCallback; | 30 typedef base::Callback<void(history::AndroidStatement*)> QueryCallback; |
| 31 | 31 |
| 32 typedef base::Callback<void( | 32 typedef base::Callback<void( |
| 33 Handle, // handle | 33 Handle, // handle |
| 34 bool, // true if the update succeeded. | 34 bool, // true if the update succeeded. |
| 35 int)> // the number of row updated. | 35 int)> // the number of row updated. |
| 36 UpdateCallback; | 36 UpdateCallback; |
| 37 typedef CancelableRequest<UpdateCallback> UpdateRequest; | 37 typedef CancelableRequest<UpdateCallback> UpdateRequest; |
| 38 | 38 |
| 39 typedef base::Callback<void( | 39 // Callback invoked when a method inserting rows in the database complete. |
| 40 Handle, // handle | 40 // The value is the new row id or 0 if the insertion failed. |
| 41 bool, // true if the insert succeeded. | 41 typedef base::Callback<void(int64)> InsertCallback; |
| 42 int64)> // the id of inserted row. | |
| 43 InsertCallback; | |
| 44 typedef CancelableRequest<InsertCallback> InsertRequest; | |
| 45 | 42 |
| 46 typedef base::Callback<void( | 43 typedef base::Callback<void( |
| 47 Handle, // handle | 44 Handle, // handle |
| 48 bool, // true if the deletion succeeded. | 45 bool, // true if the deletion succeeded. |
| 49 int)> // the number of row deleted. | 46 int)> // the number of row deleted. |
| 50 DeleteCallback; | 47 DeleteCallback; |
| 51 typedef CancelableRequest<DeleteCallback> DeleteRequest; | 48 typedef CancelableRequest<DeleteCallback> DeleteRequest; |
| 52 | 49 |
| 53 // Callback invoked when a method moving an |AndroidStatement| is complete. | 50 // Callback invoked when a method moving an |AndroidStatement| is complete. |
| 54 // The value passed to the callback is the new position, or in case of | 51 // The value passed to the callback is the new position, or in case of |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 // | 90 // |
| 94 // if |selection| is empty all history and bookmarks are deleted. | 91 // if |selection| is empty all history and bookmarks are deleted. |
| 95 Handle DeleteHistoryAndBookmarks( | 92 Handle DeleteHistoryAndBookmarks( |
| 96 const std::string& selection, | 93 const std::string& selection, |
| 97 const std::vector<base::string16>& selection_args, | 94 const std::vector<base::string16>& selection_args, |
| 98 CancelableRequestConsumerBase* consumer, | 95 CancelableRequestConsumerBase* consumer, |
| 99 const DeleteCallback& callback); | 96 const DeleteCallback& callback); |
| 100 | 97 |
| 101 // Inserts the given values into history backend, and invokes the |callback| | 98 // Inserts the given values into history backend, and invokes the |callback| |
| 102 // to return the result. | 99 // to return the result. |
| 103 Handle InsertHistoryAndBookmark(const history::HistoryAndBookmarkRow& values, | 100 base::CancelableTaskTracker::TaskId InsertHistoryAndBookmark( |
| 104 CancelableRequestConsumerBase* consumer, | 101 const history::HistoryAndBookmarkRow& values, |
| 105 const InsertCallback& callback); | 102 const InsertCallback& callback, |
| 103 base::CancelableTaskTracker* tracker); |
| 106 | 104 |
| 107 // Deletes the matched history and invokes |callback| to return the number of | 105 // Deletes the matched history and invokes |callback| to return the number of |
| 108 // the row deleted from the |callback|. | 106 // the row deleted from the |callback|. |
| 109 Handle DeleteHistory(const std::string& selection, | 107 Handle DeleteHistory(const std::string& selection, |
| 110 const std::vector<base::string16>& selection_args, | 108 const std::vector<base::string16>& selection_args, |
| 111 CancelableRequestConsumerBase* consumer, | 109 CancelableRequestConsumerBase* consumer, |
| 112 const DeleteCallback& callback); | 110 const DeleteCallback& callback); |
| 113 | 111 |
| 114 // Statement ---------------------------------------------------------------- | 112 // Statement ---------------------------------------------------------------- |
| 115 // Moves the statement's current row from |current_pos| to |destination| in DB | 113 // Moves the statement's current row from |current_pos| to |destination| in DB |
| 116 // thread. The new position is returned to the callback. The result supplied | 114 // thread. The new position is returned to the callback. The result supplied |
| 117 // the callback is constrained by the number of rows might. | 115 // the callback is constrained by the number of rows might. |
| 118 base::CancelableTaskTracker::TaskId MoveStatement( | 116 base::CancelableTaskTracker::TaskId MoveStatement( |
| 119 history::AndroidStatement* statement, | 117 history::AndroidStatement* statement, |
| 120 int current_pos, | 118 int current_pos, |
| 121 int destination, | 119 int destination, |
| 122 const MoveStatementCallback& callback, | 120 const MoveStatementCallback& callback, |
| 123 base::CancelableTaskTracker* tracker); | 121 base::CancelableTaskTracker* tracker); |
| 124 | 122 |
| 125 // Closes the statement in db thread. The AndroidHistoryProviderService takes | 123 // Closes the statement in db thread. The AndroidHistoryProviderService takes |
| 126 // the ownership of |statement|. | 124 // the ownership of |statement|. |
| 127 void CloseStatement(history::AndroidStatement* statement); | 125 void CloseStatement(history::AndroidStatement* statement); |
| 128 | 126 |
| 129 // Search term -------------------------------------------------------------- | 127 // Search term -------------------------------------------------------------- |
| 130 // Inserts the given values and returns the SearchTermID of the inserted row | 128 // Inserts the given values and returns the SearchTermID of the inserted row |
| 131 // from the |callback| on success. | 129 // from the |callback| on success. |
| 132 Handle InsertSearchTerm(const history::SearchRow& row, | 130 base::CancelableTaskTracker::TaskId InsertSearchTerm( |
| 133 CancelableRequestConsumerBase* consumer, | 131 const history::SearchRow& row, |
| 134 const InsertCallback& callback); | 132 const InsertCallback& callback, |
| 133 base::CancelableTaskTracker* tracker); |
| 135 | 134 |
| 136 // Runs the given update and returns the number of the update rows from the | 135 // Runs the given update and returns the number of the update rows from the |
| 137 // |callback| on success. | 136 // |callback| on success. |
| 138 // | 137 // |
| 139 // |row| is the value need to update. | 138 // |row| is the value need to update. |
| 140 // |selection| is the SQL WHERE clause without 'WHERE'. | 139 // |selection| is the SQL WHERE clause without 'WHERE'. |
| 141 // |selection_args| is the arguments for WHERE clause. | 140 // |selection_args| is the arguments for WHERE clause. |
| 142 Handle UpdateSearchTerms(const history::SearchRow& row, | 141 Handle UpdateSearchTerms(const history::SearchRow& row, |
| 143 const std::string& selection, | 142 const std::string& selection, |
| 144 const std::vector<base::string16>& selection_args, | 143 const std::vector<base::string16>& selection_args, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 170 const QueryCallback& callback, | 169 const QueryCallback& callback, |
| 171 base::CancelableTaskTracker* tracker); | 170 base::CancelableTaskTracker* tracker); |
| 172 | 171 |
| 173 private: | 172 private: |
| 174 Profile* profile_; | 173 Profile* profile_; |
| 175 | 174 |
| 176 DISALLOW_COPY_AND_ASSIGN(AndroidHistoryProviderService); | 175 DISALLOW_COPY_AND_ASSIGN(AndroidHistoryProviderService); |
| 177 }; | 176 }; |
| 178 | 177 |
| 179 #endif // CHROME_BROWSER_HISTORY_ANDROID_ANDROID_HISTORY_PROVIDER_SERVICE_H_ | 178 #endif // CHROME_BROWSER_HISTORY_ANDROID_ANDROID_HISTORY_PROVIDER_SERVICE_H_ |
| OLD | NEW |