| 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_backend.h" | 7 #include "chrome/browser/history/history_backend.h" |
| 8 #include "chrome/browser/history/history_service.h" | 8 #include "chrome/browser/history/history_service.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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 row, | 67 row, |
| 68 selection, | 68 selection, |
| 69 selection_args), | 69 selection_args), |
| 70 callback); | 70 callback); |
| 71 } else { | 71 } else { |
| 72 callback.Run(0); | 72 callback.Run(0); |
| 73 return base::CancelableTaskTracker::kBadTaskId; | 73 return base::CancelableTaskTracker::kBadTaskId; |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 AndroidHistoryProviderService::Handle | 77 base::CancelableTaskTracker::TaskId |
| 78 AndroidHistoryProviderService::DeleteHistoryAndBookmarks( | 78 AndroidHistoryProviderService::DeleteHistoryAndBookmarks( |
| 79 const std::string& selection, | 79 const std::string& selection, |
| 80 const std::vector<base::string16>& selection_args, | 80 const std::vector<base::string16>& selection_args, |
| 81 CancelableRequestConsumerBase* consumer, | 81 const DeleteCallback& callback, |
| 82 const DeleteCallback& callback) { | 82 base::CancelableTaskTracker* tracker) { |
| 83 DeleteRequest* request = new DeleteRequest(callback); | |
| 84 AddRequest(request, consumer); | |
| 85 HistoryService* hs = | 83 HistoryService* hs = |
| 86 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 84 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
| 87 if (hs) { | 85 if (hs) { |
| 88 hs->Schedule(HistoryService::PRIORITY_NORMAL, | 86 DCHECK(hs->thread_) << "History service being called after cleanup"; |
| 89 &HistoryBackend::DeleteHistoryAndBookmarks, NULL, request, | 87 DCHECK(hs->thread_checker_.CalledOnValidThread()); |
| 90 selection, selection_args); | 88 return tracker->PostTaskAndReplyWithResult( |
| 89 hs->thread_->message_loop_proxy().get(), |
| 90 FROM_HERE, |
| 91 base::Bind(&HistoryBackend::DeleteHistoryAndBookmarks, |
| 92 hs->history_backend_.get(), |
| 93 selection, |
| 94 selection_args), |
| 95 callback); |
| 91 } else { | 96 } else { |
| 92 request->ForwardResultAsync(request->handle(), false, 0); | 97 callback.Run(0); |
| 98 return base::CancelableTaskTracker::kBadTaskId; |
| 93 } | 99 } |
| 94 return request->handle(); | |
| 95 } | 100 } |
| 96 | 101 |
| 97 base::CancelableTaskTracker::TaskId | 102 base::CancelableTaskTracker::TaskId |
| 98 AndroidHistoryProviderService::InsertHistoryAndBookmark( | 103 AndroidHistoryProviderService::InsertHistoryAndBookmark( |
| 99 const history::HistoryAndBookmarkRow& values, | 104 const history::HistoryAndBookmarkRow& values, |
| 100 const InsertCallback& callback, | 105 const InsertCallback& callback, |
| 101 base::CancelableTaskTracker* tracker) { | 106 base::CancelableTaskTracker* tracker) { |
| 102 HistoryService* hs = | 107 HistoryService* hs = |
| 103 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 108 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
| 104 if (hs) { | 109 if (hs) { |
| 105 DCHECK(hs->thread_) << "History service being called after cleanup"; | 110 DCHECK(hs->thread_) << "History service being called after cleanup"; |
| 106 DCHECK(hs->thread_checker_.CalledOnValidThread()); | 111 DCHECK(hs->thread_checker_.CalledOnValidThread()); |
| 107 return tracker->PostTaskAndReplyWithResult( | 112 return tracker->PostTaskAndReplyWithResult( |
| 108 hs->thread_->message_loop_proxy().get(), | 113 hs->thread_->message_loop_proxy().get(), |
| 109 FROM_HERE, | 114 FROM_HERE, |
| 110 base::Bind(&HistoryBackend::InsertHistoryAndBookmark, | 115 base::Bind(&HistoryBackend::InsertHistoryAndBookmark, |
| 111 hs->history_backend_.get(), | 116 hs->history_backend_.get(), |
| 112 values), | 117 values), |
| 113 callback); | 118 callback); |
| 114 } else { | 119 } else { |
| 115 callback.Run(0); | 120 callback.Run(0); |
| 116 return base::CancelableTaskTracker::kBadTaskId; | 121 return base::CancelableTaskTracker::kBadTaskId; |
| 117 } | 122 } |
| 118 } | 123 } |
| 119 | 124 |
| 120 AndroidHistoryProviderService::Handle | 125 base::CancelableTaskTracker::TaskId |
| 121 AndroidHistoryProviderService::DeleteHistory( | 126 AndroidHistoryProviderService::DeleteHistory( |
| 122 const std::string& selection, | 127 const std::string& selection, |
| 123 const std::vector<base::string16>& selection_args, | 128 const std::vector<base::string16>& selection_args, |
| 124 CancelableRequestConsumerBase* consumer, | 129 const DeleteCallback& callback, |
| 125 const DeleteCallback& callback) { | 130 base::CancelableTaskTracker* tracker) { |
| 126 DeleteRequest* request = new DeleteRequest(callback); | |
| 127 AddRequest(request, consumer); | |
| 128 HistoryService* hs = | 131 HistoryService* hs = |
| 129 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 132 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
| 130 if (hs) { | 133 if (hs) { |
| 131 hs->Schedule(HistoryService::PRIORITY_NORMAL, | 134 DCHECK(hs->thread_) << "History service being called after cleanup"; |
| 132 &HistoryBackend::DeleteHistory, NULL, request, selection, | 135 DCHECK(hs->thread_checker_.CalledOnValidThread()); |
| 133 selection_args); | 136 return tracker->PostTaskAndReplyWithResult( |
| 137 hs->thread_->message_loop_proxy().get(), |
| 138 FROM_HERE, |
| 139 base::Bind(&HistoryBackend::DeleteHistory, |
| 140 hs->history_backend_.get(), |
| 141 selection, |
| 142 selection_args), |
| 143 callback); |
| 134 } else { | 144 } else { |
| 135 request->ForwardResultAsync(request->handle(), false, 0); | 145 callback.Run(0); |
| 146 return base::CancelableTaskTracker::kBadTaskId; |
| 136 } | 147 } |
| 137 return request->handle(); | |
| 138 } | 148 } |
| 139 | 149 |
| 140 base::CancelableTaskTracker::TaskId | 150 base::CancelableTaskTracker::TaskId |
| 141 AndroidHistoryProviderService::MoveStatement( | 151 AndroidHistoryProviderService::MoveStatement( |
| 142 history::AndroidStatement* statement, | 152 history::AndroidStatement* statement, |
| 143 int current_pos, | 153 int current_pos, |
| 144 int destination, | 154 int destination, |
| 145 const MoveStatementCallback& callback, | 155 const MoveStatementCallback& callback, |
| 146 base::CancelableTaskTracker* tracker) { | 156 base::CancelableTaskTracker* tracker) { |
| 147 HistoryService* hs = | 157 HistoryService* hs = |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 row, | 228 row, |
| 219 selection, | 229 selection, |
| 220 selection_args), | 230 selection_args), |
| 221 callback); | 231 callback); |
| 222 } else { | 232 } else { |
| 223 callback.Run(0); | 233 callback.Run(0); |
| 224 return base::CancelableTaskTracker::kBadTaskId; | 234 return base::CancelableTaskTracker::kBadTaskId; |
| 225 } | 235 } |
| 226 } | 236 } |
| 227 | 237 |
| 228 AndroidHistoryProviderService::Handle | 238 base::CancelableTaskTracker::TaskId |
| 229 AndroidHistoryProviderService::DeleteSearchTerms( | 239 AndroidHistoryProviderService::DeleteSearchTerms( |
| 230 const std::string& selection, | 240 const std::string& selection, |
| 231 const std::vector<base::string16>& selection_args, | 241 const std::vector<base::string16>& selection_args, |
| 232 CancelableRequestConsumerBase* consumer, | 242 const DeleteCallback& callback, |
| 233 const DeleteCallback& callback) { | 243 base::CancelableTaskTracker* tracker) { |
| 234 DeleteRequest* request = new DeleteRequest(callback); | |
| 235 AddRequest(request, consumer); | |
| 236 HistoryService* hs = | 244 HistoryService* hs = |
| 237 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 245 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
| 238 if (hs) { | 246 if (hs) { |
| 239 hs->Schedule(HistoryService::PRIORITY_NORMAL, | 247 DCHECK(hs->thread_) << "History service being called after cleanup"; |
| 240 &HistoryBackend::DeleteSearchTerms, NULL, request, selection, | 248 DCHECK(hs->thread_checker_.CalledOnValidThread()); |
| 241 selection_args); | 249 return tracker->PostTaskAndReplyWithResult( |
| 250 hs->thread_->message_loop_proxy().get(), |
| 251 FROM_HERE, |
| 252 base::Bind(&HistoryBackend::DeleteSearchTerms, |
| 253 hs->history_backend_.get(), |
| 254 selection, |
| 255 selection_args), |
| 256 callback); |
| 242 } else { | 257 } else { |
| 243 request->ForwardResultAsync(request->handle(), false, 0); | 258 callback.Run(0); |
| 259 return base::CancelableTaskTracker::kBadTaskId; |
| 244 } | 260 } |
| 245 return request->handle(); | |
| 246 } | 261 } |
| 247 | 262 |
| 248 base::CancelableTaskTracker::TaskId | 263 base::CancelableTaskTracker::TaskId |
| 249 AndroidHistoryProviderService::QuerySearchTerms( | 264 AndroidHistoryProviderService::QuerySearchTerms( |
| 250 const std::vector<history::SearchRow::ColumnID>& projections, | 265 const std::vector<history::SearchRow::ColumnID>& projections, |
| 251 const std::string& selection, | 266 const std::string& selection, |
| 252 const std::vector<base::string16>& selection_args, | 267 const std::vector<base::string16>& selection_args, |
| 253 const std::string& sort_order, | 268 const std::string& sort_order, |
| 254 const QueryCallback& callback, | 269 const QueryCallback& callback, |
| 255 base::CancelableTaskTracker* tracker) { | 270 base::CancelableTaskTracker* tracker) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 266 projections, | 281 projections, |
| 267 selection, | 282 selection, |
| 268 selection_args, | 283 selection_args, |
| 269 sort_order), | 284 sort_order), |
| 270 callback); | 285 callback); |
| 271 } else { | 286 } else { |
| 272 callback.Run(NULL); | 287 callback.Run(NULL); |
| 273 return base::CancelableTaskTracker::kBadTaskId; | 288 return base::CancelableTaskTracker::kBadTaskId; |
| 274 } | 289 } |
| 275 } | 290 } |
| OLD | NEW |