| 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 "chrome/browser/common/cancelable_request.h" | 11 #include "chrome/browser/common/cancelable_request.h" |
| 11 #include "chrome/browser/history/android/android_history_types.h" | 12 #include "chrome/browser/history/android/android_history_types.h" |
| 12 #include "sql/statement.h" | 13 #include "sql/statement.h" |
| 13 | 14 |
| 14 class Profile; | 15 class Profile; |
| 15 | 16 |
| 16 // This class provides the methods to communicate with history backend service | 17 // This class provides the methods to communicate with history backend service |
| 17 // for the Android content provider. | 18 // for the Android content provider. |
| 18 // The methods of this class must run on the UI thread to cooperate with the | 19 // The methods of this class must run on the UI thread to cooperate with the |
| 19 // BookmarkModel task posted in the DB thread. | 20 // BookmarkModel task posted in the DB thread. |
| 20 class AndroidHistoryProviderService : public CancelableRequestProvider { | 21 class AndroidHistoryProviderService : public CancelableRequestProvider { |
| 21 public: | 22 public: |
| 22 explicit AndroidHistoryProviderService(Profile* profile); | 23 explicit AndroidHistoryProviderService(Profile* profile); |
| 23 virtual ~AndroidHistoryProviderService(); | 24 virtual ~AndroidHistoryProviderService(); |
| 24 | 25 |
| 25 // The callback definitions ------------------------------------------------ | 26 // The callback definitions ------------------------------------------------ |
| 26 typedef base::Callback<void( | 27 |
| 27 Handle, // handle | 28 // Callback invoked when a method creating an |AndroidStatement| object is |
| 28 bool, // true if the query succeeded. | 29 // complete. The pointer is NULL if the creation failed. |
| 29 history::AndroidStatement*)> // the result of query | 30 typedef base::Callback<void(history::AndroidStatement*)> QueryCallback; |
| 30 QueryCallback; | |
| 31 typedef CancelableRequest<QueryCallback> QueryRequest; | |
| 32 | 31 |
| 33 typedef base::Callback<void( | 32 typedef base::Callback<void( |
| 34 Handle, // handle | 33 Handle, // handle |
| 35 bool, // true if the update succeeded. | 34 bool, // true if the update succeeded. |
| 36 int)> // the number of row updated. | 35 int)> // the number of row updated. |
| 37 UpdateCallback; | 36 UpdateCallback; |
| 38 typedef CancelableRequest<UpdateCallback> UpdateRequest; | 37 typedef CancelableRequest<UpdateCallback> UpdateRequest; |
| 39 | 38 |
| 40 typedef base::Callback<void( | 39 typedef base::Callback<void( |
| 41 Handle, // handle | 40 Handle, // handle |
| (...skipping 17 matching lines...) Expand all Loading... |
| 59 | 58 |
| 60 // History and Bookmarks ---------------------------------------------------- | 59 // History and Bookmarks ---------------------------------------------------- |
| 61 // | 60 // |
| 62 // Runs the given query on history backend, and invokes the |callback| to | 61 // Runs the given query on history backend, and invokes the |callback| to |
| 63 // return the result. | 62 // return the result. |
| 64 // | 63 // |
| 65 // |projections| is the vector of the result columns. | 64 // |projections| is the vector of the result columns. |
| 66 // |selection| is the SQL WHERE clause without 'WHERE'. | 65 // |selection| is the SQL WHERE clause without 'WHERE'. |
| 67 // |selection_args| is the arguments for WHERE clause. | 66 // |selection_args| is the arguments for WHERE clause. |
| 68 // |sort_order| is the SQL ORDER clause. | 67 // |sort_order| is the SQL ORDER clause. |
| 69 Handle QueryHistoryAndBookmarks( | 68 base::CancelableTaskTracker::TaskId QueryHistoryAndBookmarks( |
| 70 const std::vector<history::HistoryAndBookmarkRow::ColumnID>& projections, | 69 const std::vector<history::HistoryAndBookmarkRow::ColumnID>& projections, |
| 71 const std::string& selection, | 70 const std::string& selection, |
| 72 const std::vector<base::string16>& selection_args, | 71 const std::vector<base::string16>& selection_args, |
| 73 const std::string& sort_order, | 72 const std::string& sort_order, |
| 74 CancelableRequestConsumerBase* consumer, | 73 const QueryCallback& callback, |
| 75 const QueryCallback& callback); | 74 base::CancelableTaskTracker* tracker); |
| 76 | 75 |
| 77 // Runs the given update and the number of the row updated is returned to the | 76 // Runs the given update and the number of the row updated is returned to the |
| 78 // |callback| on success. | 77 // |callback| on success. |
| 79 // | 78 // |
| 80 // |row| is the value to update. | 79 // |row| is the value to update. |
| 81 // |selection| is the SQL WHERE clause without 'WHERE'. | 80 // |selection| is the SQL WHERE clause without 'WHERE'. |
| 82 // |selection_args| is the arguments for the WHERE clause. | 81 // |selection_args| is the arguments for the WHERE clause. |
| 83 Handle UpdateHistoryAndBookmarks( | 82 Handle UpdateHistoryAndBookmarks( |
| 84 const history::HistoryAndBookmarkRow& row, | 83 const history::HistoryAndBookmarkRow& row, |
| 85 const std::string& selection, | 84 const std::string& selection, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 const std::vector<base::string16>& selection_args, | 155 const std::vector<base::string16>& selection_args, |
| 157 CancelableRequestConsumerBase* consumer, | 156 CancelableRequestConsumerBase* consumer, |
| 158 const DeleteCallback& callback); | 157 const DeleteCallback& callback); |
| 159 | 158 |
| 160 // Returns the result of the given query from the |callback|. | 159 // Returns the result of the given query from the |callback|. |
| 161 // |projections| specifies the result columns, can not be empty, otherwise | 160 // |projections| specifies the result columns, can not be empty, otherwise |
| 162 // NULL is returned. | 161 // NULL is returned. |
| 163 // |selection| is the SQL WHERE clause without 'WHERE'. | 162 // |selection| is the SQL WHERE clause without 'WHERE'. |
| 164 // |selection_args| is the arguments for WHERE clause. | 163 // |selection_args| is the arguments for WHERE clause. |
| 165 // |sort_order| the SQL ORDER clause. | 164 // |sort_order| the SQL ORDER clause. |
| 166 Handle QuerySearchTerms( | 165 base::CancelableTaskTracker::TaskId QuerySearchTerms( |
| 167 const std::vector<history::SearchRow::ColumnID>& projections, | 166 const std::vector<history::SearchRow::ColumnID>& projections, |
| 168 const std::string& selection, | 167 const std::string& selection, |
| 169 const std::vector<base::string16>& selection_args, | 168 const std::vector<base::string16>& selection_args, |
| 170 const std::string& sort_order, | 169 const std::string& sort_order, |
| 171 CancelableRequestConsumerBase* consumer, | 170 const QueryCallback& callback, |
| 172 const QueryCallback& callback); | 171 base::CancelableTaskTracker* tracker); |
| 173 | 172 |
| 174 private: | 173 private: |
| 175 Profile* profile_; | 174 Profile* profile_; |
| 176 | 175 |
| 177 DISALLOW_COPY_AND_ASSIGN(AndroidHistoryProviderService); | 176 DISALLOW_COPY_AND_ASSIGN(AndroidHistoryProviderService); |
| 178 }; | 177 }; |
| 179 | 178 |
| 180 #endif // CHROME_BROWSER_HISTORY_ANDROID_ANDROID_HISTORY_PROVIDER_SERVICE_H_ | 179 #endif // CHROME_BROWSER_HISTORY_ANDROID_ANDROID_HISTORY_PROVIDER_SERVICE_H_ |
| OLD | NEW |