Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "chrome/browser/history/android/android_history_provider_service.h" | 5 #include "chrome/browser/history/android/android_history_provider_service.h" |
| 6 | 6 |
| 7 #include "chrome/browser/history/history.h" | 7 #include "chrome/browser/history/history.h" |
| 8 #include "chrome/browser/history/history_backend.h" | 8 #include "chrome/browser/history/history_backend.h" |
| 9 #include "chrome/browser/history/history_service_factory.h" | 9 #include "chrome/browser/history/history_service_factory.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 AndroidHistoryProviderService::Handle | 21 AndroidHistoryProviderService::Handle |
| 22 AndroidHistoryProviderService::QueryHistoryAndBookmarks( | 22 AndroidHistoryProviderService::QueryHistoryAndBookmarks( |
| 23 const std::vector<history::HistoryAndBookmarkRow::ColumnID>& projections, | 23 const std::vector<history::HistoryAndBookmarkRow::ColumnID>& projections, |
| 24 const std::string& selection, | 24 const std::string& selection, |
| 25 const std::vector<string16>& selection_args, | 25 const std::vector<string16>& selection_args, |
| 26 const std::string& sort_order, | 26 const std::string& sort_order, |
| 27 CancelableRequestConsumerBase* consumer, | 27 CancelableRequestConsumerBase* consumer, |
| 28 const QueryCallback& callback) { | 28 const QueryCallback& callback) { |
| 29 QueryRequest* request = new QueryRequest(callback); | 29 QueryRequest* request = new QueryRequest(callback); |
| 30 AddRequest(request, consumer); | 30 AddRequest(request, consumer); |
| 31 HistoryService* hs = | 31 HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists( |
|
sky
2012/06/21 17:14:31
I think you should leave all of these as they were
| |
| 32 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 32 profile_, Profile::EXPLICIT_ACCESS); |
| 33 if (hs) { | 33 if (hs) { |
| 34 hs->Schedule(HistoryService::PRIORITY_NORMAL, | 34 hs->Schedule(HistoryService::PRIORITY_NORMAL, |
| 35 &HistoryBackend::QueryHistoryAndBookmarks, NULL, request, | 35 &HistoryBackend::QueryHistoryAndBookmarks, NULL, request, |
| 36 projections, selection, selection_args, sort_order); | 36 projections, selection, selection_args, sort_order); |
| 37 } else { | 37 } else { |
| 38 request->ForwardResultAsync(request->handle(), false, 0); | 38 request->ForwardResultAsync(request->handle(), false, 0); |
| 39 } | 39 } |
| 40 return request->handle(); | 40 return request->handle(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 AndroidHistoryProviderService::Handle | 43 AndroidHistoryProviderService::Handle |
| 44 AndroidHistoryProviderService::UpdateHistoryAndBookmarks( | 44 AndroidHistoryProviderService::UpdateHistoryAndBookmarks( |
| 45 const history::HistoryAndBookmarkRow& row, | 45 const history::HistoryAndBookmarkRow& row, |
| 46 const std::string& selection, | 46 const std::string& selection, |
| 47 const std::vector<string16>& selection_args, | 47 const std::vector<string16>& selection_args, |
| 48 CancelableRequestConsumerBase* consumer, | 48 CancelableRequestConsumerBase* consumer, |
| 49 const UpdateCallback& callback) { | 49 const UpdateCallback& callback) { |
| 50 UpdateRequest* request = new UpdateRequest(callback); | 50 UpdateRequest* request = new UpdateRequest(callback); |
| 51 AddRequest(request, consumer); | 51 AddRequest(request, consumer); |
| 52 HistoryService* hs = | 52 HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists( |
| 53 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 53 profile_, Profile::EXPLICIT_ACCESS); |
| 54 if (hs) { | 54 if (hs) { |
| 55 hs->Schedule(HistoryService::PRIORITY_NORMAL, | 55 hs->Schedule(HistoryService::PRIORITY_NORMAL, |
| 56 &HistoryBackend::UpdateHistoryAndBookmarks, NULL, request, row, | 56 &HistoryBackend::UpdateHistoryAndBookmarks, NULL, request, row, |
| 57 selection, selection_args); | 57 selection, selection_args); |
| 58 } else { | 58 } else { |
| 59 request->ForwardResultAsync(request->handle(), false, 0); | 59 request->ForwardResultAsync(request->handle(), false, 0); |
| 60 } | 60 } |
| 61 return request->handle(); | 61 return request->handle(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 AndroidHistoryProviderService::Handle | 64 AndroidHistoryProviderService::Handle |
| 65 AndroidHistoryProviderService::DeleteHistoryAndBookmarks( | 65 AndroidHistoryProviderService::DeleteHistoryAndBookmarks( |
| 66 const std::string& selection, | 66 const std::string& selection, |
| 67 const std::vector<string16>& selection_args, | 67 const std::vector<string16>& selection_args, |
| 68 CancelableRequestConsumerBase* consumer, | 68 CancelableRequestConsumerBase* consumer, |
| 69 const DeleteCallback& callback) { | 69 const DeleteCallback& callback) { |
| 70 DeleteRequest* request = new DeleteRequest(callback); | 70 DeleteRequest* request = new DeleteRequest(callback); |
| 71 AddRequest(request, consumer); | 71 AddRequest(request, consumer); |
| 72 HistoryService* hs = | 72 HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists( |
| 73 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 73 profile_, Profile::EXPLICIT_ACCESS); |
| 74 if (hs) { | 74 if (hs) { |
| 75 hs->Schedule(HistoryService::PRIORITY_NORMAL, | 75 hs->Schedule(HistoryService::PRIORITY_NORMAL, |
| 76 &HistoryBackend::DeleteHistoryAndBookmarks, NULL, request, | 76 &HistoryBackend::DeleteHistoryAndBookmarks, NULL, request, |
| 77 selection, selection_args); | 77 selection, selection_args); |
| 78 } else { | 78 } else { |
| 79 request->ForwardResultAsync(request->handle(), false, 0); | 79 request->ForwardResultAsync(request->handle(), false, 0); |
| 80 } | 80 } |
| 81 return request->handle(); | 81 return request->handle(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 AndroidHistoryProviderService::Handle | 84 AndroidHistoryProviderService::Handle |
| 85 AndroidHistoryProviderService::InsertHistoryAndBookmark( | 85 AndroidHistoryProviderService::InsertHistoryAndBookmark( |
| 86 const history::HistoryAndBookmarkRow& values, | 86 const history::HistoryAndBookmarkRow& values, |
| 87 CancelableRequestConsumerBase* consumer, | 87 CancelableRequestConsumerBase* consumer, |
| 88 const InsertCallback& callback) { | 88 const InsertCallback& callback) { |
| 89 InsertRequest* request = new InsertRequest(callback); | 89 InsertRequest* request = new InsertRequest(callback); |
| 90 AddRequest(request, consumer); | 90 AddRequest(request, consumer); |
| 91 HistoryService* hs = | 91 HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists( |
| 92 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 92 profile_, Profile::EXPLICIT_ACCESS); |
| 93 if (hs) { | 93 if (hs) { |
| 94 hs->Schedule(HistoryService::PRIORITY_NORMAL, | 94 hs->Schedule(HistoryService::PRIORITY_NORMAL, |
| 95 &HistoryBackend::InsertHistoryAndBookmark, NULL, request, values); | 95 &HistoryBackend::InsertHistoryAndBookmark, NULL, request, values); |
| 96 } else { | 96 } else { |
| 97 request->ForwardResultAsync(request->handle(), false, 0); | 97 request->ForwardResultAsync(request->handle(), false, 0); |
| 98 } | 98 } |
| 99 return request->handle(); | 99 return request->handle(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 AndroidHistoryProviderService::Handle | 102 AndroidHistoryProviderService::Handle |
| 103 AndroidHistoryProviderService::DeleteHistory( | 103 AndroidHistoryProviderService::DeleteHistory( |
| 104 const std::string& selection, | 104 const std::string& selection, |
| 105 const std::vector<string16>& selection_args, | 105 const std::vector<string16>& selection_args, |
| 106 CancelableRequestConsumerBase* consumer, | 106 CancelableRequestConsumerBase* consumer, |
| 107 const DeleteCallback& callback) { | 107 const DeleteCallback& callback) { |
| 108 DeleteRequest* request = new DeleteRequest(callback); | 108 DeleteRequest* request = new DeleteRequest(callback); |
| 109 AddRequest(request, consumer); | 109 AddRequest(request, consumer); |
| 110 HistoryService* hs = | 110 HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists( |
| 111 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 111 profile_, Profile::EXPLICIT_ACCESS); |
| 112 if (hs) { | 112 if (hs) { |
| 113 hs->Schedule(HistoryService::PRIORITY_NORMAL, | 113 hs->Schedule(HistoryService::PRIORITY_NORMAL, |
| 114 &HistoryBackend::DeleteHistory, NULL, request, selection, | 114 &HistoryBackend::DeleteHistory, NULL, request, selection, |
| 115 selection_args); | 115 selection_args); |
| 116 } else { | 116 } else { |
| 117 request->ForwardResultAsync(request->handle(), false, 0); | 117 request->ForwardResultAsync(request->handle(), false, 0); |
| 118 } | 118 } |
| 119 return request->handle(); | 119 return request->handle(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 AndroidHistoryProviderService::Handle | 122 AndroidHistoryProviderService::Handle |
| 123 AndroidHistoryProviderService::MoveStatement( | 123 AndroidHistoryProviderService::MoveStatement( |
| 124 history::AndroidStatement* statement, | 124 history::AndroidStatement* statement, |
| 125 int current_pos, | 125 int current_pos, |
| 126 int destination, | 126 int destination, |
| 127 CancelableRequestConsumerBase* consumer, | 127 CancelableRequestConsumerBase* consumer, |
| 128 const MoveStatementCallback& callback) { | 128 const MoveStatementCallback& callback) { |
| 129 MoveStatementRequest* request = new MoveStatementRequest(callback); | 129 MoveStatementRequest* request = new MoveStatementRequest(callback); |
| 130 AddRequest(request, consumer); | 130 AddRequest(request, consumer); |
| 131 HistoryService* hs = | 131 HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists( |
| 132 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 132 profile_, Profile::EXPLICIT_ACCESS); |
| 133 if (hs) { | 133 if (hs) { |
| 134 hs->Schedule(HistoryService::PRIORITY_NORMAL, | 134 hs->Schedule(HistoryService::PRIORITY_NORMAL, |
| 135 &HistoryBackend::MoveStatement, NULL, request, statement, | 135 &HistoryBackend::MoveStatement, NULL, request, statement, |
| 136 current_pos, destination); | 136 current_pos, destination); |
| 137 } else { | 137 } else { |
| 138 request->ForwardResultAsync(request->handle(), current_pos); | 138 request->ForwardResultAsync(request->handle(), current_pos); |
| 139 } | 139 } |
| 140 return request->handle(); | 140 return request->handle(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void AndroidHistoryProviderService::CloseStatement( | 143 void AndroidHistoryProviderService::CloseStatement( |
| 144 history::AndroidStatement* statement) { | 144 history::AndroidStatement* statement) { |
| 145 HistoryService* hs = | 145 HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists( |
| 146 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 146 profile_, Profile::EXPLICIT_ACCESS); |
| 147 if (hs) { | 147 if (hs) { |
| 148 hs->ScheduleAndForget(HistoryService::PRIORITY_NORMAL, | 148 hs->ScheduleAndForget(HistoryService::PRIORITY_NORMAL, |
| 149 &HistoryBackend::CloseStatement, statement); | 149 &HistoryBackend::CloseStatement, statement); |
| 150 } else { | 150 } else { |
| 151 delete statement; | 151 delete statement; |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 | 154 |
| 155 AndroidHistoryProviderService::Handle | 155 AndroidHistoryProviderService::Handle |
| 156 AndroidHistoryProviderService::InsertSearchTerm( | 156 AndroidHistoryProviderService::InsertSearchTerm( |
| 157 const history::SearchRow& row, | 157 const history::SearchRow& row, |
| 158 CancelableRequestConsumerBase* consumer, | 158 CancelableRequestConsumerBase* consumer, |
| 159 const InsertCallback& callback) { | 159 const InsertCallback& callback) { |
| 160 InsertRequest* request = new InsertRequest(callback); | 160 InsertRequest* request = new InsertRequest(callback); |
| 161 AddRequest(request, consumer); | 161 AddRequest(request, consumer); |
| 162 HistoryService* hs = | 162 HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists( |
| 163 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 163 profile_, Profile::EXPLICIT_ACCESS); |
| 164 if (hs) { | 164 if (hs) { |
| 165 hs->Schedule(HistoryService::PRIORITY_NORMAL, | 165 hs->Schedule(HistoryService::PRIORITY_NORMAL, |
| 166 &HistoryBackend::InsertSearchTerm, NULL, request, row); | 166 &HistoryBackend::InsertSearchTerm, NULL, request, row); |
| 167 } else { | 167 } else { |
| 168 request->ForwardResultAsync(request->handle(), false, 0); | 168 request->ForwardResultAsync(request->handle(), false, 0); |
| 169 } | 169 } |
| 170 return request->handle(); | 170 return request->handle(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 AndroidHistoryProviderService::Handle | 173 AndroidHistoryProviderService::Handle |
| 174 AndroidHistoryProviderService::UpdateSearchTerms( | 174 AndroidHistoryProviderService::UpdateSearchTerms( |
| 175 const history::SearchRow& row, | 175 const history::SearchRow& row, |
| 176 const std::string& selection, | 176 const std::string& selection, |
| 177 const std::vector<string16>& selection_args, | 177 const std::vector<string16>& selection_args, |
| 178 CancelableRequestConsumerBase* consumer, | 178 CancelableRequestConsumerBase* consumer, |
| 179 const UpdateCallback& callback) { | 179 const UpdateCallback& callback) { |
| 180 UpdateRequest* request = new UpdateRequest(callback); | 180 UpdateRequest* request = new UpdateRequest(callback); |
| 181 AddRequest(request, consumer); | 181 AddRequest(request, consumer); |
| 182 HistoryService* hs = | 182 HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists( |
| 183 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 183 profile_, Profile::EXPLICIT_ACCESS); |
| 184 if (hs) { | 184 if (hs) { |
| 185 hs->Schedule(HistoryService::PRIORITY_NORMAL, | 185 hs->Schedule(HistoryService::PRIORITY_NORMAL, |
| 186 &HistoryBackend::UpdateSearchTerms, NULL, request, row, selection, | 186 &HistoryBackend::UpdateSearchTerms, NULL, request, row, selection, |
| 187 selection_args); | 187 selection_args); |
| 188 } else { | 188 } else { |
| 189 request->ForwardResultAsync(request->handle(), false, 0); | 189 request->ForwardResultAsync(request->handle(), false, 0); |
| 190 } | 190 } |
| 191 return request->handle(); | 191 return request->handle(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 AndroidHistoryProviderService::Handle | 194 AndroidHistoryProviderService::Handle |
| 195 AndroidHistoryProviderService::DeleteSearchTerms( | 195 AndroidHistoryProviderService::DeleteSearchTerms( |
| 196 const std::string& selection, | 196 const std::string& selection, |
| 197 const std::vector<string16>& selection_args, | 197 const std::vector<string16>& selection_args, |
| 198 CancelableRequestConsumerBase* consumer, | 198 CancelableRequestConsumerBase* consumer, |
| 199 const DeleteCallback& callback) { | 199 const DeleteCallback& callback) { |
| 200 DeleteRequest* request = new DeleteRequest(callback); | 200 DeleteRequest* request = new DeleteRequest(callback); |
| 201 AddRequest(request, consumer); | 201 AddRequest(request, consumer); |
| 202 HistoryService* hs = | 202 HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists( |
| 203 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 203 profile_, Profile::EXPLICIT_ACCESS); |
| 204 if (hs) { | 204 if (hs) { |
| 205 hs->Schedule(HistoryService::PRIORITY_NORMAL, | 205 hs->Schedule(HistoryService::PRIORITY_NORMAL, |
| 206 &HistoryBackend::DeleteSearchTerms, NULL, request, selection, | 206 &HistoryBackend::DeleteSearchTerms, NULL, request, selection, |
| 207 selection_args); | 207 selection_args); |
| 208 } else { | 208 } else { |
| 209 request->ForwardResultAsync(request->handle(), false, 0); | 209 request->ForwardResultAsync(request->handle(), false, 0); |
| 210 } | 210 } |
| 211 return request->handle(); | 211 return request->handle(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 AndroidHistoryProviderService::Handle | 214 AndroidHistoryProviderService::Handle |
| 215 AndroidHistoryProviderService::QuerySearchTerms( | 215 AndroidHistoryProviderService::QuerySearchTerms( |
| 216 const std::vector<history::SearchRow::ColumnID>& projections, | 216 const std::vector<history::SearchRow::ColumnID>& projections, |
| 217 const std::string& selection, | 217 const std::string& selection, |
| 218 const std::vector<string16>& selection_args, | 218 const std::vector<string16>& selection_args, |
| 219 const std::string& sort_order, | 219 const std::string& sort_order, |
| 220 CancelableRequestConsumerBase* consumer, | 220 CancelableRequestConsumerBase* consumer, |
| 221 const QueryCallback& callback) { | 221 const QueryCallback& callback) { |
| 222 QueryRequest* request = new QueryRequest(callback); | 222 QueryRequest* request = new QueryRequest(callback); |
| 223 AddRequest(request, consumer); | 223 AddRequest(request, consumer); |
| 224 HistoryService* hs = | 224 HistoryService* hs = HistoryServiceFactory::GetForProfileIfExists( |
| 225 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 225 profile_, Profile::EXPLICIT_ACCESS); |
| 226 if (hs) { | 226 if (hs) { |
| 227 hs->Schedule(HistoryService::PRIORITY_NORMAL, | 227 hs->Schedule(HistoryService::PRIORITY_NORMAL, |
| 228 &HistoryBackend::QuerySearchTerms, NULL, request, projections, | 228 &HistoryBackend::QuerySearchTerms, NULL, request, projections, |
| 229 selection, selection_args, sort_order); | 229 selection, selection_args, sort_order); |
| 230 } else { | 230 } else { |
| 231 request->ForwardResultAsync(request->handle(), false, 0); | 231 request->ForwardResultAsync(request->handle(), false, 0); |
| 232 } | 232 } |
| 233 return request->handle(); | 233 return request->handle(); |
| 234 } | 234 } |
| OLD | NEW |