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

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

Issue 10217010: Completed the code path from AndroidProviderService to HistoryBackend. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address the comments Created 8 years, 8 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_HISTORY_ANDROID_ANDROID_HISTORY_PROVIDER_SERVICE_H_
6 #define CHROME_BROWSER_HISTORY_ANDROID_ANDROID_HISTORY_PROVIDER_SERVICE_H_
7
8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "chrome/browser/cancelable_request.h"
11 #include "chrome/browser/history/android/android_history_types.h"
12 #include "sql/statement.h"
13
14 class Profile;
15
16 // This class provides the methods to communicate with history backend service
17 // for the Android content provider.
18 // The methods of this class must run on the UI thread to cooperate with the
19 // BookmarkModel task posted in the DB thread.
20 class AndroidHistoryProviderService : public CancelableRequestProvider {
21 public:
22 explicit AndroidHistoryProviderService(Profile* profile);
23 virtual ~AndroidHistoryProviderService();
24
25 // The callback definitions ------------------------------------------------
26 typedef base::Callback<void(
27 Handle, // handle
28 bool, // true if the query succeeded.
29 history::AndroidStatement*)> // the result of query
30 QueryCallback;
31 typedef CancelableRequest<QueryCallback> QueryRequest;
32
33 typedef base::Callback<void(
34 Handle, // handle
35 bool, // true if the update succeeded.
36 int)> // the number of row updated.
37 UpdateCallback;
38 typedef CancelableRequest<UpdateCallback> UpdateRequest;
39
40 typedef base::Callback<void(
41 Handle, // handle
42 bool, // true if the insert succeeded.
43 int64)> // the id of inserted row.
44 InsertCallback;
45 typedef CancelableRequest<InsertCallback> InsertRequest;
46
47 typedef base::Callback<void(
48 Handle, // handle
49 bool, // true if the deletion succeeded.
50 int)> // the number of row deleted.
51 DeleteCallback;
52 typedef CancelableRequest<DeleteCallback> DeleteRequest;
53
54 typedef base::Callback<void(
55 Handle, // handle
56 int)> // the new position.
57 MoveStatementCallback;
58 typedef CancelableRequest<MoveStatementCallback> MoveStatementRequest;
59
60 // History and Bookmarks ----------------------------------------------------
61 //
62 // Runs the given query on history backend, and invokes the |callback| to
63 // return the result.
64 //
65 // |projections| is the vector of the result columns.
66 // |selection| is the SQL WHERE clause without 'WHERE'.
67 // |selection_args| is the arguments for WHERE clause.
68 // |sort_order| is the SQL ORDER clause.
69 void QueryHistoryAndBookmarks(
sky 2012/04/27 21:37:22 How come none of these return a Handle? Do you nev
michaelbai 2012/04/27 23:26:04 It was there, it seemed that someone removed them
70 const std::vector<history::HistoryAndBookmarkRow::ColumnID>& projections,
71 const std::string selection,
sky 2012/04/27 21:37:22 const std::string&
michaelbai 2012/04/27 23:26:04 Done.
72 const std::vector<string16>& selection_args,
73 const std::string sort_order,
sky 2012/04/27 21:37:22 const std::string&
michaelbai 2012/04/27 23:26:04 Done.
74 CancelableRequestConsumerBase* consumer,
75 const QueryCallback& callback);
76
77 // Runs the given update and the number of the row updated is returned from
sky 2012/04/27 21:37:22 from -> to the
michaelbai 2012/04/27 23:26:04 Done.
78 // |callback| on success.
79 //
80 // |row| is the value to update.
81 // |selection| is the SQL WHERE clause without 'WHERE'.
82 // |selection_args| is the arguments for the WHERE clause.
83 void UpdateHistoryAndBookmarks(const history::HistoryAndBookmarkRow& row,
84 const std::string& selection,
85 const std::vector<string16>& selection_args,
86 CancelableRequestConsumerBase* consumer,
87 const UpdateCallback& callback);
88
89 // Deletes the specified rows and invokes the |callback| to return the number
90 // of row deleted on success.
91 //
92 // |selection| is the SQL WHERE clause without 'WHERE'.
93 // |selection_args| is the arguments for the WHERE clause.
94 //
95 // if |selection| is empty all history and bookmarks are deleted.
96 void DeleteHistoryAndBookmarks(const std::string& selection,
97 const std::vector<string16>& selection_args,
98 CancelableRequestConsumerBase* consumer,
99 const DeleteCallback& callback);
100
101 // Inserts the given values into history backend, and invokes the |callback|
102 // to return the result.
103 void InsertHistoryAndBookmark(const history::HistoryAndBookmarkRow& values,
104 CancelableRequestConsumerBase* consumer,
105 const InsertCallback& callback);
106
107 // Deletes the matched history and invokes |callback| to return the number of
108 // the row deleted from the |callback|.
109 void DeleteHistory(const std::string& selection,
110 const std::vector<string16>& selection_args,
111 CancelableRequestConsumerBase* consumer,
112 const DeleteCallback& callback);
113
114 // Statement ----------------------------------------------------------------
115 // Moved the statement's current row from |current_pos| to |destination| in DB
sky 2012/04/27 21:37:22 Moved -> Moves
michaelbai 2012/04/27 23:26:04 Done.
116 // thread. The new position will be returned in the callback and might not be
sky 2012/04/27 21:37:22 will be -> is returned to the callback. The result
michaelbai 2012/04/27 23:26:04 Done.
117 // the |destination| if the |destination| isn't less than the count of rows.
118 void MoveStatement(history::AndroidStatement* statement,
119 int current_pos,
120 int destination,
121 CancelableRequestConsumerBase* consumer,
122 const MoveStatementCallback& callback);
123
124 // Asks to close the statement in database thread. The ownership of
sky 2012/04/27 21:37:22 Closes the statement on the db thread. AndroidHist
michaelbai 2012/04/27 23:26:04 Done.
125 // |statement| is transferred.
126 void CloseStatement(history::AndroidStatement* statement);
127
128 // Search term --------------------------------------------------------------
129 // Inserts the given valus and return the SearchTermID of the inserted row
sky 2012/04/27 21:37:22 valus -> values return -> returns
michaelbai 2012/04/27 23:26:04 Done.
130 // from the |callback| on success.
131 void InsertSearchTerm(const history::SearchRow& row,
132 CancelableRequestConsumerBase* consumer,
133 const InsertCallback& callback);
134
135 // Runs the given update and returns the number of the updated rows from the
sky 2012/04/27 21:37:22 of the updated -> of update
michaelbai 2012/04/27 23:26:04 Done.
136 // |callback| on success.
137 //
138 // |row| is the value need to update.
139 // |selection| is the SQL WHERE clause without 'WHERE'.
140 // |selection_args| is the arguments for WHERE clause.
141 void UpdateSearchTerms(const history::SearchRow& row,
142 const std::string& selection,
143 const std::vector<string16>& selection_args,
144 CancelableRequestConsumerBase* consumer,
145 const UpdateCallback& callback);
146
147 // Deletes the matched rows and the number of deleted rows is returned from
148 // the |callback| on success.
149 // |selection| is the SQL WHERE clause without 'WHERE'.
150 // |selection_args| is the arguments for WHERE clause.
151 //
152 // if |selection| is empty all search be deleted.
153 void DeleteSearchTerms(const std::string& selection,
154 const std::vector<string16>& selection_args,
155 CancelableRequestConsumerBase* consumer,
156 const DeleteCallback& callback);
157
158 // Returns the result of the given query from the |callback|.
159 // |projections| specifies the result columns, can not be empty, otherwise
160 // NULL is returned.
161 // |selection| is the SQL WHERE clause without 'WHERE'.
162 // |selection_args| is the arguments for WHERE clause.
163 // |sort_order| the SQL ORDER clause.
164 void QuerySearchTerms(
165 const std::vector<history::SearchRow::ColumnID>& projections,
166 const std::string selection,
sky 2012/04/27 21:37:22 const std::string&
michaelbai 2012/04/27 23:26:04 Done.
167 const std::vector<string16>& selection_args,
168 const std::string sort_order,
sky 2012/04/27 21:37:22 const std::string&
michaelbai 2012/04/27 23:26:04 Done.
169 CancelableRequestConsumerBase* consumer,
170 const QueryCallback& callback);
171
172 private:
173 Profile* profile_;
174
175 DISALLOW_COPY_AND_ASSIGN(AndroidHistoryProviderService);
176 };
177
178 #endif // CHROME_BROWSER_HISTORY_ANDROID_ANDROID_HISTORY_PROVIDER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698