Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_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.
| |
| 6 #define CHROME_BROWSER_ANDROID_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 Android content provider. | |
|
sky
2012/04/25 15:57:25
the Android cont...
michaelbai
2012/04/26 05:32:48
Done.
| |
| 18 // 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.
| |
| 19 // BookmarkModel task posted in DB thread. | |
| 20 // 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
| |
| 21 // always runs in the Java thread. | |
| 22 class AndroidProviderService : public CancelableRequestProvider, | |
| 23 public base::RefCountedThreadSafe<AndroidProviderService> { | |
| 24 public: | |
| 25 explicit AndroidProviderService(Profile* profile); | |
| 26 | |
| 27 // The callback definitions ------------------------------------------------ | |
| 28 typedef base::Callback<void( | |
| 29 Handle, // handle | |
| 30 bool, // true if the query succeeded. | |
| 31 history::AndroidStatement*)> // the result of query | |
| 32 QueryCallback; | |
| 33 typedef CancelableRequest<QueryCallback> QueryRequest; | |
| 34 | |
| 35 typedef base::Callback<void( | |
| 36 Handle, // handle | |
| 37 bool, // true if the update succeeded. | |
| 38 int)> // the number of row updated. | |
| 39 UpdateCallback; | |
| 40 typedef CancelableRequest<UpdateCallback> UpdateRequest; | |
| 41 | |
| 42 typedef base::Callback<void( | |
| 43 Handle, // handle | |
| 44 bool, // true if the insert succeeded. | |
| 45 int64)> // the id of inserted row. | |
| 46 InsertCallback; | |
| 47 typedef CancelableRequest<InsertCallback> InsertRequest; | |
| 48 | |
| 49 typedef base::Callback<void( | |
| 50 Handle, // handle | |
| 51 bool, // true if the deletion succeeded. | |
| 52 int)> // the number of row deleted. | |
| 53 DeleteCallback; | |
| 54 typedef CancelableRequest<DeleteCallback> DeleteRequest; | |
| 55 | |
| 56 typedef base::Callback<void( | |
| 57 Handle, // handle | |
| 58 int)> // the new position. | |
| 59 MoveStatementCallback; | |
| 60 typedef CancelableRequest<MoveStatementCallback> MoveStatementRequest; | |
| 61 | |
| 62 // History and Bookmarks ---------------------------------------------------- | |
| 63 | |
| 64 void QueryHistoryAndBookmarks( | |
|
sky
2012/04/25 15:57:25
Add descriptions for all of the methods.
michaelbai
2012/04/26 05:32:48
Done.
| |
| 65 const std::vector<history::HistoryAndBookmarkRow::ColumnID>& projections, | |
| 66 const std::string selection, | |
| 67 const std::vector<string16>& selection_args, | |
| 68 const std::string sort_order, | |
| 69 CancelableRequestConsumerBase* consumer, | |
| 70 const QueryCallback& callback); | |
| 71 | |
| 72 void UpdateHistoryAndBookmarks(const history::HistoryAndBookmarkRow& row, | |
| 73 const std::string& selection, | |
| 74 const std::vector<string16>& selection_args, | |
| 75 CancelableRequestConsumerBase* consumer, | |
| 76 const UpdateCallback& callback); | |
| 77 | |
| 78 void DeleteHistoryAndBookmarks(const std::string& selection, | |
| 79 const std::vector<string16>& selection_args, | |
| 80 CancelableRequestConsumerBase* consumer, | |
| 81 const DeleteCallback& callback); | |
| 82 | |
| 83 void InsertHistoryAndBookmark(const history::HistoryAndBookmarkRow& values, | |
| 84 CancelableRequestConsumerBase* consumer, | |
| 85 const InsertCallback& callback); | |
| 86 | |
| 87 void DeleteHistory(const std::string& selection, | |
| 88 const std::vector<string16>& selection_args, | |
| 89 CancelableRequestConsumerBase* consumer, | |
| 90 const DeleteCallback& callback); | |
| 91 | |
| 92 // Statement ---------------------------------------------------------------- | |
| 93 // Moved the statement's current row from |current_pos| to |destination| in DB | |
| 94 // thread. The new position will be returned in the callback and might not be | |
| 95 // the |destination| if the |destination| isn't less than the count of rows. | |
| 96 void MoveStatement(history::AndroidStatement* statement, | |
| 97 int current_pos, | |
| 98 int destination, | |
| 99 CancelableRequestConsumerBase* consumer, | |
| 100 const MoveStatementCallback& callback); | |
| 101 | |
| 102 // Asks to close the statement in database thread. The ownership of | |
| 103 // |statement| is transferred. | |
| 104 void CloseStatement(history::AndroidStatement* statement); | |
| 105 | |
| 106 // Search term -------------------------------------------------------------- | |
| 107 void InsertSearchTerm(const history::SearchRow& row, | |
| 108 CancelableRequestConsumerBase* consumer, | |
| 109 const InsertCallback& callback); | |
| 110 | |
| 111 void UpdateSearchTerms(const history::SearchRow& row, | |
| 112 const std::string& selection, | |
| 113 const std::vector<string16>& selection_args, | |
| 114 CancelableRequestConsumerBase* consumer, | |
| 115 const UpdateCallback& callback); | |
| 116 | |
| 117 void DeleteSearchTerms(const std::string& selection, | |
| 118 const std::vector<string16>& selection_args, | |
| 119 CancelableRequestConsumerBase* consumer, | |
| 120 const DeleteCallback& callback); | |
| 121 | |
| 122 void QuerySearchTerms( | |
| 123 const std::vector<history::SearchRow::ColumnID>& projections, | |
| 124 const std::string selection, | |
| 125 const std::vector<string16>& selection_args, | |
| 126 const std::string sort_order, | |
| 127 CancelableRequestConsumerBase* consumer, | |
| 128 const QueryCallback& callback); | |
| 129 | |
| 130 private: | |
| 131 friend class base::RefCountedThreadSafe<AndroidProviderService>; | |
| 132 | |
| 133 virtual ~AndroidProviderService(); | |
| 134 | |
| 135 void ForwardEmptyInsertResultAsync(InsertRequest* request); | |
| 136 void ForwardEmptyQueryResultAsync(QueryRequest* request); | |
| 137 void ForwardEmptyUpdateResultAsync(UpdateRequest* request); | |
| 138 void ForwardEmptyDeleteResultAsync(UpdateRequest* request); | |
| 139 void ForwardEmptyMoveStatementResultAsync(MoveStatementRequest* request, | |
| 140 int value); | |
| 141 | |
| 142 Profile* profile_; | |
| 143 | |
| 144 DISALLOW_COPY_AND_ASSIGN(AndroidProviderService); | |
| 145 }; | |
| 146 | |
| 147 #endif // CHROME_BROWSER_ANDROID_PROVIDER_SERVICE_H_ | |
| OLD | NEW |