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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/history/android/android_history_provider_service.h
diff --git a/chrome/browser/history/android/android_history_provider_service.h b/chrome/browser/history/android/android_history_provider_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..e9245136e1947b6c11ae0857c0a17f339449ee58
--- /dev/null
+++ b/chrome/browser/history/android/android_history_provider_service.h
@@ -0,0 +1,178 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_HISTORY_ANDROID_ANDROID_HISTORY_PROVIDER_SERVICE_H_
+#define CHROME_BROWSER_HISTORY_ANDROID_ANDROID_HISTORY_PROVIDER_SERVICE_H_
+
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+#include "chrome/browser/cancelable_request.h"
+#include "chrome/browser/history/android/android_history_types.h"
+#include "sql/statement.h"
+
+class Profile;
+
+// This class provides the methods to communicate with history backend service
+// for the Android content provider.
+// The methods of this class must run on the UI thread to cooperate with the
+// BookmarkModel task posted in the DB thread.
+class AndroidHistoryProviderService : public CancelableRequestProvider {
+ public:
+ explicit AndroidHistoryProviderService(Profile* profile);
+ virtual ~AndroidHistoryProviderService();
+
+ // The callback definitions ------------------------------------------------
+ typedef base::Callback<void(
+ Handle, // handle
+ bool, // true if the query succeeded.
+ history::AndroidStatement*)> // the result of query
+ QueryCallback;
+ typedef CancelableRequest<QueryCallback> QueryRequest;
+
+ typedef base::Callback<void(
+ Handle, // handle
+ bool, // true if the update succeeded.
+ int)> // the number of row updated.
+ UpdateCallback;
+ typedef CancelableRequest<UpdateCallback> UpdateRequest;
+
+ typedef base::Callback<void(
+ Handle, // handle
+ bool, // true if the insert succeeded.
+ int64)> // the id of inserted row.
+ InsertCallback;
+ typedef CancelableRequest<InsertCallback> InsertRequest;
+
+ typedef base::Callback<void(
+ Handle, // handle
+ bool, // true if the deletion succeeded.
+ int)> // the number of row deleted.
+ DeleteCallback;
+ typedef CancelableRequest<DeleteCallback> DeleteRequest;
+
+ typedef base::Callback<void(
+ Handle, // handle
+ int)> // the new position.
+ MoveStatementCallback;
+ typedef CancelableRequest<MoveStatementCallback> MoveStatementRequest;
+
+ // History and Bookmarks ----------------------------------------------------
+ //
+ // Runs the given query on history backend, and invokes the |callback| to
+ // return the result.
+ //
+ // |projections| is the vector of the result columns.
+ // |selection| is the SQL WHERE clause without 'WHERE'.
+ // |selection_args| is the arguments for WHERE clause.
+ // |sort_order| is the SQL ORDER clause.
+ 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
+ const std::vector<history::HistoryAndBookmarkRow::ColumnID>& projections,
+ const std::string selection,
sky 2012/04/27 21:37:22 const std::string&
michaelbai 2012/04/27 23:26:04 Done.
+ const std::vector<string16>& selection_args,
+ const std::string sort_order,
sky 2012/04/27 21:37:22 const std::string&
michaelbai 2012/04/27 23:26:04 Done.
+ CancelableRequestConsumerBase* consumer,
+ const QueryCallback& callback);
+
+ // 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.
+ // |callback| on success.
+ //
+ // |row| is the value to update.
+ // |selection| is the SQL WHERE clause without 'WHERE'.
+ // |selection_args| is the arguments for the WHERE clause.
+ void UpdateHistoryAndBookmarks(const history::HistoryAndBookmarkRow& row,
+ const std::string& selection,
+ const std::vector<string16>& selection_args,
+ CancelableRequestConsumerBase* consumer,
+ const UpdateCallback& callback);
+
+ // Deletes the specified rows and invokes the |callback| to return the number
+ // of row deleted on success.
+ //
+ // |selection| is the SQL WHERE clause without 'WHERE'.
+ // |selection_args| is the arguments for the WHERE clause.
+ //
+ // if |selection| is empty all history and bookmarks are deleted.
+ void DeleteHistoryAndBookmarks(const std::string& selection,
+ const std::vector<string16>& selection_args,
+ CancelableRequestConsumerBase* consumer,
+ const DeleteCallback& callback);
+
+ // Inserts the given values into history backend, and invokes the |callback|
+ // to return the result.
+ void InsertHistoryAndBookmark(const history::HistoryAndBookmarkRow& values,
+ CancelableRequestConsumerBase* consumer,
+ const InsertCallback& callback);
+
+ // Deletes the matched history and invokes |callback| to return the number of
+ // the row deleted from the |callback|.
+ void DeleteHistory(const std::string& selection,
+ const std::vector<string16>& selection_args,
+ CancelableRequestConsumerBase* consumer,
+ const DeleteCallback& callback);
+
+ // Statement ----------------------------------------------------------------
+ // 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.
+ // 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.
+ // the |destination| if the |destination| isn't less than the count of rows.
+ void MoveStatement(history::AndroidStatement* statement,
+ int current_pos,
+ int destination,
+ CancelableRequestConsumerBase* consumer,
+ const MoveStatementCallback& callback);
+
+ // 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.
+ // |statement| is transferred.
+ void CloseStatement(history::AndroidStatement* statement);
+
+ // Search term --------------------------------------------------------------
+ // 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.
+ // from the |callback| on success.
+ void InsertSearchTerm(const history::SearchRow& row,
+ CancelableRequestConsumerBase* consumer,
+ const InsertCallback& callback);
+
+ // 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.
+ // |callback| on success.
+ //
+ // |row| is the value need to update.
+ // |selection| is the SQL WHERE clause without 'WHERE'.
+ // |selection_args| is the arguments for WHERE clause.
+ void UpdateSearchTerms(const history::SearchRow& row,
+ const std::string& selection,
+ const std::vector<string16>& selection_args,
+ CancelableRequestConsumerBase* consumer,
+ const UpdateCallback& callback);
+
+ // Deletes the matched rows and the number of deleted rows is returned from
+ // the |callback| on success.
+ // |selection| is the SQL WHERE clause without 'WHERE'.
+ // |selection_args| is the arguments for WHERE clause.
+ //
+ // if |selection| is empty all search be deleted.
+ void DeleteSearchTerms(const std::string& selection,
+ const std::vector<string16>& selection_args,
+ CancelableRequestConsumerBase* consumer,
+ const DeleteCallback& callback);
+
+ // Returns the result of the given query from the |callback|.
+ // |projections| specifies the result columns, can not be empty, otherwise
+ // NULL is returned.
+ // |selection| is the SQL WHERE clause without 'WHERE'.
+ // |selection_args| is the arguments for WHERE clause.
+ // |sort_order| the SQL ORDER clause.
+ void QuerySearchTerms(
+ const std::vector<history::SearchRow::ColumnID>& projections,
+ const std::string selection,
sky 2012/04/27 21:37:22 const std::string&
michaelbai 2012/04/27 23:26:04 Done.
+ const std::vector<string16>& selection_args,
+ const std::string sort_order,
sky 2012/04/27 21:37:22 const std::string&
michaelbai 2012/04/27 23:26:04 Done.
+ CancelableRequestConsumerBase* consumer,
+ const QueryCallback& callback);
+
+ private:
+ Profile* profile_;
+
+ DISALLOW_COPY_AND_ASSIGN(AndroidHistoryProviderService);
+};
+
+#endif // CHROME_BROWSER_HISTORY_ANDROID_ANDROID_HISTORY_PROVIDER_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698