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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 if (hs) { | 81 if (hs) { |
82 hs->Schedule(HistoryService::PRIORITY_NORMAL, | 82 hs->Schedule(HistoryService::PRIORITY_NORMAL, |
83 &HistoryBackend::DeleteHistoryAndBookmarks, NULL, request, | 83 &HistoryBackend::DeleteHistoryAndBookmarks, NULL, request, |
84 selection, selection_args); | 84 selection, selection_args); |
85 } else { | 85 } else { |
86 request->ForwardResultAsync(request->handle(), false, 0); | 86 request->ForwardResultAsync(request->handle(), false, 0); |
87 } | 87 } |
88 return request->handle(); | 88 return request->handle(); |
89 } | 89 } |
90 | 90 |
91 AndroidHistoryProviderService::Handle | 91 base::CancelableTaskTracker::TaskId |
92 AndroidHistoryProviderService::InsertHistoryAndBookmark( | 92 AndroidHistoryProviderService::InsertHistoryAndBookmark( |
93 const history::HistoryAndBookmarkRow& values, | 93 const history::HistoryAndBookmarkRow& values, |
94 CancelableRequestConsumerBase* consumer, | 94 const InsertCallback& callback, |
95 const InsertCallback& callback) { | 95 base::CancelableTaskTracker* tracker) { |
96 InsertRequest* request = new InsertRequest(callback); | |
97 AddRequest(request, consumer); | |
98 HistoryService* hs = | 96 HistoryService* hs = |
99 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 97 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
100 if (hs) { | 98 if (hs) { |
101 hs->Schedule(HistoryService::PRIORITY_NORMAL, | 99 DCHECK(hs->thread_) << "History service being called after cleanup"; |
102 &HistoryBackend::InsertHistoryAndBookmark, NULL, request, values); | 100 DCHECK(hs->thread_checker_.CalledOnValidThread()); |
| 101 return tracker->PostTaskAndReplyWithResult( |
| 102 hs->thread_->message_loop_proxy().get(), |
| 103 FROM_HERE, |
| 104 base::Bind(&HistoryBackend::InsertHistoryAndBookmark, |
| 105 hs->history_backend_.get(), |
| 106 values), |
| 107 callback); |
103 } else { | 108 } else { |
104 request->ForwardResultAsync(request->handle(), false, 0); | 109 callback.Run(0); |
| 110 return base::CancelableTaskTracker::kBadTaskId; |
105 } | 111 } |
106 return request->handle(); | |
107 } | 112 } |
108 | 113 |
109 AndroidHistoryProviderService::Handle | 114 AndroidHistoryProviderService::Handle |
110 AndroidHistoryProviderService::DeleteHistory( | 115 AndroidHistoryProviderService::DeleteHistory( |
111 const std::string& selection, | 116 const std::string& selection, |
112 const std::vector<base::string16>& selection_args, | 117 const std::vector<base::string16>& selection_args, |
113 CancelableRequestConsumerBase* consumer, | 118 CancelableRequestConsumerBase* consumer, |
114 const DeleteCallback& callback) { | 119 const DeleteCallback& callback) { |
115 DeleteRequest* request = new DeleteRequest(callback); | 120 DeleteRequest* request = new DeleteRequest(callback); |
116 AddRequest(request, consumer); | 121 AddRequest(request, consumer); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 HistoryService* hs = | 163 HistoryService* hs = |
159 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 164 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
160 if (hs) { | 165 if (hs) { |
161 hs->ScheduleAndForget(HistoryService::PRIORITY_NORMAL, | 166 hs->ScheduleAndForget(HistoryService::PRIORITY_NORMAL, |
162 &HistoryBackend::CloseStatement, statement); | 167 &HistoryBackend::CloseStatement, statement); |
163 } else { | 168 } else { |
164 delete statement; | 169 delete statement; |
165 } | 170 } |
166 } | 171 } |
167 | 172 |
| 173 base::CancelableTaskTracker::TaskId |
| 174 AndroidHistoryProviderService::InsertSearchTerm( |
| 175 const history::SearchRow& row, |
| 176 const InsertCallback& callback, |
| 177 base::CancelableTaskTracker* tracker) { |
| 178 HistoryService* hs = |
| 179 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
| 180 if (hs) { |
| 181 DCHECK(hs->thread_) << "History service being called after cleanup"; |
| 182 DCHECK(hs->thread_checker_.CalledOnValidThread()); |
| 183 return tracker->PostTaskAndReplyWithResult( |
| 184 hs->thread_->message_loop_proxy().get(), |
| 185 FROM_HERE, |
| 186 base::Bind( |
| 187 &HistoryBackend::InsertSearchTerm, hs->history_backend_.get(), row), |
| 188 callback); |
| 189 } else { |
| 190 callback.Run(0); |
| 191 return base::CancelableTaskTracker::kBadTaskId; |
| 192 } |
| 193 } |
| 194 |
168 AndroidHistoryProviderService::Handle | 195 AndroidHistoryProviderService::Handle |
169 AndroidHistoryProviderService::InsertSearchTerm( | |
170 const history::SearchRow& row, | |
171 CancelableRequestConsumerBase* consumer, | |
172 const InsertCallback& callback) { | |
173 InsertRequest* request = new InsertRequest(callback); | |
174 AddRequest(request, consumer); | |
175 HistoryService* hs = | |
176 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | |
177 if (hs) { | |
178 hs->Schedule(HistoryService::PRIORITY_NORMAL, | |
179 &HistoryBackend::InsertSearchTerm, NULL, request, row); | |
180 } else { | |
181 request->ForwardResultAsync(request->handle(), false, 0); | |
182 } | |
183 return request->handle(); | |
184 } | |
185 | |
186 AndroidHistoryProviderService::Handle | |
187 AndroidHistoryProviderService::UpdateSearchTerms( | 196 AndroidHistoryProviderService::UpdateSearchTerms( |
188 const history::SearchRow& row, | 197 const history::SearchRow& row, |
189 const std::string& selection, | 198 const std::string& selection, |
190 const std::vector<base::string16>& selection_args, | 199 const std::vector<base::string16>& selection_args, |
191 CancelableRequestConsumerBase* consumer, | 200 CancelableRequestConsumerBase* consumer, |
192 const UpdateCallback& callback) { | 201 const UpdateCallback& callback) { |
193 UpdateRequest* request = new UpdateRequest(callback); | 202 UpdateRequest* request = new UpdateRequest(callback); |
194 AddRequest(request, consumer); | 203 AddRequest(request, consumer); |
195 HistoryService* hs = | 204 HistoryService* hs = |
196 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 205 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 projections, | 254 projections, |
246 selection, | 255 selection, |
247 selection_args, | 256 selection_args, |
248 sort_order), | 257 sort_order), |
249 callback); | 258 callback); |
250 } else { | 259 } else { |
251 callback.Run(NULL); | 260 callback.Run(NULL); |
252 return base::CancelableTaskTracker::kBadTaskId; | 261 return base::CancelableTaskTracker::kBadTaskId; |
253 } | 262 } |
254 } | 263 } |
OLD | NEW |