Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Side by Side Diff: chrome/browser/history/android/android_history_provider_service.cc

Issue 930363002: Remove adapter method on HistoryBackend delegating to AndroidProviderBackend (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/history/history_backend.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/favicon/favicon_service.h" 7 #include "chrome/browser/favicon/favicon_service.h"
8 #include "chrome/browser/favicon/favicon_service_factory.h" 8 #include "chrome/browser/favicon/favicon_service_factory.h"
9 #include "chrome/browser/history/android/android_provider_backend.h"
9 #include "chrome/browser/history/history_backend.h" 10 #include "chrome/browser/history/history_backend.h"
10 #include "chrome/browser/history/history_service.h" 11 #include "chrome/browser/history/history_service.h"
11 #include "chrome/browser/history/history_service_factory.h" 12 #include "chrome/browser/history/history_service_factory.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 14 #include "components/history/core/browser/android/android_history_types.h"
14 using history::HistoryBackend; 15 #include "components/history/core/browser/history_db_task.h"
16
17 namespace {
18
19 // AndroidProviderTask wraps two callbacks into an HistoryDBTask so that they
20 // can be passed to HistoryService::ScheduleDBTask. ResultType must be default
21 // constructible and copyable.
22 template <typename ResultType>
23 class AndroidProviderTask : public history::HistoryDBTask {
24 public:
25 typedef base::Callback<ResultType(history::AndroidProviderBackend*)>
26 RequestCallback;
27 typedef base::Callback<void(ResultType)> ResultCallback;
28
29 AndroidProviderTask(const RequestCallback& request_cb,
30 const ResultCallback& result_cb)
31 : request_cb_(request_cb), result_cb_(result_cb), result_(ResultType{}) {
droger 2015/02/18 14:04:01 ResultType{}: That "(Uniform) Initialization Synta
32 DCHECK(!request_cb_.is_null());
33 DCHECK(!result_cb_.is_null());
34 }
35
36 ~AndroidProviderTask() override {}
37
38 private:
39 // history::HistoryDBTask implementation.
40 bool RunOnDBThread(history::HistoryBackend* backend,
41 history::HistoryDatabase* db) override {
42 if (backend->android_provider_backend())
43 result_ = request_cb_.Run(backend->android_provider_backend());
44 return true;
45 }
46
47 void DoneRunOnMainThread() override { result_cb_.Run(result_); }
48
49 RequestCallback request_cb_;
50 ResultCallback result_cb_;
51 ResultType result_;
52 };
53
54 // Creates an instance of AndroidProviderTask using the two callback and using
55 // type deduction.
56 template <typename ResultType>
57 scoped_ptr<history::HistoryDBTask> CreateAndroidProviderTask(
58 const base::Callback<ResultType(history::AndroidProviderBackend*)>&
59 request_cb,
60 const base::Callback<void(ResultType)>& result_cb) {
61 return scoped_ptr<history::HistoryDBTask>(
62 new AndroidProviderTask<ResultType>(request_cb, result_cb));
63 }
64
65 // History and bookmarks ----------------------------------------------------
66
67 // Inserts the given values into android provider backend.
68 history::AndroidURLID InsertHistoryAndBookmarkAdapter(
69 const history::HistoryAndBookmarkRow& row,
70 history::AndroidProviderBackend* backend) {
71 return backend->InsertHistoryAndBookmark(row);
72 }
73
74 // Runs the given query on android provider backend and returns the result.
75 //
76 // |projections| is the vector of the result columns.
77 // |selection| is the SQL WHERE clause without 'WHERE'.
78 // |selection_args| is the arguments for WHERE clause.
79 // |sort_order| is the SQL ORDER clause.
80 history::AndroidStatement* QueryHistoryAndBookmarksAdapter(
81 const std::vector<history::HistoryAndBookmarkRow::ColumnID>& projections,
82 const std::string& selection,
83 const std::vector<base::string16>& selection_args,
84 const std::string& sort_order,
85 history::AndroidProviderBackend* backend) {
86 return backend->QueryHistoryAndBookmarks(projections, selection,
87 selection_args, sort_order);
88 }
89
90 // Returns the number of row updated by the update query.
91 //
92 // |row| is the value to update.
93 // |selection| is the SQL WHERE clause without 'WHERE'.
94 // |selection_args| is the arguments for the WHERE clause.
95 int UpdateHistoryAndBookmarksAdapter(
96 const history::HistoryAndBookmarkRow& row,
97 const std::string& selection,
98 const std::vector<base::string16>& selection_args,
99 history::AndroidProviderBackend* backend) {
100 int count = 0;
101 backend->UpdateHistoryAndBookmarks(row, selection, selection_args, &count);
102 return count;
103 }
104
105 // Deletes the specified rows and returns the number of rows deleted.
106 //
107 // |selection| is the SQL WHERE clause without 'WHERE'.
108 // |selection_args| is the arguments for the WHERE clause.
109 //
110 // If |selection| is empty all history and bookmarks are deleted.
111 int DeleteHistoryAndBookmarksAdapter(
112 const std::string& selection,
113 const std::vector<base::string16>& selection_args,
114 history::AndroidProviderBackend* backend) {
115 int count = 0;
116 backend->DeleteHistoryAndBookmarks(selection, selection_args, &count);
117 return count;
118 }
119
120 // Deletes the matched history and returns the number of rows deleted.
121 int DeleteHistoryAdapter(const std::string& selection,
122 const std::vector<base::string16>& selection_args,
123 history::AndroidProviderBackend* backend) {
124 int count = 0;
125 backend->DeleteHistory(selection, selection_args, &count);
126 return count;
127 }
128
129 // Statement ----------------------------------------------------------------
130
131 // Move the statement's current position.
132 int MoveStatementAdapter(history::AndroidStatement* statement,
133 int current_pos,
134 int destination,
135 history::AndroidProviderBackend* backend) {
136 DCHECK_LE(-1, current_pos);
137 DCHECK_LE(-1, destination);
138
139 int cur = current_pos;
140 if (current_pos > destination) {
141 statement->statement()->Reset(false);
142 cur = -1;
143 }
144 for (; cur < destination; ++cur) {
145 if (!statement->statement()->Step())
146 break;
147 }
148
149 return cur;
150 }
151
152 // CloseStatementTask delete the passed |statement| in the DB thread (or in the
153 // UI thread if the HistoryBackend is destroyed before the task is executed).
154 class CloseStatementTask : public history::HistoryDBTask {
155 public:
156 // Close the given statement. The ownership is transfered.
157 CloseStatementTask(history::AndroidStatement* statement)
158 : statement_(statement) {
159 DCHECK(statement_);
160 }
161
162 ~CloseStatementTask() override { delete statement_; }
163
164 // Returns the cancelable task tracker to use for this task. The task owns it,
165 // so it can never be cancelled. This is required due to be compatible with
166 // HistoryService::ScheduleDBTask() interface.
167 base::CancelableTaskTracker* tracker() { return &tracker_; }
168
169 private:
170 // history::HistoryDBTask implementation.
171 bool RunOnDBThread(history::HistoryBackend* backend,
172 history::HistoryDatabase* db) override {
173 delete statement_;
174 statement_ = nullptr;
175 return true;
176 }
177
178 void DoneRunOnMainThread() override {}
179
180 history::AndroidStatement* statement_;
181 base::CancelableTaskTracker tracker_;
182 };
183
184 // Search terms -------------------------------------------------------------
185
186 // Inserts the given values and returns the SearchTermID of the inserted row.
187 history::SearchTermID InsertSearchTermAdapter(
188 const history::SearchRow& row,
189 history::AndroidProviderBackend* backend) {
190 return backend->InsertSearchTerm(row);
191 }
192
193 // Returns the number of row updated by the update query.
194 //
195 // |row| is the value to update.
196 // |selection| is the SQL WHERE clause without 'WHERE'.
197 // |selection_args| is the arguments for the WHERE clause.
198 int UpdateSearchTermsAdapter(const history::SearchRow& row,
199 const std::string& selection,
200 const std::vector<base::string16> selection_args,
201 history::AndroidProviderBackend* backend) {
202 int count = 0;
203 backend->UpdateSearchTerms(row, selection, selection_args, &count);
204 return count;
205 }
206
207 // Deletes the matched rows and returns the number of deleted rows.
208 //
209 // |selection| is the SQL WHERE clause without 'WHERE'.
210 // |selection_args| is the arguments for WHERE clause.
211 //
212 // If |selection| is empty all search terms will be deleted.
213 int DeleteSearchTermsAdapter(const std::string& selection,
214 const std::vector<base::string16> selection_args,
215 history::AndroidProviderBackend* backend) {
216 int count = 0;
217 backend->DeleteSearchTerms(selection, selection_args, &count);
218 return count;
219 }
220
221 // Returns the result of the given query.
222 //
223 // |projections| specifies the result columns.
224 // |selection| is the SQL WHERE clause without 'WHERE'.
225 // |selection_args| is the arguments for WHERE clause.
226 // |sort_order| is the SQL ORDER clause.
227 history::AndroidStatement* QuerySearchTermsAdapter(
228 const std::vector<history::SearchRow::ColumnID>& projections,
229 const std::string& selection,
230 const std::vector<base::string16>& selection_args,
231 const std::string& sort_order,
232 history::AndroidProviderBackend* backend) {
233 return backend->QuerySearchTerms(projections, selection, selection_args,
234 sort_order);
235 }
236
237 } // namespace
15 238
16 AndroidHistoryProviderService::AndroidHistoryProviderService(Profile* profile) 239 AndroidHistoryProviderService::AndroidHistoryProviderService(Profile* profile)
17 : profile_(profile) { 240 : profile_(profile) {
18 } 241 }
19 242
20 AndroidHistoryProviderService::~AndroidHistoryProviderService() { 243 AndroidHistoryProviderService::~AndroidHistoryProviderService() {
21 } 244 }
22 245
23 base::CancelableTaskTracker::TaskId 246 base::CancelableTaskTracker::TaskId
24 AndroidHistoryProviderService::QueryHistoryAndBookmarks( 247 AndroidHistoryProviderService::QueryHistoryAndBookmarks(
25 const std::vector<history::HistoryAndBookmarkRow::ColumnID>& projections, 248 const std::vector<history::HistoryAndBookmarkRow::ColumnID>& projections,
26 const std::string& selection, 249 const std::string& selection,
27 const std::vector<base::string16>& selection_args, 250 const std::vector<base::string16>& selection_args,
28 const std::string& sort_order, 251 const std::string& sort_order,
29 const QueryCallback& callback, 252 const QueryCallback& callback,
30 base::CancelableTaskTracker* tracker) { 253 base::CancelableTaskTracker* tracker) {
31 HistoryService* hs = HistoryServiceFactory::GetForProfile( 254 HistoryService* hs = HistoryServiceFactory::GetForProfile(
32 profile_, ServiceAccessType::EXPLICIT_ACCESS); 255 profile_, ServiceAccessType::EXPLICIT_ACCESS);
33 if (hs) { 256 if (!hs) {
34 DCHECK(hs->thread_) << "History service being called after cleanup"; 257 callback.Run(nullptr);
35 DCHECK(hs->thread_checker_.CalledOnValidThread());
36 return tracker->PostTaskAndReplyWithResult(
37 hs->thread_->message_loop_proxy().get(),
38 FROM_HERE,
39 base::Bind(&HistoryBackend::QueryHistoryAndBookmarks,
40 hs->history_backend_.get(),
41 projections,
42 selection,
43 selection_args,
44 sort_order),
45 callback);
46 } else {
47 callback.Run(NULL);
48 return base::CancelableTaskTracker::kBadTaskId; 258 return base::CancelableTaskTracker::kBadTaskId;
49 } 259 }
260 return hs->ScheduleDBTask(
261 CreateAndroidProviderTask(
262 base::Bind(&QueryHistoryAndBookmarksAdapter, projections, selection,
263 selection_args, sort_order),
264 callback),
265 tracker);
50 } 266 }
51 267
52 base::CancelableTaskTracker::TaskId 268 base::CancelableTaskTracker::TaskId
53 AndroidHistoryProviderService::UpdateHistoryAndBookmarks( 269 AndroidHistoryProviderService::UpdateHistoryAndBookmarks(
54 const history::HistoryAndBookmarkRow& row, 270 const history::HistoryAndBookmarkRow& row,
55 const std::string& selection, 271 const std::string& selection,
56 const std::vector<base::string16>& selection_args, 272 const std::vector<base::string16>& selection_args,
57 const UpdateCallback& callback, 273 const UpdateCallback& callback,
58 base::CancelableTaskTracker* tracker) { 274 base::CancelableTaskTracker* tracker) {
59 HistoryService* hs = HistoryServiceFactory::GetForProfile( 275 HistoryService* hs = HistoryServiceFactory::GetForProfile(
60 profile_, ServiceAccessType::EXPLICIT_ACCESS); 276 profile_, ServiceAccessType::EXPLICIT_ACCESS);
61 if (hs) { 277 if (!hs) {
62 DCHECK(hs->thread_) << "History service being called after cleanup";
63 DCHECK(hs->thread_checker_.CalledOnValidThread());
64 return tracker->PostTaskAndReplyWithResult(
65 hs->thread_->message_loop_proxy().get(),
66 FROM_HERE,
67 base::Bind(&HistoryBackend::UpdateHistoryAndBookmarks,
68 hs->history_backend_.get(),
69 row,
70 selection,
71 selection_args),
72 callback);
73 } else {
74 callback.Run(0); 278 callback.Run(0);
75 return base::CancelableTaskTracker::kBadTaskId; 279 return base::CancelableTaskTracker::kBadTaskId;
76 } 280 }
281 return hs->ScheduleDBTask(
282 CreateAndroidProviderTask(base::Bind(&UpdateHistoryAndBookmarksAdapter,
283 row, selection, selection_args),
284 callback),
285 tracker);
77 } 286 }
78 287
79 base::CancelableTaskTracker::TaskId 288 base::CancelableTaskTracker::TaskId
80 AndroidHistoryProviderService::DeleteHistoryAndBookmarks( 289 AndroidHistoryProviderService::DeleteHistoryAndBookmarks(
81 const std::string& selection, 290 const std::string& selection,
82 const std::vector<base::string16>& selection_args, 291 const std::vector<base::string16>& selection_args,
83 const DeleteCallback& callback, 292 const DeleteCallback& callback,
84 base::CancelableTaskTracker* tracker) { 293 base::CancelableTaskTracker* tracker) {
85 HistoryService* hs = HistoryServiceFactory::GetForProfile( 294 HistoryService* hs = HistoryServiceFactory::GetForProfile(
86 profile_, ServiceAccessType::EXPLICIT_ACCESS); 295 profile_, ServiceAccessType::EXPLICIT_ACCESS);
87 if (hs) { 296 if (!hs) {
88 DCHECK(hs->thread_) << "History service being called after cleanup";
89 DCHECK(hs->thread_checker_.CalledOnValidThread());
90 return tracker->PostTaskAndReplyWithResult(
91 hs->thread_->message_loop_proxy().get(),
92 FROM_HERE,
93 base::Bind(&HistoryBackend::DeleteHistoryAndBookmarks,
94 hs->history_backend_.get(),
95 selection,
96 selection_args),
97 callback);
98 } else {
99 callback.Run(0); 297 callback.Run(0);
100 return base::CancelableTaskTracker::kBadTaskId; 298 return base::CancelableTaskTracker::kBadTaskId;
101 } 299 }
300 return hs->ScheduleDBTask(
301 CreateAndroidProviderTask(base::Bind(&DeleteHistoryAndBookmarksAdapter,
302 selection, selection_args),
303 callback),
304 tracker);
102 } 305 }
103 306
104 base::CancelableTaskTracker::TaskId 307 base::CancelableTaskTracker::TaskId
105 AndroidHistoryProviderService::InsertHistoryAndBookmark( 308 AndroidHistoryProviderService::InsertHistoryAndBookmark(
106 const history::HistoryAndBookmarkRow& values, 309 const history::HistoryAndBookmarkRow& values,
107 const InsertCallback& callback, 310 const InsertCallback& callback,
108 base::CancelableTaskTracker* tracker) { 311 base::CancelableTaskTracker* tracker) {
109 HistoryService* hs = HistoryServiceFactory::GetForProfile( 312 HistoryService* hs = HistoryServiceFactory::GetForProfile(
110 profile_, ServiceAccessType::EXPLICIT_ACCESS); 313 profile_, ServiceAccessType::EXPLICIT_ACCESS);
111 if (hs) { 314 if (!hs) {
112 DCHECK(hs->thread_) << "History service being called after cleanup";
113 DCHECK(hs->thread_checker_.CalledOnValidThread());
114 return tracker->PostTaskAndReplyWithResult(
115 hs->thread_->message_loop_proxy().get(),
116 FROM_HERE,
117 base::Bind(&HistoryBackend::InsertHistoryAndBookmark,
118 hs->history_backend_.get(),
119 values),
120 callback);
121 } else {
122 callback.Run(0); 315 callback.Run(0);
123 return base::CancelableTaskTracker::kBadTaskId; 316 return base::CancelableTaskTracker::kBadTaskId;
124 } 317 }
318 return hs->ScheduleDBTask(
319 CreateAndroidProviderTask(
320 base::Bind(&InsertHistoryAndBookmarkAdapter, values), callback),
321 tracker);
125 } 322 }
126 323
127 base::CancelableTaskTracker::TaskId 324 base::CancelableTaskTracker::TaskId
128 AndroidHistoryProviderService::DeleteHistory( 325 AndroidHistoryProviderService::DeleteHistory(
129 const std::string& selection, 326 const std::string& selection,
130 const std::vector<base::string16>& selection_args, 327 const std::vector<base::string16>& selection_args,
131 const DeleteCallback& callback, 328 const DeleteCallback& callback,
132 base::CancelableTaskTracker* tracker) { 329 base::CancelableTaskTracker* tracker) {
133 HistoryService* hs = HistoryServiceFactory::GetForProfile( 330 HistoryService* hs = HistoryServiceFactory::GetForProfile(
134 profile_, ServiceAccessType::EXPLICIT_ACCESS); 331 profile_, ServiceAccessType::EXPLICIT_ACCESS);
135 if (hs) { 332 if (!hs) {
136 DCHECK(hs->thread_) << "History service being called after cleanup";
137 DCHECK(hs->thread_checker_.CalledOnValidThread());
138 return tracker->PostTaskAndReplyWithResult(
139 hs->thread_->message_loop_proxy().get(),
140 FROM_HERE,
141 base::Bind(&HistoryBackend::DeleteHistory,
142 hs->history_backend_.get(),
143 selection,
144 selection_args),
145 callback);
146 } else {
147 callback.Run(0); 333 callback.Run(0);
148 return base::CancelableTaskTracker::kBadTaskId; 334 return base::CancelableTaskTracker::kBadTaskId;
149 } 335 }
336 return hs->ScheduleDBTask(
337 CreateAndroidProviderTask(
338 base::Bind(&DeleteHistoryAdapter, selection, selection_args),
339 callback),
340 tracker);
150 } 341 }
151 342
152 base::CancelableTaskTracker::TaskId 343 base::CancelableTaskTracker::TaskId
153 AndroidHistoryProviderService::MoveStatement( 344 AndroidHistoryProviderService::MoveStatement(
154 history::AndroidStatement* statement, 345 history::AndroidStatement* statement,
155 int current_pos, 346 int current_pos,
156 int destination, 347 int destination,
157 const MoveStatementCallback& callback, 348 const MoveStatementCallback& callback,
158 base::CancelableTaskTracker* tracker) { 349 base::CancelableTaskTracker* tracker) {
159 HistoryService* hs = HistoryServiceFactory::GetForProfile( 350 HistoryService* hs = HistoryServiceFactory::GetForProfile(
160 profile_, ServiceAccessType::EXPLICIT_ACCESS); 351 profile_, ServiceAccessType::EXPLICIT_ACCESS);
161 if (hs) { 352 if (!hs) {
162 DCHECK(hs->thread_) << "History service being called after cleanup";
163 DCHECK(hs->thread_checker_.CalledOnValidThread());
164 return tracker->PostTaskAndReplyWithResult(
165 hs->thread_->message_loop_proxy().get(),
166 FROM_HERE,
167 base::Bind(&HistoryBackend::MoveStatement,
168 hs->history_backend_.get(),
169 statement,
170 current_pos,
171 destination),
172 callback);
173 } else {
174 callback.Run(current_pos); 353 callback.Run(current_pos);
175 return base::CancelableTaskTracker::kBadTaskId; 354 return base::CancelableTaskTracker::kBadTaskId;
176 } 355 }
356 return hs->ScheduleDBTask(
357 CreateAndroidProviderTask(base::Bind(&MoveStatementAdapter, statement,
358 current_pos, destination),
359 callback),
360 tracker);
177 } 361 }
178 362
179 void AndroidHistoryProviderService::CloseStatement( 363 void AndroidHistoryProviderService::CloseStatement(
180 history::AndroidStatement* statement) { 364 history::AndroidStatement* statement) {
181 HistoryService* hs = HistoryServiceFactory::GetForProfile( 365 HistoryService* hs = HistoryServiceFactory::GetForProfile(
182 profile_, ServiceAccessType::EXPLICIT_ACCESS); 366 profile_, ServiceAccessType::EXPLICIT_ACCESS);
183 if (hs) { 367 if (!hs) {
184 hs->ScheduleTask(HistoryService::PRIORITY_NORMAL,
185 base::Bind(&HistoryBackend::CloseStatement,
186 hs->history_backend_.get(), statement));
187 } else {
188 delete statement; 368 delete statement;
369 return;
189 } 370 }
371 scoped_ptr<CloseStatementTask> task(new CloseStatementTask(statement));
372 base::CancelableTaskTracker* tracker = task->tracker();
373 hs->ScheduleDBTask(task.Pass(), tracker);
190 } 374 }
191 375
192 base::CancelableTaskTracker::TaskId 376 base::CancelableTaskTracker::TaskId
193 AndroidHistoryProviderService::InsertSearchTerm( 377 AndroidHistoryProviderService::InsertSearchTerm(
194 const history::SearchRow& row, 378 const history::SearchRow& row,
195 const InsertCallback& callback, 379 const InsertCallback& callback,
196 base::CancelableTaskTracker* tracker) { 380 base::CancelableTaskTracker* tracker) {
197 HistoryService* hs = HistoryServiceFactory::GetForProfile( 381 HistoryService* hs = HistoryServiceFactory::GetForProfile(
198 profile_, ServiceAccessType::EXPLICIT_ACCESS); 382 profile_, ServiceAccessType::EXPLICIT_ACCESS);
199 if (hs) { 383 if (!hs) {
200 DCHECK(hs->thread_) << "History service being called after cleanup";
201 DCHECK(hs->thread_checker_.CalledOnValidThread());
202 return tracker->PostTaskAndReplyWithResult(
203 hs->thread_->message_loop_proxy().get(),
204 FROM_HERE,
205 base::Bind(
206 &HistoryBackend::InsertSearchTerm, hs->history_backend_.get(), row),
207 callback);
208 } else {
209 callback.Run(0); 384 callback.Run(0);
210 return base::CancelableTaskTracker::kBadTaskId; 385 return base::CancelableTaskTracker::kBadTaskId;
211 } 386 }
387 return hs->ScheduleDBTask(
388 CreateAndroidProviderTask(base::Bind(&InsertSearchTermAdapter, row),
389 callback),
390 tracker);
212 } 391 }
213 392
214 base::CancelableTaskTracker::TaskId 393 base::CancelableTaskTracker::TaskId
215 AndroidHistoryProviderService::UpdateSearchTerms( 394 AndroidHistoryProviderService::UpdateSearchTerms(
216 const history::SearchRow& row, 395 const history::SearchRow& row,
217 const std::string& selection, 396 const std::string& selection,
218 const std::vector<base::string16>& selection_args, 397 const std::vector<base::string16>& selection_args,
219 const UpdateCallback& callback, 398 const UpdateCallback& callback,
220 base::CancelableTaskTracker* tracker) { 399 base::CancelableTaskTracker* tracker) {
221 HistoryService* hs = HistoryServiceFactory::GetForProfile( 400 HistoryService* hs = HistoryServiceFactory::GetForProfile(
222 profile_, ServiceAccessType::EXPLICIT_ACCESS); 401 profile_, ServiceAccessType::EXPLICIT_ACCESS);
223 if (hs) { 402 if (!hs) {
224 DCHECK(hs->thread_) << "History service being called after cleanup";
225 DCHECK(hs->thread_checker_.CalledOnValidThread());
226 return tracker->PostTaskAndReplyWithResult(
227 hs->thread_->message_loop_proxy().get(),
228 FROM_HERE,
229 base::Bind(&HistoryBackend::UpdateSearchTerms,
230 hs->history_backend_.get(),
231 row,
232 selection,
233 selection_args),
234 callback);
235 } else {
236 callback.Run(0); 403 callback.Run(0);
237 return base::CancelableTaskTracker::kBadTaskId; 404 return base::CancelableTaskTracker::kBadTaskId;
238 } 405 }
406 return hs->ScheduleDBTask(
407 CreateAndroidProviderTask(
408 base::Bind(&UpdateSearchTermsAdapter, row, selection, selection_args),
409 callback),
410 tracker);
239 } 411 }
240 412
241 base::CancelableTaskTracker::TaskId 413 base::CancelableTaskTracker::TaskId
242 AndroidHistoryProviderService::DeleteSearchTerms( 414 AndroidHistoryProviderService::DeleteSearchTerms(
243 const std::string& selection, 415 const std::string& selection,
244 const std::vector<base::string16>& selection_args, 416 const std::vector<base::string16>& selection_args,
245 const DeleteCallback& callback, 417 const DeleteCallback& callback,
246 base::CancelableTaskTracker* tracker) { 418 base::CancelableTaskTracker* tracker) {
247 HistoryService* hs = HistoryServiceFactory::GetForProfile( 419 HistoryService* hs = HistoryServiceFactory::GetForProfile(
248 profile_, ServiceAccessType::EXPLICIT_ACCESS); 420 profile_, ServiceAccessType::EXPLICIT_ACCESS);
249 if (hs) { 421 if (!hs) {
250 DCHECK(hs->thread_) << "History service being called after cleanup";
251 DCHECK(hs->thread_checker_.CalledOnValidThread());
252 return tracker->PostTaskAndReplyWithResult(
253 hs->thread_->message_loop_proxy().get(),
254 FROM_HERE,
255 base::Bind(&HistoryBackend::DeleteSearchTerms,
256 hs->history_backend_.get(),
257 selection,
258 selection_args),
259 callback);
260 } else {
261 callback.Run(0); 422 callback.Run(0);
262 return base::CancelableTaskTracker::kBadTaskId; 423 return base::CancelableTaskTracker::kBadTaskId;
263 } 424 }
425 return hs->ScheduleDBTask(
426 CreateAndroidProviderTask(
427 base::Bind(&DeleteSearchTermsAdapter, selection, selection_args),
428 callback),
429 tracker);
264 } 430 }
265 431
266 base::CancelableTaskTracker::TaskId 432 base::CancelableTaskTracker::TaskId
267 AndroidHistoryProviderService::QuerySearchTerms( 433 AndroidHistoryProviderService::QuerySearchTerms(
268 const std::vector<history::SearchRow::ColumnID>& projections, 434 const std::vector<history::SearchRow::ColumnID>& projections,
269 const std::string& selection, 435 const std::string& selection,
270 const std::vector<base::string16>& selection_args, 436 const std::vector<base::string16>& selection_args,
271 const std::string& sort_order, 437 const std::string& sort_order,
272 const QueryCallback& callback, 438 const QueryCallback& callback,
273 base::CancelableTaskTracker* tracker) { 439 base::CancelableTaskTracker* tracker) {
274 HistoryService* hs = HistoryServiceFactory::GetForProfile( 440 HistoryService* hs = HistoryServiceFactory::GetForProfile(
275 profile_, ServiceAccessType::EXPLICIT_ACCESS); 441 profile_, ServiceAccessType::EXPLICIT_ACCESS);
276 if (hs) { 442 if (!hs) {
277 DCHECK(hs->thread_) << "History service being called after cleanup"; 443 callback.Run(nullptr);
278 DCHECK(hs->thread_checker_.CalledOnValidThread());
279 return tracker->PostTaskAndReplyWithResult(
280 hs->thread_->message_loop_proxy().get(),
281 FROM_HERE,
282 base::Bind(&HistoryBackend::QuerySearchTerms,
283 hs->history_backend_.get(),
284 projections,
285 selection,
286 selection_args,
287 sort_order),
288 callback);
289 } else {
290 callback.Run(NULL);
291 return base::CancelableTaskTracker::kBadTaskId; 444 return base::CancelableTaskTracker::kBadTaskId;
292 } 445 }
446 return hs->ScheduleDBTask(
447 CreateAndroidProviderTask(
448 base::Bind(&QuerySearchTermsAdapter, projections, selection,
449 selection_args, sort_order),
450 callback),
451 tracker);
293 } 452 }
294 453
295 base::CancelableTaskTracker::TaskId 454 base::CancelableTaskTracker::TaskId
296 AndroidHistoryProviderService::GetLargestRawFaviconForID( 455 AndroidHistoryProviderService::GetLargestRawFaviconForID(
297 favicon_base::FaviconID favicon_id, 456 favicon_base::FaviconID favicon_id,
298 const favicon_base::FaviconRawBitmapCallback& callback, 457 const favicon_base::FaviconRawBitmapCallback& callback,
299 base::CancelableTaskTracker* tracker) { 458 base::CancelableTaskTracker* tracker) {
300 FaviconService* fs = FaviconServiceFactory::GetForProfile( 459 FaviconService* fs = FaviconServiceFactory::GetForProfile(
301 profile_, ServiceAccessType::EXPLICIT_ACCESS); 460 profile_, ServiceAccessType::EXPLICIT_ACCESS);
302 DCHECK(fs); 461 DCHECK(fs);
303 return fs->GetLargestRawFaviconForID(favicon_id, callback, tracker); 462 return fs->GetLargestRawFaviconForID(favicon_id, callback, tracker);
304 } 463 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/history/history_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698