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

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

Issue 15275004: bookmarks: Get rid of the dependency on history_notifications.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more android fixes Created 7 years, 7 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
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_PROVIDER_BACKEND_H_ 5 #ifndef CHROME_BROWSER_HISTORY_ANDROID_ANDROID_PROVIDER_BACKEND_H_
6 #define CHROME_BROWSER_HISTORY_ANDROID_ANDROID_PROVIDER_BACKEND_H_ 6 #define CHROME_BROWSER_HISTORY_ANDROID_ANDROID_PROVIDER_BACKEND_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/hash_tables.h" 12 #include "base/hash_tables.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "chrome/browser/history/android/android_cache_database.h" 15 #include "chrome/browser/history/android/android_cache_database.h"
16 #include "chrome/browser/history/android/android_history_types.h" 16 #include "chrome/browser/history/android/android_history_types.h"
17 #include "chrome/browser/history/android/sql_handler.h" 17 #include "chrome/browser/history/android/sql_handler.h"
18 #include "chrome/browser/history/history_backend.h" 18 #include "chrome/browser/history/history_backend.h"
19 #include "chrome/browser/history/history_notifications.h" 19 #include "chrome/browser/history/history_notifications.h"
20 #include "sql/statement.h" 20 #include "sql/statement.h"
21 #include "sql/transaction.h" 21 #include "sql/transaction.h"
22 22
23 class BookmarkService; 23 class BookmarkService;
24 24
25 namespace chrome {
26 struct FaviconChangedDetails;
27 }
28
25 namespace history { 29 namespace history {
26 30
27 class AndroidProviderBackend; 31 class AndroidProviderBackend;
28 class AndroidURLsSQLHandler; 32 class AndroidURLsSQLHandler;
29 class HistoryDatabase; 33 class HistoryDatabase;
30 class ThumbnailDatabase; 34 class ThumbnailDatabase;
31 35
32 // This class provides the query/insert/update/remove methods to implement 36 // This class provides the query/insert/update/remove methods to implement
33 // android.provider.Browser.BookmarkColumns and 37 // android.provider.Browser.BookmarkColumns and
34 // android.provider.Browser.SearchColumns API. 38 // android.provider.Browser.SearchColumns API.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 150
147 struct HistoryNotification { 151 struct HistoryNotification {
148 HistoryNotification(int type, HistoryDetails* detail); 152 HistoryNotification(int type, HistoryDetails* detail);
149 ~HistoryNotification(); 153 ~HistoryNotification();
150 154
151 int type; 155 int type;
152 // The ownership of the HistoryDetails pointer is transfered to |detail|. 156 // The ownership of the HistoryDetails pointer is transfered to |detail|.
153 HistoryDetails* detail; 157 HistoryDetails* detail;
154 }; 158 };
155 typedef std::vector<HistoryNotification> HistoryNotifications; 159 typedef std::vector<HistoryNotification> HistoryNotifications;
160 typedef std::vector<chrome::FaviconChangedDetails*> FaviconNotifications;
156 161
157 // The scoped transaction for AndroidProviderBackend. 162 // The scoped transaction for AndroidProviderBackend.
158 // 163 //
159 // The new transactions are started automatically in both history and 164 // The new transactions are started automatically in both history and
160 // thumbnail database and could be a nesting transaction, if so, rolling back 165 // thumbnail database and could be a nesting transaction, if so, rolling back
161 // of this transaction will cause the exsting and subsequent nesting 166 // of this transaction will cause the exsting and subsequent nesting
162 // transactions failed. 167 // transactions failed.
163 // 168 //
164 // Commit() is used to commit the transaction, otherwise the transaction will 169 // Commit() is used to commit the transaction, otherwise the transaction will
165 // be rolled back when the object is out of scope. This transaction could 170 // be rolled back when the object is out of scope. This transaction could
(...skipping 26 matching lines...) Expand all
192 // Runs the given update and returns the number of updated rows in 197 // Runs the given update and returns the number of updated rows in
193 // |update_count| and return true on success, false on error. 198 // |update_count| and return true on success, false on error.
194 // 199 //
195 // The notifications are returned in |notifications| and the ownership of them 200 // The notifications are returned in |notifications| and the ownership of them
196 // is transfered to caller. 201 // is transfered to caller.
197 // 202 //
198 // |row| is the value to update. 203 // |row| is the value to update.
199 // |selection| is the SQL WHERE clause without 'WHERE'. 204 // |selection| is the SQL WHERE clause without 'WHERE'.
200 // |selection_args| is the arguments for the WHERE clause. 205 // |selection_args| is the arguments for the WHERE clause.
201 bool UpdateHistoryAndBookmarks(const HistoryAndBookmarkRow& row, 206 bool UpdateHistoryAndBookmarks(const HistoryAndBookmarkRow& row,
202 const std::string& selection, 207 const std::string& selection,
203 const std::vector<string16>& selection_args, 208 const std::vector<string16>& selection_args,
204 int* update_count, 209 int* update_count,
205 HistoryNotifications* notifications); 210 HistoryNotifications* notifications,
211 FaviconNotifications* favicon_notifications);
206 212
207 // Inserts the given values and returns the URLID of the inserted row. 213 // Inserts the given values and returns the URLID of the inserted row.
208 // The notifications are returned in |notifications| and the ownership of them 214 // The notifications are returned in |notifications| and the ownership of them
209 // is transfered to caller. 215 // is transfered to caller.
210 // The EnsureInitializedAndUpdated() will not be invoked if the 216 // The EnsureInitializedAndUpdated() will not be invoked if the
211 // |ensure_initialized_and_updated| is false. 217 // |ensure_initialized_and_updated| is false.
212 AndroidURLID InsertHistoryAndBookmark(const HistoryAndBookmarkRow& values, 218 AndroidURLID InsertHistoryAndBookmark(
213 HistoryNotifications* notifications, 219 const HistoryAndBookmarkRow& values,
214 bool ensure_initialized_and_updated); 220 HistoryNotifications* notifications,
221 FaviconNotifications* favicon_notifications,
222 bool ensure_initialized_and_updated);
sky 2013/05/20 14:48:13 out params should be last.
215 223
216 // Deletes the specified rows and returns the number of the deleted rows in 224 // Deletes the specified rows and returns the number of the deleted rows in
217 // |deleted_count|. 225 // |deleted_count|.
218 // |selection| is the SQL WHERE clause without 'WHERE'. 226 // |selection| is the SQL WHERE clause without 'WHERE'.
219 // |selection_args| is the arguments for the WHERE clause. 227 // |selection_args| is the arguments for the WHERE clause.
220 // 228 //
221 // The notifications are returned in |notifications| and the ownership of them 229 // The notifications are returned in |notifications| and the ownership of them
222 // is transfered to the caller. 230 // is transfered to the caller.
223 // if |selection| is empty all history and bookmarks are deleted. 231 // if |selection| is empty all history and bookmarks are deleted.
224 bool DeleteHistoryAndBookmarks(const std::string& selection, 232 bool DeleteHistoryAndBookmarks(const std::string& selection,
225 const std::vector<string16>& selection_args, 233 const std::vector<string16>& selection_args,
226 int* deleted_count, 234 int* deleted_count,
227 HistoryNotifications* notifications); 235 HistoryNotifications* notifications);
228 236
229 // Deletes the matched history, returns true on success, false on error. 237 // Deletes the matched history, returns true on success, false on error.
230 // The number of deleted row is returned in |deleted_count|. 238 // The number of deleted row is returned in |deleted_count|.
231 // The notifications are returned in |notifications| and the ownership of them 239 // The notifications are returned in |notifications| and the ownership of them
232 // is transfered to caller. 240 // is transfered to caller.
233 // The url row is kept and the visit is reset if the matched url is 241 // The url row is kept and the visit is reset if the matched url is
234 // bookmarked. 242 // bookmarked.
235 bool DeleteHistory(const std::string& selection, 243 bool DeleteHistory(const std::string& selection,
236 const std::vector<string16>& selection_args, 244 const std::vector<string16>& selection_args,
237 int* deleted_count, 245 int* deleted_count,
238 HistoryNotifications* notifications); 246 HistoryNotifications* notifications,
247 FaviconNotifications* favicon_notifications);
239 248
240 // Initializes and updates tables if necessary. 249 // Initializes and updates tables if necessary.
241 bool EnsureInitializedAndUpdated(); 250 bool EnsureInitializedAndUpdated();
242 251
243 // Initializes AndroidProviderBackend. 252 // Initializes AndroidProviderBackend.
244 bool Init(); 253 bool Init();
245 254
246 // Update android_urls and bookmark_cache table if it is necessary. 255 // Update android_urls and bookmark_cache table if it is necessary.
247 bool UpdateTables(); 256 bool UpdateTables();
248 257
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 const std::string& sort_order); 312 const std::string& sort_order);
304 313
305 // Delete the given urls' history, returns true on success, or false on error. 314 // Delete the given urls' history, returns true on success, or false on error.
306 // If |delete_bookmarks| is set, the bookmarks are deleted as well. 315 // If |delete_bookmarks| is set, the bookmarks are deleted as well.
307 // The notifications are returned in |notifications| and the ownership of them 316 // The notifications are returned in |notifications| and the ownership of them
308 // is transfered to caller. 317 // is transfered to caller.
309 bool DeleteHistoryInternal(const TableIDRows& urls, 318 bool DeleteHistoryInternal(const TableIDRows& urls,
310 bool delete_bookmarks, 319 bool delete_bookmarks,
311 HistoryNotifications* notifications); 320 HistoryNotifications* notifications);
312 321
322 void SendFaviconChangedNotifications(
323 const FaviconNotifications& favicon_notifications);
324
313 void BroadcastNotifications(const HistoryNotifications& notifications); 325 void BroadcastNotifications(const HistoryNotifications& notifications);
314 326
315 // Add the search term from the given |values|. It will add the values.url() 327 // Add the search term from the given |values|. It will add the values.url()
316 // in the urls table if it doesn't exist, insert visit in the visits table, 328 // in the urls table if it doesn't exist, insert visit in the visits table,
317 // also add keyword in keyword_search_term. 329 // also add keyword in keyword_search_term.
318 bool AddSearchTerm(const SearchRow& values); 330 bool AddSearchTerm(const SearchRow& values);
319 331
320 // SQLHandlers for different tables. 332 // SQLHandlers for different tables.
321 scoped_ptr<SQLHandler> urls_handler_; 333 scoped_ptr<SQLHandler> urls_handler_;
322 scoped_ptr<SQLHandler> visit_handler_; 334 scoped_ptr<SQLHandler> visit_handler_;
(...skipping 20 matching lines...) Expand all
343 bool initialized_; 355 bool initialized_;
344 356
345 HistoryBackend::Delegate* delegate_; 357 HistoryBackend::Delegate* delegate_;
346 358
347 DISALLOW_COPY_AND_ASSIGN(AndroidProviderBackend); 359 DISALLOW_COPY_AND_ASSIGN(AndroidProviderBackend);
348 }; 360 };
349 361
350 } // namespace history 362 } // namespace history
351 363
352 #endif // CHROME_BROWSER_HISTORY_ANDROID_ANDROID_PROVIDER_BACKEND_H_ 364 #endif // CHROME_BROWSER_HISTORY_ANDROID_ANDROID_PROVIDER_BACKEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698