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

Side by Side Diff: chrome/browser/history/android/android_history_provider_service.h

Issue 369673009: Change AndroidHistoryProviderService to use CancelableTaskTracker (2/6) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cancelable_task_tracker.2
Patch Set: Fix unit tests Created 6 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
OLDNEW
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
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // the |callback| on success. 149 // the |callback| on success.
151 // |selection| is the SQL WHERE clause without 'WHERE'. 150 // |selection| is the SQL WHERE clause without 'WHERE'.
152 // |selection_args| is the arguments for WHERE clause. 151 // |selection_args| is the arguments for WHERE clause.
153 // 152 //
154 // if |selection| is empty all search be deleted. 153 // if |selection| is empty all search be deleted.
155 Handle DeleteSearchTerms(const std::string& selection, 154 Handle DeleteSearchTerms(const std::string& selection,
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 // Runs the query and invokes the |callback| to return the result.
160 //
161 // |projections| specifies the result columns, can not be empty, otherwise 161 // |projections| specifies the result columns, can not be empty, otherwise
162 // NULL is returned. 162 // NULL is returned.
163 // |selection| is the SQL WHERE clause without 'WHERE'. 163 // |selection| is the SQL WHERE clause without 'WHERE'.
164 // |selection_args| is the arguments for WHERE clause. 164 // |selection_args| is the arguments for WHERE clause.
165 // |sort_order| the SQL ORDER clause. 165 // |sort_order| the SQL ORDER clause.
166 Handle QuerySearchTerms( 166 base::CancelableTaskTracker::TaskId QuerySearchTerms(
167 const std::vector<history::SearchRow::ColumnID>& projections, 167 const std::vector<history::SearchRow::ColumnID>& projections,
168 const std::string& selection, 168 const std::string& selection,
169 const std::vector<base::string16>& selection_args, 169 const std::vector<base::string16>& selection_args,
170 const std::string& sort_order, 170 const std::string& sort_order,
171 CancelableRequestConsumerBase* consumer, 171 const QueryCallback& callback,
172 const QueryCallback& callback); 172 base::CancelableTaskTracker* tracker);
173 173
174 private: 174 private:
175 Profile* profile_; 175 Profile* profile_;
176 176
177 DISALLOW_COPY_AND_ASSIGN(AndroidHistoryProviderService); 177 DISALLOW_COPY_AND_ASSIGN(AndroidHistoryProviderService);
178 }; 178 };
179 179
180 #endif // CHROME_BROWSER_HISTORY_ANDROID_ANDROID_HISTORY_PROVIDER_SERVICE_H_ 180 #endif // CHROME_BROWSER_HISTORY_ANDROID_ANDROID_HISTORY_PROVIDER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698