Chromium Code Reviews| Index: chrome/browser/android_provider_service.h |
| diff --git a/chrome/browser/android_provider_service.h b/chrome/browser/android_provider_service.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c8209407c5a809ec1e4a38decaf7e53ba57f1bb5 |
| --- /dev/null |
| +++ b/chrome/browser/android_provider_service.h |
| @@ -0,0 +1,147 @@ |
| +// 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_ANDROID_PROVIDER_SERVICE_H_ |
|
sky
2012/04/25 15:57:25
This class is named too generically, additionally
michaelbai
2012/04/26 05:32:48
Done.
|
| +#define CHROME_BROWSER_ANDROID_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 Android content provider. |
|
sky
2012/04/25 15:57:25
the Android cont...
michaelbai
2012/04/26 05:32:48
Done.
|
| +// The methods of this class should run in UI thread to cooperate with the |
|
sky
2012/04/25 15:57:25
should -> must
on the UI thread
michaelbai
2012/04/26 05:32:48
Done.
|
| +// BookmarkModel task posted in DB thread. |
| +// To be a subclass of RefCountedThreadSafe is convenient for the caller which |
|
sky
2012/04/25 15:57:25
I don't get this comment. Your earlier comment say
michaelbai
2012/04/26 05:32:48
You are right! I removed RefCounted, it is not nec
|
| +// always runs in the Java thread. |
| +class AndroidProviderService : public CancelableRequestProvider, |
| + public base::RefCountedThreadSafe<AndroidProviderService> { |
| + public: |
| + explicit AndroidProviderService(Profile* profile); |
| + |
| + // 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 ---------------------------------------------------- |
| + |
| + void QueryHistoryAndBookmarks( |
|
sky
2012/04/25 15:57:25
Add descriptions for all of the methods.
michaelbai
2012/04/26 05:32:48
Done.
|
| + const std::vector<history::HistoryAndBookmarkRow::ColumnID>& projections, |
| + const std::string selection, |
| + const std::vector<string16>& selection_args, |
| + const std::string sort_order, |
| + CancelableRequestConsumerBase* consumer, |
| + const QueryCallback& callback); |
| + |
| + void UpdateHistoryAndBookmarks(const history::HistoryAndBookmarkRow& row, |
| + const std::string& selection, |
| + const std::vector<string16>& selection_args, |
| + CancelableRequestConsumerBase* consumer, |
| + const UpdateCallback& callback); |
| + |
| + void DeleteHistoryAndBookmarks(const std::string& selection, |
| + const std::vector<string16>& selection_args, |
| + CancelableRequestConsumerBase* consumer, |
| + const DeleteCallback& callback); |
| + |
| + void InsertHistoryAndBookmark(const history::HistoryAndBookmarkRow& values, |
| + CancelableRequestConsumerBase* consumer, |
| + const InsertCallback& 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 |
| + // thread. The new position will be returned in the callback and might not be |
| + // 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 |
| + // |statement| is transferred. |
| + void CloseStatement(history::AndroidStatement* statement); |
| + |
| + // Search term -------------------------------------------------------------- |
| + void InsertSearchTerm(const history::SearchRow& row, |
| + CancelableRequestConsumerBase* consumer, |
| + const InsertCallback& callback); |
| + |
| + void UpdateSearchTerms(const history::SearchRow& row, |
| + const std::string& selection, |
| + const std::vector<string16>& selection_args, |
| + CancelableRequestConsumerBase* consumer, |
| + const UpdateCallback& callback); |
| + |
| + void DeleteSearchTerms(const std::string& selection, |
| + const std::vector<string16>& selection_args, |
| + CancelableRequestConsumerBase* consumer, |
| + const DeleteCallback& callback); |
| + |
| + void QuerySearchTerms( |
| + const std::vector<history::SearchRow::ColumnID>& projections, |
| + const std::string selection, |
| + const std::vector<string16>& selection_args, |
| + const std::string sort_order, |
| + CancelableRequestConsumerBase* consumer, |
| + const QueryCallback& callback); |
| + |
| + private: |
| + friend class base::RefCountedThreadSafe<AndroidProviderService>; |
| + |
| + virtual ~AndroidProviderService(); |
| + |
| + void ForwardEmptyInsertResultAsync(InsertRequest* request); |
| + void ForwardEmptyQueryResultAsync(QueryRequest* request); |
| + void ForwardEmptyUpdateResultAsync(UpdateRequest* request); |
| + void ForwardEmptyDeleteResultAsync(UpdateRequest* request); |
| + void ForwardEmptyMoveStatementResultAsync(MoveStatementRequest* request, |
| + int value); |
| + |
| + Profile* profile_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AndroidProviderService); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_ANDROID_PROVIDER_SERVICE_H_ |